
Mission 5 of 7
Let Claude Code run hands-off, without wrecking anything.
Permissions are a list the model consults. Hooks are code that runs every time, whatever the prompt says. Build hooks that block dangerous commands, clean up after it and check the tests.
What you'll do
Learn the difference between a rule the model reads and a rule the harness enforces.
Block the dangerous commands, auto-format every file it touches, and refuse a 'done' while tests fail.
Use a throwaway worktree or a container so the worst case is a deleted folder.
- Force pushes, rm -rf and .env access refused whatever the prompt says
- An end to the fake 'tests pass' problem
- Claude Code set up with a CLAUDE.md and the permissions file from mission 1
- Node installed (the hooks here are small Node scripts; any language works, Node is just everywhere)
- A project with a test command and a linter. If you don't have a linter, skip the format hook, keep the other two
Your progress0/6
Why 'please don't' isn't enough
Understand the difference between a rule the model reads and a rule the harness enforces.
Before you build anything, it's worth seeing why a hook is different from a rule you write down.
Advice versus enforcement
Everything in CLAUDE.md is advice. Good advice, followed most of the time, but advice. If you write 'never force push', it will follow that 98 times out of 100.
The hundredth time, after a confusing merge, it might decide a force push is the fix. And a confused model with a force push is how you lose a day.
A hook is different. It's a script that Claude Code runs itself at a fixed moment: just before a tool call, just after, or when it's about to stop.
The script sees what's about to happen and can block it, change the outcome, or feed information back. The model can't skip it, argue with it or forget it. It's enforcement, not persuasion.
The three moments you care about
- PreToolUse: before a tool runs. Block things here. The tool call never happens if the hook says no.
- PostToolUse: after a tool runs. Clean up here. Format the file it just wrote, lint it, and send any errors back so it fixes them.
- Stop: when it thinks it's finished. Verify here. If tests fail, tell it it's not finished.
DROP TABLE, and which to run prettier.