> Claude Code hooks are user-defined shell commands that execute at various points in Claude Code's lifecycle. Hooks provide deterministic control over Claude Code's behavior, ensuring certain actions always happen rather than relying on the LLM to choose to run them.
Claude Code released hooks a few days ago, and I set up a few hooks to improve my experience (and velocity) using Claude Code:
• check-package-age.sh: prevents CC from installing outdated packages
• code-quality-primer.sh / code-quality-validator.sh: Validates code quality
• code-similarity-check.sh: Helps prevent duplicate code (and uses an indexer to support faster method lookup)
• pre-commit-check.sh: Blocks bad commits with lint/test checks
• claude-context-updater.sh: Auto-updates CLAUDE.md to keep context fresh (and helps CC navigate the codebase faster)
To help me debug that the hooks were running, I added (local) logging, and I can see stats on the hooks that have run.
I tend to add a new hook when I notice CC not behaving as I want. I've got a backlog of hooks to add.
This is mostly functional, though before it being 'perfect' I figured I'd put it out here to get input and maybe some other contributors.
> Claude Code hooks are user-defined shell commands that execute at various points in Claude Code's lifecycle. Hooks provide deterministic control over Claude Code's behavior, ensuring certain actions always happen rather than relying on the LLM to choose to run them.
Claude Code released hooks a few days ago, and I set up a few hooks to improve my experience (and velocity) using Claude Code:
• check-package-age.sh: prevents CC from installing outdated packages • code-quality-primer.sh / code-quality-validator.sh: Validates code quality • code-similarity-check.sh: Helps prevent duplicate code (and uses an indexer to support faster method lookup) • pre-commit-check.sh: Blocks bad commits with lint/test checks • claude-context-updater.sh: Auto-updates CLAUDE.md to keep context fresh (and helps CC navigate the codebase faster)
To help me debug that the hooks were running, I added (local) logging, and I can see stats on the hooks that have run.
I tend to add a new hook when I notice CC not behaving as I want. I've got a backlog of hooks to add.
This is mostly functional, though before it being 'perfect' I figured I'd put it out here to get input and maybe some other contributors.