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

Antigravity CLI in Claude Code and Codex: The Setup Google Allows

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

Google Antigravity Additional Terms of Service, section 6

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:

  1. "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.
  2. "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 agy were a model endpoint.
  3. "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.

The other harness calls agy. It never holds agy's key.What section 6 permits, and the three lines it draws
Permitted: a call, like any script makes
1 · OrchestratorClaude Code or CodexDecides to hand off one task
2 · ShellIt runs agy -pGoogle's unmodified CLI, headless
3 · Antigravityagy does the taskIts own loop, your own sign-in
4 · ResultText or JSON on stdoutThe orchestrator reads it and decides
Forbidden
The token leaves agyAntigravity OAuth used in another tool
agy as a model proxyAnother agent’s loop runs through it
One plan, many peopleShared, pooled or resold entitlements

As of Dec 2, 2026 · Source: Google Antigravity Additional Terms of Service, section 6

Your setupWhat section 6 says
A Claude Code subagent that runs agy -pPermitted: "calling it as a tool or subagent from another harness"
A Codex skill or a CI script that runs agy -pPermitted: "using the Antigravity CLI in headless mode"
An editor that shows Antigravity through agy acpPermitted: "wrapping it with a third-party UI (e.g., via agent client protocol)"
A tool that signs in with Antigravity's OAuth token itselfForbidden, line (a)
A wrapper that answers another agent's model calls through agyForbidden, line (b)
Several people's jobs on one person's planForbidden, line (c)

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.

One headless call, as Google's headless guide shows it

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. json prints one object at the end with status, response, error on failure, duration_seconds, num_turns and usage (token counts). stream-json prints one event per line while it works, including each tool call.
  • A schema when you need fields, not prose. --json-schema takes a schema string or a path to a .json file, and the parsed answer lands in structured_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 in status. An unknown --model fails loudly instead of quietly running another model.
  • No memory between calls. Each agy -p starts a fresh conversation. To continue one, pass --continue for the most recent or --conversation <id> with the conversation_id from an earlier answer.

How it is given a directory and a task:

  • The directory is the one you start it in. agy works on the folder it is launched from; the stream-json output opens with an init event that reports it as cwd. 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 -p starts in auto mode 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

  1. 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/agy on macOS and Linux. Check it with agy --version. If your shell says agy: command not found, add ~/.local/bin to your PATH. Google's getting-started guide

  2. Sign in once, interactively, as the same user

    Run agy in 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 guide

  3. Check your quota from the shell

    Since CLI v1.5.22 (December 2, 2026), agy usage shows your account's quota without starting a conversation, and it takes --output-format json too. Inside the interactive CLI, /usage shows the same, per model group.

  4. 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.allow in ~/.gemini/antigravity-cli/settings.json, such as command(git) or command(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:

Markdown
---
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:

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:

Markdown
---
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:

Python
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 with agy 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 -p starts 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.

  1. 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.

  2. Give the review a shape

    Save a schema at .claude/agy-review.schema.json so 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"]}

  3. 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.

  4. 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.

  5. Check nothing else moved

    Run git status. If the review run changed a file, you see it here and can inspect it with git diff before anything goes further.

The command the subagent runs:

Bash
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 9m
Illustration: Claude Code hands a branch review to Antigravity
You

Use the antigravity subagent to review feature/rate-limit against main, and wait for its report.

Agent · Claude Code

Handing the review to Antigravity, with the branch and the output schema named.

Bash

agy -p "Review what branch feature/rate-limit changes…" --output-format json --json-schema .claude/agy-review.schema.json --print-timeout 9m

exit 0

status SUCCESS · structured_output.findings · usage

Agent · Claude Code

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 -p runs 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 quota agy usage shows.

What that quota looks like depends on the plan, per Google's plans page, which applies to personal Google accounts:

PlanAntigravity quota, as Google states it
Free and Google AI PlusA quota refreshed weekly, with a weekly rate limit
Paid Google AI ProA high quota refreshed every five hours until the weekly limit is reached
Google AI UltraThe highest quota, refreshed every five hours, and the highest weekly limits

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.

What you seeWhyThe fix
authentication required, and the run exitsNo cached sign-in for this user on this machineRun agy once interactively as that user. For CI, use a Gemini API key or ADC
Error: failed to retrieve token: secret keyring is lockedThe system keyring is locked or has no session, often over SSHLinux: export $(dbus-launch) and unlock the keyring. macOS over SSH: security unlock-keychain ~/Library/Keychains/login.keychain-db
In Claude Code: Command did not complete within its 120s timeout and was moved to the backgroundBash's two-minute default ran out firstKeep --print-timeout below the Bash timeout and ask for up to ten minutes; raise BASH_MAX_TIMEOUT_MS for longer jobs
agy exits 3 and prints an AGY_ERROR line--print-timeout cut the turn shortRaise the limit, or split the task into smaller ones
Exit 0, but the work isn't done and stderr names a toolAn action needed approval nobody could give, so it was soft-deniedAllow that action in permissions.allow in agy's settings
Exit 1: the model "is not recognized"A --model slug that doesn't existList the real ones with agy models
From Codex, agy can't reach GoogleCodex's sandbox controls network accessThe prefix_rule above, or network_access

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:

  1. Reviews go one at a time. Commit, hand off, wait for the report, then edit. That is the worked example above.
  2. 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, run agy -p from ../myapp-agy, and merge its branch when you've read it. Remove it afterwards with git worktree remove ../myapp-agy (git's worktree docs).
  3. In Claude Code, let the subagent carry the worktree. Add isolation: worktree to the subagent's frontmatter and Claude Code runs it in a temporary worktree, where its Bash commands, agy -p included, 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 agy into 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.

Published
Category
Build
Related Articles
LM Studio: What It Is and How to Run Your First Local Model

LM Studio: What It Is and How to Run Your First Local Model

Find the LM Studio desktop installer, choose a model that fits your memory, chat offline, and send your first request to its local server.Dec 2, 2026Build
Kiro Crew: What Teams Share and How to Get Started

Kiro Crew: What Teams Share and How to Get Started

How a shared Kiro Crew turns review feedback into team skills, who can join, what the crew seat costs and how to connect your first host.Dec 2, 2026Build
How to Install Claude Code on macOS, Linux and Windows

How to Install Claude Code on macOS, Linux and Windows

Install Claude Code on macOS, Linux or Windows. Choose your terminal, verify the install, sign in, fix common errors and update or uninstall it.Dec 2, 2026Build
Claude Managed Agents on Amazon Bedrock and the Claude API

Claude Managed Agents on Amazon Bedrock and the Claude API

Choose between the Claude API and Amazon Bedrock, see who runs the tools and bills usage, and create an agent with Anthropic’s documented request.Dec 1, 2026Build
Harness Tuned for One Model, Run on Another: What Google's Papers Measured

Harness Tuned for One Model, Run on Another: What Google's Papers Measured

Google's Harness² papers, read closely: what happened when a harness met a new model, what carries over, and a first-week checklist for switching models.Dec 1, 2026Build
Claude Buddy: What Happened to the Terminal Pet?

Claude Buddy: What Happened to the Terminal Pet?

Why /buddy stopped working in Claude Code, what the maintainer said, and how to tell the terminal pet from Anthropic’s Desktop Buddy hardware project.Dec 1, 2026Build
NotebookLM MCP

NotebookLM MCP

Connect Claude Code to Google's NotebookLM MCP server. See who can use it, how to add sources, and which community tools can answer notebook questions.Dec 1, 2026Build
Grok Build TUI: How to bring your terminal work across

Grok Build TUI: How to bring your terminal work across

Which command brings your settings or sessions into Grok Build, how Cursor’s harness runs workflows, and what stays on your laptop when you steer from iOS.Dec 1, 2026Build
Newsletter

One letter, every Sunday.Working systems, not hot takes.

Weekly. No spam. Unsubscribe anytime.