Builds on steps 2 and 3. Agent hooks only protect agent sessions. A teammate using a different editor, or running a command by hand, skips all of it.
Read time1 min
SectionClaude Code Setup Playbook
01 — 4 · git hooks & ci
What to do
Why: git hooks and CI apply to everyone. They are your backstop.
Do this:
Add a pre-commit hook that runs format, lint, type check and unit tests.
Run the same checks in CI so a skipped local hook still gets caught.
Add a commit-message check if your team has a convention.
For each rule you care about, ask whether a lint rule can enforce it. If yes, write the lint rule and skip the prose.
02 — 4 · git hooks & ci
Example
Example..githooks/pre-commit:
bash
#!/usr/bin/env bash
set -e
npm run format
npm run lint
npm run typecheck
npm test
Turn it on once per clone:
bash
git config core.hooksPath .githooks
A small custom lint rule is often worth more than a paragraph of guidance. For instance, "route handlers must not import the database client directly" can be one ESLint rule. Once it exists, the sentence in your docs only has to explain why.
03 — 4 · git hooks & ci
Check it works
Check: make a deliberately bad commit, such as a lint error. It should be rejected. Then open a PR with the same error and confirm CI fails too.
Watch out: if the pre-commit takes more than about a minute, people will start using --no-verify. Run only changed files locally and everything in CI.