Google Antigravity's global hooks file is ~/.gemini/config/hooks.json, in the .gemini folder of your home directory. The agy command line, the desktop app and the IDE all read it. A project can add its own hooks in .agents/hooks.json at the project's root. Both files load and both fire: when they have hooks for the same event, the project's run first, then the global ones. Changes take effect from the next session, with no trust step.
01The two files
~/.gemini/config/hooks.jsonEvery session, in every folder.agents/hooks.json in the project folderSessions in that projectOn Mac the global file is /Users/<you>/.gemini/config/hooks.json, and on Linux /home/<you>/.gemini/config/hooks.json. On Windows we expect it under your user folder, at %USERPROFILE%\.gemini\config\hooks.json, but we haven't tested agy on Windows, so check where your installation keeps its .gemini folder.
Note the folder names. The global file is in .gemini/config/, not directly in .gemini/, and the project folder is .agents/, not .gemini/ or .antigravity/. A file with the right contents in the wrong place is simply ignored.
02Creating the global file
The file may not exist until you, or a tool, create it. On Mac and Linux:
mkdir -p ~/.gemini/config
test -f ~/.gemini/config/hooks.json || echo '{}' > ~/.gemini/config/hooks.json
Then add a named group. The top-level keys are group names you choose, and each holds events:
{
"my-alerts": {
"Stop": [
{ "type": "command", "command": "/Users/me/bin/agy-done.py", "timeout": 10 }
]
}
}
If the file already has groups (from Antigravity Notifier or another tool), add yours as another key at the same level. Don't nest it inside someone else's group, and keep the whole file valid JSON. A broken file is the first thing to check when hooks stop running.
Check it before you start a session:
python3 -m json.tool ~/.gemini/config/hooks.json > /dev/null && echo "valid JSON"
03Project hooks
A project's .agents/hooks.json uses the same format. It suits hooks that belong to one repository, such as a check that runs the project's own tests, and it can be committed so everyone on the project gets it.
Two things to know:
- It adds, it doesn't replace. Global hooks still run in that project. If both files have a
Stophook, you get both, the project's first. - It runs without asking. Antigravity has no trust step for hooks, and a global hook runs even in a workspace you haven't trusted. Look at a project's
.agents/hooks.jsonbefore you start a session in a repository you didn't write, the same way you would look at its build scripts.
Project hooks also load in agy -p print mode, which makes them a safe place to try out a new hook without changing your global file.
04When an edit takes effect
Hooks are loaded when a session starts. After you edit either file, start a new session; one that is already running keeps the hooks it started with. There is nothing to approve: no /hooks review, no trust hash.
05Paths in commands
Use full paths in command, such as /Users/me/bin/agy-done.py, rather than relying on ~ or your shell's PATH, which may not be set up the way you expect when Antigravity starts the hook. If you move a script, update the path, or the hook fails.
A failing hook matters more for some events than others. Antigravity is fail-closed for PreToolUse: if that hook can't run, exits non-zero, times out or prints no decision, the tool is blocked. A broken path in a PreToolUse hook can stop every command. See the PreToolUse guide.
06Backups and tools that edit the file
Several tools may share the global file, so edit it carefully and keep a copy:
cp ~/.gemini/config/hooks.json ~/.gemini/config/hooks.json.bak
Antigravity Notifier is one such tool. antigravity-notifier pair adds a single group, antigravity-notifier, to ~/.gemini/config/hooks.json, keeps a one-time backup of the file as it was, refuses to change a file that isn't valid JSON, and touches nothing else. antigravity-notifier uninstall removes only that group, and antigravity-notifier doctor checks that the hooks are in place. It is free for Mac, Windows (beta) and Linux, independent and not made by Google, and it supports the agy command line; the desktop app and IDE read the same file but aren't supported yet.
07FAQ
Do the desktop app and IDE have their own hooks file?
No, they read the same global ~/.gemini/config/hooks.json as the agy command line. We have only tested hook behaviour in the command line.
Can a project turn off my global hooks?
Not by adding a .agents/hooks.json: both files load and both fire.
I added a hook and nothing happens. Why?
Check, in order: the path (.gemini/config/, not .gemini/), that the file is valid JSON, that you started a new session, and that the command's full path is right. A longer checklist is in Antigravity notifications not working.
Which runs first, global or project hooks?
The project's hooks run first, then the global ones.