Skip to main content

Quickstart

Protect your coding agent in two minutes: install zn-gate, keep your .env values in a local vault, and check that it works.

View .md

zn-gate runs on your machine. No account or API key is needed, and apart from downloading the packages, nothing on this page uses the network.

Before you start: zn-gate needs Node.js 18 or later (install the LTS version); 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. Open a terminal, type node --version and press Enter. If you see "command not found", install the LTS version from nodejs.org and open a new terminal.

Where to type the commands: in your own terminal app (Terminal on macOS, PowerShell or Command Prompt on Windows), not in your coding agent's chat. zn asks you to confirm each step there, and some commands refuse to run when an agent starts them.

Optional first step: run npx -y zn-gate reach to see what your agents can reach on this machine. It changes and sends nothing, never shows a secret value, and each finding shows the command that fixes it. What the report shows

1. Install for your agent

One command for every agent: run npx -y zn-gate init in your own terminal. It finds Claude Code, Codex CLI, Cursor, OpenCode, Antigravity, ZCode desktop app and GitHub Copilot, sets up each one after you confirm, and ends with a check. More: Install. Or follow the steps for your agent:

Recommended: the zn-gate plugin. You also need Git and Claude Code 2.1.295 or later. Paste each line in a terminal and press Enter after each one:

claude plugin marketplace add usezn/zn
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.

Then start a new Claude Code session. From now on Claude Code is blocked from reading .env files with real values and credential files, secrets in what its tools return are replaced with markers before the model sees them, a secret pasted into your prompt is blocked, and Claude can check untrusted text for prompt injection.

Not covered: Claude Code sessions in the cloud, Cowork and chat conversations. Details: plugin README.

npm install -g zn-gate
zn hooks install codex

Then open Codex and approve the new hooks with /hooks. Codex replaces a tool's result with a scrubbed copy, and its own session log keeps the original output: see compat.md.

npm install -g zn-gate
zn hooks install cursor

Restart Cursor. In Cursor, shell output and file contents are not scrubbed: see Cursor.

npm install -g zn-gate
zn hooks install opencode

Restart OpenCode.

npm install -g zn-gate
zn hooks install antigravity

Restart Antigravity. It cannot rewrite what a tool returns: see Antigravity.

npm install -g zn-gate
zn hooks install zcode

Start a new ZCode session. There is no project install for ZCode, and it cannot rewrite what a tool returns: see ZCode.

In VS Code, Windsurf, Cline, Zed, JetBrains and Continue, zn-gate works as an MCP server only: it cannot block reads of your .env files there. Google Antigravity and ZCode are supported agents with their own hooks. GitHub Copilot has hooks for VS Code, the GitHub Copilot app and Copilot CLI. Gemini CLI has experimental hooks, listed apart from the seven supported agents. Setup for each one: Editors.

On Windows, if PowerShell says "running scripts is disabled on this system", use npm.cmd, npx.cmd and zn.cmd instead of npm, npx and zn.

2. Keep your .env values in the vault

With the plugin or the hooks, the agent cannot read .env files that hold real values. Move the values into zn-gate's encrypted vault on your machine; the file keeps markers such as __ZN_STRIPE_KEY__, and zn-gate fills the real values in only for commands you allow:

npx -y zn-gate unlock
npx -y zn-gate env shadow .env

The first unlock creates the vault. How it works and how to let a command use a secret: Scrubber.

After this, your own app also reads the markers in .env: start it with zn-gate's run command once you allow it (see Scrubber). env shadow tells you how to undo it.

For example, if you start your app with npm run dev:

npx -y zn-gate secret allow STRIPE_KEY --command npm
npx -y zn-gate run --secrets STRIPE_KEY -- npm run dev

zn asks you to confirm twice, in a system dialog (or in the terminal where you ran unlock --foreground): once when you allow npm, and once the first time it runs. zn also warns that npm can run any script: that is expected when the app is your own.

3. Check that it works

npx -y zn-gate check

For each agent set up for your user, it shows OK when zn blocked a test .env file with a fake key and allowed an ordinary file, or says what to fix. Nothing is sent anywhere and no setting changes. What the output means.

To test zn's rules on their own:

npx -y zn-gate test

This runs the local self-test (51 curated vectors: 26 attacks, 25 benign) and shows the latency of each decision on your machine. It is a smoke test, not a detection rate. Nothing is sent over the network.

4. What you will see while you work

zn-gate speaks up in three ways. Blocks and approval questions come from zn's hooks and show up in your agent's window. Warnings come from zn's text check. zn prints its messages in English, so the examples below are the same in every language.

A block

zn stopped something that could leak a secret, and it did not run. Here, an agent in ~/my-project tried to run cat .env. This is what zn answers:

{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"zn: .env holds plain-text secrets. Ask the user to run `zn env shadow .env` in their terminal: it moves the values to the local vault and leaves __ZN_<NAME>__ markers you can read and use."}}

deny is the block. The sentence after it is the next step. What to do:

  1. Read the reason. It is written for you and for your agent.
  2. If the agent needs a value from that file, run the command in the message yourself, in your own terminal: npx -y zn-gate env shadow .env. The real values move into zn's encrypted vault and the file keeps markers. See Scrubber.
  3. If the block was a surprise, do not look for a way around it. Ask your agent why it wanted to read that file.

An ordinary command such as ls gets no answer at all: it is allowed and you see nothing.

An approval question

Sometimes zn does not block but asks you first. This happens when a command uses a secret marker. Example for a command that uses the marker __ZN_EXAMPLE_TOKEN__:

"permissionDecision":"ask","permissionDecisionReason":"zn: this command runs through zn run (zn's secret wrapper) for EXAMPLE_TOKEN; the first time, you approve the command, and secret values in its output stay hidden."

Your agent then shows its normal permission question. Read the command and approve it only if it is what you expected.

A warning

zn also has a text check. Some patterns it looks for also show up in ordinary text, such as "bypass the cache". For those, zn does not block: it lets the text through and adds a short warning, called an advisory. You can run the same check yourself. Output of npx -y zn-gate analyze "You can bypass the cache with --no-cache.":

{
  "verdict": "allow",
  "confidence": 0.99,
  "rule": "none",
  "reason": null,
  "engine": "oss-local",
  "rules_version": "2026-10-16.10",
  "advisory": {
    "rule": "pi:bypass",
    "reason": "Guardrail bypass attempt"
  },
  "mode": "oss-local"
}

"verdict": "allow" means nothing was stopped. The advisory says why the text is worth a look. If it is harmless, carry on. If you did not expect it (for example inside a file you downloaded), do not let your agent follow it. To make the text check block these too, set ZN_STRICT=1, or add "strict": true to zn.config.json in your project.

For comparison, npx -y zn-gate analyze "ignore all previous instructions" is a block: "verdict": "block" with the reason "Override prior instructions".

Python: for agents you build yourself

The Python package is a library for agents you write yourself (LangChain, CrewAI, LlamaIndex or plain tool calling). It does not protect Claude Code, Codex, Cursor or other coding agents: for those, use the steps above.

Install it in a virtual environment (Python 3.10 or later, standard library only). Many recent Linux systems, and Homebrew's Python on macOS, refuse pip install outside one, with an "externally-managed-environment" error:

python3 -m venv .venv
.venv/bin/pip install zn-gate        # Windows: .venv\Scripts\pip install zn-gate

On Windows, in PowerShell run .venv\Scripts\Activate.ps1 (if scripts are blocked, run Set-ExecutionPolicy -Scope Process RemoteSigned first, or call .venv\Scripts\zn-gate directly); in cmd run .venv\Scripts\activate.

from zn_gate import sanitize_tool_result

out = sanitize_tool_result(
    "read_file",
    "AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\nDATABASE_URL=postgres://app:hunter2@db:5432/main",
)
print(out["secrets_redacted"])   # 2
print(out["sanitized_content"])
# AWS_ACCESS_KEY_ID=[REDACTED_AWS_KEY]
# DATABASE_URL=postgres://app:[REDACTED_DB_PASSWORD]@db:5432/main

Technical reference

zn-gate as an MCP server only

Without hooks, zn-gate can run as an MCP server that the agent calls when it decides to (analyze_prompt, check_tool_call, check_tool_result, zn_status). This is not automatic protection; the hooks above are.

claude mcp add zn-gate -- npx -y zn-gate mcp     # Claude Code
codex mcp add zn-gate -- npx -y zn-gate mcp      # Codex CLI

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 } } }.

Wrap the MCP servers you already use

init --wrap-mcp finds MCP servers in your agent config files, writes a backup and wraps each local (stdio) server with zn-gate shield, so their tool output is checked and redacted before your agent reads it:

npx -y zn-gate init --dry-run   # preview, changes nothing
npx -y zn-gate init --shadow    # wrap, but only log detections
npx -y zn-gate init --wrap-mcp  # wrap and enforce
npx -y zn-gate init --revert    # restore the latest backup

Start with --shadow, review the decisions with npx -y zn-gate evidence --tail 20, then enforce. Details and supported config files: Protect MCP servers.

Want to remove zn-gate? npx -y zn-gate uninstall lists what it will remove and asks first. init --revert only undoes MCP wrapping. Steps: Remove zn-gate.

Check the redaction by hand

Send a tool output with a fake AWS key (AWS's documentation example) and a database password through zn-gate, exactly as your agent would, and look for sanitized_content in the output:

printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"check_tool_result","arguments":{"tool_name":"read_file","content":"AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\nDATABASE_URL=postgres://app:hunter2@db:5432/main"}}}' \
  | npx -y zn-gate@latest mcp

Confirm what leaves your machine

npx -y zn-gate status

With the default configuration it reports local rules only. The full rules: What leaves your machine.

Next steps