Skip to content

Hooks Rationale ​

Per-hook design history for content/hooks/hooks.json: why each hook is warn-only or blocking, its kill-switch, and the codexMatcher decision. Moved verbatim out of the JSON $comment on 2026-08-20 — the 14.7k-char string cost ~3.7k tokens on every read of the file. Update this page whenever a hook entry changes behavior.

text
text
Hooks devkit wires into ~/.claude/settings.json (idempotent, marker '# od-managed', personal hooks preserved). Hooks run through the current-symlinked native devkit binary, updated with each sync. Full per-hook rationale (blocking history, codexMatcher decisions, measured trade-offs): docs/reference/hooks-rationale.md in the devkit source repo. Kill-switches: OD_SKIP_PUSH_GATE, OD_ALLOW_BRANCH_SWITCH, OD_SKIP_DESTRUCTIVE_GUARD, OD_SKIP_MCP_AWARENESS, OD_SKIP_BACKLOG_HINT, OD_SKIP_AGENT_STATE_IGNORE, DEVKIT_SKIP_SESSION_CLOSE_HINT, DEVKIT_SKIP_RECALL_ENTRY_HINT, DEVKIT_SKIP_DENIAL_DIAGNOSE, DEVKIT_SKIP_INDEX_HINT, DEVKIT_SKIP_INDEX_GAP_HINT, DEVKIT_SKIP_MEMORY_BUDGET, DEVKIT_SKIP_RESUME_HINT, DEVKIT_SKIP_SESSION_OVERLAP, DEVKIT_SKIP_SHARED_PATH_COMMIT, DEVKIT_SKIP_FILE_SIZE, DEVKIT_SKIP_DOCS_FIRST, DEVKIT_SKIP_QUESTION_GATE, DEVKIT_SKIP_REPORT_PROMISE_GATE, DEVKIT_SKIP_SELF_CHECK_GATE, OD_TELEMETRY=0, OD_ALLOWED_SSH_HOSTS (remote-exec opt-in).

Context7's opt-in docs hint and query guard are cataloged in devkit/tools/context7.md; fallback is silent after an attempted call, without parsing provider error envelopes.

Code Mode boundaries (Spec 1001) ​

The Rust prompt dispatcher silently skips source: poll_event before policies or one-shot state. Inner PreToolUse calls retain normal decisions: interactive Claude local discards return ask; absolute secret/remote restrictions remain denials. hooks/code_mode_tests.rs covers captured inner-call shapes, not every backend's polling payload or the separate vendored ponytail tracker.

content/hooks/hooks.json sets finite ceilings: command hooks 600 seconds, UserPromptSubmit 30 seconds, SessionEnd 10 seconds (above Pi's former 1.5-second fallback). These are not added delays or measured worst cases; a native Code Mode timeout still refuses the call.

Question gate and frontend stop gate (2026-10-17) ​

Both are once-per-key nudges, not security controls. Session analysis 2026-10-14..17: 390 AskUserQuestion questions in 3 days, the recommended option picked in 84 % of 257 answers, and about eight typed "check it yourself in the browser" requests.

  • Question gate (devkit hook pretool, Claude matcher AskUserQuestion only): denies every question set unless each question has header User call or is a mandatory free-text input, so the agent sorts it per agent-questions.md > Question Routing; the rule asks for that header up front on intent and approval questions, so only questions the agent should decide pay the denied round. Silent during a /grill-me round before the first file write, under DEVKIT_DELEGATE_DEPTH, and when the payload cannot be evaluated (fails open). Kill switch DEVKIT_SKIP_QUESTION_GATE=1. A second opinion (Codex) rejected a hard deny with an agent-set Gate: escape label as self-bypassable.
  • Report promise gate (inside announce-stop-gate, after the announce check): blocks a last assistant reply promising a later report without background tasks or a ScheduleWakeup, Monitor or CronCreate tool use in the current turn. Silent for active stop hooks, delegates and unreadable transcripts. Kill switch DEVKIT_SKIP_REPORT_PROMISE_GATE=1.
  • Self-check gate (inside announce-stop-gate, after the whole chain): blocks the first Stop after a meaningful delivery (an edit tool or at least five delivery calls), once per delivery state per transcript (Spec 981: 52 of 54 visible Stop boxes in a 7-day replay were this gate), asking for the review pass the maintainer otherwise typed by hand (a request to check again, 2026-11-03): request coverage, evidence per claim, strongest counter-reason, then report. When an earlier gate already blocks, its message is appended there, so that block's stop_hook_active cannot skip it. Reads Claude, Codex rollout and Pi session transcripts (the Pi adapter passes transcript_path on every event, and every transcript reader maps Pi records to the Claude shape through claude_record). Silent for chat-only turns, turns whose only tool calls are Orca CLI messaging (a coordinator relay; 35 of 339 blocks in the 2026-11-05 audit; Codex code-mode calls still count as work), replies ending in a question, turns arming ScheduleWakeup/Monitor/CronCreate, background tasks, delegates and unreadable transcripts. An unchanged delivery state is not checked again, so the former Self-check: nothing to add. round trip is gone. The review-debt Stop gate likewise defers while background tasks run and blocks once per owned-commit set (a .stopped marker beside the PostToolUse .notified one); commit-prep exit 4 stays the hard review gate. Enforced without a shadow period by explicit maintainer request. Kill switch DEVKIT_SKIP_SELF_CHECK_GATE=1.

Noise, ownership and timing (Spec 981, 2026-11-11) ​

Owner decision "Alles inkl. Start + fail-open" on the two 2026-11-11 hook audits. Context-stage and cache-pause hints are model-only context, never a systemMessage. Deleted as rule-text duplicates: friction_hint, boilerplate_hint, spill_reread, sed_batch_nudge, style-reminder, the PreToolUse review_before_commit nudge (core.md Autopilot review, the review-debt gates and commit-prep exit 4 cover it) and the after-commit release notice (SessionStart still reports a due release). test_prep_first stays: it denies, so it is a gate, not advice; siblings_before_fix_commit stays because no rule text names the GUARD: trailer.

One owner per injected concern: on Claude the plugins own ADHD and ponytail (Rust injects them only for Codex: session_start/notify.rs if codex, the prompt ponytail switch on has_turn_id); pen_scope from the canvas guard and the design guard and related-repo from Bash and Read/Edit serve different tool classes, so none is a second emitter.

agent-state-ignore stamps a clean check in $DEVKIT_HOME/state/agent-state-clean/ and skips its three git processes for a day; a repair or tracked-file note leaves no stamp, so a broken project is checked on every start. The retired spec-route-probe/reuse-guard stubs left hooks.rs with Spec 988 once no installed config called them (2026-11-29).

Every devkit hook <name> call appends epoch_ms name ms exit to $DEVKIT_HOME/state/hook-timing.tsv (rotated at 1 MiB). worker_stop_gate releases a block it cannot count besides its three-blocks-without-progress cap.

Measured against origin/main (7-day replay of 1436 transcripts, release builds): Stop boxes per delivery turn 0.834 → 0.661 (interactive only 0.683 → 0.523); the SessionStart hook set 201 → 168 ms median, A11 35 → 3 ms. Method and numbers: Spec 981 > Results.

Post-edit lint batching ​

Scoped PostToolUse edits queue each file once until Stop. Assertion-drop warnings and frontend reminders remain immediate; formatter, linter, syntax and optional secret checks now run on the final bytes at Stop, not after every intermediate edit. Diagnostics block that Stop once so the agent sees them before ending; the drained batch does not block again without a new edit. Missing session/event identity, subagent edits (which have no main Stop), or an unwritable queue fall back to immediate checks. Baseline-safe formatting and diagnostic deduplication are unchanged. Queue keys include the session, agent and project; parallel edits use separate atomic file markers.

Dispatcher wiring (Spec 372) ​

hooks.json used to wire five PreToolUse policies and four UserPromptSubmit policies as nine separate entries. Each entry spawned its own process that re-read the same stdin JSON and re-resolved the repository root — measured 82.4 ms per Bash call for the five-hook PreToolUse chain. None of that duplicated cost bought anything: the policies never needed a second parse of the same payload, only their own decision on it.

2026-09-22 (Spec 568): no shipped hook is a shell script any more. All 25 files under content/hooks/ and hooks/ are deleted, every hooks.json entry carries its nativeCommand, and the wiring writes <home>/current/bin/devkit hook <name> # od-managed into Claude's settings and the Codex hook config — there is no switch left to select a script path, and OpenCode receives no hook command at all. The recorded shell-decision corpus that replayed each hook against the binary was retired on 2026-09-23 together with every other shell-parity recording.

2026-09-22 (Spec 560): the shared shell implementation described below is gone. hook-dispatch-pretool.sh and hook-dispatch-prompt.sh now exec devkit hook pretool|prompt; the policy chain, its order and every decision live in rust/devkit/src/hooks/. Measured the same day: PreToolUse 155 ms → 22 ms, UserPromptSubmit 62 ms → 13 ms. The rest of this page is the history of why the entries were merged first.

Current edit dispatchers (2026-10-28) ​

Edit PreToolUse policies share devkit hook edit-pretool; PostToolUse lint and session attribution share devkit hook posttool (--codex retains Codex's narrower lint matcher). Each policy keeps its tool matcher and switches. Policy panics are isolated; output merging preserves the event, and an unmergeable batch retains separate payload lines plus a stderr diagnostic. Both dispatchers use the shared lossy stdin decoder. Index-gap hints remain a separate Read policy.

Codex edits only through apply_patch, and codex-cli 0.166 matches the Edit|Write|MultiEdit|NotebookEdit matcher against it (payload captured 2026-11-05), so the entry needs no codexMatcher — adding one would also change the hook hash and force a new /hooks trust review. edit-pretool turns each file the patch names into its own Claude-shaped payload and runs every edit policy on it: Add File as Write with its content, Update File as MultiEdit with one old/new pair per hunk (so design-verdict's script-only exception still applies), Move to as Write and Delete File as Edit; relative paths resolve against the payload cwd. The Pencil design guard stays Claude-only.

Pack edit gates (2026-10-30) ​

Post-edit tool selection comes from validated central pack edit blocks. ESLint is not run by the post-edit hook: its 4–17 s per-file cold start exceeds the 3 s inline budget, so devkit lint-prep (role lint, changed files; mandatory before review, see tests/lint_prep.rs project_local_eslint_is_scoped_to_changed_files) and a project quality script own it. Shell/JSON/secret checks and queue/HEAD safety stay native. Broken stylelint configuration now emits one LINT_UNAVAILABLE advisory per session instead of silently skipping.

Pre-835/current release-equivalent binaries, CPU 19 affinity on spark-onedot, warmed, 15 alternating samples per fixture with bytes and session state reset:

FixtureBaseline median msCurrent median ms
eslint70.14766.889
missing config22.59818.926
known crash64.75768.116
unknown crash69.02169.326
prettier clean HEAD75.12076.609
prettier dirty HEAD63.30456.669
spec contract25.73429.813
stylelint67.59841.659
php44.41844.789
blade18.60526.050
nested package64.46072.107
packless64.75566.501
multiple tools104.20085.857

Exit/stdout/stderr, rewritten bytes and semantic invocation logs match; expected formatter arguments and the removed stylelint discovery probe are checked separately. Blade exceeds the original baseline × 1.10 + 3 ms limit. Main accepted the bounded catalog-startup cost and carried the original latency target to prevalidated-catalog-cache-for-hook-latency; the suite retains a 25 ms startup allowance ceiling until that work lands. Debug samples additionally showed 15–20 ms startup overhead and scheduling jitter. Catalog loading follows generated/path exits; gate extension/config/skip checks precede program discovery and execution. A shared-definition parse cache did not settle timing and was removed rather than adding another cache.

Historical per-process measurements ​

Ten-run medians of every wired entry against the binary, 2026-09-22 (a since-removed hook-latency maintainer command, --runs 10) — the ported hooks had no measurement of their own until the Spec 568 review asked for one:

eventhookmseventhookms
PreToolUse Bashhook-dispatch-pretool15PostToolUse Bashsession-scope14
PreToolUse Editspec-route-probe2PostToolUse Readindex-gap-hint39
UserPromptSubmithook-dispatch-prompt8PostToolUse Editpost-edit-lint1
SessionStarthook-dispatch-session44PostToolUse Editreuse-guard (retired)1
PreCompactprecompact-guidance44Stopannounce-stop-gate2
SessionEndsession-manifest2
SessionEndsession-end-apply2SubagentStartsubagent-context2
SessionStartusage-emit1SessionStartagent-state-ignore2

Three of these sit an order of magnitude above the rest, and each for its own reason: index-gap-hint and hook-dispatch-session each probe an external codegraph, precompact-guidance wrote the resume snapshot (since Spec 981 only on Codex, which reads it back; the Claude copy had no reader). index-gap-hint lost three shasum spawns per Read in the same review (46 ms → 39 ms measured; the marker name is a hash, so the once-per-file throttle could not run before them) — what remains is the repository resolve plus that probe. session-scope costs its 14 ms twice per Bash or mcp__pencil__ call, once in the PreToolUse snapshot and once in the PostToolUse pass, and scales with the checkout's dirty set: the number above is this repo with a warm tree. A plain read-only Bash call (git status, grep, sed -n 'A,Bp', ls; no substitution, heredoc or file redirect) skips both halves since 2026-11-05: the next writing call refreshes the snapshot before it runs, so attribution still covers exactly what a writing call changed.

The Stop gates (announce, report-promise, needless-stop, design-proof, self-check) read only the transcript tail: a 256 KiB window that grows fourfold until it holds the current turn's opening user record (or the last 400 lines for the final-reply check), so a verdict equals the whole-file one. On a 75 MB transcript they had read the file five times per Stop (7.6 s measured 2026-11-04). The final-reply check parses from the end and stops at the last turn step, and every gate skips the parse of lines whose top-level type none of them reads (api-request dumps are ~85 % of a long Claude transcript). The Agent pretool's route receipt parses only the lines naming runtime-route and the results answering them. denial-diagnose starts its prep subprocess only when the last 800 lines hold two denial texts; before 2026-11-05 every Bash call paid that whole-file read (243 ms warm on a 75 MB transcript, 10 ms without it).

The original shell merge reduced nine entries to two: hook-dispatch-pretool (PreToolUse) and hook-dispatch-prompt (UserPromptSubmit). Both resolved to thin entry scripts (content/hooks/hook-dispatch-pretool.sh, content/hooks/hook-dispatch-prompt.sh) that set only their own event and call the shared implementation, content/hooks/hook-dispatch.sh.

The shared script parsed the payload once, exported the parsed fields for policies to reuse, and ran each policy that the call's tool_name matched. Blocking Bash policies remained synchronous and first. Advisories then ran concurrently, with output merged in the original policy order.

Ten-run medians from the since-removed hook-latency command (historical measurement) in the same worktree:

EventHookBeforeAfter
PreToolUse Bashhook-dispatch-pretool365 ms143 ms
UserPromptSubmithook-dispatch-prompt228 ms109 ms
PostToolUse Editreuse-guard493 ms15 ms

reuse-guard was retired on 2026-11-05: its detectors ran only under DEVKIT_REUSE_GUARD_LIVE=1, which nothing set (0 HINT_REUSE_GUARD events over 1592 sessions in 14 days). The PostToolUse dispatcher no longer runs it, and its devkit hook reuse-guard stub was removed with Spec 988 once installed configs had reconciled. The review boundary still runs the symbol and jscpd detectors. Interleaved n=31 devkit hook posttool Edit runs of the installed release builds before (bfd6e3dc) and after (75280c8a) the retirement measured JS 75.7 → 76.1 ms and README.md 74.9 → 72.5 ms median. That is within noise, as expected for a hook that already exited early.

Why two entry scripts instead of one. lib/model-routing.sh:255 requires every .hooks[].name in the contract to be globally unique, and :262 requires the named script to exist and be executable — a single name cannot cover both the PreToolUse and the UserPromptSubmit event. content/hooks/destructive-guard.sh:11-12 already carries the same shape for the same reason (a thin, separately named wrapper around one shared detection). The dispatcher reuses that pattern instead of inventing a new one: two small, executable, distinctly named wrappers around one implementation.

Matchers are unchanged, only where they are evaluated moved. Each policy keeps its own matcher inside hook-dispatch.sh — test-prep-first, pre-push-gate, branch-switch-guard, destructive-guard, cd-guard and denial-diagnose still only reach Bash. No policy gains or loses an event; the merged hooks.json entry itself carries the union matcher (Grep|Glob|Bash) plus the codexMatcher that preserves Codex's narrower Bash-only scope. The dispatcher exits with the most restrictive status any invoked policy returned, so a blocking policy (destructive-guard, pre-push-gate) still blocks through the merged entry exactly as it did through its own.

Policy stdout is buffered rather than streamed. Two policies emitting their own top-level JSON object would concatenate into something that parses as neither, and since cd-guard rewrites instead of blocking that collision is reachable: it fires on exactly the compound cd … commands whose permission denials denial-diagnose reports on, so the two correlate rather than exclude each other. From the second emitting policy on, the dispatcher merges them into one object — additionalContext joined, updatedInput merged, the strongest permissionDecision winning. A single emitter is still passed through byte for byte, because a policy's own shape (a legacy {"decision":"block"} among them) is not the dispatcher's to normalize.

An unparsable-but-present or panicking PreToolUse evaluation fails open only for tools that cannot destroy anything (Read, Grep, Glob, Agent, Artifact, AskUserQuestion, codegraph_explore) and for Bash that a panic-guarded re-check proves read-only with no secret or credential hit; pencil, Edit, unknown tools and unclassifiable Bash stay blocked (exit 2), because a blocking policy must not fail open on a command it cannot classify (Spec 981, hooks/fail_open_tests.rs proves both directions); an empty payload still passes (exit 0), the same behavior destructive-guard.sh had on its own before the merge. UserPromptSubmit carries no blocking policy, so an unparsable prompt payload there just stays silent.

The Claude wiring sets onFailure: "block" for hook-dispatch-pretool so a missing binary, a crash outside the panic guard or a timeout blocks the tool call; repair the installation from a terminal with devkit sync or devkit rollback. The shipped manifest omits this key so older binaries can validate an update before activating its new binary; the first session under the new binary repairs entries materialized by an old updater. The key can ship again only when every supported outgoing updater accepts it.

Per-hook rationale (kept from the pre-merge wiring — only the invocation changed) ​

  • pre-push-gate — PreToolUse (Bash) denies default-branch pushes without a PASS receipt for every Rust suite mapped from that push's range. Receipts cover the exact pushed tree or a tested tree whose delta selects none of that suite's inputs through the same affected map; unavailable or unmapped deltas stay denied. Green runs record the tested worktree and also HEAD^{tree} when the suite's mapped inputs are unchanged, including a clean worktree. Each suite retains the last eight tested trees; failures invalidate the current state without erasing other tested states. Denials distinguish missing, dirty/untracked and stale receipts. Run the printed devkit maint test-prep --suite ... command. Chained shapes (git commit && git push) are refused: push must run as its own call. Unrelated base failures and unconditional consistency-floor suites do not block the range. Shell/spec findings remain advisory and visible even when receipt resolution denies a push with Git global options. OD_SKIP_PUSH_GATE=1 explicitly bypasses the gate.

  • branch-switch-guard — blocking PreToolUse (Bash): blocks a branch-move command only when a second live Claude Code session shares this exact checkout, so one session cannot drag HEAD out from under the other. Fail-open on every other uncertainty.

  • self-kill-guard — blocking PreToolUse (Bash, Linux only): refuses a pkill -f, or a pgrep -f feeding kill, whose pattern matches the command text itself. On Linux the shell running the call carries that text in its argv, so the kill ends the shell (exit 144) and drops the rest of the chain: 11 kills in 7 sessions over 3 days (2026-10-10). BSD pkill excludes its ancestors, hence Linux only. The deny names -A (procps-ng 4 skips ancestors) and the bracket form ('[s]eq 1 40') for older procps. Narrowing options (-A, -P, -u, -v, -x, ...), anchored patterns and a pgrep piped through grep -v pass. Not detected: a script written and run in the same call, or bash -c '…pkill -f…', both of which still self-kill.

  • destructive-guard — blocking PreToolUse (Bash): blocks the destructive shell class (git reset --hard, forced push/clean, rm -rf on a protected root, remote exec without an allowed host). Kill-switch OD_SKIP_DESTRUCTIVE_GUARD=1. Self-disables on a Codex turn — Codex wires the same detection in full mode separately.

  • cd-guard — rewriting PreToolUse (Bash): removes a leading cd into the directory the call already starts in. The cd is redundant there, but it makes the working directory statically unresolvable for the permission engine, so a path-scoped deny rule (Read(./**/.env)) cannot be ruled out and an otherwise silent read-only command becomes a permission prompt. Until 2026-09-12 the hook exited 2 and asked for the command again without the prefix, which cost a full retry turn per hit; it now returns hookSpecificOutput.updatedInput (Claude Code 2.1.269) so the call runs on the first attempt, and applies it silently: until 2026-10-05 it reported each rewrite through additionalContext, but dropping a cd into the directory the call already starts in cannot change what runs, so the note bought no information and re-entered the context on every hit without stopping the next cd (devkit/audit/code-intel-quick-test-2-2026-10-05.md). A shape that cannot be rewritten without changing semantics still blocks with the original message: || and a pipe (where the cd decides whether the rest runs), a background &, and a remainder that itself begins at a separator (cd <cwd> && ; ls, which would hand back a syntax error). A bare cd with nothing after it neither blocks nor rewrites — it carries no file argument for a path-scoped rule to match, so it is only named. The target is resolved under the quote class bash would use: a single-quoted $CLAUDE_PROJECT_DIR or ~ stays literal, because bash does not expand it either and the cd it writes fails, which is what makes the && after it short-circuit. A cd into a subdirectory or another checkout is untouched. Kill-switch DEVKIT_SKIP_CD_GUARD=1.

  • denial-diagnose — advisory PreToolUse (Bash): from the second permission denial in a turn on, reports matching configured deny rules without inferring a cause when none matches. SessionStart no longer launches daily headroom learning, and the on-demand devkit verbosity-learn-prep diagnosis was removed on 2026-10-20 (69c592769).

  • subagent-context — advisory SubagentStart (Claude only; Codex .turn_id payloads exit silently): hands every native subagent the handoff contract (reply only what Main acts on, one line per change or finding, at most 1200 characters; a review returns its brief's findings format, an audit one line per item beyond that, detail and tables into the brief's report file) plus the headings of .agents/context/GOTCHAS.md > Critical. Measured 2026-09-27: 401 subagent results in 14 days, median 3295 characters, 83 % above 1200 — each one re-read by Main on every later turn. One-shot per subagent, ~130 tokens plus the gotcha headings, inside the SessionStart class.

  • friction-hint — retired 2026-11-11 (hooks audit F4): the visible per-prompt line duplicated what /friction-feedback already reads from OD_FRICTION lines; the friction-hint-prep script stays.

  • recall-entry-hint — advisory UserPromptSubmit: loads the recall ladder on the prompt that asks about past context, not on a context-file touch.

Every kill-switch above still works unchanged through the merged entries — the dispatcher only changed how a policy is invoked, never whether.

hook-dispatch-session ​

One SessionStart process instead of four: resume-hint, index-hint, backlog-hint and mcp-awareness are run in that priority order and the first hint with output owns the block; the hints after it are not run (each would consume its daily throttle marker and book a HINT_* telemetry event for text nobody saw) and are named in one systemMessage line (the not-evaluated list), so the human sees what was not evaluated and the model pays for one hint only. Every hint keeps its own kill-switch and stays runnable standalone; the Codex projection carries the dispatcher like any other hooks.json entry, so both runtimes receive the same single block (Autohand finding 7, 2026-09-15).

The backlog hint also reaches the model through SessionStart additionalContext: it may offer /todo once at a natural break, never interrupting the current task.

The memory budget rides outside that priority chain: when the project's auto-memory MEMORY.md exceeds DEVKIT_MEMORY_BUDGET_BYTES (default 8192), its instruction is prepended to whichever block wins, at most once per day per project. It emits a short advisory line, never an agent dispatch or an instruction to edit memory. Every index byte is re-read on each request (measured 2026-09-26: 13.2 KB index, 6.6k tokens of a 36k session baseline). Kill switch: DEVKIT_SKIP_MEMORY_BUDGET=1.

Dead memory paths ride along the same way, once per day per project and independent of the budget: every backticked path in the project's memory files whose top-level directory exists but whose file does not is listed (at most 10 files, 3 paths each), with advisory guidance for a user-requested cleanup: re-point memories first, delete only confirmed-gone facts, preserve valid mandates and leave unresolved memories unchanged. When the budget hint fires, the path hint waits for another session, keeping output to one hint. The budget trim only reaches these when the index overflows; measured 2026-10-09 on this repo, 25 of 87 memories named deleted files with the index under budget. A path under a deleted top-level directory, a top-level file and an extensionless file stay silent, the price of skipping relative fragments without a 1.5 s git log --diff-filter=D. Same kill switch.

Retired routing hints ​

The spec-route-probe hook is retired; its compatibility stub left with Spec 988. Workflow rules and the commit-prep review gate already cover its review routing; Docs-first remains in edit-pretool independently. The debug-entry hint, capture knowledge/Related hints and share discovery hint are retired because workflow and capture rules already route those requests. Correction handling and the skills themselves remain unchanged. Finished SHADOW_SKILL_ROUTING_* measurement and its evaluation command are removed; historical hint conversion decoding remains available. The historical classifier originated in ec70c4804 and was retired in 3ff4ddd6b; its supplied 663-NONE/30-day sample has no recoverable matched correction/cost attribution. Spec 964 adds the single executable route::skills worker subset, not the retired classifier. Automatic choices remain shadow receipts without workflow instructions; no dormant historical hint gate is restored. Main's dated evaluation and any hint activation belong to follow-up Spec 969; skill-routing-benefit.md records the current unproven verdict. Existing discovery hints remain suggestions, never unasked workflow starts.

context-usage-warn ​

Reports context cost to the model through additionalContext, without pushing a context reset or state-parking workflow. It runs as a UserPromptSubmit policy out of hook-dispatch.sh rather than as a hooks.json entry: a manifest entry would change the hook count that five assertions pin.

Human-driven mains receive one model-visible hint; the user decides whether to open a fresh session. Supervised workers and coordinators use native compaction in place. The hint uses the known window and the conservative fallback when the window is unknown. No tool is denied for context size.

The thresholds mark cost, not capacity: an agent once relayed a cost notice as "context full" at 23 %. The hint therefore prints the share of the real window, never a "full" report. The prompt hook never sees the window size: devkit statusline stores Claude Code's context_window_size per session in the warn state directory, and without it the share is left out (DEVKIT_CONTEXT_WINDOW overrides). An assumed 1M window printed 22 % where the statusline showed a different share.

One durable marker per session is shared by prompt and post-tool hooks, including process restarts and context drops. Atomic creation deduplicates concurrent hooks. Unwritable state fails silent rather than repeating automatic cut instructions. Session-close hints never authorize an autonomous main cut. DEVKIT_SKIP_CONTEXT_WARN=1 turns it off.

cold-cache-hint ​

Names the cost of a pause once the prompt cache has expired. The cache lives one hour; the first prompt after a longer pause re-writes the whole context. Across 200 maintainer sessions (2026-09-26) pauses over an hour were 35 % of all cache-write tokens lost to a missed cache, 17.4M. The hint fires on that first prompt, so it cannot save it — it names the rewrite without recommending /clear or /compact. Same UserPromptSubmit policy slot as context-usage-warn, recorded as HINT_COLD_CACHE. Historical hint conversion readers remain available. DEVKIT_COLD_CACHE_SECS (default: the TTL the last request wrote with — 300 on the five-minute cache, else 3600) and DEVKIT_COLD_CACHE_TOKENS (default 150000, below which the rewrite is not worth a line; across 191 pauses over an hour in 7 days, 2026-10-06, it covers 82 % of the re-written tokens, 300000 covered 56 %) tune it; DEVKIT_SKIP_COLD_CACHE_HINT=1 turns it off.

index-gap-hint ​

Warn-only PostToolUse advisory on Read (Spec 385): the coverage flag in content/rules/agent-graph.md is per stack, not per file, so an agent reading a file the tree-sitter parser skipped — or one it parsed into zero symbols — got no correction before this hook existed. It looks up the read file's repo-relative path in a per-project-and-session cache of codegraph files --json and posts one additionalContext line when the file is absent from that listing or carries nodeCount: 0, throttled to once per file per session. A file outside the project directory stays silent: 188 of 210 hints (audit 2026-11-05) named a sibling worktree's or another repo's file, which the project's index never lists. The cached listing answers first; only a miss re-runs codegraph files (~0.8 s here) after an index write, because the watcher touches the index after every edit (shipping p90 was 1.4 s).

Fail-open everywhere: missing codegraph/jq, no .codegraph/ directory, an unparsable stdin payload, a failing or empty listing, or an extension the parser does not cover all leave the hook silent with exit 0, never blocking. DEVKIT_SKIP_INDEX_GAP_HINT=1 turns it off.

No codexMatcher. lib/hooks.sh:550 falls back to the plain .matcher when none is set, so the entry still reaches Codex — it just never matches there, since Codex has no Read tool name to compare against. Same reasoning as the hook's own Out-of-Scope: a narrower Codex wiring was deliberately not added.

session-overlap ​

Warn-only PreToolUse advisory on Edit|Write|MultiEdit: parallel sessions in one checkout only learned of each other at review or commit time, after the overlapping edit was made. The session-scope recorder already lists every file a session touched in <git-dir>/od-session-scope/<session>.files; this hook reads those records before an edit and posts one additionalContext line (SESSION_OVERLAP path=… session=… since=…m) when another session's record names the target file and was written within 30 minutes. Once per file per session (marker under $TMPDIR/od-session-overlap-<session>/), silent on the happy path, fail-open on any missing git dir or record. DEVKIT_SKIP_SESSION_OVERLAP=1 turns it off. No codexMatcher.

design-verdict ​

Edit-pretool deny (2026-10-20): with design/*.pen and a component inventory, editing an inventory-mapped file needs .agents/context/.state/design-verdicts/<component>-<hash>.md, under 12 h old, first line frame: <nr>. A deny, because the pen-design skill text alone was skipped. DEVKIT_SKIP_DESIGN_VERDICT=1 turns it off.

path-rule-preload ​

Edit-pretool deny (2026-10-29): Claude Code loads a paths: rule only after the tool that touched a matching file, so the Write that creates a session's first SKILL.md was drafted without skill-editing.md (probe: the rule arrived after the Write). Once per session and rule set, a Write that creates a new file matching rules no earlier Read/Edit/Write touched is denied with those rule bodies (16 KB cap, the rest by path); the resend passes. Bodies instead of names, because shared-path-commit showed 70 % blind reruns of a name-only deny. Skipped in delegates (DEVKIT_DELEGATE_DEPTH). Bash-created files are not covered. Ships in shadow: would-blocks land in hook-audit.jsonl as path-rule-preload.

shared-path-commit ​

A Bash advisory of the PreToolUse dispatcher. Agents ignored the edit-time SESSION_OVERLAP line and ran git commit -- <path>, which commits the whole file: twice on 2026-10-09 a parallel session's uncommitted hunks broke HEAD (0d5e66fff, e46be58bf). Context on an allowed call arrives after the commit ran. Until 2026-10-19 the guard denied once and let the identical rerun pass; in 30 days 389 of 553 denies (70 %) were blind reruns, so it now attaches a notice ([shared-path-commit] paths=…, once per path and HEAD) that names the after-the-fact check instead. Replaying only recorded own edits was tried and reverted (devkit/evaluation/rejected-changes.tsv). Pathspecs of git commit and git add, -a/-A sweeps, git -C and an earlier cd are resolved. DEVKIT_SKIP_SHARED_PATH_COMMIT=1 turns it off.

file-size ​

A post-edit hint: an edit that leaves a file over 5,000 tokens (bytes/4) gets one split hint per file. 33 % of all Reads hit such files (2026-10-19). Lockfiles, binaries, @generated and linguist-generated paths are exempt, and so is a file carrying @ratchet-files-ignore: <why> within its first 10 lines (the opt-out of the ratchet-files skill, so a repo already using it keeps its exemptions). The commit-time deny never left audit mode: 1,202 logged would-blocks by 2026-11-04 included non-commit commands, so it was removed. DEVKIT_SKIP_FILE_SIZE=1 turns it off.

docs-first ​

Runs inside edit-pretool under its own internal docs-first name, so it costs no extra process: the first code edit of a session in a project with .agents/context/STACK.md gets one additionalContext line unless a successful Read of this project's STACK.md or CONVENTIONS.md, or a project-local skill load (.claude/skills/*/SKILL.md), came first; it names those skills. A Bash cat does not count, since a command line cannot prove the file was read. Codex has no Read or Skill tool, so in a Codex rollout a shell read (cat, sed, head, …) of this project's doc or project skill SKILL.md counts; otherwise every Codex session would get the hint. Measured over the 2026-08/10 transcripts: 79 of 174 stack-project sessions made their first code edit without either. Once per session (marker $TMPDIR/od-docs-first-<hash>), a hint rather than a deny. DEVKIT_SKIP_DOCS_FIRST=1 turns it off.

resume-hint ​

Names every active Spec's state at SessionStart, so a resumed session does not re-read the Spec to find out where it stands. It scans devkit/specs/*.md (legacy specs/*.md, never completed/), keeps the in-progress and in-review files, and for the three newest runs devkit spec-resume-prep on each — in parallel, because the preps are independent reads of one repo and three of them measured 627 ms wall sequentially against 365 ms together (fixture, 5-run minimum). One additionalContext line per Spec carries Status, the Step and AC counters, the first 80 characters of the last Progress-Log line, then stale once last_session_age_minutes passes DEVKIT_RESUME_HINT_STALE_MINUTES (default 10080) and drift/planned-drift when spec-resume-prep reports changed files. A Spec whose prep fails prints Resume <ID> · state unreadable (<exit>) and the other Specs still render; no active Spec is silence. No codexMatcher, like the other SessionStart hints; DEVKIT_SKIP_RESUME_HINT=1 turns it off.

Hookms median (historical hook-latency --runs 10 measurement)bytes per Spec
resume-hint14144

rtk-rewrite ​

The native PreToolUse dispatcher attempts RTK rewriting only after every policy succeeds without stdout. It filters a closed set of readable Git commands before invoking rtk hook claude. Policy blocks, advice, context, decisions and trailing newlines survive unchanged; any policy output suppresses rewriting.

Machine formats, shell expressions and command git escapes never reach this managed rewrite. Only one valid native response preserving other input fields and already carrying permissionDecision: "allow" is forwarded. Failures leave the original command available. Personal RTK hooks retain their own behavior.

Codex documents updatedInput for Bash. Reusing the dispatcher keeps the pre-existing hook definitions and their native trust positions unchanged. Installations that have never trusted these definitions still need /hooks review; the installer never grants trust.

open-checklist ​

The needless Stop gate logs (shadow, hook-audit.jsonl) a final reply with an unchecked task that names no todo; promote it to a once-only block after the audit shows true hits only. Code fences, gated requests and existing Stop skips remain exempt. Kill switch: DEVKIT_SKIP_NEEDLESS_STOP_GATE=1.

session-close prompt hints ​

UserPromptSubmit reminds once per session after a reply carrying Naechster Schritt: Session fertig and once at four hours after the transcript file's birth time; it stats, never reads, the transcript. DEVKIT_SKIP_SESSION_CLOSE_HINT=1 disables both. These are intent/lifetime signals, never context-size reset advice.

Internal docs — onedot-devkit · devkit

devkitdevkit syncdevkit statusdevkit doctordevkit helpInternal docs · ONEDOT digital crew