Question
We have pre-commit hooks enforcing file-length limits, commit message format, and other rules. Should we also add Claude Code hooks to enforce the same rules at the AI layer?
Claude Code hook types available
PreToolUse — fires before any tool call (Bash, Edit, Write, etc.)
PostToolUse — fires after
UserPromptSubmit — fires when user submits a prompt
SubagentStart — fires when a subagent spawns
Potential use cases
PreToolUse on Write/Edit: block writes to files approaching 600-line limit with a helpful message
PostToolUse on Bash: warn if a shell command ran without a timeout
SubagentStart: inject shell-config context into every subagent automatically
UserPromptSubmit: append current branch/recent commits to every prompt
Risks / concerns
- Hooks run on every tool call — badly written hooks slow every operation
- Hooks that block execution can frustrate flow (same UX issue we already have with pre-commit hooks)
- Duplicates existing pre-commit coverage — may be redundant for file-length
- Hooks are stored in
~/.claude/settings.json, not the repo — harder to share/version
Recommendation needed
Evaluate: which hooks add value not already covered by pre-commit? Are any worth the latency overhead?
Question
We have pre-commit hooks enforcing file-length limits, commit message format, and other rules. Should we also add Claude Code hooks to enforce the same rules at the AI layer?
Claude Code hook types available
PreToolUse— fires before any tool call (Bash, Edit, Write, etc.)PostToolUse— fires afterUserPromptSubmit— fires when user submits a promptSubagentStart— fires when a subagent spawnsPotential use cases
PreToolUseonWrite/Edit: block writes to files approaching 600-line limit with a helpful messagePostToolUseonBash: warn if a shell command ran without atimeoutSubagentStart: inject shell-config context into every subagent automaticallyUserPromptSubmit: append current branch/recent commits to every promptRisks / concerns
~/.claude/settings.json, not the repo — harder to share/versionRecommendation needed
Evaluate: which hooks add value not already covered by pre-commit? Are any worth the latency overhead?