Claude Code Hooks Starter (Free)
Free Claude Code hooks examples: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Notification and Stop, plus a local tester that checks your hook's output.
View Claude Code Hooks Starter (Free)
Four Claude Code hooks that deny the commands you never want an agent to run, ask before the risky ones, keep it out of your secrets, and make it fix a key it just wrote into a file.

Four tested Claude Code hooks, packaged as a plugin, that stop the mistakes an agent makes when it moves fast:
| Hook | Event | What it does |
|---|---|---|
| guard_bash.py | PreToolUse Bash | Denies rm -rf of /, ~, *, . or a top-level dir, force-push or delete of main/master/production/release/*, curl … | sh, chmod -R 777, writes to disk devices, fork bombs, env-var exfiltration. Asks before git reset --hard, git clean -fdx, discarding changes, branch -D, DROP/TRUNCATE through a DB client, printing .env, terraform destroy, kubectl delete ns, aws s3 rm --recursive, npm publish. Checks every part of a && b; c, $( ) and backticks, strips sudo/FOO=1 prefixes. |
| protect_files.py | PreToolUse Edit|Write|MultiEdit|NotebookEdit | Denies writes to .env* (not .env.example), keys and certs, .git/, secrets/, *.tfstate, .npmrc/.pypirc/.netrc. Asks before editing lockfiles, CI workflows and Claude/hook settings. |
| secret_scan.py | PostToolUse Edit|Write|MultiEdit | If the file now contains a live-looking AWS, GitHub, Stripe live, Slack, Google, OpenAI or Anthropic key or a private key block, exits 2 so Claude sees it and moves it to an env var. Values are masked in the message. |
| audit_log.py | PostToolUse * | Appends one redacted JSON line per tool call to .claude/logs/tool-audit.jsonl (time, session, agent, tool, command or path). |
Every rule has a code (git_reset_hard, pipe_to_shell, …) shown in the reason, so you can switch one off per project.
The screenshot is real output from the kit’s own commands. Tested from a fresh download of this exact zip: ./run_tests.sh ran 17 tests OK on Python 3.13 and 3.10.

As a plugin (recommended): add this folder to a plugin marketplace you use, or point Claude Code at it, then enable youraitools-safety-hooks (the plugin's name; Claude Code reserves names starting with claude-). Hooks load from hooks/hooks.json with ${CLAUDE_PLUGIN_ROOT} paths.
Per project, without plugins: copy hooks/ to .claude/hooks/ in your repo and merge settings.example.json into .claude/settings.json. Run /hooks in Claude Code to confirm they are listed.
Requires python3 on PATH (3.9+). No packages, no network.
python3 tools/try_hooks.py # sample commands and files, with the decision for each
python3 tools/try_hooks.py "git push -f origin main" "rm -rf ./build"
./run_tests.sh # 17 test groups, ~90 cases{
"allow": ["git_reset_hard", "package_publish"],
"protected_branches": ["main", "release/*"],
"protected_paths": ["migrations/*", "infra/prod/*"],
"allow_paths": [".npmrc"],
"ask_paths": ["docker-compose.prod.yml"],
"scan_skip": ["fixtures/*"],
"audit_log": true
}A broken config file is ignored (the defaults stay on) and the reason goes to stderr.
PreToolUse hooks print permissionDecision: "deny" or "ask" with a reason and exit 0; anything else is silent, so Claude Code's normal permission flow applies (a hook staying silent never approves anything). The secret scan exits 2 after the write, which shows Claude the message so it fixes the file.
Zip, 17 KB, v1.0.1, 14 files, plugin youraitools-safety-hooks. You may use and modify this kit for your own work and for clients you serve, including paid client work. Not affiliated with or endorsed by Anthropic.
Tested Claude Code hooks as a plugin: block rm -rf and force-push to main, protect .env and lockfiles, catch API keys in files, audit log. $19 once.
Free Claude Code hooks examples: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Notification and Stop, plus a local tester that checks your hook's output.
View Claude Code Hooks Starter (Free)24 Cursor rules (.mdc) for Next.js, TypeScript, React, Python, FastAPI, Django, Go, Rust and more. Detects your stack, installs in one command, lints your rules. $12 once.
View Cursor Rules PackFree Cursor rules examples in .mdc format: agent workflow, commits, testing, security, code review. Includes a linter that shows why a rule isn't applying.
View Cursor Rules Starter (Free)