Shell
Claude Code Verification Hooks
What This Does
These hooks automatically verify that code works correctly before Claude hands off to you. If checks fail, Claude will keep working until everything passes.
How It Works
1. After Writing Code (verify-after-write.sh)
When Claude creates a new file, this hook automatically:
- ✅ Checks TypeScript types (if applicable)
- ✅ Runs linting checks
- ✅ Runs tests
- ❌ Blocks completion if anything fails
- 🔄 Claude continues fixing until all checks pass
2. After Editing Code (verify-after-edit.sh)
When Claude modifies existing files:
- ✅ Same checks as write hook
- ✅ Ensures changes don't break existing code
- 🔄 Keeps Claude in the loop until fixed
3. Before Starting Work (pre-task-check.sh)
When you submit a new prompt:
- ⚠️ Warns if you have uncommitted changes
- ⚠️ Suggests creating feature branch if on main/master
- 💡 Helps maintain good git hygiene
What Gets Checked
TypeScript/JavaScript Files
- Type checking (
tsc --noEmit) - Linting (
eslint) - Test suite (
npm test)
Python Files
- Syntax validation (
py_compile)
Skipped Files
Documentation, config files (.md, .json, .yaml, etc.) are skipped to avoid noise.
How It Feels
Before Hooks:
You: "Add login button"
Claude: "Done! ✅ (but actually has type errors)"
You: "It's broken..."
With Hooks:
You: "Add login button"
Claude: "Creating button..."
🔍 Hook runs checks
❌ Type error detected
Claude: "Fixing type error..."
🔍 Hook runs again
✅ All checks passed!
Claude: "Done! Verified working ✅"
Customization
Edit the hook scripts to:
- Add more checks (formatting, security scans, etc.)
- Change which files trigger checks
- Adjust error thresholds
- Add project-specific validations
Disabling Hooks
To temporarily disable:
mv ~/.claude/hooks.json ~/.claude/hooks.json.disabled
To re-enable:
mv ~/.claude/hooks.json.disabled ~/.claude/hooks.json
Troubleshooting
If hooks seem stuck:
- Check
~/.claude/hooks/*.shlogs - Verify tools are installed (
tsc,eslint, etc.) - Temporarily disable to debug: see above
The Result
You get verified, working code every time. No more "Done!" messages followed by broken builds.