Make the rule unskippable
Earlier you deleted "never push to main" from CLAUDE.md, because a rule that dangerous shouldn't depend on Claude reading carefully. Now give it somewhere it actually holds.
A PreToolUse hook runs before every matching tool call and can stop it. Wire one onto the Bash tool in the queries project so a push to main is refused rather than requested. Claude Code loads hooks when a session starts, so the hook you write here takes effect on the next run.
Diese Übung ist Teil des Kurses
<Kurs>Claude Code in Action</Kurs>Übungsanweisungen
- Start Claude Code with
claude. - Ask Claude to write a
PreToolUsehook script athooks/block-main-push.jsthat refuses any Bash command pushing to main, and explains why. - Ask Claude to wire that script into
.claude/settings.jsonas aPreToolUsehook with the matcher set toBash. - Type
/exitto exit Claude Code.
Interaktive praktische Übung
Verwandle Theorie mit einer unserer interaktiven Übungen in die Praxis
Übung starten