Claude Code Quality Hooks

Detect and prevent lazy rewrites, skipped reads, and untested commits.

667 hooks 9,200+ tests 800+ hours tested
The problem is real. Analysis of 6,852 Claude Code sessions found code read counts dropped from 6.6x to 2x per edit, and full-file rewrites increased significantly. (Source: The Register, April 2026)

Quick Install

Install all quality hooks with one command:

npx cc-safe-setup --install-example overwrite-guard
npx cc-safe-setup --install-example full-rewrite-detector
npx cc-safe-setup --install-example diff-size-guard
npx cc-safe-setup --install-example commit-quality-gate
npx cc-safe-setup --install-example push-requires-test-pass
npx cc-safe-setup --install-example pre-compact-checkpoint

What Each Hook Does

HookDetectsAction
overwrite-guardWriting to existing files without reading firstWarning
full-rewrite-detectorRewriting >80% of a file when partial edit would sufficeWarning
diff-size-guardToo many files changed without committingWarning / Block
commit-quality-gateEmpty or vague commit messagesBlock
push-requires-test-passPushing without running testsBlock
pre-compact-checkpointContext compaction about to happenAuto-save

Why Quality Hooks Matter

Claude Code can produce excellent work, but it can also take shortcuts:

Hooks don't fix the model. They provide a safety net that catches quality issues before they reach your codebase.

Customize Thresholds

# diff-size-guard: change file count thresholds
export CC_DIFF_WARN=5    # warn at 5+ files changed
export CC_DIFF_BLOCK=20  # block at 20+ files changed

Find More Hooks

# Search by keyword
npx cc-safe-setup --examples quality
npx cc-safe-setup --examples overwrite
npx cc-safe-setup --examples diff
npx cc-safe-setup --examples commit

Or use the Hook Selector to get a personalized recommendation in 5 questions.

Token consumption is another side effect of lazy behavior.
Retries and rewrites waste tokens. Learn how CLAUDE.md optimization can cut consumption in half.
Token Book (Chapter 1 free)