ECC hooks are event-driven automations attached to specific harness lifecycle events. Each event represents a precise moment in an AI session — before a tool runs, after it completes, at session start, or before context compaction — giving you fine-grained control over agent behavior without modifying your harness configuration.Documentation 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.
Hook Execution Flow
The core execution pipeline for tool-use events:- PreToolUse hooks run before the tool executes. They can block (exit code 2) or warn (stderr without blocking).
- PostToolUse hooks run after the tool completes. They can analyze output but cannot block.
- Stop hooks run after each Claude response.
- SessionStart / SessionEnd hooks run at session lifecycle boundaries.
- PreCompact hooks run before context compaction.
All 18 Lifecycle Events
All event names are case-sensitive. Use them exactly as shown when defining hooks in your hooks.json.
| Event | When It Fires | Common Uses |
|---|---|---|
SessionStart | When a harness session begins | Load prior context, detect project state |
UserPromptSubmit | When the user sends a message | Sanitize input, log request |
PreToolUse | Before any tool executes | Validation, blocking, reminders |
PermissionRequest | When a tool requires explicit permission | Audit permission grants |
PostToolUse | After a tool completes successfully | Format code, analyze output, log |
PostToolUseFailure | After a tool fails | Log failure, trigger recovery |
Notification | For system notifications | Alert routing |
SubagentStart | When a sub-agent session begins | Track delegation |
SubagentStop | When a sub-agent session ends | Aggregate sub-agent results |
Stop | When Claude finishes each response | Quality gates, session summaries |
PreCompact | Before context compaction | Save state, export snapshot |
InstructionsLoaded | After system instructions are loaded | Validate instruction integrity |
TeammateIdle | When a teammate agent is idle | Coordination signals |
TaskCompleted | When a task is marked complete | Metrics, notifications |
ConfigChange | When ECC config changes | Sync config, audit |
WorktreeCreate | When a git worktree is created | Register in state store |
WorktreeRemove | When a git worktree is removed | Cleanup, deregister |
SessionEnd | When a session ends | Persist final state, cleanup |
Event Groups by Phase
Session Lifecycle — SessionStart, SessionEnd, PreCompact
Session Lifecycle — SessionStart, SessionEnd, PreCompact
These events bracket the session. ECC uses
SessionStart to load bounded prior context from the SQLite state store, keeping the context window lean. PreCompact saves a snapshot before the harness truncates history. SessionEnd persists final summaries.Tool Execution — PreToolUse, PostToolUse, PostToolUseFailure
Tool Execution — PreToolUse, PostToolUse, PostToolUseFailure
The tightest feedback loop.
PreToolUse can inspect the tool name and input before execution — and block it (exit 2) for policy violations. PostToolUse sees the output and is ideal for formatting, linting, and logging. PostToolUseFailure fires only when the tool itself errors.Key tool matchers: Bash, Edit, Write, Read, MultiEdit.Response Lifecycle — Stop, UserPromptSubmit
Response Lifecycle — Stop, UserPromptSubmit
Stop fires after Claude completes each response — useful for console.log audits, session summaries, and cost tracking. UserPromptSubmit fires when the user submits a message, before any tool is called.Permission and Notification — PermissionRequest, Notification
Permission and Notification — PermissionRequest, Notification
PermissionRequest fires when a tool requires explicit user permission (e.g., running a destructive shell command). Use these hooks to audit or log permission grants.Multi-Agent — SubagentStart, SubagentStop, TeammateIdle
Multi-Agent — SubagentStart, SubagentStop, TeammateIdle
Multi-agent events fire for sub-agent delegation.
SubagentStart and SubagentStop bracket a delegated session. TeammateIdle signals when a coordinated agent is available for work.Worktree & Config — WorktreeCreate, WorktreeRemove, ConfigChange, InstructionsLoaded, TaskCompleted
Worktree & Config — WorktreeCreate, WorktreeRemove, ConfigChange, InstructionsLoaded, TaskCompleted
Infrastructure-level events. Worktree hooks integrate with ECC’s orchestration layer.
ConfigChange fires when ECC config is modified at runtime. InstructionsLoaded validates the system prompt after load. TaskCompleted is emitted by the epic/task tracking system.Installing Hooks
Hooks are installed as part of thehooks-runtime module, included in the core profile and above:
Runtime Hook Controls
Adjust hook behavior without editinghooks.json:
minimal— essential lifecycle and safety hooks onlystandard— default; balanced quality and safety checksstrict— additional reminders and stricter guardrails