# Antigravity hooks reference: force_ask, fail-closed, and --dangerously-skip-permissions

Google Antigravity's five hook events, the stdin payload field by field, the decisions a hook can return including force_ask, why a crashed hook blocks the call, a minimal hook you can write, and troubleshooting.

<div style="margin:8px 0 28px;padding:20px 22px;border:1px solid var(--line-2);border-radius:12px;background:var(--color-accent-light,#f0effe);">
  <p style="margin:0 0 12px;font-size:15px;line-height:1.6;color:var(--acp-text);"><strong>Just want the answer?</strong> An Antigravity hook is a command registered in <code>hooks.json</code> that answers <code>PreToolUse</code> calls with a JSON decision: <code>allow</code>, <code>deny</code>, <code>ask</code>, <code>force_ask</code>, or <code>deny_unless_prior_grant</code>. A crashed hook blocks the call. One entry in <code>~/.gemini/config/hooks.json</code>:</p>
  <pre data-track="AntigravityHooks: Hero Config Copy" style="margin:0 0 12px;background:var(--color-surface,#faf9ff);border:1px solid var(--line-2);border-radius:8px;padding:12px 14px;overflow-x:auto;"><code>{
  "hooks": {
    "PreToolUse": [
      { "matcher": "*",
        "hooks": [ { "type": "command", "command": "node ~/.acp/hooks/antigravity/hook.mjs" } ] }
    ]
  }
}</code></pre>
  <p style="margin:0;font-size:13px;color:var(--acp-text-dim);"><a href="/integrations/antigravity" data-track="AntigravityHooks: Setup Guide" style="font-weight:600;">Install the ACP hook in one command &rarr;</a> &nbsp;&middot;&nbsp; <a href="/controls/antigravity" data-track="AntigravityHooks: Controls Page">Antigravity's full control model &rarr;</a> &nbsp;&middot;&nbsp; free up to 5 agents</p>
</div>

*Last updated: November 8, 2026. Everything here is read from [Google's hooks documentation](https://antigravity.google/docs/hooks/) 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.

<!-- source: https://agenticcontrolplane.com/controls/antigravity -->

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

```json
{
  "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:

```json
{ "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](/blog/antigravity-permissions-reference). 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](/integrations/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.

```js
#!/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](/integrations/antigravity) 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`](/blog/claude-code-hooks-reference), 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](https://cloud.agenticcontrolplane.com/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

- **`PostToolUse` carries no tool output.** Only the transcript file has it, so you cannot scan results from the hook payload.
- **`--dangerously-skip-permissions` is total.** No hook, ACP's included, is consulted under the flag, and no deny survives it.
- **`--local` is 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.json` with 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](/cost-tracking) 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](/blog/claude-code-hooks-reference), the [Codex CLI hooks reference](/blog/codex-cli-hooks-reference) and the [Cursor hooks reference](/blog/cursor-hooks-reference).

## What to do

1. **Exit 0, always.** On Antigravity a hook that dies takes the call with it. Put every outcome, errors included, in the JSON.
2. **Register once per event, with the event as an argument.** The payload will not say which event you are serving.
3. **Configure by file.** The variables you exported may not arrive.
4. **Use `force_ask` for holds that must reach a person.** A cached grant cannot answer it, and headless Antigravity soft-denies it on its own.
5. **Alert on the flag.** `--dangerously-skip-permissions` removes every hook, yours included. Scoped `permissions.allow` rules are the way to unblock a headless run.

## Frequently asked questions



## Where to read more

- [Antigravity's full control model](/controls/antigravity): the permissions engine, the sandbox, headless behavior, the enterprise plane, and a blocked call end to end
- [Antigravity permissions reference](/blog/antigravity-permissions-reference): `allow` / `ask` / `deny`, the seven actions, prefix and `regex:` matching, the presets
- [Install ACP for Antigravity](/integrations/antigravity): the hook, the merge behavior, what the dashboard shows, and troubleshooting
- [antigravity-acp-plugin on GitHub](https://github.com/agentic-control-plane/antigravity-acp-plugin): MIT, zero dependencies, one readable file
- [Google's Antigravity hooks documentation](https://antigravity.google/docs/hooks/): the upstream source for the contract
- [Claude Code hooks reference](/blog/claude-code-hooks-reference): the closest sibling contract, fail-open instead of fail-closed
- [Cursor hooks reference](/blog/cursor-hooks-reference): a third fail-open core, with an LLM classifier ahead of it
- [Codex CLI hooks reference](/blog/codex-cli-hooks-reference): a narrower, shell-first hook surface
