
hookshield: Safety Hooks for Claude Code
One command adds safety hooks to Claude Code in your repo. Blocks rm -rf outside the project, force pushes, git reset --hard, reading .env files and keys, edits to migrations that already ran, and destructive database commands. Formats every file the agent edits and runs your type-check, lint and tests before it may say it's done. Keeps your existing hooks. Free and open source. #컨설팅
hookshield: safety hooks for Claude Code
One command gives Claude Code guardrails in your repo. It stops the agent from running rm -rf ~, force-pushing over your team's work, reading your .env, or editing a migration that already ran. It formats every file the agent edits, and it runs your type-check, lint and tests before the agent is allowed to say "done".
How to use
Ask your agent:
Install hookshield in this repo.
It shows you what will change, asks first, then sets up four hooks in .claude/. Start a new Claude Code session and they're active. Commit .claude/ so your whole team gets the same guard.
What it blocks
| Blocked | Still allowed |
|---|---|
rm -rf ~, rm -rf /, rm -rf ., rm -rf ../other |
rm -rf node_modules dist .next |
git push --force, -f, force-with-lease to main |
force-with-lease to your own branch |
git reset --hard, git clean -fd, git checkout . |
git reset --soft, git restore --staged . |
git commit --no-verify |
normal commits |
DROP TABLE, TRUNCATE, DELETE with no WHERE |
SELECT, DELETE ... WHERE |
supabase db reset, prisma migrate reset, terraform destroy |
supabase migration new, prisma migrate dev |
reading or editing .env, *.pem, *.p8, id_rsa, service-account keys |
.env.example, public keys |
| editing a migration that already exists | creating a new migration |
curl ... | bash, chmod -R 777, mkfs |
When something is blocked, the agent is told why and asked to check with you instead of finding a way around it.
What else it does
- Formats after every edit with what your repo already uses: prettier or biome, ruff or black, gofmt, rustfmt, swiftformat, ktlint.
- Checks before "done". If the agent changed files, your checks run when it tries to finish (for example
npm run typecheck,npm run lint,npm test). If they fail, it sees the errors and keeps fixing. After 3 tries it stops and tells you, so it never loops forever.
Example
> git push --force origin main
hookshield blocked this (force-push): force push can overwrite commits
on the remote that other people rely on.
Works with
Node/TypeScript (Next.js, Expo, React), Supabase, Python, Go, Rust, Swift/Xcode and Kotlin/Gradle. Needs Node 18+ and nothing else: no dependencies, no network calls, no data collected.
FAQ
Will it break my existing hooks? No. It merges into .claude/settings.json, keeps your hooks, and saves a backup on first install.
Something I need is blocked. Add it to allowCommands or allowPaths in .claude/hookshield.json, or turn a rule off with disabledRules. Only you can edit that file; the agent is blocked from changing it.
How do I remove it? Ask your agent to uninstall hookshield. It removes only its own hooks.
Is it a sandbox? No. It's a seatbelt: it stops the common accidents. Keep backups and branch protection on.
Open source (MIT): https://github.com/ANM-DEV9184/hookshield


