section · guides
Hooks Deprecated
Deprecated Hooks
Hooks are removed when their behavior is absorbed into a consolidated hook, moved into
declarative rules, or expressed as persona/skill guidance. Removal without an entry here
is a policy violation: construct doctor checks this ledger against the hooks manifest.
Consolidation into lib/hooks/policy-engine.mjs
policy-engine.mjs is the consolidated hook for session policy. It is wired in platforms/claude/settings.template.json for three events:
- PreToolUse (matcher
Write|Edit|MultiEdit|NotebookEdit|TodoWrite|Bash): bootstrap rule - Stop: red-CI block, open-beads block, drive-mode criteria, drive-session advisory
- UserPromptSubmit: reserved; no-op today
bootstrap-guard.mjs
- Original event: PreToolUse
- Original behavior: Blocked Write/Edit/Bash mutations until the session was grounded: either via
project_context+memory_searchMCP calls or 3+ exploratory reads. - Now:
lib/hooks/policy-engine.mjsPreToolUse handler. State persisted at~/.cx/bootstrap-state.json, scoped per-session, 24h TTL.
drive-guard.mjs
- Original event: Stop
- Original behavior: Blocked Stop when drive mode was active and acceptance criteria lacked evidence.
- Now:
lib/hooks/policy-engine.mjsStop handler: drive section. Reads.construct/drive-state.json(per-project) and~/.cx/drive-session.json(global advisory).
continuation-enforcer.mjs
- Original event: PostToolUse (TodoWrite)
- Original behavior: Reinforced TodoWrite usage to prevent premature stopping.
- Now: Two replacements that are policy-aligned with
CLAUDE.md:85("use bd, not TodoWrite"):policy-engine.mjsStop handler:open-bdsection blocks Stop when anybd list --status in_progressissue is open. Bypass:CONSTRUCT_STOP_OK_OPEN_BD=1.policy-engine.mjsStop handler: drive section enforces criteria completion.
console-warn.mjs
- Original event: PostToolUse (Edit/Write)
- Original behavior: Detected
console.log/console.debug/debuggerstatements in edited files. - Now:
lib/hooks/adaptive-lint.mjs:130:[adaptive-lint] console.log/debug in \<file>:\<loc>advisory.
read-tracker.mjs
- Original event: PostToolUse (Read)
- Original behavior: SHA-16 file-hash store at
~/.cx/file-hashes.jsonfor edit-guard staleness detection; recorded read deltas vialib/read-tracker-store.mjs. - Now:
lib/hooks/audit-reads.mjsstage 1 (always-on, runs regardless ofCONSTRUCT_AUDIT_READS): same hash-store upsert + read-tracker delta + retention pruning. Folding into audit-reads fixed a quiet correctness bug: the prior split meant edit-guard's staleness check broke when audit-reads was off, because nothing else maintained the hash store.
env-check.mjs
- Original event: SessionStart
- Original behavior: Compared
.env.examplevs.envandprocess.env; surfaced placeholder/missing required vars at session open. - Now:
lib/hooks/session-start.mjsbuildEnvCheckNote(cwd)helper, appended to the existing session-start output as part of the unified tier-2 emission. One fewer SessionStart process spawn.
Stalled-mid-consolidation hooks
These hooks were removed but the consolidated replacement is not yet implemented in policy-engine.mjs. Their behaviors are currently absent. Treat as known gaps:
task-completed-guard.mjs
- Was: PreToolUse on
workflow_update_task, required verification evidence before allowing status to be set todone. - Status: Not implemented in policy-engine. The Stop-time
open-bdcheck is a partial substitute (blocks Stop with open work) but doesn't gate the status transition itself. - Follow-up: Add a
taskrule topolicy-engine.mjsPreToolUse that checksworkflow_update_taskagainst the rule inrules/policy/task.yaml.
workflow-guard.mjs
- Was: UserPromptSubmit; routed significant work through workflow state, warned when non-trivial mutations ran without an active workflow task.
- Status: Not implemented.
policy-engine.mjsUserPromptSubmit handler is a no-op. - Follow-up: Implement the
workflowrule fromrules/policy/workflow.yaml.
mcp-task-scope.mjs
- Was: PreToolUse on MCP tool calls; warned when an MCP call was outside the declared task scope.
- Status: Not implemented.
mcp-audit.mjsrecords attribution but does not enforce scope. - Follow-up: Add MCP scope check to
policy-engine.mjsPreToolUse.
repeated-read-guard.mjs
- Was: PreToolUse on Read; warned after a file was read more than a configurable threshold within a session.
- Status: Declarative-only via
rules/common/efficiency.md. Behavioral enforcement absent.
teammate-idle-guard.mjs
- Was: PostToolUse on Task; tracked agent start times and warned on idle dispatched agents.
- Status: Declarative-only via
commands/build/feature.md. Behavioral enforcement absent.
New Stop-time policy added with this consolidation
These behaviors were never separate hooks but are new to policy-engine.mjs Stop:
- red-CI block: queries
gh run list --branch=\<current> --limit=1; exits 2 if last run failed and the agent edited code this session. Bypass:CONSTRUCT_STOP_OK_RED_CI=1. - open-bd block: queries
bd list --status in_progress --json; exits 2 if any issues are open. Bypass:CONSTRUCT_STOP_OK_OPEN_BD=1. - drive-session advisory: reads
~/.cx/drive-session.json; emits stderr advisory ifopen: true. Non-blocking.