Skip to content

Evaluate Claude Code hooks to enforce repo rules (file-length, commit msg, etc.) #16

Description

@nichm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤖 scrumbotScrumbot is analyzing this issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions