Getting started
Agent Safety & Hooks Pack
You can read this before you buy. After checkout, unzip agent-safety-hooks and copy that folder into a project you already have. These are plain Node scripts. There is no npm install inside the pack.
What you need installed
- Node.js 18 or newer. package.json sets engines to >=18, and the scripts have no dependencies.
- The project you want the hooks to protect, on disk.
- Claude Code, Cursor, or both. Ready-made configs are in examples/claude/ and examples/cursor/.
- Git on PATH, if you want the pre-commit hook. The installer runs git rev-parse, and the test suite's last checks create a throwaway repository.
The first 15 minutes
-
Copy the folder in under its own name
Put the unzipped folder at the root of your project as .agent-safety-hooks. The example configs call node .agent-safety-hooks/hooks/.... Renaming the folder means those paths need the same edit.
-
Run the tests
From the project root. The README says a good run ends with 57/57 checks passed. The script runs every hook as a subprocess, then the pre-commit hook inside a temporary git repo.
node .agent-safety-hooks/test/run.mjs -
Turn the hooks on for your client
Claude Code: merge examples/claude/settings.json into .claude/settings.json, and append examples/claude/CLAUDE.md to your CLAUDE.md. In Claude Code, run /hooks and confirm they loaded. Cursor: copy examples/cursor/hooks.json to .cursor/hooks.json, and copy the four .mdc files in examples/cursor/rules/ to .cursor/rules/. Restart Cursor and check the Hooks tab in settings.
-
Optional: block secret commits
From the project root, and only if this folder is already a git repository:
node .agent-safety-hooks/scripts/install-git-hook.mjs -
Ignore the audit log
Add .agent-audit.jsonl to .gitignore. hooks/audit-log.mjs appends each tool call there and redacts secrets. If you install the pre-commit hook and a hook was already present, the installer copies the old file to pre-commit.bak when that file does not already mention scan-secrets.
Common problems
- The test does not end at 57/57
- Use Node 18 or newer, run the command from the project that contains .agent-safety-hooks, and have git on PATH. The last checks call git init in a temporary directory. The script prints PASS or FAIL for each check and a final count.
- The hooks never run
- The example commands use the path .agent-safety-hooks/hooks/. The folder needs that name, at the project root. Claude Code needs the settings merged into .claude/settings.json. Cursor needs the restart and the Hooks tab. Run /hooks in Claude Code to see what loaded.
- It asks me before a command I use all the time
- Approval prompts are the risky list in the README: git push, publishing, deploys, curl that sends data, migrations, sudo, deletes and global installs. Destructive commands are denied outright. To skip the prompt for a command you trust, add its regex to allowCommands in a guard.config.json at the project root. examples/guard.config.json is the sample. Destructive commands stay blocked either way.
- A normal string was flagged as a secret
- Add the comment guard:allow-secret on that line. The README says the scanner skips a line with that marker.
- The pre-commit installer fails
- Run it from inside a git repository. The script calls git rev-parse --show-toplevel. If the project has no repository yet, run git init first. git also has to be on PATH.
- The agent cannot open .env or a key file
- On Claude Code, secret-guard blocks reads and writes of .env, *.pem, *.key, id_rsa, .aws/credentials and .npmrc, and it blocks edits that contain common API-key and private-key shapes. On Cursor, the hook is wired to beforeReadFile, so it blocks reading those secret files and does not block writing secrets into ordinary files. The Cursor no-secrets rule tells the agent not to hard-code them, and the pre-commit hook can still block a commit that contains them. A real token belongs in the environment, outside the repo.
- Can a carefully written command get around this?
- The README says the hooks are a safety net: pattern matching can be evaded by an obfuscated command, and the token totals are estimates from the transcript size. Keep real secrets out of the repo, use least-privilege tokens, and keep backups.
Back to Agent Safety & Hooks Pack for what's included and checkout.