# zn-gate for Claude Code

Install the zn-gate plugin for Claude Code: it blocks reads of .env files with real values, scrubs secrets from tool output and blocks secrets pasted into prompts.

Source: https://usezn.com/docs/install/claude-code/

You need Node.js 18 or later, Git and Claude Code 2.1.295 or later. Paste each line in a terminal and press Enter after each one:

```bash
claude plugin marketplace add usezn/zn
claude plugin install zn-gate@usezn
```

Then start a new Claude Code session.

Already ran `zn hooks install claude-code` before? Run `zn hooks uninstall claude-code` first, otherwise both sets of hooks run.

## What you get

- Claude Code is 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.
- Claude can check untrusted text for prompt injection.

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

## Keep your .env values in the vault

The agent cannot read `.env` files with real values. Move the values into zn-gate's encrypted vault, and the file keeps markers such as `__ZN_STRIPE_KEY__`:

```bash
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: start it with zn-gate's run command once you allow it. `env shadow` tells you how to undo it. More: [the vault](https://usezn.com/docs/quickstart/#2-keep-your-env-values-in-the-vault).

## Check that it works

In a new terminal, run `npx -y zn-gate check`. It should show **OK** for Claude Code. [What the output means](https://usezn.com/docs/check/).

On Windows PowerShell, if npm or npx says "running scripts is disabled on this system", use `npx.cmd` instead of `npx`: see [Install](https://usezn.com/docs/install/#windows-powershell).
