🪝
Hooks System — Standards as Automated Checkpoints
Every standard becomes an executable checkpoint
P1Infrastructure
Summary
Claude Code's hooks system attaches shell commands to lifecycle events: PreToolUse, PostToolUse, Notification, Stop. Hooks transform manual standards into automated enforcement. The Claude Code source leak was caused by a missing build pipeline check — exactly the kind of gap hooks prevent.
Technical Details
Hook types and enforcement use:
• PreToolUse: validate before action (block writes to protected files)
• PostToolUse: verify after action (run tests after edit, lint after code generation)
• Notification: alert on events (log tool usage, send metrics)
• Stop: cleanup on session end (commit pending changes, update status)
V5.3 Standard enforcement via hooks:
- Pre-deploy: check Docker mem_limit, restart policy, healthcheck
- Post-edit: run project-specific linters and tests
- Pre-commit: validate commit message format, check for secrets
- Post-build: verify source maps excluded (prevents the leak scenario)
Irony: Anthropic's own leak was caused by not having a hook that checks for source maps in npm packages. The fix was 1 line in .npmignore.
Implementation Pattern
TypeScript (conceptual)
// Hook configuration in settings.json
{
"hooks": {
"PreToolUse": [{
"matcher": "Edit",
"hooks": [{
"type": "command",
"command": "python /scripts/check_protected_files.py \"$FILE_PATH\""
}]
}],
"PostToolUse": [{
"matcher": "Write",
"hooks": [{
"type": "command",
"command": "npm run lint -- --fix && npm run test -- --bail"
}]
}]
}
}Architecture Insight
Hooks encode the principle: 'standards as code, not documentation'. Every process gap is a missing hook. The leak's root cause wasn't a bug — it was a missing automated check.
Official / Public Basis
Hooks system officially documented at docs.anthropic.com/en/docs/claude-code/hooks. Configuration via settings.json.
Governance Concerns
Hooks are the enforcement arm of governance. Every standard that matters should have a hook. Manual standards are suggestions; hook-enforced standards are guarantees.
LightHope Ecosystem Mapping
V5.3/V5.4 compliance automation, m8005 deployment validation, all projects pre-deploy checks, m495 skill validation gates