install-hook¶
Install or remove claude-review as a git pre-commit hook.
Usage¶
Flags¶
| Flag | Description |
|---|---|
--remove |
Remove the pre-commit hook |
Description¶
The pre-commit hook runs claude-review automatically every time you run git commit. If critical findings are detected, the commit is blocked until you address them (or explicitly bypass with git commit --no-verify).
Install¶
This writes a shell script to .git/hooks/pre-commit in the current repository.
What the hook does¶
When git commit is run, the hook:
- Checks that
ANTHROPIC_API_KEYis set - Runs
claude-review diffon the staged changes - If any critical or high severity findings are found, prints the report and exits with code 1 (blocking the commit)
- If only medium/suggestion findings exist, shows a summary but allows the commit to proceed
Remove¶
Bypass for a single commit¶
If you need to commit despite failing review (e.g., a work-in-progress commit):
Customizing behavior¶
The hook respects your claude-review.config.json. To reduce noise in pre-commit runs, consider a project config that uses fewer agents and focuses on critical issues only:
{
"agents": 2,
"focus": ["security", "logic"],
"confidence_threshold": 0.90,
"model": "claude-haiku-4-5-20251001"
}
This keeps hook runs fast and cheap while still catching the most important issues before they land.
Team setup¶
To ensure everyone on your team has the hook installed, add setup instructions to your CONTRIBUTING.md or Makefile:
Note
Git hooks are not tracked by version control. Each developer must run install-hook themselves. If you want hooks that are enforced at the repo level, consider CI instead — see CI Integration.