Loading learning content…
Loading learning content…
Configure lifecycle hooks to auto-format, type-check, and enforce standards on every change.
Read through the lesson, mark it complete when the concept is clear, then move to the next lesson in the sequence or jump back to the module map.
Hooks are automated scripts that run at specific points in the Claude Code lifecycle. They enforce quality standards without relying on remembering to run checks manually.
PreToolUse — runs before a tool executes. Use to validate, block dangerous operations, or modify parameters.
PostToolUse — runs after a tool executes. Use to format code, run type checks, or log changes.
Stop — runs when a session ends. Use for final audits: check for console.log statements, verify test coverage, save session state.
PreCompact — runs before context compaction. Use to save critical state.
Auto-format TypeScript on every edit:
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{"type": "command", "command": "prettier --write $TOOL_INPUT_FILE"}]
}]
}
}
Block force pushes:
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{"type": "command", "command": "echo $TOOL_INPUT_COMMAND | grep -q 'force' && exit 1 || exit 0"}]
}]
}
}
The ECC harness includes pre-configured hooks:
Hooks are reliable; reminders aren't. Any quality standard that matters should be a hook. Manual "remember to run X" instructions are forgotten under pressure. Encode the standard, don't rely on memory.
Configure hooks in ~/.claude/settings.json for global standards, or in .claude/settings.json for project-specific rules.