After installing agy, most developers spend their first few weeks stuck in a basic loop: cd into a repo, run agy, type a prompt, and wait for edits. Once you actually adopt agy as your daily driver, the bottleneck is rarely model intelligence—it is a handful of recurring workflow papercuts:

  • Switching modes, picking models, and dismissing unwanted prompts every time you open a new session;
  • Providing vague context so the model burns turns grepping the entire repository and still edits the wrong file;
  • Long sessions getting slow and unfocused without a clear rule for when to /compact, /fork, or /rewind;
  • Wiring agy into shell scripts or CI pipelines only to get unstable output instead of clean JSON—or worse, hanging the job indefinitely.

This guide walks through agy CLI configuration, interactive workflows, and headless mode in the exact order you use them day to day. Every command and output below was verified locally on Linux with agy v1.5.19.

agy CLI daily workflow and high-frequency command cheat sheet


1. Authentication & settings.json

1. Four Authentication Methods

The first time you run agy, it guides you through login and stores credentials in your system Keyring by default. Over SSH on a remote host with no local browser, it automatically prints an out-of-band (OOB) auth URL—open it in your local browser, authorize, and paste the callback code back into the terminal.

Four authentication modes are supported (configured via auth.type):

Auth Mode Use Case Notes
oauth-personal Personal Google account (Free / Pro / Ultra) Default; lowest-friction interactive login
oauth-business Gemini Enterprise account Requires gcp.project and gcp.location
gemini-api-key Direct Gemini API Key Can be injected via the GEMINI_API_KEY env var
agent-platform Gemini Enterprise Agent Platform Supports API Key or ADC credentials

To switch accounts, run /logout inside the TUI; the next launch triggers the login flow again.

2. My Production settings.json

Persistent CLI configuration lives at ~/.gemini/antigravity-cli/settings.json. You can edit it through the full-screen menu with /config (alias /settings) inside the TUI, or edit the JSON directly (adding $schema at the top enables autocomplete and validation in your editor).

Here is the sanitized config I actually run on my workstation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"$schema": "https://antigravity.google/schemas/v1/settings.json",
"colorScheme": "tokyo night",
"agentMode": "auto",
"enableTerminalSandbox": true,
"pickerGrouping": "grouped",
"permissions": {
"deny": [
"read_file(/home/user/.ssh)",
"read_file(/home/user/.gemini/secrets)",
"command(rm -rf*)",
"command(rm -fr*)",
"command(git push --force*)",
"command(git push -f*)",
"command(sudo*)"
]
},
"statusLine": {
"type": "command",
"command": "'/usr/bin/node' '/home/user/.agy-powerline/statusline.js'",
"stack_with_default": true,
"enabled": true
},
"title": {
"type": "command",
"command": "~/.gemini/antigravity-cli/title.sh",
"enabled": true
},
"trustedWorkspaces": [
"/home/user/workspace/project-a",
"/home/user/blog/hippo0913.github.io"
]
}

A few easy-to-miss fields worth highlighting:

  • statusLine and title: Both support pointing to a local script. agy streams throttled JSON snapshots of live session state (agent_state, tool_confirmation_pending, workspace, vcs.branch, conversation_title, subagents, etc.) to the script via stdin.
    • Setting "stack_with_default": true under statusLine keeps the built-in status row (mode, model, effort level) while stacking your custom line underneath.
    • title dynamically updates the terminal window title. My title.sh inspects agent_state and tool_confirmation_pending and prefixes the title with a status dot (🟢 idle / 🟣 running / 🟡 awaiting approval / 🔴 error), so with four or five terminal windows open I can spot a blocked approval at a glance.
  • trustedWorkspaces: The first time you trust a directory, the CLI appends its path here automatically so you are not prompted again.
  • One-off overrides with --settings: When you want different settings for a single run without modifying settings.json on disk, pass --settings:
1
2
3
4
5
# Temporarily switch to read-only plan mode without saving on exit
agy --settings '{"agentMode":"plan"}'

# Or point to a standalone JSON config file
agy --settings ./ci-agy-settings.json -p "Review changes on the current branch"

Real-world pitfall: When enableTerminalSandbox is true, do not use ** glob wildcards inside permissions.deny read_file(...) rules (for example, read_file(/home/user/.ssh/**)). During sandbox initialization, path validation immediately fails with sandbox configuration error: deny ...: globs not supported., breaking every command inside the sandbox. To block an entire sensitive directory, use the exact directory path: read_file(/home/user/.ssh).


2. Launching, Resuming & Multi-Repo Context

Day to day, only a handful of launch flags do almost all the work:

Command Behavior When to Use
agy Start a new session in the current directory Starting a fresh, self-contained task
agy -c Resume the most recent session in this directory (--continue) Picking up where you left off after closing the terminal or the next morning
agy -r <id> Resume by conversation ID (--resume / --conversation) Jumping back to an older session or continuing a headless -p run
agy -i "<task>" Launch with an initial prompt and stay in the interactive TUI (--prompt-interactive) Wrapping in shell aliases for one-command task startup
agy --add-dir <path> Attach extra directories to the workspace (repeatable) Split frontend/backend repos, or a sibling shared-proto dependency
agy conversations list List locally stored conversations and disk usage Finding a past conversation ID, or pairing with clean to prune old history

One habit worth forming early: agy isolates conversation history by launch working directory. If you prefer working from the Git repository root, always launch from the root. Running agy at the root and later running agy -c inside backend/ resumes two completely separate conversation histories.


3. Pairing --mode with --effort

Many people never touch execution modes or reasoning tiers after installing agy—which leads to waiting thirty seconds of deep thinking for a one-line config tweak, or watching the agent scatter edits across a dozen files during a cross-module refactor before anyone agreed on a plan.

First, separate what each dimension controls:

  • --mode (permissions and pace): Controls whether the agent pauses for approval before editing files or running commands. Inside the TUI, press Shift + Tab anytime to cycle modes without restarting.
  • --effort (reasoning depth): Controls the thinking budget per turn across five tiers: low, medium, high, xhigh, and max (available tiers vary by model; run agy models to inspect models and supported levels on your account). Switch mid-session anytime with /effort medium or /effort high.

Follow this decision tree and you will rarely pick the wrong combination:

Here is how the four execution modes compare:

Mode File Edits / Creation Terminal Commands Best For
Default (unset) Prompts with diff approval Follows permission rules + sandbox Getting started, or touching sensitive core code
accept-edits Auto-approved Still prompted per permission rules Trusting code edits while gating shell scripts
auto Auto-approved Auto-runs inside sandbox; prompts to escape sandbox Daily driver—smoothest edit-and-test feedback loop
plan Direct code edits blocked Read-only exploration; produces a plan first Large changes, cross-module refactors, unfamiliar codebases

The most comfortable daily rhythm is setting "agentMode": "auto" as the default in settings.json. Whenever a task looks non-trivial, hit Shift + Tab to drop into plan (or run /plan), review and confirm the plan, then toggle back to auto so the agent can implement and verify tests end to end.


4. Inside the TUI: @, !, Slash Commands & Keybindings

1. @ and !: Better Than Typing Two Extra Paragraphs

  • @ (pinpoint context): Typing @ opens an autocomplete picker for file paths, directories, past conversations, rules, and connected MCP resources.
    • Instead of asking “check why the blog table styling wraps awkwardly”, write @source/css/table-polish.css Why is the first column in this table wrapping?. Pointing directly at the target file skips several rounds of search tool calls, cuts latency and token usage, and keeps edits on target.
  • ! (run local shell commands inline): Prefix a line with ! to execute a shell command directly in your local terminal—for example !git status, !git diff --stat, or !yarn build. Output prints straight into the stream, so you do not need to switch tmux panes just to check branch state.

2. High-Frequency Slash Commands You Will Actually Use Daily

Type / to open the full command menu, or run /help (shortcut ?) to inspect every command supported by your installed version. These are the ones that earn a permanent spot in muscle memory:

Command Alias What It Solves
/plan [task] — Explore the codebase, align on constraints, and write a reviewable plan before editing
/diff — Open an interactive diff view to review changes turn-by-turn or across uncommitted edits
/compact [instructions] — Compress long conversation history into a summary checkpoint to free context window
/rewind /undo Roll back to an earlier turn when a thread goes off the rails—no need to re-explain context
/fork /branch Clone a new session from the current turn to safely prototype an alternative approach
/resume /switch Open the session picker to jump between past conversations in the current repo
/context — Inspect token usage breakdown across the context window to decide when to compact
/model — Switch models (supports /model <model> <prompt> for a single-turn override)
/effort [level] — View or adjust reasoning effort on the fly
/config /settings Open the interactive config panel to edit settings.json
/clear /new Clear current context and start a fresh conversation in place

Two habits make long sessions dramatically cleaner:

  1. Give /compact a focus: Avoid running a bare /compact. Tell it what must survive—for example, /compact Keep the API schema contract and the two failing unit tests—so critical constraints do not get summarized away.
  2. Run /fork before major pivots: When you are halfway through a refactor and unsure between two designs, /fork a branch to test Plan B. If it does not pan out, switch right back to the original session with an untouched context.

3. Keybindings & Custom keybindings.json

Six default shortcuts cover almost every interaction:

Shortcut Action
Shift + Tab Cycle execution modes (default → accept-edits → auto → plan)
Esc Interrupt streaming output or dismiss the active dialog/panel
Esc × 2 Quickly clear drafted text in the input box when not streaming
Ctrl + G Open your external $EDITOR (Vim / VS Code) to draft multi-line prompts
Ctrl + L Clear and redraw the terminal screen
Ctrl + D × 2 Exit agy when the input box is empty (same as /exit)

To remap keys, create ~/.gemini/antigravity-cli/keybindings.json (delete the file anytime to restore defaults):

1
2
3
4
5
{
"cli.clear_screen": ["ctrl+l"],
"prompt.insert_newline": ["shift+enter", "ctrl+j"],
"edit.open_editor": ["ctrl+g"]
}

Three protected bindings cannot be disabled or remapped: cli.exit (Ctrl + D), cli.escape (Esc / Ctrl + C), and cli.enter (Enter), preventing a bad config from locking you inside the TUI.


5. Headless Mode (-p): Wiring agy into Scripts and CI

Beyond the interactive TUI, passing -p (--print / --prompt) turns agy into a standard Unix command you can drop into shell pipelines, Git hooks, or CI jobs.

It follows clean stream separation: the final answer goes to stdout, while progress updates, warnings, and diagnostic logs go to stderr. You can safely pipe stdout straight into jq or redirect it to a file without progress-spinner noise corrupting the payload.

Headless mode reuses locally stored credentials. Before running scripts on a fresh machine or container, either complete one interactive login or set GEMINI_API_KEY.

1. Choosing Between the Three --output-format Options

Format stdout Payload Typical Use Case
text (default) Plain-text response Commit summaries, PR comments, simple shell variable capture
json Single JSON object printed on completion Extracting fields with jq, tracking token usage and latency
stream-json Line-delimited NDJSON event stream Live monitoring of tool calls and progress, or multi-turn programmatic control with --input-format stream-json

2. Verified Example: --output-format json + --json-schema

The biggest headache in LLM automation is chattiness—you ask for raw JSON and the model wraps it in Markdown fences or prepends “Sure, here is the result:”. Passing --json-schema enforces a strict output structure. Here is real output captured locally on agy v1.5.19:

Verified output of agy CLI headless mode with JSON Schema

Two fields in the JSON payload are especially useful in production pipelines:

  1. structured_output: Whenever --json-schema is supplied, the schema-validated object lands cleanly under .structured_output. Downstream scripts can extract values directly with jq -r '.structured_output.xxx'—zero regex cleanup against .response.
  2. conversation_id: Headless runs still persist conversation history to disk. If a CI review script flags a surprising conclusion, copy the conversation_id from the job log and run agy -r <conversation_id> locally to pick up that exact context and interrogate the reasoning.

3. Three Safety Flags for Every CI Script

1
2
3
4
5
6
7
8
# Example: inspect current branch changes in CI and emit a structured risk report
git diff origin/main...HEAD | agy -p "Review the code changes from stdin and list potential bugs and regression risks" \
--model gemini-3.8-flash-medium \
--output-format json \
--json-schema ./scripts/review-schema.json \
--print-timeout 90s \
--disable-slash-commands \
> review-report.json

Bake these three flags into your CI script templates:

  • --print-timeout 90s: Defaults to 0s (no timeout). Without an explicit cap, a network hiccup or model loop can burn through your entire CI runner budget.
  • --disable-slash-commands: Prevents lines starting with /xxx inside piped diffs, logs, or PR descriptions from being accidentally expanded as slash commands or Skills.
  • Explicit lightweight --model: For batch jobs and CI checks, pin a Flash model or low effort tier to keep latency and cost predictable.

Series Navigation