Skip to content

Claude Code mods: adopt as a Codev extension surface (discussion) #1761

Open

Description

@amrmelsayed

Discussion issue. No work is committed to yet; this collects the review and the decisions it needs so the team can rule on them in one place.

Full review with ranked candidates, constraints and a worked guard example: https://claude.ai/artifact/GDdfPdEmmyrAkpuMdqBy5B

Capability claims below were re-verified on 2026-10-05 against every page of the mods documentation (overview, interface, events, api, reference, admin, test, troubleshoot). The reference page is now written against 2.1.289.

What changed

Claude Code 2.1.287 (1 Oct 2026) added mods: plugins whose JavaScript/TypeScript event handlers run inside the Claude Code process. A handler sits in a middleware chain and can observe an event, rewrite it, or answer it. Everything it does outside its own code goes through one API object ($), which is what lets claude plugin validate list a mod's events and calls before it runs. Mods are on by default; this repo's machines are on 2.1.288.

What they can do that settings hooks, skills and MCP cannot:

  • Draw: a pane beside the transcript, a band above the prompt, the status line, and replace Claude Code's own rows (spinner, tool-call rows, the question dialog). Not the permission prompt.
  • Step into a tool call or a request: hold it while asking the user, deny it with a reason Claude reads, or return allow/ask/deny on tool.check.
  • Keep state across hooks and across hot reloads ($.state), and per machine ($.store). $.state resets on /clear, /resume and /branch, and session.start does not fire again after them; a mod reloads saved values in a classic.SessionStart hook filtered on source.
  • Run a /command immediately without a Claude turn; register tools the model can call; call a model; run timers; message other sessions ($.session.send, session.receive); submit a prompt that waits for idle ($.prompt.submit). $.prompt.submit prefixes a sentence naming the mod as the sender unless asUser: true, and resolves only when the new turn starts, so it is never awaited while Claude is working.
  • Fail closed: a .catch handler answers when the hook throws or times out.

The hooks module has no Node APIs, no timer globals and no I/O of its own; every file, process, network and UI action goes through $. That fits codev-sdk's zero-dependency, environment-agnostic design (an adapter over $.http) and rules out node-flavoured imports.

Where mods run: hooks run everywhere a plugin loads (terminal, Desktop app, VS Code chat panel, claude -p, Agent SDK, cloud). Drawing works only in the terminal and the Desktop app. Codev's VS Code terminals are xterm views onto Tower PTYs running claude, so panes and bands do draw inside Codev's terminal tabs; an auto-opened pane needs 144 columns (110 once the user has opened it themselves), so the band is the safe surface there.

Not sandboxed: a mod runs with the user's permissions and can approve a tool call that an ask rule or a non-managed PreToolUse hook would stop. It can lift a deny rule too, except where the built-in guard loads (a machine with managed settings, or a Team/Enterprise sign-in). The guard's options (allowManagedModsOnly, allowModsToOverrideDenyRules) and disableSideloadFlags are read from managed settings only. prependPlugins is also honoured from user settings on a machine with no managed settings and no Team/Enterprise sign-in.

Codev today, in mod terms

Codev mechanism Today Mod equivalent Change
Worktree write guard (#1018) PreToolUse command hook written into each builder's .claude/settings.local.json by the Claude harness tool.call + .catch Fails closed instead of open; also sees Bash writes
Role injection --append-system-prompt from HarnessProvider prompt.section / prompt.context No gain; keep the flag (cross-harness)
Skills in four copies (.claude/.codex × root/skeleton) File copy, parity-tested One codev plugin holding skills + mods + hooks Collapses the two Claude copies; Codex copies stay
afx send delivery (Spec 1313, #1664) Mailbox in global.db, then PTY keystrokes onto a render-gate-verified empty composer $.prompt.submit waits for idle; session.receive/$.session.send The measured gate rule becomes a native wait; contract surface for main
Attention / liveness (#1595, #1446) PTY-silence inference, lastDataAt turn.start/turn.complete, tool.check resolving to ask, session.end, classic.Notification Ground truth from the harness; this is #1595's own design
Status line Unused $.ui.status, AbovePrompt band, Spinner suffix Per-session place for held mail, gate state, context fullness

Candidates, ranked

  1. Gate and git discipline guard (high value, low effort). tool.call on Bash denying git add -A|--all|., git reset --hard, git checkout -- ., git clean -fd, git stash, git worktree remove, git branch -D builder/*, gh pr merge --squash; holds porch approve behind $.ui.ask("Did the human give the word?"). .catch denies on failure. Serves the irreversible-acts rules in CLAUDE.md and Builder worktree write-guard: prevent writes anchored at the main checkout root #1018. $.ui.ask rejects in claude -p and when the user dismisses it, so the default answer is refuse.
  2. Lifecycle reporter for Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 (high, medium). Posts working / needs-input / idle / dead to Tower's keyed workspace API via $.http.fetch. Fail-open: no data must never read as idle. Filter subagent turns on e.agentId.
  3. Last-ask capture for lane card: capture and surface the user's last ask per lane (hook-based, latest-only, loopback-only) #1674 (high, low). prompt.submit observer, latest only, loopback only, returns next(e) unchanged.
  4. Lane Card terminal renderer for lane card: per-lane status card for fast re-orientation across architect and builder terminals #1672 (high, medium). A third renderer of the same LaneCard JSON: band chip everywhere, pane on wide terminals; polls Tower on $.clock.every, never spawns gh.
  5. Context-fullness band + refresh prompt (medium, low). $.session.usage() percent in the band with the /arch-save threshold; session.measure fires after each turn and when a plan-limit percent changes, so no polling. session.compact toast, optionally { skip } once for architects. Any value kept in $.state is reloaded on classic.SessionStart after /clear. $.ui.status output is prefixed with a warning glyph and the mod's name, so the band is the cleaner surface.
  6. Attribution scrub (medium, trivial). attribution.text returning empty enforces the no-AI-attribution rule at the source.
  7. Mailbox delivery over native session messaging (high value, high effort, main's contract surface). Keep the mailbox in global.db as the record; deliver to Claude harnesses with $.prompt.submit; Codex/Antigravity keep the render gate. Open questions: does Claude Code's "idle" match mailbox gate: a recipient that is producing output holds mail until its turn ends — only a human draft should hold (Claude Code queues input mid-turn) #1664's "human not at the line"; and which framing the builder should read, since $.prompt.submit carries a sender sentence unless asUser: true.
  8. Arch-init on clear (medium, low). classic.SessionStart with source: clear submits /arch-init <name> after afx whoami confirms an architect. Unverified: whether a mod-submitted /arch-init <name> expands as a slash command at all. Spike item.
  9. Codev tools for the model (low). $.tool.register for porch/lane queries (Claude sees them as mcp__codev__<name>); defer.
  10. Thread Now-line writer: do not build. The Now line is the one authored field by design; a mod writing it from e.answer is self-report without judgment.
  11. Fleet policy mod: conditional. plugin.register refusing builder-installed mods from a prepend-tier mod. On a solo machine prependPlugins in user settings puts it first, but a builder can edit that file, so it is a rule, not a lock; a lock needs managed settings, so documentation for team adopters.
  12. Consult SDK runs: watch item. Hooks fire in Agent SDK sessions; load Codev mods only via the spawn path so consult never sees them, or filter on surface at session.start.
  13. Issue peek (high, low; owner use case, detail in the 2026-10-05 comment). turn.complete and prompt.submit scan for #N; the band shows one chip per reference with a digit hotkey; the digit alone opens a user-opened pane (any width, inline above the prompt in a VS Code tab) with title, state, labels, body and newest comments from Tower's getIssue path over $.http.fetch, cached in $.store. /issue N registered immediate: true opens the same pane mid-turn. Cross-harness floor: an async terminal-link tooltip in apps/vscode (vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412 baseline).

Constraints that shape any plan

  • Claude-only. Every mod is a Claude-harness optimisation behind HarnessProvider; shell hook, role flag and render gate remain the cross-harness floor. No Codev behaviour may require a mod.
  • Load path: CLAUDE_CODE_PLUGIN_DIRS loads a plugin directory where --plugin-dir cannot be passed, so the Claude harness can add it at spawn without touching the user's plugin list; architects install the same plugin from a marketplace. A directory-loaded plugin is addressed as <name>@inline in pluginConfigs.
  • Trust: in an interactive session no mod loads in a directory the user has not trusted. Builder worktrees are fresh directories, so the spawn path's trust handling must be checked before a codev plugin is relied on in builders.
  • Budgets: 10 s of own time per hook (time inside next and mods API calls excluded, except $.clock.sleep), .catch handlers 1 s, prompt.edit hooks 50 ms, $.process.run 30 s default (argv list, no shell), $.store 4 MiB per machine and non-atomic, one plugin test 5 s default. Tower stays the state owner.
  • Network policy covers $.http.fetch: with web fetching off for the org or session, Tower posts from candidates 2 and 4 are refused. $.process.run is not covered.
  • Failure mode: three hooks-worker crashes unload every non-built-in mod for the session until /reload-plugins; --safe-mode and --bare disable installed mods. A mod guard is a second line; porch, branch protection and the human stay authoritative.
  • Ordering: managed PreToolUse hooks run before any mod; other settings hooks run after the last mod and are skipped if a mod answers without next. If the write guard stays a shell hook while a Codev mod answers Bash calls, the hook is bypassed for those calls. Migrate both into one mod or always call next for file tools.
  • Testing: claude plugin test runs without a session, stubs Claude Code's answers, mounts drawings, and exits 1 on failure; fits the CI matrix.

Proposed sequence (for discussion)

  1. Spike, run as EXPERIMENT Spike: Claude Code mods for Codev (guard, attribution scrub, context band, issue peek) as an EXPERIMENT for #1761 #1782 (owner-directed 2026-10-05; replaces the earlier "uncommitted, in an architect session" plan so the hypothesis, method and numbers leave a record under codev/experiments/): candidates 6, 1, the band from 5, and 13 (13 proves the band-chip-to-pane pattern that 4 depends on). The builder writes, validates and plugin-tests the mod; the two live-session questions are answered by a handoff command the vscode architect runs in a Tower terminal, so no builder loads a mod into its own session. Questions to answer: does the $.ui.ask hold behave inside a Codev PTY under Tower while the render gate is holding mail; does a mod-submitted /arch-init <name> expand as a slash command; how does a fresh worktree's trust prompt interact with mod loading; and does a digit-hotkey band chip reach a user-opened inline pane acceptably inside a Codev VS Code terminal tab.
  2. Ship a codev plugin from the package; Claude harness sets CLAUDE_CODE_PLUGIN_DIRS at spawn, version-gated on 2.1.287; write guard migrated in with the shell hook kept as fallback; plugin tests in CI. AIR or PIR under area/tower (touches harness.ts).
  3. Re-scope Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 and lane card: capture and surface the user's last ask per lane (hook-based, latest-only, loopback-only) #1674 to mods and build them as one lane posting to Tower. lane card: per-lane status card for fast re-orientation across architect and builder terminals #1672 is at its spec gate and treats Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 as its ground-truth feed, so its plan should know the feed is a mod.
  4. Lane Card pane as 1672's third renderer, at plan time, after afx card proves the data model.
  5. Spec candidate 7 as a SPIR under main's contract seat, after 2 and 3 have shown a Codev mod living reliably in every Claude session.

Decisions needed

  1. Distribution: ship a codev Claude Code plugin from the package (also collapsing the two Claude skill copies)?
  2. Builder trust stance: state in the builder role that builders do not install or author mods, and that the spawn path is the only loader. Rule, not lock, for solo use.
  3. Re-scope Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 and lane card: capture and surface the user's last ask per lane (hook-based, latest-only, loopback-only) #1674 to mods now, before 1672 plans against them? The split already proposed on Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 fits; only the mechanism line moves.
  4. Where the first spike runs: an architect session with --plugin-dir. Retired 2026-10-05: the spike runs as EXPERIMENT Spike: Claude Code mods for Codev (guard, attribution scrub, context band, issue peek) as an EXPERIMENT for #1761 #1782 with a live-session handoff to the vscode architect.
  5. Codex/OpenCode parity: accept Claude-harness-only features with the existing mechanisms as the floor, and say so in the skeleton docs.

Refs: #1018, #1595, #1674, #1672, #1729, #1446, #1664, Spec 1313, #1365, #1473.

Activity

  1. added
    area/cross-cutting
    on Oct 3, 2026
  2. amrmelsayed commented on Oct 5, 2026

    @amrmelsayed
    CollaboratorAuthor

    Codex: do these extension points exist there?

    Checked 2026-10-05 against the Codex docs and tracker. Short answer: no in-process extension point and nothing that draws in the Codex TUI. Every surface a mod adds or redraws (pane, band, toast, log line, redrawn message and tool rows, spinner, question dialog, hint line) has no Codex counterpart. The non-visual half of the value is reachable through three out-of-process routes.

    What Codex has

    • Settings hooks, out of process (hooks). Twelve lifecycle events: SessionStart, SessionEnd, UserPromptSubmit, PreToolUse, PermissionRequest, PostToolUse, Stop, Interrupt, PreCompact, PostCompact, SubagentStart, SubagentStop. Handlers are shell commands or MCP tool calls fed JSON on stdin. A PreToolUse hook can deny with a reason or rewrite the input; PermissionRequest can allow or deny; Stop can inject a continuation prompt; UserPromptSubmit can add context but not rewrite the prompt. No hook can hold a call and ask the user a custom question, draw anything, or keep in-process state. Default timeout 600 s. Non-managed hooks need a one-time trust review; managed hooks (MDM, requirements.toml) are trusted by policy.
    • TUI customisation is a fixed menu (config reference). Status line items are model, approval, context_usage, session_id, sandbox, cwd, spinner; terminal title items, themes, keymaps, and notifications via a notify command or OSC 9 / bell. No custom text, no command-backed items. A command-backed status line is an open request since April (#17827; #20244 closed as its duplicate).
    • Plugins (plugins) bundle skills, MCP servers, browser extensions and hooks from marketplaces. The "custom UI" a plugin can carry is MCP app UI for ChatGPT and the desktop app, not the terminal.
    • App server (app-server). JSON-RPC over stdio or WebSocket exposing turn start and completion, streamed items and tool calls, token usage and approvals; a client can start, steer mid-turn, and interrupt. The VS Code extension runs on it, and the TUI can attach to a running server with --remote. Whether a second client can observe the same thread beside the TUI is undocumented.
    • The internal Rust extension traits that appeared in 0.159 (model request contributors, tool lifecycle observers; #47679, #47662) are a compile-time API for embedders of the core crate, not loadable by a plugin or user. Not a route for Codev.

    Candidates on Codex

    Candidate Codex route
    1 Guard Deny with reason via PreToolUse: yes. The $.ui.ask hold: no. Fail-closed on hook failure: unstated.
    2 Lifecycle reporter, 3 last-ask Workable from hooks (UserPromptSubmit, Stop, PermissionRequest, Interrupt, SessionEnd map onto working / idle / needs-input). App server gives the same as ground truth.
    4 Lane Card renderer None in the TUI.
    5 Context band The number is a native status-line item; PreCompact can refuse compaction (continue: false). No threshold marker, no band.
    7 Mailbox delivery Only through the app server's steer / start-turn calls, a different architecture from PTY keystrokes and a spike of its own.
    8 Re-init on clear Stop can inject a continuation prompt; no clear event, no prompt submission from SessionStart.
    6, 9, 10, 11, 12 No equivalent event (6); MCP tools (9); n/a (10); managed hooks give the policy half (11); hooks fire in codex exec too (12).

    So the framing above holds: mods are a Claude-harness optimisation, the shell hook and render gate stay the floor, and a Codex session in Codev gets the reporter and the deny half of the guard, not the visuals or the hold.

    Owner use case: peek at an issue referenced as #1234 without leaving the terminal

    Today (#1412) a #N in a terminal is a VS Code terminal link: cmd+click resolves it through the forge and opens the in-editor issue viewer or the browser. That is a separate view every time. The only in-place affordance the VS Code terminal-link API offers is a plain-string tooltip, so richer peeking has to come from one of the points above.

    Mod route (Claude harness, any terminal: Tower web, VS Code tab, plain shell). Proposed as candidate 13, Issue peek (high value, low effort), and the strongest spike exercise so far because it touches band, pane and a fetch in one small mod:

    • turn.complete scans e.answer, and prompt.submit the typed text, for #N and PR #N. The band shows one chip per reference with a digit hotkey: 1 #1672 Lane Card · spec gate 2 #1131 resolve state · plan gate. A digit hotkey on a band button fires when the user types the digit alone into an empty prompt and pauses, so the peek costs one keystroke and no mouse.
    • Pressing a chip calls $.ui.open with focus: true and closeOnEscape: true. Because the user opened it, the pane appears at any width: beside the transcript on a wide terminal, inline above the prompt in a VS Code tab. The pane draws title, state, labels, body as Markdown, and the newest comments; hotkeys o opens the forge page, c copies the URL, Esc closes.
    • Data comes from Tower's forge getIssue path over $.http.fetch, the same path vscode: TerminalLinkProvider — make #N / PR #N references in terminals clickable (issue viewer / browser) #1412's click uses, cached in $.store for the session. No gh spawned per session.
    • A /issue 1234 command registered with immediate: true opens the same pane while Claude is working.
    • Heavier variant, deferred: redraw AssistantMessage as Markdown with pressableLinks so the #1234 text itself is pressable. That replaces Claude Code's own rendering of every reply, and whether onLinkPress receives the href is unverified.

    Cross-harness floor (area/vscode, both harnesses). provideTerminalLinks may return asynchronously, so the tooltip on hover can carry #1672 · Lane Card · open · spec gate from a cached Tower lookup. One line, not a body, but it answers "which issue is this" without a click. Worth its own small item regardless of the mods decision.

    Codex: nothing in the TUI; the VS Code tooltip is the only peek.

    Proposed change to the sequence: the spike runs candidates 6, 1, the band from 5, and 13, since 13 is the owner's own daily friction and proves the band-chip-to-pane pattern that candidate 4 depends on.

  3. amrmelsayed commented on Oct 5, 2026

    @amrmelsayed
    CollaboratorAuthor

    Visual review (public artifact, updated with the spike outcome): https://claude.ai/artifact/GDdfPdEmmyrAkpuMdqBy5B

    Spike #1782 complete: hypothesis held. Recommendation on decisions 1 and 2

    Phase 1 of the sequence above ran as EXPERIMENT #1782 (PR #1786 merged, 0c4d1fc; record in codev/experiments/1782-claude-code-mods-spike/notes.md). Engine-side: validate passes, 16 tests pass on both surfaces, every hook's own time 0 to 1 ms. Live, in an 80-column Codev VS Code tab: the hold draws and fails closed, the digit chip opens the issue peek inline, /issue works mid-turn, re-init after /clear works through $.command.run, and the mod is live after the trust prompt with no reload.

    Decision 1, ship a codev plugin: the spike says yes, staged. Guard and attribution scrub first (no drawing risk); band and issue peek second with labels fitted to bodyColumns, the workspace root sent to Tower, and a prefetch or Tower-side cache for the ~1 s cold issue lookup; the plugin loads from the installed package folder, never a path a session writes; CI warms claude with one networked run before claude plugin test and adds a claude -p "/cmd" --plugin-dir probe. Before relying on it in builders, check the one trust case left open: a builder launched without skip-permissions in a worktree outside a trusted parent (afx spawn does not pre-trust).

    Decision 2, builders neither install nor author mods and the spawn path is the only loader: the spike says yes, strengthened. During the live run a session with the spike mod loaded, hot reload on, rewrote that mod in the builder's worktree and the change applied at once. The rule costs authoring nothing: the whole spike was built, validated and tested without loading a mod into a builder session.

    Corrections to the review from the spike: candidate 8 uses $.command.run, not $.prompt.submit (a host check rejects any submitted text beginning with /); a .catch handler must do nothing that can fail, since one that throws leaves the hook absent and the command runs; the render-gate-under-hold question stays open and moves to candidate 7.

    Decisions 3 and 5 are unchanged by the spike and still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cross-cutting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions