Day 95 of 98 · Thursday · Learning

The hook that refuses - gitleaks guarding the home-dir repo (commit 02af8fc)Hands-on

Commit autonomy now covers your home directory, guarded by two mechanical gates instead of a question: an allow-list .gitignore and a gitleaks pre-commit hook that refuses any commit containing a recognizable secret.

Catch-up progress
95/98
Why this matters to you

The home-dir repo (/Users/tom on main) sits on top of .claude.json, .cloudflared/, Keychain exports and every dotfile. Before 10-11 the rule was 'ask first'. Asking is a gate that depends on remembering; a hook runs every time, including in a headless run at 3 a.m.

A git hook is a script git runs at a fixed moment. pre-commit runs after you stage files and before the commit object exists; if it exits non-zero, there is no commit. The hook at /Users/tom/.git/hooks/pre-commit is seven lines: refuse if gitleaks is missing, otherwise run gitleaks git --pre-commit --staged --no-banner --redact.

gitleaks is a scanner with a few hundred patterns: AWS access keys (AKIA...), GitHub tokens (ghp_...), Anthropic keys (sk-ant-...), Slack tokens, private-key blocks, and high-entropy strings next to words like password. --staged means it reads only what is about to be committed; --redact means the refusal message masks the secret instead of printing it into a log.

The allow-list .gitignore is the other gate. Its first line is /* - ignore everything - followed by ! lines that let in only CLAUDE.md, its docs, the r3f skill and the particle-globe source. A deny-list would need to name every dangerous file in advance; an allow-list only needs to name the safe ones. Two rules still need you: never widen the allow-list, never git add -f.

Worked example

Plant a fake key in a tracked file, try to commit it, watch the refusal, undo.

cat /Users/tom/.git/hooks/pre-commit
gitleaks version
cd /Users/tom
echo 'aws_key = AKIAIOSFODNN7EXAMPLE' >> README.md
git add README.md
git commit -m "test: should be refused"
git checkout -- README.md
git status --short
▶ Do it now
  1. Read the hook and the first fifteen lines of /Users/tom/.gitignore. Say in one sentence what each gate stops.
  2. Run the planted-key test above and read the refusal. Then confirm with git log -1 that the last commit is still 02af8fc or later, not your test.
  3. Restore README.md and check git status is clean. The clean status is the side-effect.

Gotchas

Go deeper: /Users/tom/.gitignore - the allow-list · gitleaks on GitHub · _docs/CHANGELOG-claude-md.md - the 10-11 entry
One-card takeaway

A gate that runs itself beats a gate that has to be remembered.