Domdhi logoDOMDHI.OS
BACK_TO_COURSE

Roles, Models and Safety Rails

Hooks and Guardrails: Rails That Run Without You

Safety You Do Not Have to Remember

Hooks are scripts the runtime fires on events. Claude registers 17 handlers; the ones that matter most for day-to-day safety:

Hook When Effect
secret-scanner Before Write/Edit Blocks writing a secret
path-guardrail Before Write/Edit Enforces path tiers — and blocks edits to frozen tests
guardrail Before shell commands Blocks, nudges or asks confirmation on destructive commands via guardrail-rules.yaml
commit-guard Before shell commands Blocks inline git commit -m and hook-skipping forms such as --no-verify
post-read-scrubber After Read/Bash Scans output for secrets and redacts shell output

The rest handle memory (memory-recall, memory-session-capture, memory-capture), worktrees, failure analysis (damage-control), telemetry and plan organization.

Git Hooks the Toolkit Manages

Install and update also write five small git hooks into .git/hooks (never tracked): pre-commit, commit-msg, pre-merge-commit, pre-applypatch and pre-push. They scan every commit, merge and git am — including a raw git commit typed in a terminal — and pre-push scans every object a push would publish, refuses deletions, non-fast-forward and mirror pushes, and refuses pushes to auto/* branches. All of them run on the pinned, hash-verified Betterleaks engine; install it once per machine with node .claude/core/secret-engine-install.js. A missing engine fails closed.

Commits Go Through commit.js

Write the message to docs/.output/.state/.commit-msg, stage specific files, then run node .claude/core/commit.js — with --ship-check in the build workflows (Module 3). It normalizes the message and, when the managed hooks are not active, scans the staged set itself.

git add path/to/file-a path/to/file-b   # never git add . in a shared tree
node .claude/core/commit.js              # commits only what is staged

--all sweeps everything and is unsafe when another process shares the working tree. The toolkit commits locally only; push, publish, deploy and PR need the owner's explicit go.

WARNING

Know the exact coverage: the commit hooks cover commit, merge and git am; the pre-push scan is the backstop for every route that ran no hook. Nothing protects a commit that is never pushed, and a person can always skip a hook. Newly installed or changed native hooks may also need review or trust in your runtime before they run.

QUIZ

Why is `git add .` followed by a commit discouraged in this workflow?

Sign in to track lesson progress and earn a certificate.SIGN IN TO SAVE PROGRESS