Install zn-gate
Protect your coding agent with one command: npx -y zn-gate init finds Claude Code, Codex CLI, Cursor, OpenCode, Antigravity and ZCode and sets each up.
Pick your agent and system
Choose where you work and see only the commands for that choice, how to check them and what to expect. These are the steps for zn-gate 1.18.0; they are the same ones the pages for each agent list below. Without JavaScript, every combination is listed.
Agent
System
Claude Code: plugin (recommended) on macOS and Linux
You need: Node.js 18 or later (install the LTS version from nodejs.org); the plugin needs 20.19 or later, Git and Claude Code 2.1.295 or later.
1. Run these commands
claude plugin marketplace add usezn/zn#plugin-v1.18.0
claude plugin install zn-gate@useznThen start a new Claude Code session.
2. Check that it works
In a new terminal, run:
npx -y zn-gate checkIt should show OK for Claude Code. What the output means
3. What to expect
- Claude Code is blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced or redacted before the model sees them, and a secret pasted into a prompt is blocked.
- Not covered: Claude Code sessions in the cloud, Cowork and chat. If the zn hook cannot run (for example, node is missing), tool calls run unchecked and prompts are blocked.
Claude Code: plugin (recommended) on Windows (PowerShell)
You need: Node.js 18 or later (install the LTS version from nodejs.org); the plugin needs 20.19 or later, Git and Claude Code 2.1.295 or later.
1. Run these commands
claude plugin marketplace add usezn/zn#plugin-v1.18.0
claude plugin install zn-gate@useznThen start a new Claude Code session.
Using Git Bash on Windows? Choose macOS or Linux: the commands are the same.
2. Check that it works
In a new terminal, run:
npx.cmd -y zn-gate checkIt should show OK for Claude Code. What the output means
3. What to expect
- Claude Code is blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced or redacted before the model sees them, and a secret pasted into a prompt is blocked.
- Not covered: Claude Code sessions in the cloud, Cowork and chat. If the zn hook cannot run (for example, node is missing), tool calls run unchecked and prompts are blocked.
- On Windows, Claude Code is the route we test. Claude Code 2.1.299 or later is recommended.
Claude Code: hooks on macOS and Linux
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npx -y zn-gate hooks install claude-codeThen start a new Claude Code session. Use either the plugin or zn’s hooks, not both: with both, two sets of hooks run.
2. Check that it works
In a new terminal, run:
npx -y zn-gate checkIt should show OK for Claude Code. What the output means
3. What to expect
- Claude Code is blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced or redacted before the model sees them, and a secret pasted into a prompt is blocked.
- Not covered: Claude Code sessions in the cloud, Cowork and chat. If the zn hook cannot run (for example, node is missing), tool calls run unchecked and prompts are blocked.
Claude Code: hooks on Windows (PowerShell)
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npx.cmd -y zn-gate hooks install claude-codeThen start a new Claude Code session. Use either the plugin or zn’s hooks, not both: with both, two sets of hooks run.
Using Git Bash on Windows? Choose macOS or Linux: the commands are the same.
2. Check that it works
In a new terminal, run:
npx.cmd -y zn-gate checkIt should show OK for Claude Code. What the output means
3. What to expect
- Claude Code is blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced or redacted before the model sees them, and a secret pasted into a prompt is blocked.
- Not covered: Claude Code sessions in the cloud, Cowork and chat. If the zn hook cannot run (for example, node is missing), tool calls run unchecked and prompts are blocked.
- On Windows, Claude Code is the route we test. Claude Code 2.1.299 or later is recommended.
Codex CLI on macOS and Linux
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm install -g zn-gate
zn hooks install codexThen open Codex and approve the new hooks with /hooks.
2. Check that it works
In a new terminal, run:
zn-gate checkIt should show OK for Codex CLI. What the output means
3. What to expect
- Reads of .env files with values and credential files are blocked, in shell commands and in patches. Tool output is scrubbed before the model sees it, and a secret pasted into a prompt is blocked.
- Codex calls its hooks a guardrail, not an enforcement boundary: if the zn hook cannot run, the call or prompt goes ahead. Codex’s own session log keeps the original output.
Codex CLI on Windows (PowerShell)
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm.cmd install -g zn-gate
zn.cmd hooks install codexThen open Codex and approve the new hooks with /hooks.
Using Git Bash on Windows? Choose macOS or Linux: the commands are the same.
2. Check that it works
In a new terminal, run:
npx.cmd -y zn-gate checkIt should show OK for Codex CLI. What the output means
3. What to expect
- Reads of .env files with values and credential files are blocked, in shell commands and in patches. Tool output is scrubbed before the model sees it, and a secret pasted into a prompt is blocked.
- Codex calls its hooks a guardrail, not an enforcement boundary: if the zn hook cannot run, the call or prompt goes ahead. Codex’s own session log keeps the original output.
- On Windows, we ran the hook command by hand from PowerShell and from Command Prompt; it is not part of our automated tests.
Cursor on macOS and Linux
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm install -g zn-gate
zn hooks install cursorThen restart Cursor.
2. Check that it works
In a new terminal, run:
zn-gate checkIt should show OK for Cursor. What the output means
3. What to expect
- File reads and shell reads of .env files with values and credential files are blocked, a secret pasted into a prompt is blocked, and MCP calls that carry a secret value are blocked.
- Shell output and file contents are not scrubbed; only MCP output is. Write protection is best effort.
Cursor on Windows (PowerShell)
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm.cmd install -g zn-gate
zn.cmd hooks install cursorThen restart Cursor.
Using Git Bash on Windows? Choose macOS or Linux: the commands are the same.
2. Check that it works
In a new terminal, run:
npx.cmd -y zn-gate checkIt should show OK for Cursor. What the output means
3. What to expect
- File reads and shell reads of .env files with values and credential files are blocked, a secret pasted into a prompt is blocked, and MCP calls that carry a secret value are blocked.
- Shell output and file contents are not scrubbed; only MCP output is. Write protection is best effort.
- Not tested on Windows.
OpenCode on macOS and Linux
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm install -g zn-gate
zn hooks install opencodezn-gate installs a small OpenCode plugin. Then restart OpenCode.
2. Check that it works
In a new terminal, run:
zn-gate checkIt should show OK for OpenCode. What the output means
3. What to expect
- Reads of .env files with values and credential files are blocked in every tool, every tool’s output is scrubbed before the model sees it, and a secret pasted into a prompt is blocked.
- If the zn plugin cannot run, calls and messages are blocked. zn-gate check confirms zn’s rules for OpenCode but does not start OpenCode.
OpenCode on Windows (PowerShell)
You need: Node.js 18 or later (install the LTS version from nodejs.org).
1. Run these commands
npm.cmd install -g zn-gate
zn.cmd hooks install opencodezn-gate installs a small OpenCode plugin. Then restart OpenCode.
Using Git Bash on Windows? Choose macOS or Linux: the commands are the same.
2. Check that it works
In a new terminal, run:
npx.cmd -y zn-gate checkIt should show OK for OpenCode. What the output means
3. What to expect
- Reads of .env files with values and credential files are blocked in every tool, every tool’s output is scrubbed before the model sees it, and a secret pasted into a prompt is blocked.
- If the zn plugin cannot run, calls and messages are blocked. zn-gate check confirms zn’s rules for OpenCode but does not start OpenCode.
- Not tested on Windows.
zn-gate runs on your machine. No account, no API key, nothing sent anywhere unless you turn on the optional cloud check. zn-gate needs Node.js 18 or later (the plugin needs 20.19 or later). Get the LTS version from nodejs.org. For security, use the latest patch of a supported Node.js line (22.23.4, 24.22.1, 26.12.1 or later): Node.js 18 and 20 are end-of-life and get no security fixes, even though zn-gate still runs on them. With an older Node.js, the zn-gate and zn commands you run stop and say how to install it; hooks keep running with a warning.
Windows PowerShell: if a command says "running scripts is disabled on this system", run
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedonce in PowerShell, or usenpx.cmdin place ofnpx(or run the commands in Command Prompt). More in Use zn-gate on Windows.
One command for every agent
npx -y zn-gate init
It finds Claude Code, Codex CLI, Cursor, OpenCode, Antigravity and ZCode desktop app on your machine, shows the setup for each one that is not protected yet, runs each step after you confirm it in your own terminal, and ends with a check. Run it yourself, with no arguments: when an AI agent or a script runs it, it only prints the steps.
Or pick your agent
Six supported agents
- Claude Code: the zn-gate plugin (recommended).
- Codex CLI: zn's hooks.
- Cursor: zn's hooks.
- OpenCode: a small plugin that zn-gate installs.
- Google Antigravity: zn's hooks.
- ZCode (z.ai): zn's hooks, for your user only.
Experimental
- Gemini CLI: experimental hooks.
- GitHub Copilot: experimental hooks of zn, for VS Code, the GitHub Copilot app and Copilot CLI.
MCP-only editors (scan, no hooks)
- VS Code, Windsurf, Cline, Zed, JetBrains, Continue: MCP server only.
Each page has the same steps that init runs, what you get, and what is not covered.
Already installed? Check that it works.
Building your own agent with LangChain, CrewAI or LlamaIndex? Use the Python package: see the quickstart.
Windows PowerShell
npm and npx can fail with "running scripts is disabled on this system". Use npm.cmd, npx.cmd and zn.cmd instead (for example npx.cmd -y zn-gate init), run the commands from Command Prompt, or allow local scripts for your account with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.
Full guide: Use zn-gate on Windows (PowerShell, Git Bash, file locations, hooks, limits).
Further reading
- Protect Claude Code, Codex CLI, Cursor or OpenCode with one command: what the one-command setup changes in each agent, how to check it and how to remove it.
- Verify a release: how to check that the zn-gate files you install were built by our release workflow.
- Troubleshooting: the messages people most often meet when installing and first using zn-gate, and what to do.
- Remove zn-gate: one step with
zn-gate uninstall, or piece by piece.
Updating zn-gate
Updating later? See Upgrading zn-gate.