Antigravity hooks reference: force_ask, fail-closed, and --dangerously-skip-permissions
Just want the answer? An Antigravity hook is a command registered in hooks.json that answers PreToolUse calls with a JSON decision: allow, deny, ask, force_ask, or deny_unless_prior_grant. A crashed hook blocks the call. The entry ACP uses in ~/.gemini/config/hooks.json is below.
Install ACP first: the line below writes ~/.acp/hooks/antigravity/hook.mjs and merges this entry for you. Pasting the entry without that file makes the hook fail, and Antigravity then blocks every tool call.
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
irm https://agenticcontrolplane.com/install.ps1 | iex
{
"hooks": {
"PreToolUse": [
{ "matcher": "*",
"hooks": [ { "type": "command", "command": "node ~/.acp/hooks/antigravity/hook.mjs" } ] }
]
}
}
Install the ACP hook in one command → · Antigravity's full control model → · free up to 5 agents
Two limits before you install. The hook needs a free workspace, because --local skips Antigravity. And no hook runs in a session started with --dangerously-skip-permissions. To write your own hook with no ACP at all, the 20-line version is further down.
Last updated: November 8, 2026. Everything here is read from Google’s hooks documentation or verified against the agy 1.1.21 binary as of September 16, 2026. The one thing we have not seen live is how the interactive terminal UI renders a force_ask reason.
Antigravity is Google’s agent-first development environment. It includes the IDE, the agy command line (which replaced Gemini CLI in May 2026), and extensions for VS Code, JetBrains, Zed and Xcode. All of them read one shared hook registration. Its hooks are younger than Claude Code’s and narrower than Cursor’s, but they make two distinctive choices. A hook’s ask is a first-class decision that the person sees, and a hook that fails blocks the call instead of letting it through. This page covers the five events, the payload, the decisions, and the one flag that removes all of it.
Where hooks live
hooks.json is read from two places, shared across every Antigravity surface:
| Scope | Location | Notes |
|---|---|---|
| Workspace | .agents/hooks.json |
Behind folder trust. Trust the folder and its hooks are live |
| User (global) | ~/.gemini/config/hooks.json |
Shared by the CLI, the IDE and the app. The ACP installer writes here, merged under its own key |
The file looks like this:
{
"hooks": {
"PreToolUse": [
{
"matcher": "run_command",
"hooks": [
{ "type": "command", "command": "node ~/hooks/check-shell.mjs", "timeout": 30 }
]
}
],
"Stop": [
{ "type": "command", "command": "node ~/hooks/receipt.mjs", "timeout": 10 }
]
}
}
Tool events (PreToolUse, PostToolUse) are a list of { matcher, hooks[] } groups. Stop is a flat list of commands with no matcher. type: "command" is the only handler kind. timeout is in seconds and defaults to 30.
The five events
PreToolUse, PostToolUse, PreInvocation, PostInvocation, Stop. Tool events take a regex matcher against the tool name, such as run_command|view_file, browser_.*, or * for everything. Handlers are shell commands that read camelCase JSON on stdin and print a JSON decision on stdout.
PreInvocation and PostInvocation can inject steps into the agent loop, and PostInvocation can force the loop to continue or end. Stop hooks can re-enter the loop with decision: "continue", up to a built-in limit, so an always-blocking stop hook cannot hold the agent forever.
One quirk to know before you write a handler: the payload does not name its own event. Claude-style hooks carry a hookEventName field, and Antigravity’s do not. A handler that serves more than one event is registered once per event, with the event passed as an argument.
What arrives on stdin
The PreToolUse payload, field by field:
| Field | Type | What it carries |
|---|---|---|
toolCall.name |
string | Antigravity’s native tool name: run_command, view_file, write_to_file, replace_file_content, multi_replace_file_content, grep_search, find_by_name, list_dir, search_web, read_url_content, invoke_subagent, or an MCP tool’s own name |
toolCall.args |
object | The tool’s arguments. For run_command the shell string is args.CommandLine, not command (verified on 1.1.21) |
conversationId |
string | The session. Stable across every call in one conversation |
workspacePaths |
string[] | The open workspace roots. The first is the closest thing to a working directory |
modelName |
string | The model serving the turn |
stepIdx |
number | The step’s index within the turn |
PostToolUse has the same shape plus an error string when the call failed. It does not carry the tool’s output. It also fires on non-tool steps, with toolCall set to null, so a handler must filter those before it logs anything. The payload names a transcript file that holds the full exchange if you need more.
Two things are missing. There is no event name, and there is no permission-mode field, so nothing in the payload says whether a person is watching. A hook that should behave differently unattended has to learn that from somewhere else. The hook environment is sanitized, so that means a file it reads.
The decisions, and a native ask
A PreToolUse hook answers:
{ "decision": "deny", "reason": "…" }
decision is one of allow, deny, ask, force_ask or deny_unless_prior_grant. An optional permissionOverrides array can grant action(target) resources for the rest of the turn, using the same syntax as Antigravity’s permission rules. An unknown decision value is an error (“unknown pre-tool hook decision”). An empty decision is tolerated.
ask prompts the person but respects a cached “Always Allow” grant from earlier in the session. force_ask prompts every time and ignores that cache. That is the useful difference: a hold that a cached grant cannot answer for you.
PostToolUse is for audit, not content scanning
PostToolUse fires after the call with toolCall and an error string, but not the output. A hook can log that a call happened and whether it failed. It cannot see what a view_file returned or scan a command’s stdout for secrets. The full exchange is in the transcript file the payload points to.
Two more sharp edges
The hook environment is sanitized. Only whitelisted variables reach the subshell, so configuration through environment variables mostly does not work. Put it in a file the hook reads.
.git is read-only in the sandbox. With the terminal sandbox on, a repo’s .git directory mounts read-only, even for an otherwise writable agent.
Fail-closed by default
A failing PreToolUse hook blocks the call. Crash, timeout or non-zero exit all give “pre-tool hook failed”, and the tool does not run. There is no exit-code deny either. A denial has to travel as JSON with exit 0.
That cuts both ways. A broken policy hook never lapses silently, which is the opposite of a fail-open core where an unreachable backend quietly turns enforcement off. But a hook whose own backend goes down can block every tool call in the session unless the hook has a plan of its own.
The ACP hook for Antigravity has one. It always exits 0 with a JSON decision, including when it crashes, and applies its own posture on top. If the gateway is unreachable, interactive sessions proceed with a loud [ACP] UNGOVERNED warning and a line in ~/.acp/lapse.log, so an outage never bricks a session you are sitting at. Unattended tiers stay blocked, because nobody is there to notice a silent gap.
A minimal hook you can write yourself
The smallest useful PreToolUse hook is a deny-list on shell commands. It reads the payload, checks toolCall.args.CommandLine, and always exits 0 with a decision, even on malformed input, because on Antigravity a hook that throws blocks the call.
#!/usr/bin/env node
// ~/hooks/deny-list.mjs: minimal Antigravity PreToolUse hook
let raw = "";
process.stdin.on("data", (d) => (raw += d));
process.stdin.on("end", () => {
let payload = {};
try { payload = JSON.parse(raw); } catch { /* still answer */ }
const call = payload.toolCall ?? {};
const cmd = call.name === "run_command" ? String(call.args?.CommandLine ?? "") : "";
if (/\brm -rf\b|--force\b|\bDROP TABLE\b|\bgh repo delete\b/i.test(cmd)) {
console.log(JSON.stringify({
decision: "deny",
reason: "Blocked by policy: destructive command",
}));
return;
}
console.log(JSON.stringify({ decision: "allow" }));
});
// Never exit non-zero: Antigravity treats a failing hook as an error and
// blocks the call. Every outcome travels as JSON on stdout.
Register it under PreToolUse with "matcher": "run_command" and it sees every shell call. Swap deny for force_ask and the same script becomes a hold that a person must answer, with no cached grant able to skip it.
This hook has two limits. Matching a string is not parsing a shell command, and destructive behavior hides in compound commands, scripts and aliases that no pattern list anticipates. It also does not know whether anyone is watching. It will force_ask on a CI runner exactly as it does in the IDE. In the IDE a person answers. Headless, Antigravity soft-denies it.
The ACP version uses the same contract. It checks each call against your workspace policy, reads the tier from a config file because the environment is sanitized, and records every decision, denies included, in a log you can read later.
The bypass flag removes the hooks
--dangerously-skip-permissions auto-approves every tool permission request in Antigravity. We ran an A/B pair of otherwise identical headless turns on agy 1.1.21 and saw something other bypass flags do not do: PreToolUse hooks are not invoked at all. No hook runs, no decision is made, and no record exists. That includes ACP’s hook.
In Claude Code, deny rules and hooks still fire under --dangerously-skip-permissions, and a hook deny still blocks the call. On Antigravity, use scoped permissions.allow rules to unblock headless runs, and treat the flag showing up in a fleet as something to alert on.
What the ACP hook does with this contract
The installer detects Antigravity (the agy CLI, or an existing ~/.gemini/antigravity-cli profile), places the hook at ~/.acp/hooks/antigravity/hook.mjs, and merges its registration into ~/.gemini/config/hooks.json under its own acp key. The file is shared across the CLI, IDE and app, so the merge does not overwrite hooks already there. Before each tool runs, the hook asks the gateway through /govern/tool-use. After it runs, a completion record goes to /govern/tool-output. At the end of a session, a receipt with a console link appears in the scrollback.
Antigravity’s native tool names (run_command, view_file, replace_file_content and so on) are normalized before the policy check, and the native name stays in the audit record as client_tool_name. The hook turns an ACP ask into force_ask. Today the gateway holds Antigravity calls the same way it does on every harness other than Claude Code: the call is blocked, you approve it on the Approvals page or from the email, and the agent retries. The always-blocked floor (a recursive delete of root, for one) was verified live under the run_command name.
Troubleshooting
The hook is not firing. /hooks inside Antigravity lists what is loaded. User hooks come from ~/.gemini/config/hooks.json. Workspace hooks come from .agents/hooks.json and only load once the folder is trusted. Check the matcher too. It is a regex on the native tool name, so Bash matches nothing here. The shell tool is run_command.
Every call is blocked with pre-tool hook failed. Your hook crashed, timed out or exited non-zero. Run it by hand with a sample payload and confirm it prints JSON and exits 0 on every path, including malformed input and an unreachable upstream.
The hook never sees the shell command. You read args.command. On Antigravity the field is args.CommandLine.
The hook cannot find its configuration. The environment is sanitized, so the variable you set in your shell did not arrive. Read a file instead.
Nothing fires under --dangerously-skip-permissions. That is expected. The flag removes the hook layer.
A PostToolUse handler logs empty calls. It fires on non-tool steps with toolCall: null. Filter those out.
A Stop hook keeps the agent going. It returned decision: "continue". Return anything else to allow the stop.
Known limits
PostToolUsecarries no tool output. Only the transcript file has it, so you cannot scan results from the hook payload.--dangerously-skip-permissionsis total. No hook, ACP’s included, is consulted under the flag, and no deny survives it.--localis not wired for Antigravity. ACP’s on-device mode (~/.acp/policy.json,~/.acp/audit.jsonl, no account) skips Antigravity, so the hook needs a workspace connection.- Configuration lives in a file. Use
~/.acp/config.jsonwith snake_case keys. Unattended fleets should set"agent_tier": "background"there. - Tool calls only, no model traffic. Antigravity’s Gemini endpoint is fixed and has no base-URL override, so its model calls cannot go through the ACP proxy. The cost X-ray lists it as tool-call control only.
How it compares
| Dimension | Antigravity | Claude Code | Codex CLI | Cursor |
|---|---|---|---|---|
| Config path | ~/.gemini/config/hooks.json; workspace .agents/hooks.json behind folder trust |
~/.claude/settings.json |
~/.codex/hooks.json; repo .codex/hooks.json |
~/.cursor/hooks.json |
| Events | PreToolUse, PostToolUse, PreInvocation, PostInvocation, Stop |
PreToolUse, PostToolUse, and more |
PreToolUse, PostToolUse, PermissionRequest, SessionEnd |
A wide agent set: preToolUse, beforeShellExecution, beforeMCPExecution, and more |
| Pre-call decisions | allow, deny, ask, force_ask, deny_unless_prior_grant, permissionOverrides |
allow / deny / ask, input rewrite |
deny (JSON or exit 2), allow + updatedInput |
permission: deny; ask accepted but not enforced on preToolUse |
| Hook failure default | Fail-closed: the call is blocked | Fail-open | Fail-open | Fail-open unless failClosed: true |
| Deny channel | JSON only, no exit-code deny | JSON, or exit 2 | JSON, or exit 2 | JSON permission: "deny" |
| Under the bypass flag | Hooks not invoked (--dangerously-skip-permissions) |
Hooks still fire | See the Codex hooks reference | See the Cursor hooks reference |
The other contracts are in full in the Claude Code hooks reference, the Codex CLI hooks reference and the Cursor hooks reference.
What to do
- Exit 0, always. On Antigravity a hook that dies takes the call with it. Put every outcome, errors included, in the JSON.
- Register once per event, with the event as an argument. The payload will not say which event you are serving.
- Configure by file. The variables you exported may not arrive.
- Use
force_askfor holds that must reach a person. A cached grant cannot answer it, and headless Antigravity soft-denies it on its own. - Alert on the flag.
--dangerously-skip-permissionsremoves every hook, yours included. Scopedpermissions.allowrules are the way to unblock a headless run.
Frequently asked questions
What hook events does Google Antigravity support?
Five: PreToolUse, PostToolUse, PreInvocation, PostInvocation, and Stop. They register in hooks.json, either workspace-local at .agents/hooks.json (behind folder trust) or user-global at ~/.gemini/config/hooks.json, shared by the CLI, the IDE, and the app. Tool events take a regex matcher on the tool name; a matcher of ‘*’ catches every tool call.
What can an Antigravity hook decide?
A PreToolUse hook answers with decision: allow, deny, ask, force_ask, or deny_unless_prior_grant, plus an optional permissionOverrides array. ask respects a cached Always-Allow grant; force_ask ignores it and prompts unconditionally.
What does an Antigravity PreToolUse hook receive on stdin?
camelCase JSON with toolCall (name and args), conversationId, workspacePaths, modelName, and stepIdx. There is no field naming the event, so a handler serving more than one event is registered once per event with the event passed as a command-line argument. For run_command, the shell string is args.CommandLine, verified live on agy 1.1.21. PostToolUse adds an error string but not the tool’s output.
What happens when an Antigravity hook crashes or times out?
The tool call is blocked. Antigravity treats a failing PreToolUse hook (crash, timeout, non-zero exit) as an error and fails closed, which is the opposite of Claude Code’s and Cursor’s fail-open defaults. A hook you install should always exit 0 with a JSON decision and carry its own plan for when its upstream is unreachable.
Does --dangerously-skip-permissions disable Antigravity hooks?
Yes, completely. We verified it live on agy 1.1.21: under the flag, PreToolUse hooks are not invoked at all, so there is no hook execution, no decision, and no record. ACP’s hook is removed along with every other. In Claude Code, hooks still fire and a deny still blocks under its bypass flag. On Antigravity the flag removes the hook layer itself, not just the prompts.
Why isn't my Antigravity hook firing?
Check /hooks inside Antigravity for what’s registered, then the file: user-global hooks live in ~/.gemini/config/hooks.json and workspace hooks in .agents/hooks.json, which only load once the folder is trusted. If the session was started with --dangerously-skip-permissions, no hook fires at all. If the hook runs but every call is blocked with ‘pre-tool hook failed’, the hook is crashing, timing out, or exiting non-zero, and on Antigravity that blocks the call instead of skipping the hook.
Where to read more
- Antigravity’s full control model: the permissions engine, the sandbox, headless behavior, the enterprise plane, and a blocked call end to end
- Antigravity permissions reference:
allow/ask/deny, the seven actions, prefix andregex:matching, the presets - Install ACP for Antigravity: the hook, the merge behavior, what the dashboard shows, and troubleshooting
- antigravity-acp-plugin on GitHub: MIT, zero dependencies, one readable file
- Google’s Antigravity hooks documentation: the upstream source for the contract
- Claude Code hooks reference: the closest sibling contract, fail-open instead of fail-closed
- Cursor hooks reference: a third fail-open core, with an LLM classifier ahead of it
- Codex CLI hooks reference: a narrower, shell-first hook surface
Running Antigravity? One command adds a hook. Each tool call it sees is recorded, and a force-push, destructive SQL or curl | sh is blocked until you approve it on the console or from the email.
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
irm https://agenticcontrolplane.com/install.ps1 | iex
What the installer writes · Antigravity guide · free up to 5 agents