For: developers using Claude Code, Codex CLI, Cursor, OpenCode, Antigravity, ZCode desktop app, Gemini CLI (experimental), Copilot CLI (experimental) or any MCP client, and teams building agents with MCP, LangChain, CrewAI or LlamaIndex.
What it does: keeps secret values out of what your agent sends to its model, checks what your agent reads and calls for prompt injection, and audits prompts, skills and configs. Everything runs on your machine, is MIT-licensed and needs no account. The Python package has no runtime dependencies; the npm package's only one is age-encryption (with its @noble/@scure dependencies) for the secret vault, bundled in the package.
Install
Everything runs on your machine; no account or API key is needed. Node.js 22 LTS is recommended (from nodejs.org). Node.js 18 or later works for the hooks and the CLI; the Claude Code plugin needs 20.19 or later. 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. On Debian or Ubuntu, sudo apt install nodejs can install an old Node.js (Ubuntu 22.04 ships version 12): run node --version and, if it is older than 18, install a current Node.js from nodejs.org or the NodeSource packages (steps in docs/first-5-minutes.md). With a Node.js older than 18, the zn-gate and zn commands stop and say how to install it.
No internet on this computer? See Install on a machine without internet.
On Alpine Linux, install Node.js with the package manager. The Node.js builds on nodejs.org do not run on Alpine, so run apk add nodejs npm instead. Use Alpine 3.21 or later: 3.21 and 3.22 ship Node.js 22, 3.23 and later ship Node.js 24. Alpine 3.20 ships Node.js 20.15, which is too old for the Claude Code plugin. The npm package is in the community repository, so if npm is not found, make sure the community repository is listed in /etc/apk/repositories.
Windows PowerShell: if a command says "running scripts is disabled on this system", run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once in PowerShell, or use npx.cmd in place of npx (or run the commands in Command Prompt). This relaxes a PowerShell protection for your user account: scripts downloaded from the internet must be signed, and local scripts run. Using the .cmd forms (npx.cmd, zn.cmd) avoids changing it. More in troubleshooting.
Windows and macOS: the install matrix says what each system needs and how to verify it. For problems, see troubleshooting and the Windows checklist; on macOS, the keychain prompt is in troubleshooting section 5.
Getting started: four steps, one command each. Run them in your own terminal.
npx -y zn-gate reach shows what your coding agents can reach on this machine: secrets in your .env files (by name only), credential files and MCP servers. It is read only and sends nothing. Details in docs/reach.md.
npx -y zn-gate init sets up protection for the coding agents it finds, one step at a time, and asks before each change.
npx -y zn-gate check tests that protection with a fake secret in a temporary folder. init runs it at the end too.
npx -y zn-gate env shadow .env moves the real values of your .env into the local vault and leaves markers in the file. The first time, run npx -y zn-gate unlock to create the vault.
One command for the coding agents on your machine:
npx -y zn-gate init
init does this:
- It finds the six coding agents it supports on your machine: Claude Code, Codex CLI, Cursor, OpenCode, Antigravity and ZCode desktop app, plus Gemini CLI (experimental) and Copilot CLI (experimental).
- For each one that is not protected yet, it shows the setup: the zn-gate plugin for Claude Code (or zn's hooks when your Node.js is older than 20.19), and zn's hooks for the others.
- It runs each step only after you confirm it.
- It ends with
zn-gate check.
Run it yourself, in your own terminal, with no arguments. When an AI agent or a script runs it, it only prints the steps.
Windows PowerShell: npm and npx can fail with "running scripts is disabled on this system", because the default execution policy blocks npm.ps1. Use npm.cmd, npx.cmd and zn.cmd instead (for example npm.cmd install -g zn-gate), run the commands from Command Prompt, or allow local scripts for your account with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned. This relaxes a PowerShell protection for your user account: scripts downloaded from the internet must be signed, and local scripts run. Using the .cmd forms (npx.cmd, zn.cmd) avoids changing it.
If something fails:
npx: command not found, or a message about the Node.js version: install the LTS version of Node.js, open a new terminal and run the command again.
- "running scripts is disabled on this system" on Windows: see the PowerShell note above.
init only prints steps and changes nothing: an AI agent or a script ran it. Run it yourself in your own terminal.
check shows NOT protected: that line says why and what to run. What the output means.
- You want to remove zn-gate:
npx -y zn-gate uninstall shows what it will remove (the Claude Code plugin, zn's hooks, wrapped MCP servers) and asks first, and it does the steps in the safe order (wrapped MCP servers put back first, then the hooks and the plugin, the program last). init --revert only puts back MCP configs saved before wrapping.
Then keep your .env values in the vault. With the plugin or the hooks, the agent cannot read .env files with real values; move them into zn-gate's encrypted vault, and the file keeps markers such as __ZN_STRIPE_KEY__:
npx -y zn-gate unlock # creates the vault the first time
npx -y zn-gate env shadow .env
After this, your own app also reads the markers in .env: start it with zn-gate's run command once you allow it (docs/secrets.md). env shadow tells you how to undo it.
New here? First 5 minutes. All the guides: docs index. Five-minute walkthrough: docs/secrets.md. Limits: docs/threat-model.md. Words you do not know: docs/glossary.md. Every command and exit code: docs/cli.md. Removing zn-gate: docs/uninstall.md.
One agent at a time (the same steps init runs):
Claude Code: the plugin. You also need Git and Claude Code 2.1.295 or later. The plugin needs Node.js 20.19 or later. With an older Node.js, npx -y zn-gate init skips the plugin and sets up zn's hooks for Claude Code instead (zn-gate check says so if the plugin is installed); update Node.js to use the plugin.
claude plugin marketplace add usezn/zn#plugin-v1.17.0
claude plugin install zn-gate@usezn
Already ran zn hooks install claude-code before? Run zn hooks uninstall claude-code first, otherwise both sets of hooks run.
Start a new Claude Code session. Claude Code is then blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced with markers or redacted before the model sees them, a secret pasted into a prompt is blocked. The plugin adds no MCP server since version 1.14.0: for the secrets server, run zn hooks install claude-code instead of the plugin. Not covered: Claude Code sessions in the cloud, Cowork and chat. Details: plugins/zn-gate.
Codex CLI, Cursor or OpenCode: the hooks.
npm install -g zn-gate
zn hooks install codex # or: cursor, opencode
If npm install -g fails with EACCES (common with Node.js from your Linux distribution, such as dnf or apk, and with Node.js from nodejs.org on macOS), do not use sudo. Give npm a folder in your home directory, then run the install again:
mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc # ~/.zshrc on macOS, ~/.profile if you have no .bashrc
Open a new terminal so the new PATH applies, then run npm install -g again for your agent (if its install failed too) and for zn-gate, and run zn hooks install again. An install that failed with EACCES did nothing.
In Codex, approve the new hooks with /hooks. In Cursor, shell output and file contents are not scrubbed. What each agent supports: docs/compat.md.
New in 1.15.0: on macOS and Linux, and for Claude Code on Windows, zn's hook launcher now runs zn-gate's hook runner only while that file matches the copy recorded at install time, and no longer falls back to a zn found on the PATH. An update with npm refreshes those launchers through a short install step (postinstall, declared in the package's DISCLOSURE file); if you update with pnpm, bun or --ignore-scripts, run zn hooks install <agent> again. Not covered: the inline PowerShell hooks that zn writes on Windows for Codex CLI, Cursor, Gemini CLI and Antigravity. They still run a zn found on the PATH and do not check the runner (docs/compat.md).
Other editors (Windsurf, Cline, Zed, JetBrains, Continue): zn-gate works there as an MCP server only. Setup for each one: usezn.com/docs/integrations/editors.
Antigravity. zn hooks install antigravity (or npx -y zn-gate init) adds a hook that runs before each tool call. It blocks reads and writes of secret files and shell commands that handle secrets, and the agent cannot edit the hook files. It cannot remove secrets from what a tool returns, Antigravity's MCP configuration files are not protected, and Antigravity does not document what happens when a hook fails (in our tests the call is blocked), so treat it as a first layer. The MCP server works there too. Details: Antigravity page.
ZCode desktop app. zn hooks install zcode (or npx -y zn-gate init) adds hooks that run before each tool call and before each prompt. It blocks reads and writes of secret files, shell commands that handle secrets, MCP calls that would send a secret, and a prompt that contains a secret, and the agent cannot edit ZCode's own config file. It cannot remove secrets from what a tool returns (zn adds a notice when an output holds one), ZCode ignores the hooks of a project, and zn's launcher blocks the call when its Node.js is gone, so treat it as a first layer. 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. Tested end to end on the ZCode desktop app 3.16.3 on Linux x64 and Windows x64 (Windows Server 2022, through the agent the app ships; the Windows app window was not driven); macOS is not tested. New in 1.15.0: the ZCode plugin protects tool calls on Windows now. In earlier versions its hooks could not start there, so ZCode ran every tool call without zn. Install the plugin again in ZCode (Settings, Plugins) after updating. Details: ZCode page.
Copilot CLI (experimental). zn hooks install copilot adds hooks that run before and after each tool call. They block reads and writes of secret files and shell commands that handle secrets, and replace secret values in the results of read-type and shell tools. They cannot block a typed prompt, Copilot lets a call through when a hook times out, so zn, which sets a 15-second timeout on its hooks, blocks the call itself at 11 seconds, it has not been tested on Windows, and Copilot's own session log keeps the original output, so treat it as a first layer. Experimental; run end to end with Copilot CLI, not tested in the VS Code app. Details: Copilot notes.
Gemini CLI (experimental). zn hooks install gemini adds a hook that runs before each tool call. It blocks reads and writes of secret files and shell commands that handle secrets, and the agent cannot edit Gemini CLI's settings files. It does not change what a tool returns, Gemini CLI hooks cannot ask you for confirmation, and 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), so treat it as a first layer. Google replaced Gemini CLI with Antigravity CLI for free and Google One accounts on 18 June 2026; Gemini CLI keeps working with zn-gate. Details: Gemini CLI notes.
Wrap any MCP server with the shield proxy, try it in shadow mode first, and review changes to its tools with pins: docs/shield.md.
Python: for agents you build yourself (rules engine and secret redaction for LangChain, CrewAI, LlamaIndex or plain tool calling). It does not protect Claude Code, Codex, Cursor or other coding agents. Install it in a virtual environment; many recent Linux systems, and Homebrew's Python on macOS, refuse pip install outside one ("externally-managed-environment"):
On Debian and Ubuntu, python3 -m venv needs the python3-venv package first: sudo apt update && sudo apt install python3-venv.
python3 -m venv .venv
.venv/bin/pip install zn-gate # Windows: .venv\Scripts\pip install zn-gate
.venv/bin/zn-gate scan . # Windows: .venv\Scripts\zn-gate scan .
zn-gate is installed inside the environment, so run it as shown, or run source .venv/bin/activate once in each terminal and then zn-gate scan . (Windows: .venv\Scripts\activate).
Only the command-line tools (scan, test, status)? Install the Python CLI as a standalone tool, without a virtual environment. On Ubuntu and Debian, first run sudo apt update && sudo apt install pipx. Bare pip is often missing there too (pip: command not found), and pip install into the system Python is refused, so use pipx, uv or a virtual environment. To get uv, follow the official uv installation guide:
pipx install zn-gate
pipx ensurepath # then close and reopen your terminal
zn-gate scan .
pipx ensurepath puts ~/.local/bin on your PATH. Until you reopen the terminal, zn-gate is reported as "command not found". With uv: uv tool install zn-gate (run uv tool update-shell if the command is not found). To run it once without installing: uvx zn-gate scan .
The Python CLI does not install hooks. To protect Claude Code, Codex CLI, Cursor, OpenCode, Antigravity or ZCode desktop app (or the experimental Gemini CLI and Copilot CLI), run npx -y zn-gate init (Node 18 or later).
For LangChain and LangGraph, ZnGuardCallbackHandler stops the run when it blocks a prompt, a tool call or a tool output, and guard_langchain_tool(tool) wraps a tool so its arguments are checked before it runs and its output is checked and masked before the model reads it. A callback cannot change what a tool returns, so the handler with mask_secrets=True (default) also stops the run on a secret in a tool output (it fails closed); to hide secrets and keep going, wrap the tool and create the handler with mask_secrets=False. See the Python package guide.
zn-gate as an MCP server only (the agent calls it when it decides to; not automatic protection):
claude mcp add zn-gate -- npx -y zn-gate mcp # Claude Code
codex mcp add zn-gate -- npx -y zn-gate mcp # Codex CLI
In Claude Code, this npx form is treated like any other MCP server: a call that carries personal data is asked about first. Only an entry that runs the installed zn-gate by absolute path skips that question (see docs/compat.md).
Cursor (~/.cursor/mcp.json) and other editors: { "mcpServers": { "zn-gate": { "command": "npx", "args": ["-y", "zn-gate", "mcp"] } } }. OpenCode (~/.config/opencode/opencode.json): { "mcp": { "zn-gate": { "type": "local", "command": ["npx", "-y", "zn-gate", "mcp"], "enabled": true } } }.
Protect the MCP servers you already use. init finds them in your agent configs, writes a backup, and wraps each local server with the zn-gate proxy: