Constructdocs
section · guides

Hooks Inventory

3 min read·guides / reference / hooks-inventory

Hooks Inventory

Classification of all hooks in lib/hooks/ into three active buckets plus a deprecated ledger. Deprecated hooks are recorded in docs/hooks-deprecated.md.

  • observability: logging, tracing, metrics; keep as hooks
  • guardrail: policy enforcement on tool use; keep or consolidate
  • keep: session lifecycle and recovery; does not fit other buckets

Hook count target: ≤ 30 (see projection below).


observability

HookEventp95msWhat it does
audit-trail.mjsPostToolUse15Append-only JSONL audit log for every mutation (project-scoped)
bash-output-logger.mjsPostToolUse20Saves long Bash stdout to ~/.cx/bash-logs/
mcp-audit.mjsPostToolUse10Logs every mcp__* call to .construct/mcp-audit.json
audit-reads.mjsPostToolUse8Always-on: file-hash store for edit-guard staleness detection + read-tracker delta. Opt-in (CONSTRUCT_AUDIT_READS=1): tamper-evident audit chain to .construct/audit-reads.jsonl.
agent-tracker.mjsPostToolUse10Records last dispatched subagent + emits handoff.received events on next:cx-\<role> results
stop-notify.mjsStop500Session summary: cost, TS results, macOS notification
session-tracking-refresh.mjsStop2000Refreshes .construct/context.{md,json} from observations/commits/beads; syncs plan.md bead-status table; archives plan.md to .construct/handoffs/ when all referenced beads are closed
post-merge-tracking.mjsPostToolUse3000After gh pr merge succeeds, closes construct-XXX beads named in the PR body's Refs: / Closes: / Fixes: lines
context-watch.mjsUserPromptSubmit20Token usage monitoring and compaction recommendation
edit-accumulator.mjsPostToolUse10Tracks files-changed count; queues TS files for end-of-session typecheck

guardrail

HookEventp95msWhat it does
policy-engine.mjsPreToolUse, Stop, UserPromptSubmit40Consolidated policy: bootstrap, drive, task-completion, workflow routing
guard-bash.mjsPreToolUse5Blocks destructive shell patterns (rm -rf /, force-push to main, DROP TABLE)
scan-secrets.mjsPostToolUse30Blocks edits containing real secret patterns (API keys, PEM, tokens)
config-protection.mjsPreToolUse5Blocks edits to protected config and meta-system files
edit-guard.mjsPreToolUse20Blocks Edit when old_string not found; warns on stale file hash
pre-push-gate.mjsPreToolUse5000Refuses claude/* pushes, blocks re-pushing a SHA CI just failed on, lints PR body on gh pr create/edit. CI runs tests/build/lint/audit.
mcp-health-check.mjsPreToolUse51Warns on calls to recently-failed MCP servers
dep-audit.mjsPostToolUse5000Runs vulnerability audit after dependency manifest edits

keep (session lifecycle and recovery)

HookEventp95msWhat it does
session-start.mjsSessionStart300Tiered context injection at session open + .env.example vs .env comparison notice
pre-compact.mjsPreCompact100Context summary before compaction
adaptive-lint.mjsPostToolUse800Auto-runs linter/formatter on edited file; flags debug logging
comment-lint.mjsPostToolUse50Blocks banned comment patterns and missing required headers
artifact-release-gate.mjsPostToolUse80Advisory: manifest structure/visual gaps on typed docs (docs/**, .construct/research/**)
stop-typecheck.mjsStop2000Runs tsc --noEmit at session end
edit-error-recovery.mjsPostToolUse10Recovery guide for failed Edit/Write calls
context-window-recovery.mjsPostToolUse10Detects context-limit errors; saves recovery snapshot
model-fallback.mjsPostToolUse100Detects rate-limit errors; invokes model failover
registry-sync.mjsPostToolUse12000Runs construct sync after edits to registry.json

Hook count

BucketCount
observability8
guardrail8
keep11
Total27

Ceiling: 30. Adding a hook requires retiring one or explicit approval.


SLA targets

EventBudgetNotes
SessionStart hooks300ms totalsession-start + env-check combined
PreToolUse hooks50ms eachMust not visibly delay tool execution
PostToolUse hooks100ms eachAsync hooks may spike briefly
Stop hooks2000ms totalUser is waiting
UserPromptSubmit50ms eachBlocks user input
PreCompact500msOne-time pause