Without hooks, every agent session starts from zero: no context from yesterday’s work, no automatic formatting after edits, no guardrails preventing a blindDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/affaan-m/ECC/llms.txt
Use this file to discover all available pages before exploring further.
git push. Hooks are ECC’s event-driven automation layer — shell commands, HTTP calls, or sub-prompts that execute at precise moments in the harness lifecycle, injecting consistent behaviour into every session without requiring manual intervention.
How Hooks Work
The execution pipeline for every tool call passes through the hook graph:SessionStart, SessionEnd, PreCompact) fire outside the per-tool flow.
- PreToolUse hooks run before the tool executes. They can block the call (exit code
2) or emit a warning (write to stderr, exit0). - PostToolUse hooks run after the tool completes. They can analyze output but cannot block.
- Stop hooks run after each complete Claude response.
- SessionStart / SessionEnd hooks run at session lifecycle boundaries.
- PreCompact hooks run before context compaction — the right moment to save state.
Supported Hook Events
All 18 hook event types defined inschemas/hooks.schema.json:
SessionStart
Session opens. Used to load bounded prior context and detect project state.
UserPromptSubmit
Fires when a user message is submitted. Runs before Claude processes it.
PreToolUse
Before any tool executes. The primary gate for quality checks and blockers.
PermissionRequest
When the harness requests elevated permissions for an operation.
PostToolUse
After a tool completes successfully. Used for formatting, logging, feedback.
PostToolUseFailure
After a tool fails. Used for error analysis and recovery signals.
Notification
Harness notification events (desktop alerts, external integrations).
SubagentStart
Before a sub-agent begins a delegated task.
Stop
After each complete Claude response. Used for audits and session persistence.
SubagentStop
After a sub-agent finishes its delegated task.
PreCompact
Before context compaction. The correct moment to save session state.
InstructionsLoaded
After CLAUDE.md / rules files are loaded into the session context.
TeammateIdle
A teammate agent becomes idle in a multi-agent session.
TaskCompleted
A discrete task unit is marked complete.
ConfigChange
ECC configuration or settings change during a session.
WorktreeCreate
A new git worktree is created for parallel agent work.
WorktreeRemove
A git worktree is removed after parallel work completes.
SessionEnd
Session closes. Used for final cleanup and end markers.
Three Hook Action Types
Every hook entry uses one of threetype values:
- command
- http
- prompt / agent
Runs a local shell command. The most common type — shell scripts or Node.js one-liners that receive tool input as JSON on stdin and return JSON on stdout.Set
"async": true for background hooks that should not block the main flow (e.g., build analysis, cost telemetry).Hook Definition Structure
A complete hooks configuration file maps event names to arrays of matcher entries:command hooks:
| Code | Meaning |
|---|---|
0 | Success — continue execution |
2 | Block the tool call (PreToolUse only) |
| Other non-zero | Error — logged but does not block |
ECC Built-In Hooks
PreToolUse Hooks
| Hook | Matcher | Behavior | Exit Code |
|---|---|---|---|
| Dev server blocker | Bash | Blocks npm run dev etc. outside tmux — ensures log access | 2 (blocks) |
| Tmux reminder | Bash | Suggests tmux for long-running commands (npm test, cargo build, docker) | 0 (warns) |
| Git push reminder | Bash | Reminds to review changes before git push | 0 (warns) |
| Pre-commit quality check | Bash | Lints staged files, validates commit message format, detects console.log / debugger / secrets | 2 (blocks critical) / 0 (warns) |
| Doc file warning | Write | Warns about non-standard .md/.txt files; allows README, CLAUDE, CONTRIBUTING, CHANGELOG, LICENSE, SKILL, docs/, skills/ | 0 (warns) |
| Strategic compact | Edit|Write | Suggests manual /compact at logical intervals (~every 50 tool calls) | 0 (warns) |
| Config protection | Write|Edit|MultiEdit | Blocks modifications to linter/formatter config files — steers agent to fix code instead | 2 (blocks) |
PostToolUse Hooks
| Hook | Matcher | What It Does |
|---|---|---|
| PR logger | Bash | Logs PR URL and review command after gh pr create |
| Build analysis | Bash | Background analysis after build commands (async, non-blocking) |
| Quality gate | Edit|Write|MultiEdit | Runs fast quality checks after edits |
| Design quality check | Edit|Write|MultiEdit | Warns when frontend edits drift toward generic template-looking UI |
| Prettier format | Edit | Auto-formats JS/TS files with Prettier after edits |
| TypeScript check | Edit | Runs tsc --noEmit after editing .ts/.tsx files |
| console.log warning | Edit | Warns about console.log statements in edited files |
Lifecycle Hooks
| Hook | Event | What It Does |
|---|---|---|
| Session start | SessionStart | Loads previous context and detects package manager |
| Pre-compact | PreCompact | Saves state before context compaction |
| Console.log audit | Stop | Checks all modified files for console.log after each response |
| Session summary | Stop | Persists session state when transcript path is available |
| Pattern extraction | Stop | Evaluates session for extractable patterns (continuous learning) |
| Cost tracker | Stop | Emits lightweight run-cost telemetry markers |
| Desktop notify | Stop | Sends macOS desktop notification with task summary |
| Session end marker | SessionEnd | Lifecycle marker and cleanup log |
Installing Hooks
Runtime Hook Controls
You can tune hook behaviour without editinghooks.json using environment variables:
| Profile | Description |
|---|---|
minimal | Essential lifecycle and safety hooks only |
standard | Default — balanced quality and safety checks |
strict | Additional reminders and stricter guardrails |
Writing a Custom Hook
Hooks receive tool input as JSON on stdin and must return JSON on stdout."async": true in the hook definition: