Antigravity CLI in Claude Code and Codex: The Setup Google Allows
Google's terms now let Claude Code or Codex call the Antigravity CLI as a subagent. The exact rule, what stays forbidden, and a setup built from the docs.
Published

Google's Antigravity terms now say you may call the Antigravity CLI as a tool or subagent from another harness. If you run Claude Code or Codex CLI, that means agy can be one of your workers. Here is the exact rule, the three things that stay forbidden, and a working setup for both harnesses, built only from the makers' own docs as of December 2026.
What Google's terms now allow
The rule sits in section 6 of the Google Antigravity Additional Terms of Service. Read on December 2, 2026, its permitting sentence says:
However, running the unmodified Antigravity harness through its supported interfaces–such as wrapping it with a third-party UI (e.g., via agent client protocol), calling it as a tool or subagent from another harness, using the Antigravity CLI in headless mode, or configuring it through supported customization and extension mechanisms (such as custom agents, MCP servers, skills, rules, hooks, plugins, or supported prompt extensions)–is permitted.
Google's FAQ puts it more plainly. Asked "Can I use Antigravity CLI headless mode from another harness or share accounts?", it starts with "Yes": running the unmodified CLI in headless mode (agy -p), "including calling it as a tool or subagent from another harness", is permitted. The terms page does not say when this wording took effect.
The key word is unmodified. You run Google's own program, signed in the way Google's docs describe, and your other harness talks to it the way a script would: it starts agy, hands it a task, and reads what comes back.
The three things that stay forbidden
The same section opens with what you may not do. Each line, and what it means for an orchestrator:
- "using entitlements or credentials (such as OAuth tokens) provided by the Antigravity service directly within third-party software, tools, or services outside the official Antigravity runtime". Your Antigravity sign-in stays inside
agy. A Claude Code or Codex setup never reads, copies or forwards it. - "modifying or bypassing the Antigravity runtime, or repurposing the Antigravity harness to act as a raw model proxy for an external agent loop or inference backend". You give Antigravity a task and it runs its own loop. You don't make it answer your other agent's model calls one by one, as if
agywere a model endpoint. - "sharing, pooling, or reselling individual entitlements across multiple users". One person's plan runs that person's work. A team's jobs don't run on one member's subscription.
On consequences, the terms say: "Violations may result in suspension of your Antigravity access with an appeal path for re-enablement. This will have no impact on your broader Google account." If you followed the account-ban reports in late November, what they said and what Google's team answered is on its own page.
Section 8 adds one more line worth knowing: if you pick a third-party model as Antigravity's main agent model, that model's terms apply too, and for Anthropic that means its commercial terms.
As of Dec 2, 2026 · Source: Google Antigravity Additional Terms of Service, section 6
The FAQ also names the route for a third-party agent that wants Gemini models directly, without Antigravity's harness: a Gemini API key from Google AI Studio or Gemini Enterprise Agent Platform.
How a headless call works
Headless mode, also called print mode, sends one prompt, waits for the agent to finish, prints the answer and exits. Google's headless guide is the reference for everything in this section.
agy -p "In one sentence, what is a git rebase?" --output-format json
{"conversation_id":"055a398f-…","status":"SUCCESS",
"response":"A git rebase rewrites the commit history by transplanting…",
"duration_seconds":7.16,"num_turns":1,"usage":{…}}
agy -p "hi" --model does-not-exist-model --output-format json; echo "exit=$?"
{"status":"ERROR","error":"invalid model selection …"} exit=1
What comes back, and where:
- The answer goes to stdout, everything else to stderr. Errors, sign-in prompts, progress and permission notices print to stderr, so the captured answer stays clean.
- Three output shapes.
--output-format text(the default) prints only the answer.jsonprints one object at the end withstatus,response,erroron failure,duration_seconds,num_turnsandusage(token counts).stream-jsonprints one event per line while it works, including each tool call. - A schema when you need fields, not prose.
--json-schematakes a schema string or a path to a.jsonfile, and the parsed answer lands instructured_output. - Exit codes you can branch on. A successful run exits
0. A run that fails to produce a response exits non-zero and also says so instatus. An unknown--modelfails loudly instead of quietly running another model. - No memory between calls. Each
agy -pstarts a fresh conversation. To continue one, pass--continuefor the most recent or--conversation <id>with theconversation_idfrom an earlier answer.
How it is given a directory and a task:
- The directory is the one you start it in.
agyworks on the folder it is launched from; thestream-jsonoutput opens with aninitevent that reports it ascwd. Run it from the repository you want it to work on. - The task is the prompt, and only the prompt. Antigravity sees none of your Claude Code or Codex conversation. Write the task so it stands alone: the goal, the files or branch, what to return and in what shape.
- It can edit files. Since CLI v1.5.7,
agy -pstarts inautomode wherever that mode is available, which approves workspace file edits and safe sandboxed commands without asking. Pin a mode with--mode, and see the section on two agents and one checkout below before you run it next to another agent.
Google's own CI example puts these together: run with --output-format json --print-timeout 10m, fail the job unless .status is SUCCESS, and keep .response.
Set it up once
Install agy and check it runs
On macOS or Linux, Google's installer is
curl -fsSL https://antigravity.google/cli/install.sh | bash; on Windows PowerShell,irm https://antigravity.google/cli/install.ps1 | iex. The binary lands in~/.local/bin/agyon macOS and Linux. Check it withagy --version. If your shell saysagy: command not found, add~/.local/binto yourPATH. Google's getting-started guideSign in once, interactively, as the same user
Run
agyin a terminal and complete the sign-in. Headless runs reuse those cached credentials from your system keyring, so sign in as the same user, on the same machine, that Claude Code or Codex runs as. Over SSH, the CLI prints a sign-in address to open on your own computer and asks you to paste back a code. Google's authentication guideCheck your quota from the shell
Since CLI v1.5.22 (December 2, 2026),
agy usageshows your account's quota without starting a conversation, and it takes--output-format jsontoo. Inside the interactive CLI,/usageshows the same, per model group.Decide what agy may do without asking
In headless mode nobody can answer a permission prompt. Grant what your tasks need ahead of time under
permissions.allowin~/.gemini/antigravity-cli/settings.json, such ascommand(git)orcommand(regex:npm run (build|lint|test)). Google's guide also offers--dangerously-skip-permissions, which approves every tool call, and warns you to prefer scoped rules.
Call Antigravity from Claude Code
In Claude Code, the clean shape is a custom subagent. A subagent runs in its own context with its own instructions and tools, and returns only its report to your main conversation (Anthropic's subagent docs). Its job here is narrow: write a standalone task, run one agy -p command, read the JSON, report.
Save this as .claude/agents/antigravity.md in your project, or in ~/.claude/agents/ for every project:
---
name: antigravity
description: Hands one self-contained task or a second-opinion review to Google's Antigravity CLI (agy) and reports its answer. Use when the user asks for Antigravity.
tools: Bash, Read
---
You hand one task to Antigravity CLI and report what it returns.
1. Write the task so it stands alone. agy sees none of this conversation:
name the goal, the files or branch, and what to return.
2. Run exactly one command, with a Bash timeout of 600000 ms:
agy -p "<the task>" --output-format json --print-timeout 9m
3. Read the JSON. If status is not SUCCESS, report the error field and stop.
4. Report the response field as Antigravity's answer, word for word.
Then add your own view, marked as yours.
5. Never read, print or pass on Antigravity's credentials, and never
reach its models any other way than this command.Then let it run without a prompt each time, in .claude/settings.json:
{
"permissions": {
"allow": ["Bash(agy -p *)"]
}
}Two numbers in that file matter. Claude Code gives a Bash command two minutes by default and lets Claude ask for up to ten (Anthropic's tools reference). agy -p has no time limit by default. Setting --print-timeout 9m makes Antigravity stop itself before Claude Code's ten-minute ceiling.
Ask for it by name: "Use the antigravity subagent to review this branch against main." Custom subagents start in the background by default, so your main conversation keeps going while Antigravity works. To make Claude wait for the report in an interactive session, Anthropic's docs say to set CLAUDE_CODE_FORK_SUBAGENT to 0 and ask Claude to wait. More on how subagents behave is in Claude Code subagents.
If you would rather type a command than name a subagent, the same instructions fit a skill: .claude/skills/antigravity/SKILL.md, with allowed-tools: Bash(agy -p *) in its frontmatter, and context: fork if it should run in its own subagent (Anthropic's skills docs).
Call Antigravity from Codex CLI
Codex learns a workflow from a skill: a folder with a SKILL.md that has a name and a description (OpenAI's skills docs). One detail decides where it goes. Codex reads repository skills from .agents/skills, and so does Antigravity: its CLI loads .agents/skills/ in your workspace and in each parent folder up to the repository root (Google's skills docs). A hand-off skill in the repository would therefore also appear in Antigravity's own skill list. Put it in your user folder instead, ~/.agents/skills/antigravity/SKILL.md, which Codex reads and Antigravity's CLI does not list:
---
name: antigravity
description: Hands one self-contained task or a second-opinion review to Google's Antigravity CLI (agy) and reports its answer. Use when the user asks for Antigravity. Don't use for work that needs this conversation's context.
---
1. Write the task so it stands alone. agy sees none of this conversation.
2. Run it as one plain command, with no pipe, redirect or $( ):
agy -p "<the task>" --output-format json --print-timeout 9m
3. Read the JSON it prints. If status is not SUCCESS, report error and stop.
4. Report response as Antigravity's answer, then your own view, marked as yours.Codex runs commands inside its sandbox, which decides which files a command can touch and whether it can use the network (OpenAI's sandbox docs). agy has to reach Google's service to do anything. There are two documented ways through.
A rule for this one command (the narrow way). Codex's rules let a command prefix run outside the sandbox. Add this to ~/.codex/rules/default.rules and restart Codex:
prefix_rule(
pattern = ["agy", "-p"],
decision = "allow",
justification = "Hand-offs to Antigravity CLI",
match = ['agy -p "Review the last commit" --output-format json'],
)Check it with codex execpolicy check --pretty --rules ~/.codex/rules/default.rules -- agy -p "hello" --output-format json. Use decision = "prompt" instead if you want to approve each call. This is why the skill asks for a plain command: Codex doesn't split a script that uses a redirect or $( ), so the rule wouldn't match it.
Network for every sandboxed command (the broad way). sandbox_workspace_write.network_access = true in Codex's config opens outbound network inside the workspace-write sandbox for every command, not just agy.
Once outside Codex's sandbox, agy follows its own permission mode and rules from the setup above. In Codex CLI, call the skill with $antigravity and your task. For an unattended run, codex exec does the same from a script; it starts in a read-only sandbox unless you pass --sandbox workspace-write (OpenAI's non-interactive docs).
What to hand Antigravity, and what to keep
Hand it work that can be described in one message and checked when it comes back:
- A second opinion or a review. A different harness reading the same code, on the model you pin with
--model(list them withagy models) and the effort you set with--effort. - A separate task that touches separate files, such as tests for a module your main agent isn't editing, run in its own worktree (below).
- A structured extraction. With
--json-schema, the answer comes back as fields your orchestrator can act on without parsing prose.
Keep in your main agent:
- Anything that depends on the conversation so far.
agy -pstarts clean every time. - Edits to files your main agent is changing right now.
- Steps that need someone to approve them mid-run. In headless mode an approval nobody can give is refused, and the run carries on without it.
- Long, open-ended work you would otherwise watch. Antigravity's own swarm and subagents are built for that inside Antigravity.
A worked example: a second opinion before you merge
You've built a rate limiter with Claude Code on a branch called feature/rate-limit. Before merging, you want Antigravity to read it cold. This is how the subagent above carries it, step by step.
Freeze what will be reviewed
Commit the branch's work. Both agents then read the same state, and anything that changes during the review shows up in
git status.Give the review a shape
Save a schema at
.claude/agy-review.schema.jsonso the findings come back as fields:{"type":"object","properties":{"findings":{"type":"array","items":{"type":"object","properties":{"file":{"type":"string"},"line":{"type":"integer"},"issue":{"type":"string"}},"required":["file","issue"]}}},"required":["findings"]}Ask Claude Code to delegate and wait
"Use the antigravity subagent to review feature/rate-limit against main, and wait for its report." The subagent writes a standalone task and runs one command.
Read the report, then decide
Claude Code relays Antigravity's findings and adds where it agrees or disagrees. You choose what to fix, and Claude fixes it in your main conversation, the only place editing your checkout.
Check nothing else moved
Run
git status. If the review run changed a file, you see it here and can inspect it withgit diffbefore anything goes further.
The command the subagent runs:
agy -p "Review what branch feature/rate-limit changes compared with main. For each bug or risky change, give the file, the line and one sentence. Do not edit any file." \
--output-format json \
--json-schema .claude/agy-review.schema.json \
--print-timeout 9mUse the antigravity subagent to review feature/rate-limit against main, and wait for its report.
Handing the review to Antigravity, with the branch and the output schema named.
agy -p "Review what branch feature/rate-limit changes…" --output-format json --json-schema .claude/agy-review.schema.json --print-timeout 9m
status SUCCESS · structured_output.findings · usage
Antigravity's findings, as it returned them, then where I agree and where I don't. Which should I fix?
"Do not edit any file" in the prompt is a request, not a lock: in auto mode Antigravity may edit workspace files without asking. That is what steps 1 and 5 are for. When a review must not be able to touch your checkout at all, give it its own worktree, as below.
Cost and quota: whose plan each call spends
Each call spends two things:
- The orchestrator's side. In Claude Code, a subagent's requests "count toward the same usage limits as your main conversation", in Anthropic's words. In Codex, the call is one more shell command inside a Codex turn.
- Antigravity's side.
agy -pruns on the credentials it finds on that machine. With the usual sign-in, that is the Antigravity quota of the Google account you signed in with, the same quotaagy usageshows.
What that quota looks like depends on the plan, per Google's plans page, which applies to personal Google accounts:
Google adds that the limits "correlate with the amount of work done by the agent", so a review of a large branch costs more than a one-line question. On Pro and Ultra, purchased AI credits can cover use past the quota; in the CLI that is the useG1Credits setting, off by default. Keep it off for unattended calls unless you mean a loop to spend credits. A Google Workspace account doesn't get an Antigravity plan, only a limited starter quota. Every json answer carries a usage block of token counts, so your orchestrator can log what each hand-off used. For the plan prices themselves, see Antigravity pricing.
Two other routes change who pays. With "modelProvider": "gemini" in agy's settings and a GEMINI_API_KEY exported, requests go straight to the Gemini API and the CLI never signs in to an account; Google suggests it for headless and CI runs. A Google Cloud project can sign in through Application Default Credentials with AGY_ADC_AUTH=true. What you can't do is point several people's jobs at one person's plan: that is line (c).
When it breaks, and the fix
Every symptom below is quoted from the makers' docs or changelogs.
Two more limits are worth knowing before you automate. auto mode needs Antigravity's terminal sandbox and a personal account; it isn't available to business or enterprise accounts, and there a headless run falls back to default mode, where shell commands ask first, so plan your allow rules. And Claude Code's background commands are capped in unattended runs: 30 minutes by default, or 10 in a claude -p run with a text prompt.
Two agents, one checkout
This is the failure the docs leave to you. Your main agent and Antigravity both edit files, and since auto mode lets agy change workspace files without asking, two of them in one folder can overwrite each other's work. Three rules prevent it:
- Reviews go one at a time. Commit, hand off, wait for the report, then edit. That is the worked example above.
- Parallel work gets its own checkout. Git's worktrees give a second working copy of the same repository on its own branch:
git worktree add -b agy-tests ../myapp-agy, runagy -pfrom../myapp-agy, and merge its branch when you've read it. Remove it afterwards withgit worktree remove ../myapp-agy(git's worktree docs). - In Claude Code, let the subagent carry the worktree. Add
isolation: worktreeto the subagent's frontmatter and Claude Code runs it in a temporary worktree, where its Bash commands,agy -pincluded, run inside that copy. Note that the copy branches from your default branch, not from your current one.
agy asks you to trust a folder the first time it opens it interactively, and keeps the folders you trusted in its settings. Google's headless guide doesn't say how a headless run treats a folder you never trusted, so if a call from a new worktree fails, open agy there once.
What this is not
- Not a way to use Antigravity's models inside Claude Code's loop. Claude Code's own model still runs Claude Code. Antigravity runs its own task with its own loop and hands back an answer.
- Not permission to wire Antigravity's sign-in into other tools. Any setup that copies its token, or turns
agyinto a model endpoint, is what lines (a) and (b) forbid, however it is packaged. - Not shared access. One plan, one person, line (c).
- Not a replacement for reading the result. Section 4 of the terms makes you "solely responsible" for what an AI agent does. Treat Antigravity's answer as a colleague's review, not a verdict.
Is calling the Antigravity CLI from Claude Code allowed?
Yes, as of December 2026. Section 6 of Google's Antigravity terms permits "calling it as a tool or subagent from another harness" and "using the Antigravity CLI in headless mode", as long as the harness runs unmodified. Google's FAQ answers the same question with "Yes".
Can I use my Antigravity OAuth token in Claude Code, OpenCode or another tool directly?
No. Line (a) of section 6 forbids using Antigravity's entitlements or credentials, "such as OAuth tokens", inside third-party software outside the official Antigravity runtime. For direct access to Gemini models from another agent, Google's FAQ points to a Gemini API key.
Could this get my Google account suspended?
The terms say violations "may result in suspension of your Antigravity access with an appeal path for re-enablement" and that this "will have no impact on your broader Google account". Calling the unmodified CLI headless is permitted, not a violation.
Whose quota does each agy call use?
The Antigravity quota of the Google account agy is signed in with on that machine, which agy usage shows. Your Claude Code subagent's own requests count toward your Claude Code usage as usual. With a Gemini API key configured instead, requests go to the Gemini API and no account session is used.
Does agy -p remember earlier calls?
No. Headless runs are stateless by default. Pass --continue for the most recent conversation or --conversation with an ID from an earlier answer's conversation_id.
New to the tool itself? Start with what Google Antigravity is and how to start, and for Claude Code's own terminal see Claude Code CLI.
Google Antigravity vs Claude Code
Which to make your main harness, and when to run both.
- Published
- Category
- Build







