Docs for AI agents
Machine-readable entry points so coding agents and LLMs can read these docs and set up zn-gate on their own.
This page is for AI agents and tools that read these docs. Just want to protect your coding agent? Open your own terminal (not the agent's chat), run
npx -y zn-gate init, thennpx -y zn-gate check. Step by step: Install.
Every docs page is available as plain Markdown: add .md to the page path (for example /docs/quickstart.md), or use the Copy page button at the top of any page. You can also send Accept: text/markdown to a docs page URL (for example /docs/quickstart/) to get the same Markdown. A page that does not exist answers 404 in Markdown, with links to the docs and the index for agents.
Entry points
| Resource | What it contains |
|---|---|
/llms.txt |
Index of canonical pages and integration paths |
/docs.md |
All docs pages in one Markdown file |
/agents.md |
Integration guidance for agent loops and verdict handling |
/openapi.json |
OpenAPI schema of the optional zn Cloud API |
/.well-known/mcp.json |
Hosted MCP endpoint of the optional zn Cloud API |
Prompt for your coding agent
Paste this into Claude Code, Cursor or a similar tool:
Read https://usezn.com/docs.md and add zn-gate to this project:
check untrusted tool output with check_tool_result (or sanitize_tool_result in Python)
before it reaches the model, use sanitized_content, stop on safe_to_ingest = false,
and log rule and reason. Keep everything local: do not set ZN_CLOUD.
Use zn-gate as a tool
- Local:
npx -y zn-gate mcpexposesanalyze_prompt,check_tool_call,check_tool_resultandzn_status. See MCP clients and tools. - Optional cloud:
https://api.usezn.com/mcpexposesanalyzeover Streamable HTTP with an API key. See Hosted MCP endpoint.
Files a --project install writes
A project install names zn on your PATH (zn hook <agent>), not the paths of your user, so these files can be committed. Add them to .gitignore if you want them to stay on your machine. Each agent's own hook trust still applies (Codex asks you to review project hooks in /hooks, see Install for Codex).
| Agent | File |
|---|---|
| Claude Code | .claude/settings.json |
| Codex CLI | .codex/hooks.json |
| Cursor | .cursor/hooks.json |
| OpenCode | .opencode/plugins/zn-gate.js |
| Antigravity | .agents/hooks.json |
| ZCode | none: ZCode does not run project hooks, so there is no --project install |
| GitHub Copilot (VS Code, CLI) | .github/hooks/zn-gate.json |
| Gemini CLI (experimental) | .gemini/settings.json |
The experimental Gemini CLI adapter, which is not among the seven supported agents, writes .gemini/settings.json with --project.
A user install writes the same files under your home directory and names the node and runner paths of that install.
A teammate who clones the project without zn on PATH gets no checks from these files, because the hook command runs zn from PATH. Claude Code 2.1.295 or later then blocks tool calls and prompts (the hooks are set to block when they cannot run); older Claude Code versions and Codex let the call go ahead. Install zn on every machine that runs the agent. On Windows, see Install on Windows. To put the hooks on every machine of a team through each agent's managed configuration, see Deploy zn-gate to a whole team.
What has been tested
- ZCode desktop app 3.16.3: tested end to end in the app on Linux. On Linux and Windows it was also tested through the agent runtime that ships with the app (details: ZCode page).
- Antigravity: tested end to end with the official
agyCLI 1.4.7 on Linux. 13 of the 15 scenarios gave a result and none failed. The model refused to delete the home folder, so that check was run on the installed hook directly; another plugin's hook did not always run next to zn's, while zn's hook always ran and its deny always applied. - Claude Code, Codex CLI and OpenCode: end-to-end runs with the agent itself, with 0 secret values sent to the model provider. Codex CLI 0.163.0 and OpenCode 1.19.3 also ran end to end on Windows Server 2022.
- Gemini CLI 0.64.0 and GitHub Copilot CLI 1.0.98: end-to-end runs against a scripted model provider, with 0 secret values sent. For VS Code and the GitHub Copilot app the hooks are documented, not tested in the app. Copilot cannot block a typed prompt, and lets a call through when a hook times out, so zn blocks the call itself at 11 seconds.
- Cursor: no end-to-end run, because Cursor has no CLI with hooks to drive.
- Clean install and Windows smoke test: a clean install on Linux ran the hooks of Claude Code, Codex CLI and Cursor. A smoke test on Windows, as an administrator and as a standard user, ran the hooks of all eight agents.
- Desktop apps: the Claude desktop app, the Cursor app, the Antigravity app and IDE, and the OpenCode desktop app have not been tested end to end yet. Anthropic's documentation says the Claude desktop app uses the same hooks as the Claude Code CLI, and Google's documentation lists the same hook files for the Antigravity app, IDE and CLI, so the hooks zn installs apply there too.
Limits that apply to every agent
- A shell command longer than 100 KB is blocked. This counts characters and includes PowerShell and the Monitor tool of Claude Code. zn could not check it within the time the agent waits for the hook. The same limit applies to a patch (
apply_patch) in Codex and OpenCode. - An event zn cannot read is refused. Empty input, or input that is not JSON, exits with code 2 and the reason on stderr. Claude Code and Codex block the call on exit code 2; Cursor also gets its deny answer. Setting
whenUnavailableto"allow"in~/.zn/config.jsonlets such events pass. - The unlocked vault answers any program of your user. A command the agent runs can ask the vault daemon for a stored secret by name. The command allow-list, first-use confirmation and host rules protect
zn runand thesecretsMCP server, not that direct request. Lock the vault when you do not need it and keep your agent's own approval rules for commands on. Details: Threat model. - Approved scripts, and every program on macOS and Windows, are started by path right after zn's last check. See the Threat model.
Antigravity
zn hooks install antigravity sets up the hook for Google Antigravity (add --project to set up one project only). Run it in your own terminal. It blocks the agent from reading or writing secret files by path and from running shell commands that handle secrets, and protects its own hook files from edits by the agent.
- A search across a folder asks for confirmation when the folder holds a plain-text
.envor key file. Matching lines and command output are not redacted, because Antigravity hooks cannot rewrite tool output. - The hook covers
PreToolUseonly: no output cleaning, and a secret pasted into the prompt is not blocked. - Antigravity does not document what happens when a hook fails; in our tests (Antigravity IDE and CLI on a real Windows machine, October 2026) the action is blocked, but Antigravity can change that in a new version.
- On Windows, the hook was verified with the kit on a real Windows machine.
ZCode
zn hooks install zcode sets up the hooks for ZCode (z.ai) in ~/.zcode/cli/config.json, for your user. Run it in your own terminal. It blocks the agent from reading or writing secret files by path, from running shell commands that handle secrets, from sending a secret in an MCP call and from sending a prompt that holds a secret, and the agent cannot edit ZCode's own config file.
- ZCode hooks cannot rewrite what a tool returns, so zn adds a notice when an output holds a secret instead of removing it. A secret pasted into the prompt is blocked, not cleaned.
- ZCode ignores the hooks of a project, so there is no
--projectinstall. Each person runs the command once on their own machine. - ZCode's documentation does not say what happens when a hook fails; in our tests with the ZCode desktop app 3.16.3 on Linux, a hook that failed (an exit code other than 2, a crash or a timeout) let the call run, and only exit code 2 or a deny answer blocked it. zn's launcher blocks the call when its Node.js is gone, so treat the hooks as a first layer.
- Tested end to end on the official ZCode desktop app 3.16.3 on Linux x64 (October 2026). The same checks passed on Windows x64 (Windows Server 2022, same app version, October 2026), for an administrator and for a standard user, through the agent the app ships; the Windows app window itself was not driven. macOS was not tested. Details: ZCode desktop app.
Experimental agents
zn hooks install gemini sets up hooks for Gemini CLI (add --project to set up one project only). Run it in your own terminal. It is experimental. It blocks the agent from reading or writing secret files by path and from running shell commands that handle secrets, and protects its own hook files from edits by the agent. Where it differs:
- Gemini CLI: blocks what zn would refuse, and what it would ask about (with the reason and how to approve it), because its hooks cannot ask for confirmation. For everything else Gemini CLI's own approval applies. Gemini CLI lets a call run when a hook crashes or times out, so zn blocks it instead (a hook that fails is answered with a block, and zn sets a 15-second timeout on its hook and answers a check still running after 11 seconds with a block).
zn-gate check reports each of these hooks. More: Google Antigravity.
Not covered yet
Hermes Agent and the Cursor CLI. Gemini CLI has experimental hooks and is listed apart from the seven supported agents. A proxy for outgoing HTTP from zn run (for curl, gh or SDKs) is planned for a later release.
zn Team policy choices by zn-gate version
The organization policy sets one choice per rule: Not blocked, Warn or Block (see zn Team).
| zn-gate version | Block | Warn |
|---|---|---|
| 1.6.0 to 1.7.x | Yes | No. The zn service removes the warn field: the rule's other limits still apply, but there is no notice and no warn record. |
| 1.8.0 and later | Yes | Yes |
zn-gate tells the server on each policy download which policy features it understands, so warn rules are sent only to 1.8.0 and later.