---
name: invoke-antigravity
description: Run Google Antigravity (the `agy` CLI) headlessly through `cairn invoke antigravity` for an adversarial second opinion, code review, plan review or an independent Gemini pass, with progress readable mid-run, the conversation resumable later, and the exchange recorded in cairn. Use when the user says "invoke antigravity", "ask antigravity", "ask agy", "antigravity review", "gemini review", "second opinion from antigravity", "antigravity resume", or asks for a cross-model quality gate from Google's agent.
argument-hint: "[prompt or gate name] [model] [effort]"
allowed-tools: Bash(cairn:*), Bash(qmd:*), Bash(agy:*), Read, AskUserQuestion, Monitor
---
Read [the harness contract](../../references/harnesses/contract.md) and its relevant
Claude or Codex reference from this installed package before host-specific operations.
Then read [the peer review doctrine](../../references/peer-review.md).
# Invoke Antigravity
The engine is `cairn invoke antigravity`. This skill only drives it. The CLI is authoritative
for flags: run `cairn invoke antigravity --help`. Every run is recorded under cairn's data
root, the Antigravity conversation is exported as a session document and linked to the
calling session, and an exchange document with the prompt, progress, answer and result per
round lands in the calling session's folder.
## Host caveat
Which credential a run needs depends on the billing route (section 3b). On route `gcp`,
`agy` authenticates with Application Default Credentials (ADC), not its own login, and the
ADC refresh token expires on a schedule under a Workspace session-length policy. The engine
probes it before every spawn and in `cairn doctor` (`gcloud auth application-default
print-access-token`, up to 20 s, outside the run's own clock): a rejected token is exit 2,
`billing check failed`, with the `gcloud auth application-default login` command to give the
user; `billing: ADC token not verified` is a warning (no gcloud, no network) and the run
starts. On route `plan` or `inherit` without ADC, `agy` needs its own
cached login: the user must have run `agy` interactively once on this machine, else the run
fails at once with "authentication required" and `retryable: false`; ask the user to log in,
do not retry. `cairn doctor` reports both. Inside the Codex sandbox `agy` may not reach its
credential store either; run with escalated permissions or from the Claude host.
## 1. Prompt
Take the prompt from the user's words, or pick a gate prompt from the doctrine. Write
anything longer than a few lines to a file and pass `--prompt-file`. Always ask for the
`VERDICT:` line when the task is a review.
## 2. Model and effort
```bash
agy models
```
Offer only slugs from that list (for example `gemini-3.1-pro-high`); the slug carries the
model's own thinking level. `agy models` needs agy's own login, so on route `gcp` it can say
"Please sign in" while runs work; then use the configured model or omit `--model`, do not
ask the user to log in for it. `--effort` is cairn's separate reasoning-effort flag, one of
`low`, `medium`, `high`, `xhigh`, `max`. Both are optional: omit them to let `agy` choose, or
ask with the host's input tool when the user cares. Defaults come from the config
(`cairn config show --json`, key `invoke.antigravity`). An unknown slug fails the run with
exit 1 and the available models in `error`.
## 3. Profile
Default `--profile review`: `agy --mode plan`, which reads the workspace and defers every
file write until a human approves the plan, so a headless run cannot change anything. Ask
before `edit` (`--mode accept-edits`: file writes apply) or `full`
(`--dangerously-skip-permissions`: every tool call approved). In `plan` and `accept-edits` a
shell command runs only when an allow rule covers it (section 3a); `full` needs no rules.
`--mode` passes a native agy mode directly (`plan`, `accept-edits`, `auto`) and overrides the
profile. The record stores the exact flags that ran.
Plan mode reads the `--cd` tree with no rule; any other path needs a `read_file(
)`
allow rule or `--add-dir`, else the `read_file` is auto-denied and agy can end the turn right
there with no answer. Put every file the peer must read inside `--cd`, pass `--extra
--add-dir ` (last on the line, and again on every `--resume`: the flag is recorded in
the round's `argv` but not reapplied), or paste the text into the prompt. The brief itself
is passed as text, so its own location needs nothing.
## 3a. Shell permissions (check once per machine)
Headless `agy` cannot prompt, so a tool call that needs approval is auto-denied, with or
without a tool error in the stream; the turn may go on without it or end right there with
no answer, and agy reports success either way. A review that cannot run `grep`, `rg` or
`git diff` is weak, and an implementation that cannot run its tests is unverified. Check
once, before the first run on a machine:
```bash
cairn doctor # "antigravity permissions": both rule lists
cairn hook install --harness antigravity --grant-commands # write cairn's allow and deny sets
```
The grant writes `command(...)` allow rules (rg, grep, ls, cat, head, tail, find, echo,
`sed -n`, read-only `git` subcommands, pytest / ruff / mypy / `uv run` and `make` equivalents)
and a deny set (`supabase`, `psql`, `terraform`, `aws`, `gcloud`, `kubectl`, `curl`, `wget`,
`python`, `python3`, `git commit|push|checkout|stash|reset`, `read_file(.env*)`) to
`~/.gemini/antigravity-cli/settings.json`, keeps every existing rule, skips a deny the user
allows explicitly, and prints each rule it added. Tell the user what it wrote. A rule matches
word by word (`command(git log)` covers `git log -3`, not `git` alone), every segment of a
compound command (`a && b`, pipes) needs its own rule, and a deny rule beats an allow rule.
The engine enforces this per run:
- `--profile edit` or `--mode accept-edits` with no command rule is refused before the
spawn: exit 2, `permissions check failed`, the `--grant-commands` line in the message.
`--skip-permission-check` starts it anyway for a task that needs no shell.
- `review` (plan) and `auto` start and carry a `permissions:` warning instead.
- A round whose peer was refused calls and ended with an empty answer is `status: denied`
(exit 2, `retryable: true`), whether agy reported the refusal as a tool error (a shell
command) or only counted it (a soft-denied read); `error` names each refused command and
the rule it needs, and each refused path with the `read_file()` rule or `--add-dir`
that would cover it. A refusal beside a real answer stays `succeeded` with a
`permissions:` warning that carries the same verdicts; `denied` in the result lists the
tool and target of each. `tail` follows the round to its record (adopting it when both
processes are gone), `wait` holds for the record of a round another reader is adopting
(then `status: busy`, exit 75), and `status` reads the record once it exists.
- The round record in `thread.json` keeps `permissions` (the allow, deny and ask rules in
force when the round started, and `roots`: the workspace and every `--add-dir`); an
`ask` rule denies headlessly and counts as one in every verdict. A resume after a change
to any of the three lists tells the peer what changed (section 7).
When a project needs a command outside the defaults (`poetry run pytest`, `make format`),
add it to `permissions.allow` by hand, never to `full`.
## 3b. Billing route (optional)
`agy` bills either the user's consumer plan quota or, through Application Default
Credentials (ADC), Vertex AI on a GCP project. The route is decided by the environment the
`agy` process starts with, so a headless run from an agent can silently bill the wrong pool.
cairn makes it explicit per run; read the current setting first:
```bash
cairn config show --json # key invoke.antigravity.billing
cairn doctor # "antigravity billing" line: route, and for gcp whether ADC is ready
```
- `inherit` (default): the host environment is passed through unchanged.
- `plan`: `AGY_ADC_AUTH` is stripped; the run bills the consumer plan quota.
- `gcp`: `AGY_ADC_AUTH=true` (plus `GOOGLE_CLOUD_QUOTA_PROJECT` / `GOOGLE_CLOUD_LOCATION`
when `project` / `location` are set). Before anything is spawned cairn checks that the ADC
file exists and a quota project is known; otherwise exit 2 with the `gcloud` command to
run. After the run cairn reads `agy`'s own log and records `billing.observed`
(`auth_method`, `quota_project`, the projects the model requests went to). A mismatch is a
`billing:` warning and `billing.problem` in the result; report it to the user.
Set it once for the machine, or override one round with `--billing`:
```bash
cairn config set invoke.antigravity.billing.route gcp
cairn config set invoke.antigravity.billing.project
cairn invoke antigravity --billing plan --prompt "…" # one round on the plan quota
```
Only change the route when the user asks; it is their money. The summary line
`billing: route=gcp project= auth=adc quota_project= verified` confirms a GCP run.
## 4. Run in the background
Start it the way the host reference describes (Claude: `Bash` with `run_in_background:
true`; Codex: `exec_command` with a long yield) and keep the handle:
```bash
cairn invoke antigravity --json --prompt-file [--model ] [--effort ] \
--profile review [--cd ] [--timeout-s 1800]
```
`agy` chooses the conversation id and reports it in its first event; the engine prints it on
stderr as soon as it is known, with the run directory and the events path on the same line.
On Claude the caller is detected from `CLAUDE_CODE_SESSION_ID`, so `--parent` is redundant;
pass it only from a shell that has no host session. Nested runs are refused at depth 1
unless the user asks for `--allow-nested`.
## 5. Watch
```bash
cairn invoke tail # one line per event, until the final event
cairn invoke status # health line, progress bullets, answer so far
cairn invoke wait --json # block until the round exits; print its result line
```
`tail` replays and follows the round's event stream: `START `, `TOOL
`, `CMD `, `WRITE `, `DENIED `, `MSG `, and ends
with `RESULT ` (exit 0 on `succeeded`, else the round's exit code). On Claude it is
the whole `Monitor` command; no filter and no guess at the events file name. `wait` is the
one completion handle: it prints the same JSON line the runner prints and exits with its
code, so a second waiter loop is never needed.
`status` shows execution state, activity with its age, and the last event, then the progress
bullets (`run:`, `wrote:`, `denied:`, `tool:`, `message:`). `silent` beyond the stall
threshold means a probable hang: wait one more interval, then
`cairn invoke cancel ` and resume with a narrower task, or report. Silence
from the host task is never completion.
## 6. Read the result
One JSON line on the task's stdout. Lead with `last_message`. Then check `status`,
`outcome`, `exit_code`, `retryable`, `warnings` and `publication`. Check every claim in
`last_message` against `files_written` (the paths the peer's write tools finished, from the
event stream) and the diff: the peer's report can describe a design it abandoned. `denied`
lists every call agy refused. Evaluate critically per the doctrine. Exit codes: 0 succeeded;
2 self-check, depth, permissions or usage refusal, or a `denied` round; 75 thread busy;
124 wall-clock timeout; 125 idle timeout; 130 cancelled; otherwise the `agy` exit code.
A round that did not succeed carries `code` and `fix`; `cairn errors CODE` gives the next step.
## 7. Debate
```bash
cairn invoke antigravity --json --resume --prompt "This is () following up. Re: . . Convince me otherwise or concede. End with one line: VERDICT: accept | reject | unresolved - ."
```
Resume inherits the recorded cwd, profile, model and effort and continues the same `agy`
conversation. When the agy rules changed since the previous round, or that round had
refusals, cairn prepends a note to the prompt: the rules added and removed, and for each
refused command whether it is now allowed, still denied, or still unmatched. Nothing to
restate by hand. `agy` cannot fork a conversation, so `--fork` is refused. At most three
rounds per thread, then escalate to the user with the accepted, dismissed and unresolved
lists.
## 8. Close
Tell the user: the conversation id, the exchange document path and the Antigravity session
document path from the result, and how to continue:
`cairn invoke antigravity --resume --prompt "…"` for another round, or
`cairn resume antigravity:` to open it interactively. If `warnings` is empty
and `indexed` is true, `/search` finds the exchange document and `/recall` lists the peer
session now; if `indexed` is false, `rg` finds them at once and `/search` after
`cairn invoke publish ` or the next `cairn sync`.
## Errors
- Exit 2 with `permissions check failed` before any run: an `accept-edits` run with no
command rule. Run `cairn hook install --harness antigravity --grant-commands`, then start
again; `--skip-permission-check` only for a task that needs no shell.
- `status: denied` (exit 2, `retryable: true`): agy refused the calls in `denied` and the
peer answered nothing. For a command, add the rule `error` names to `permissions.allow`
(or run the grant); for a path outside the workspace, move the file inside `--cd`, add
the `read_file()` rule, or pass `--extra --add-dir `; then `--resume`; the
peer is told what changed.
- `warnings` with `permissions:`: the run answered, but agy refused the calls listed, or no
command rule exists at all. Read the verdicts; fix the rules before the next round.
- Exit 2 before any run: an unknown effort, `--fast` (Codex only), `--fork`, a nested run
refused, or `billing check failed` (route `gcp` without ADC or a quota project, or with
an ADC token Google rejected: give the user the `gcloud` command in the message, or set
`invoke.antigravity.billing.project`).
- `warnings` with `billing: ADC token not verified`: the probe could not conclude (no
gcloud, no network); the run started. If it then fails with `ADC token refresh failed`,
the user must run `gcloud auth application-default login`; a transport failure is
retryable.
- `warnings` with `billing:` otherwise: the run finished but agy did not take the requested
route (wrong auth method or project). Tell the user which credits were used; do not retry
blind.
- Exit 1 with `invalid model selection` in `error`: pick a slug from `agy models`.
- Exit 124 or 125: raise `--timeout-s` or `--idle-timeout-s`, or narrow the task. Never retry
blind; read `status` first.
- `retryable: false`: check `outcome` first. `cancelled` means someone stopped it; a login or
model error needs the user. Report the `error` text.
- `warnings`: the answer is saved but a publishing step is pending. `cairn invoke publish
` finishes it; the next `cairn sync` also does.
- `status: busy` (exit 75): another round of this conversation is running. Wait or `status` it.