Skip to main content
tests/test_commit_hook.py · chapter Tests and team tooling, file 15 · 67 lines · open in the repository

What it does

The commit hook (.claude/hooks/pre-commit-tests.sh) blocks exactly the commits whose tests fail, judged on what the commit will contain. Each test builds a throwaway git repo with one test file and feeds the hook a Bash command the way Claude Code does.

What is inside

What it checks

  • commands that do not commit pass through (line 40)
  • a commit is judged on the staged files (line 47)
  • commit a adds changes to tracked files but not untracked ones (line 57)
  • staging and committing in one command is refused (line 65)

Source

tests/test_commit_hook.py