All notes

Antigravity's agy -p edits files without asking: how to make it read-only

AntigravityGeminiAI agentsCode review

The first thing Google’s Antigravity CLI did on my machine was write a file and run a command, without asking. That was a one-shot agy -p run, which since version 1.5.7 starts in auto mode wherever auto mode is available. A settings file passed with --settings on every run keeps it to reading, and it says so when it refuses.

I installed agy 1.5.15 to have a second reviewer when Codex hits its usage limit. A reviewer only needs to read. So before pointing it at a repository, I tried it in an empty folder:

agy -p "Do two things in the current directory: (1) create a file named probe.txt containing the word hello; (2) run the shell command 'whoami'. Then report in one line each whether each step succeeded or was refused." --model gemini-4-neon-low --output-format json

Both worked. probe.txt was there, and the answer quoted my Windows account name back to me. It didn’t ask about either, and it exited with code 0.

Why it didn’t ask

I’d expected a question, and the docs seemed to agree. The settings reference gives toolPermission a default of request-review, which “prompts for write, bash, web, and MCP tools unless an allow rule covers them.” And agy --help lists --mode with three values and no default.

The answer is on the docs page about headless use. If agentMode isn’t set, agy -p runs in auto mode wherever auto mode is available. Auto mode has existed on Windows since 1.4.4, for personal accounts, and became the starting mode in 1.5.7. It approves edits inside the workspace and runs commands in its sandbox. A prompt would have had nowhere to go anyway: there’s no terminal to answer it in a one-shot run.

--mode plan looked like a way out. That run ended with a plan and a request to approve it, and created nothing. But the docs only say plan mode uses read-only tools to build its outline, not that it blocks writes. I didn’t want a reviewer whose safety rests on its own restraint.

The settings file

{
  "agentMode": "",
  "toolPermission": "request-review",
  "enableTerminalSandbox": false,
  "permissions": {
    "deny": [
      "write_file(*)", "command(*)", "mcp(*)", "execute_url(*)",
      "read_file(.env)", "read_file(.env.local)",
      "read_file(.env.production)", "read_file(.env.development)"
    ]
  }
}

The modes page lists default mode as agentMode: "", the mode that asks before writing a file or running a command. Auto mode needs the terminal sandbox, so turning the sandbox off is a second lock on the same door. The deny rules are what I actually count on. Deny beats ask and allow, and the docs say deny rules apply in every mode. execute_url is its browser agent. The .env lines are a small extra, not a promise: they don’t cover every file a secret can live in, so I don’t point it at folders that hold keys.

It can still search the web. The rules cover files, commands, MCP tools and the browser agent, which is what I needed.

Same test, plus a read, with the file:

agy -p "Do three things in the current directory: (1) read probe.txt and quote its content; (2) create a file named probe3.txt containing the word hello; (3) run 'whoami'." --settings readonly.json --model gemini-4-neon-low --output-format json

It quoted probe.txt and refused the other two with “permission denied by user-configured deny rule”. No probe3.txt. The exit code was 0 again, so a script has to read the answer to know what was refused.

Reviewing with it

A read-only agent can’t run git diff, because that’s a command. So I write the diff to a file in a scratch folder and give agy that folder with --add-dir:

git diff HEAD~1 HEAD -- src/ > $scratch\diff.patch
agy -p "<the review brief, naming $scratch\diff.patch>" --add-dir $scratch --settings readonly.json --model gemini-4-neon-high --output-format json --print-timeout 900s

I read the review from the response field of the JSON. For a follow-up question, --conversation with the run’s conversation_id picks up where it left off. And I compare git status --short before and after. They have to match.

Its first real review was the commit that added the figure to Spreadsheets were the first vibe coding. It took 256 seconds and came back with five findings. Four held up when I checked them against the code, all in the figure’s labels and colours. The fifth said the article never mentions 2012. It does. Afterwards git status and HEAD read exactly as before.