Claude Code Has Hidden Hook System for Auto-Linting
Claude Code includes a hidden hook system that automatically runs linting tools on code changes, helping developers maintain code quality and catch errors
Someone found that Claude Code has a hook system that runs scripts automatically before or after tool calls - super useful for auto-linting or security checks.
Drop a .claude/settings.json in your project:
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "./scripts/lint.sh" }]
}],
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "./scripts/security-check.sh" }]
}]
}
}
The hooks receive JSON on stdin with the full tool input. If your script exits with code 2, it blocks the action entirely.
Pretty handy for building guardrails - like preventing Claude from running sketchy bash commands or automatically checking code style after every file edit. No more manually reviewing every single change.
Related Tips
Parallel Git Worktrees: A Claude Team Productivity Hack
Claude Team members share how parallel Git worktrees enable them to work on multiple branches simultaneously, switching contexts faster and boosting
Smart Claude.md Strategy for Cleaner Monorepos
A practical guide exploring how to use Claude.md files to maintain consistent AI coding assistance across monorepo workspaces, reducing context pollution and
Maestro: Run Multiple Claude Code Sessions in Parallel
Maestro enables developers to orchestrate and run multiple Claude AI coding sessions simultaneously in parallel, streamlining complex development workflows and