@ask-llm/plugin 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.claude-plugin/plugin.json +20 -0
  2. package/.mcp.json +3 -0
  3. package/LICENSE +21 -0
  4. package/README.md +135 -0
  5. package/agents/antigravity-reviewer.md +139 -0
  6. package/agents/brainstorm-coordinator.md +305 -0
  7. package/agents/codex-reviewer.md +194 -0
  8. package/agents/codex-verifier.md +149 -0
  9. package/agents/fable-reviewer.md +44 -0
  10. package/agents/gemini-reviewer.md +130 -0
  11. package/agents/ollama-reviewer.md +131 -0
  12. package/agents/sol-reviewer.md +60 -0
  13. package/codex-pair-defaults.json +4 -0
  14. package/dist/antigravity-run.d.ts +3 -0
  15. package/dist/antigravity-run.d.ts.map +1 -0
  16. package/dist/antigravity-run.js +32 -0
  17. package/dist/antigravity-run.js.map +1 -0
  18. package/dist/codex-run.d.ts +3 -0
  19. package/dist/codex-run.d.ts.map +1 -0
  20. package/dist/codex-run.js +32 -0
  21. package/dist/codex-run.js.map +1 -0
  22. package/dist/index.d.ts +7 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +39 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ollama-run.d.ts +3 -0
  27. package/dist/ollama-run.d.ts.map +1 -0
  28. package/dist/ollama-run.js +32 -0
  29. package/dist/ollama-run.js.map +1 -0
  30. package/dist/run.d.ts +3 -0
  31. package/dist/run.d.ts.map +1 -0
  32. package/dist/run.js +32 -0
  33. package/dist/run.js.map +1 -0
  34. package/hooks/hooks.json +55 -0
  35. package/package.json +104 -0
  36. package/pi/extensions/codex-pair.ts +870 -0
  37. package/pi/extensions/index.ts +13 -0
  38. package/pi/extensions/provider-tools.ts +241 -0
  39. package/pi/tsconfig.json +10 -0
  40. package/prompts/review.txt +75 -0
  41. package/scripts/codex-pair-debounce-worker.mjs +103 -0
  42. package/scripts/codex-pair-log.mjs +271 -0
  43. package/scripts/codex-pair-prompt-drain.mjs +81 -0
  44. package/scripts/codex-pair-session.mjs +194 -0
  45. package/scripts/codex-pair-stop-gate.mjs +271 -0
  46. package/scripts/codex-pair-watch.mjs +1525 -0
  47. package/scripts/lib/broker-lifecycle.mjs +575 -0
  48. package/scripts/lib/broker-rpc.mjs +203 -0
  49. package/scripts/lib/broker-transport.mjs +407 -0
  50. package/scripts/lib/broker.mjs +537 -0
  51. package/scripts/lib/debounce-state.mjs +208 -0
  52. package/scripts/lib/parser.d.mts +12 -0
  53. package/scripts/lib/parser.mjs +229 -0
  54. package/scripts/lib/process.mjs +39 -0
  55. package/scripts/lib/prompt.d.mts +8 -0
  56. package/scripts/lib/prompt.mjs +41 -0
  57. package/scripts/lib/session-registry.mjs +162 -0
  58. package/scripts/lib/state.d.mts +58 -0
  59. package/scripts/lib/state.mjs +733 -0
  60. package/scripts/lib/stop-gate.mjs +134 -0
  61. package/skills/antigravity-review/SKILL.md +49 -0
  62. package/skills/brainstorm/SKILL.md +105 -0
  63. package/skills/brainstorm-all/SKILL.md +43 -0
  64. package/skills/codex-image/SKILL.md +120 -0
  65. package/skills/codex-pair/SKILL.md +315 -0
  66. package/skills/codex-pair-ack/SKILL.md +64 -0
  67. package/skills/codex-pair-pause/SKILL.md +62 -0
  68. package/skills/codex-pair-resume/SKILL.md +52 -0
  69. package/skills/codex-review/SKILL.md +52 -0
  70. package/skills/codex-verify/SKILL.md +110 -0
  71. package/skills/compare/SKILL.md +151 -0
  72. package/skills/fable-review/SKILL.md +42 -0
  73. package/skills/gemini-review/SKILL.md +40 -0
  74. package/skills/multi-review/SKILL.md +182 -0
  75. package/skills/ollama-review/SKILL.md +40 -0
  76. package/skills/sol-review/SKILL.md +41 -0
@@ -0,0 +1,315 @@
1
+ ---
2
+ name: codex-pair
3
+ description: Show codex-pair status and set up the per-edit Codex review hook for this project. Detects whether codex-pair is active, paused, or not yet configured. On first run (no marker), offers interactive setup with auto-detected project context. On subsequent runs, shows current state, recent review activity, and toggle instructions. The per-edit hook itself runs automatically; this command is the human-facing dashboard for it.
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Set up and report status for recall-first per-edit Codex review. The repository marker carries review context but is not, by itself, authorization on Pi. Preserve bounded file context, debounce, pause/resume, acknowledgement, deduplication, failure disclosure, and explicit host lifecycle limitations.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Pi requires project trust, this repository marker, and explicit user-owned allowlist consent through `/codex-pair`. Pairing is asynchronous in TUI/RPC/long-lived JSON modes, uses `tool_result`, and surfaces findings non-blockingly. One-shot print mode, blocking Stop-gate parity, and nested Fable execution are unsupported.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # /codex-pair — setup and status dashboard
26
+
27
+ `/codex-pair` is a user-invocable command that orchestrates setup-and-status for the codex-pair PostToolUse hook. The HOOK runs automatically on every Edit/Write/MultiEdit when a project opts in via `.codex-pair/context.md`; this COMMAND is what you invoke to set up that opt-in (first time) or check the hook's current state (any time).
28
+
29
+ The hook empirically catches bugs earlier across any codebase and any task type — the improvement is task-agnostic per the [ADR-077](../../../../docs/DECISIONS.md) 4-task benchmark and the [ADR-095](../../../../docs/DECISIONS.md) lived-experience replication. Reference documentation on what the hook does, its cost characteristics, and its configuration knobs is in the second half of this file (below the Instructions section).
30
+
31
+ > **Note on what the hook is for:** the bug classes and example domains in the reference section below describe what codex-pair *catches in other projects* — they're benchmark fixtures, not properties of `ask-llm` itself. ask-llm is a CLI bridge between MCP clients and LLM CLIs with no money handling, no auth paths, no user-facing security surface. codex-pair runs against this repo for dogfooding (and continues to catch real bugs — see ADR-095).
32
+
33
+ ## Instructions
34
+
35
+ ### Phase 1: Detect current state
36
+
37
+ 1. Locate the marker by walking up from `process.cwd()` looking for `.codex-pair/context.md`. Stop at `$HOME` or filesystem root.
38
+
39
+ ```bash
40
+ dir=$(pwd); while [ "$dir" != "/" ] && [ "$dir" != "$HOME" ]; do
41
+ if [ -f "$dir/.codex-pair/context.md" ]; then echo "$dir"; break; fi
42
+ dir=$(dirname "$dir")
43
+ done
44
+ ```
45
+
46
+ Set `MARKER_DIR` to the result. Empty result means no marker exists.
47
+
48
+ 2. If `MARKER_DIR` is set, check whether the pause sentinel exists:
49
+ ```bash
50
+ [ -f "$MARKER_DIR/.codex-pair/state/paused" ] && echo "PAUSED" || echo "ACTIVE"
51
+ ```
52
+
53
+ 3. If `MARKER_DIR` is set and state is ACTIVE, read the last 5 log entries:
54
+ ```bash
55
+ tail -n 5 "$MARKER_DIR/.codex-pair/log.jsonl" 2>/dev/null | jq -c '{ts: .timestamp, verdict: .verdict, file: .file, concerns: .concerns}'
56
+ ```
57
+
58
+ 4. If `.codex-pair/ignore` exists, read it for the active patterns.
59
+
60
+ ### Phase 2: Branch on detected state
61
+
62
+ - **No marker found** → execute Phase 3 (setup)
63
+ - **Marker found, state = PAUSED** → execute Phase 4 (paused dashboard)
64
+ - **Marker found, state = ACTIVE** → execute Phase 5 (active dashboard)
65
+
66
+ ### Phase 3: Interactive setup (no marker found)
67
+
68
+ 1. Tell the user: "codex-pair is not yet configured for this project. Setting up now."
69
+
70
+ 2. Auto-detect project context by reading what's already available:
71
+ - `package.json` (name, description, dependencies — infers language/framework)
72
+ - `README.md` first 50 lines (project purpose statement)
73
+ - `pyproject.toml` / `Cargo.toml` / `go.mod` if present (non-Node projects)
74
+
75
+ You (Claude) already have this context in your tools — use Read to fetch the files, then synthesize a one-paragraph project-purpose summary.
76
+
77
+ 3. Draft a `.codex-pair/context.md` from the detected context. Structure:
78
+ ```markdown
79
+ # .codex-pair/context.md
80
+
81
+ <one-paragraph project-purpose summary derived from README/package.json>
82
+
83
+ ## Domain invariants Codex can't infer from a single file
84
+
85
+ <draft 3-5 bullet-point invariants based on what you found. Examples
86
+ to seed thinking — pick the ones that match what this actual project
87
+ does, drop the ones that don't, add others if obvious>
88
+
89
+ - <invariant 1 you inferred>
90
+ - <invariant 2 you inferred>
91
+ - <invariant 3 you inferred>
92
+ ```
93
+
94
+ 4. Use `AskUserQuestion` to confirm before writing. Question shape:
95
+ > "Here's a draft `.codex-pair/context.md` for your project. Should I create it as-is, let you edit it first, or skip setup?"
96
+ >
97
+ > Options: **Create as drafted** (recommended) | **Show me the draft to edit** | **Cancel setup**
98
+ >
99
+ > Include the full drafted content as the `preview` field on the recommended option so the user sees it before deciding.
100
+
101
+ 5. On user confirmation:
102
+ - `mkdir -p .codex-pair`
103
+ - Write `.codex-pair/context.md` with the confirmed content
104
+ - Check `.gitignore` for an existing `.codex-pair/` line; if missing, ASK the user whether to append it (don't modify `.gitignore` without consent — they may have an intentional reason for the current state, or want global gitignore instead).
105
+
106
+ 6. Confirm setup with a status table (same format as Phase 5 below):
107
+ ```
108
+ ✓ codex-pair active for <MARKER_DIR>
109
+ Next Edit/Write/MultiEdit will trigger a Codex review.
110
+ Pause with `/codex-pair-pause` · Resume with `/codex-pair-resume`
111
+ ```
112
+
113
+ ### Phase 4: Paused dashboard
114
+
115
+ Read the sentinel file:
116
+ ```bash
117
+ cat "$MARKER_DIR/.codex-pair/state/paused" 2>/dev/null
118
+ ```
119
+
120
+ If the sentinel is **non-empty** it is an auto-pause written by the hook (quota exhaustion or consecutive failures — see #176). Parse its JSON body and render:
121
+
122
+ ```
123
+ codex-pair status — <MARKER_DIR>
124
+
125
+ State: AUTO-PAUSED ⏸
126
+ Paused since: <at field from JSON>
127
+ Kind: <kind field: "quota" or "failures">
128
+ Reason: <reason field>
129
+ Resets ~ <resetHint field> (omit this line if resetHint is absent)
130
+
131
+ To resume: /codex-pair-resume
132
+ To remove: rm -rf <MARKER_DIR>/.codex-pair
133
+ ```
134
+
135
+ If the sentinel is **empty** it is a manual pause. Render:
136
+
137
+ ```
138
+ codex-pair status — <MARKER_DIR>
139
+
140
+ State: PAUSED ⏸
141
+ Paused since: <mtime of .codex-pair/state/paused>
142
+ Pause reason: <last entry in log.jsonl with verdict:"skipped" + reason starting with "paused"> (if available)
143
+
144
+ To resume: /codex-pair-resume
145
+ To remove: rm -rf <MARKER_DIR>/.codex-pair
146
+ ```
147
+
148
+ ### Phase 5: Active dashboard
149
+
150
+ Render a status table:
151
+
152
+ ```
153
+ codex-pair status — <MARKER_DIR>
154
+
155
+ State: ACTIVE ✓
156
+ Marker model: <model from frontmatter of context.md, or "default (gpt-5.6-sol)">
157
+ Surface threshold: <surfaceThreshold from frontmatter, or "med">
158
+ Cost/review: varies by Codex plan and workload / ~13–50s wall-clock
159
+
160
+ Recent reviews (last 5):
161
+ <timestamp> <verdict> <file> <H#/M#/L# concerns>
162
+ <timestamp> <verdict> <file> <H#/M#/L# concerns>
163
+ ...
164
+
165
+ Ignore patterns active: <count from .codex-pair/ignore, or "none">
166
+ Include patterns active: <count from .codex-pair/include, or "none — reviewing all files">
167
+
168
+ To pause: /codex-pair-pause
169
+ To exclude a file pattern: append to <MARKER_DIR>/.codex-pair/ignore
170
+ To restrict to specific paths: create <MARKER_DIR>/.codex-pair/include
171
+ ```
172
+
173
+ If recent reviews include any verdicts of `error`, `spawn_failed`, or `timeout`, add a "Recent failures" subsection with the reason field of the most recent failure.
174
+
175
+ ## Reference: hook behavior, when to use, configuration
176
+
177
+ (Everything below this point is reference documentation for the underlying PostToolUse hook — read this when you need to explain the hook to the user, when sizing whether the hook is worth enabling, or when configuring it via env vars or frontmatter.)
178
+
179
+ The hook surfaces HIGH and MED concerns to Claude on the next turn; logs everything to `.codex-pair/log.jsonl`. **Empirically catches a class of bug that confidence-filtered review structurally suppresses** — the recall improvement holds across structurally different task types (see ADR-077 for the precision-vs-recall data).
180
+
181
+ ## When to use this vs `/codex-review`
182
+
183
+ The decision is about **code characteristics**, not project domain. Any project — payments, infra, parsers, plugins, this very repo — has both kinds of code; the recall-first hook earns its keep wherever there's a category of bug that "looks fine but runs wrong."
184
+
185
+ | Use `/codex-review` (precision-first) | Use codex-pair (recall-first) |
186
+ |---|---|
187
+ | Routine PR review | Code with hidden invariants the model can't infer from one file |
188
+ | Glue code, simple CRUD, refactors | Code where latent bugs cost more than per-edit review (~$0.04–0.07) |
189
+ | You want one comprehensive report | Code evolving fast under written constraints (spec, protocol, ADR) |
190
+ | You're cost-sensitive (~$0.04/review) | State coordination, concurrency, anything order-sensitive |
191
+ | Default for everything | The "looks fine, runs wrong" failure mode would be expensive to catch later |
192
+
193
+ The empirical finding from the 4-task benchmark (four structurally different task types — CRUD, parsing, RFC-spec implementation, stateful logic): `/codex-review`'s "confidence ≥ 80" filter structurally suppresses **looks-fine-runs-wrong** bugs — code that compiles, lints, and type-checks but produces wrong results at runtime because of an implicit invariant the model couldn't infer from a single file. codex-pair's HIGH/MED/LOW threshold catches them. Different classes of bug, not the same class with different completeness. **The recall improvement is task-agnostic** — measured across all four task types, not just one.
194
+
195
+ ## How to enable it
196
+
197
+ **Per-project opt-in.** Create a file named `.codex-pair/context.md` in your project root with project context for the reviewer:
198
+
199
+ ```markdown
200
+ # .codex-pair/context.md
201
+
202
+ This is a payment-processing service. All currency calculations must use
203
+ integer cents internally (floating-point loses precision on every charge).
204
+ Concurrent requests are real. URL inputs are untrusted.
205
+
206
+ [Add domain invariants Codex can't infer from one file in isolation.
207
+ Examples —
208
+ Security: "all routes check user.role before any state read".
209
+ Specs: "protocol XYZ frame format must include version byte".
210
+ State: "cart syncs to localStorage on every mutation".
211
+ Concurrency: "this handler must be idempotent under retry".]
212
+ ```
213
+
214
+ The hook is always loaded by the plugin, but **self-gates on this file's presence**. No file → silent no-op (zero codex calls, zero cost). File present → every Edit/Write/MultiEdit triggers a codex review.
215
+
216
+ The marker file's *presence* is the switch; its *content* is the context codex needs to review intelligently. One artifact, two purposes.
217
+
218
+ **Do NOT commit the `.codex-pair/` directory** — gitignore it. The marker is per-developer opt-in: each contributor's review context is their own (model preference, severity threshold, project rules they care about). One developer iterating on prompt wording shouldn't dirty the shared history. The hook itself IS project policy (it ships in the plugin); the marker is the per-developer activation switch. Per [ADR-092](../../../../docs/DECISIONS.md), every state artifact (marker, log, cache, ignore globs, pause sentinel, inflight locks) nests under the single directory, so one `.gitignore` line covers everything — including any future state files added later:
219
+
220
+ ```
221
+ .codex-pair/
222
+ ```
223
+
224
+ To onboard a new contributor, point them at this skill (or `apps/docs/plugin/hooks.md`) to write their own marker — or share a template via a separate (committed) `.codex-pair.example/context.md` they can copy and tweak locally.
225
+
226
+ ## How to pause or disable
227
+
228
+ | Goal | How |
229
+ |---|---|
230
+ | Temporarily for this project (keep marker, keep project context) | `/codex-pair-pause` (resume with `/codex-pair-resume`) |
231
+ | Per-file/per-directory | Add patterns to `.codex-pair/ignore` (gitignore-style globs) |
232
+ | Permanently for this project | `rm -rf .codex-pair/` |
233
+ | Just this session | `/plugin disable ask-llm` |
234
+ | Just this command | `CODEX_PAIR_DISABLED=1 <whatever command>` |
235
+
236
+ `/codex-pair-pause` writes a `.codex-pair/state/paused` sentinel that the hook checks on every Edit/Write/MultiEdit; while present, the hook exits silently with a `verdict:"skipped"` log entry naming the pause. `/codex-pair-resume` removes the sentinel (and the consecutive-failure counter, so a resumed project doesn't re-pause on the next single failure). The pause is per-project and per-developer — the single `.codex-pair/` gitignore entry already covers the sentinel (and every other state file) per [ADR-092](../../../../docs/DECISIONS.md).
237
+
238
+ **Auto-pauses self-heal** (2026-07-02 design): a quota auto-pause expires after `CODEX_PAIR_QUOTA_PAUSE_TTL_MS` (default 6h); a failures auto-pause expires after `CODEX_PAIR_FAILURES_PAUSE_TTL_MS` (default 24h) or immediately when the plugin version changed since the pause was written. Expiry is checked at SessionStart (with a reminder or auto-resume notice injected into context) and on every edit. Manual pauses never auto-expire.
239
+
240
+ ## Behavior when active
241
+
242
+ ```
243
+ Claude edits src/billing/charge.ts
244
+ │
245
+ ▼
246
+ PostToolUse hook fires
247
+ │
248
+ ├─ Walk up from cwd looking for .codex-pair/context.md
249
+ │
250
+ ├─ NOT FOUND → exit silently (no codex call, no log)
251
+ │
252
+ └─ FOUND → read marker content as project context
253
+ ▼
254
+ Run codex review with HIGH/MED/LOW grading
255
+ ▼
256
+ Surface HIGH+MED to stderr (Claude reads next turn)
257
+ ▼
258
+ Log every call to .codex-pair/log.jsonl (incl. NONE verdicts)
259
+ ```
260
+
261
+ ## Cost characteristics
262
+
263
+ - Usage varies by Codex plan and workload (`gpt-5.6-sol` with reasoning tokens)
264
+ - ~13–50s per file wall-clock
265
+ - Files >20 KB skipped (override with `CODEX_PAIR_MAX_FILE_BYTES`)
266
+ - node_modules, dist, lockfiles, images skipped automatically
267
+ - A 50-edit session = ~$2–3.50 + ~10–40 cumulative minutes of codex latency
268
+
269
+ For the typical opted-in project (small surface where review depth matters), this is acceptable. For routine refactor work, leave the marker file out.
270
+
271
+ ## Output format
272
+
273
+ When codex surfaces concerns to Claude, they appear as system reminders on the next turn, prefixed with `[codex-pair]` and the file path. The full per-call log (including PASS verdicts and timing) is in `.codex-pair/log.jsonl` alongside the marker.
274
+
275
+ Example concern surface:
276
+
277
+ ```
278
+ [codex-pair] src/billing/charge.ts
279
+
280
+ [HIGH] Monetary values are modeled as floating-point numbers
281
+ src/billing/charge.ts:12: `price` accepts arbitrary JS numbers for money,
282
+ which violates the stated requirement that currency uses integer cents.
283
+ Use integer minor units such as `priceCents: z.number().int().nonnegative()`.
284
+ ```
285
+
286
+ ## Configuration knobs (env vars)
287
+
288
+ | Variable | Default | Effect |
289
+ |---|---|---|
290
+ | `CODEX_PAIR_DISABLED` | unset | Set to `1` to bypass the hook entirely (kill switch) |
291
+ | `CODEX_PAIR_MAX_FILE_BYTES` | `20000` | Skip files larger than this many bytes |
292
+ | `ASK_CODEX_TIMEOUT_MS` | `800000` | Per-call codex timeout (inherited from @ask-llm/codex-mcp, ADR-074) |
293
+ | `ASK_CODEX_REASONING_EFFORT` | `medium` | Codex reasoning effort for continuous per-edit reviews; `/codex-review` and `/brainstorm` default to `high` instead. |
294
+ | `ASK_CODEX_DEBOUNCE_MS` | `15000` | Settle window: a burst of edits to one file within this window is collapsed into a single review of the settled state (ADR-112). Set to `0` to disable debounce and review every edit synchronously. |
295
+ | `ASK_CODEX_DEBOUNCE_MAX_MS` | `60000` | Hard cap from the first edit of a burst — forces a review even under a continuous edit stream. |
296
+ | `CODEX_PAIR_QUOTA_PAUSE_TTL_MS` | `21600000` (6h) | Quota auto-pauses self-heal after this long. |
297
+ | `CODEX_PAIR_FAILURES_PAUSE_TTL_MS` | `86400000` (24h) | Failure auto-pauses self-heal after this long, or immediately on a plugin-version change. |
298
+
299
+ Both debounce knobs are also settable per-marker via `context.md` frontmatter (`debounceMs` / `debounceMaxMs`), which takes precedence over the env vars. With debounce on (the default), a review fires shortly *after* you stop editing a file and its verdict surfaces on your next edit or next prompt (via the `UserPromptSubmit` drain) — not synchronously on the triggering edit. Set `debounceMs: 0` in the marker frontmatter for the old synchronous behavior.
300
+
301
+ ## Empirical justification
302
+
303
+ The design decisions in this skill (HIGH/MED/LOW grading, marker-file gate, complement-not-replacement positioning) come from a 4-task benchmark documented in detail at branch `experiment/codex-pair-poc` and in [ADR-077](../../../../docs/DECISIONS.md). The benchmark deliberately picked four **structurally different task types** so the result would generalize, not be a fluke of one domain — a todo CRUD endpoint, a URL shortener, an RFC-spec implementation (JSON Patch RFC 6902), and a stateful business-logic module. The headline 3-arm comparison from task 4:
304
+
305
+ ```
306
+ Claude alone: 2/10 probes pass
307
+ Claude + /codex-review: 7/10
308
+ Claude + codex-pair: 10/10
309
+ ```
310
+
311
+ The three probes `/codex-review` missed exemplified the "looks fine, runs wrong" class the precision filter suppresses — numeric-precision drift, cross-cutting validation gaps, edge-case bounds errors. **The improvement reproduced across all four tasks**, not just the headline one — confirming the recall gain is task-agnostic. Wherever a project has implicit correctness invariants the model can't infer from a single file in isolation (and most projects do, somewhere), codex-pair catches them earlier than a confidence-filtered review on a finished PR.
312
+
313
+ Subsequent lived-experience audit ([ADR-095](../../../../docs/DECISIONS.md)) confirmed the benchmark holds in real flow: codex-pair flagged 32 unique bugs during a single dense broker-implementation session in this very repo, including 2 BLOCKING bugs that `/multi-review` independently re-caught 5+ hours later. The benchmark is reproducible empirical evidence; ADR-095 is the field replication.
314
+
315
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: codex-pair-ack
3
+ description: Acknowledge a codex-pair finding by its 16-character hash and a user-owned reason. Use when the user wants to suppress a repeated finding reminder or defer a host gate where supported.
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Acknowledge one finding by its 16-character concern hash with a non-empty user reason. Acknowledgement suppresses that finding's reminder/gate; it does not disable future reviews or claim the concern was fixed.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Run `/codex-pair-ack <hash> <reason>`. On Pi this dismisses the matching reminder; there is no blocking Stop gate.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # Acknowledge a codex-pair HIGH finding
26
+
27
+ Records an ack for the given finding hash so the codex-pair Stop-gate skips it on future turn-ends. The gate prints a full 16-char hash in its block message, e.g. `[fc69d46835dfd2ab] src/auth.ts` — pass that hash verbatim.
28
+
29
+ ## Instructions
30
+
31
+ 1. **Parse args.** The first whitespace-delimited token is `<hash>` (16-char hex). The remaining text (strip enclosing quotes if present) is `<reason>`. If either is missing, print usage and stop:
32
+ ```
33
+ Usage: /codex-pair-ack <hash> "<reason>"
34
+ Example: /codex-pair-ack fc69d46835dfd2ab "false positive — test-only code path"
35
+ ```
36
+
37
+ 2. **Locate the `.codex-pair/` directory.** Walk up from the current working directory looking for `.codex-pair/context.md`. The directory that contains `.codex-pair/` is `<markerDir>`. If no marker is found after reaching the filesystem root, tell the user:
38
+ ```
39
+ codex-pair is not enabled in this project (no .codex-pair/context.md found). Nothing to acknowledge.
40
+ ```
41
+
42
+ 3. **Validate the hash** before using it: it must match `^[0-9a-f]{16}$`. If it does not, print the usage block from step 1 and stop (a malformed hash means the user mistyped it).
43
+
44
+ 4. **Record the ack** by running the Bash command below. Substitute real values for `<plugin-root>` (the absolute path of this plugin, i.e. the value of `CLAUDE_PLUGIN_ROOT`), `<markerDir>`, and `<hash>`. **Do NOT interpolate `<reason>` into the command string** — the reason is read from stdin via a single-quoted heredoc so the shell never expands `$(...)`, backticks, or quotes inside it (injection-safe). Replace the `<reason>` line with the user's reason text verbatim:
45
+ ```bash
46
+ node --input-type=module -e '
47
+ import { addAck } from "<plugin-root>/scripts/lib/state.mjs";
48
+ import { readFileSync } from "node:fs";
49
+ // With `node -e CODE A B`, process.argv = [node, A, B] (no script-file
50
+ // placeholder), so argv[1]=markerDir, argv[2]=hash.
51
+ addAck(process.argv[1], process.argv[2], { reason: readFileSync(0, "utf8").trim() });
52
+ ' "<markerDir>" "<hash>" <<'CODEX_PAIR_ACK_REASON'
53
+ <reason>
54
+ CODEX_PAIR_ACK_REASON
55
+ ```
56
+ `addAck` writes a concurrency-safe shard under `<markerDir>/.codex-pair/state/acks/` (creating the directory if needed). The hash is passed verbatim — no resolution is performed.
57
+
58
+ 5. **Confirm** to the user:
59
+ ```
60
+ Acknowledged `<hash>` — <reason>. The Stop-gate will skip this finding.
61
+ ```
62
+ If the node one-liner exits non-zero, surface the error output so the user can diagnose it.
63
+
64
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: codex-pair-pause
3
+ description: Pause codex-pair for this project without removing `.codex-pair/context.md`. Writes the shared `.codex-pair/state/paused` sentinel. Use during noisy refactors, hook dogfooding, or other temporary review pauses.
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Create the project-local `.codex-pair/state/paused` sentinel without removing the marker or history. This is a manual pause and remains until explicitly resumed.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Run `/codex-pair-pause` or create the sentinel exactly as described by the portable contract.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # Pause codex-pair for this project
26
+
27
+ Pauses the codex-pair hook for the current project without removing the `.codex-pair/context.md` marker. The marker (and its project context) stays in place — only the temporary pause sentinel is written. Resume with `/codex-pair-resume`.
28
+
29
+ The hook may also pause itself automatically — on provider quota exhaustion or after
30
+ 3 consecutive review failures — writing the same sentinel with a JSON body that
31
+ records why (`kind`, `reason`, `resetHint`). Manual and automatic pauses are resumed
32
+ the same way.
33
+
34
+ ## When to use
35
+
36
+ - Starting a noisy refactor where every edit would surface concerns you've already decided to accept
37
+ - Working on docs/comments/typos where review adds no value
38
+ - Dogfooding the hook itself (avoid recursive self-reviews)
39
+ - Burning down a known-issues list where you don't want codex re-flagging them on every save
40
+
41
+ For permanent disable, remove the `.codex-pair/` directory instead (`rm -rf .codex-pair/`). For per-file/per-directory opt-out, use `.codex-pair/ignore` (gitignore-style globs).
42
+
43
+ ## Instructions
44
+
45
+ 1. Locate the `.codex-pair/context.md` marker by walking up from the current working directory (the project ROOT is the directory holding `.codex-pair/`). If no marker is found, inform the user: "codex-pair is not enabled in this project (no `.codex-pair/context.md` marker found). Nothing to pause."
46
+
47
+ 2. Create the pause sentinel:
48
+ ```bash
49
+ mkdir -p <marker-dir>/.codex-pair/state
50
+ touch <marker-dir>/.codex-pair/state/paused
51
+ ```
52
+ Replace `<marker-dir>` with the directory containing `.codex-pair/`.
53
+
54
+ 3. Confirm to the user with the marker directory path:
55
+ ```
56
+ codex-pair paused for <marker-dir>
57
+ Resume with /codex-pair-resume (or `rm <marker-dir>/.codex-pair/state/paused`)
58
+ ```
59
+
60
+ 4. If `.gitignore` in the marker directory does not already contain `.codex-pair/`, mention it as a suggestion (do not modify the user's .gitignore without asking).
61
+
62
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: codex-pair-resume
3
+ description: Resume codex-pair for this project after a previous pause. Removes `.codex-pair/state/paused` and clears failure state. Review resumes on the next supported file edit; missing state is a no-op.
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Remove the project-local pause sentinel and clear the consecutive-failure counter so the next successful edit can be reviewed. Missing state is a no-op.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Run `/codex-pair-resume` or remove the sentinel and failure counter exactly as described by the portable contract.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # Resume codex-pair for this project
26
+
27
+ Removes the pause sentinel written by `/codex-pair-pause`, restoring normal codex-pair review behavior. The `.codex-pair/context.md` marker and `.codex-pair/state/` directory are left in place (the directory holds the cache, inflight locks, and any other future state per [ADR-092](../../../../docs/DECISIONS.md)).
28
+
29
+ ## Instructions
30
+
31
+ 1. Locate the `.codex-pair/context.md` marker by walking up from the current working directory (the project ROOT is the directory holding `.codex-pair/`). If no marker is found, inform the user: "codex-pair is not enabled in this project (no `.codex-pair/context.md` marker found). Nothing to resume."
32
+
33
+ 2. Check whether the pause sentinel exists at `<marker-dir>/.codex-pair/state/paused`:
34
+ - If it does not exist, tell the user: "codex-pair was not paused — no `.codex-pair/state/paused` sentinel found. No change."
35
+ - If it exists and is non-empty, it is an auto-pause written by the hook itself
36
+ (quota exhaustion or repeated failures — see #176). `cat` it and show the user
37
+ the `kind`, `reason`, and `resetHint` fields before removing, so they know
38
+ whether the provider has likely recovered.
39
+ - Remove it, together with the consecutive-failure counter — resuming while
40
+ the counter is still at threshold would re-pause on the very next single
41
+ failure. Quote the paths so marker directories with spaces work:
42
+ ```bash
43
+ rm -f -- "<marker-dir>/.codex-pair/state/paused" "<marker-dir>/.codex-pair/state/failures.json"
44
+ ```
45
+
46
+ 3. Confirm to the user with the marker directory path:
47
+ ```
48
+ codex-pair resumed for <marker-dir>
49
+ The next Edit/Write/MultiEdit will trigger a review.
50
+ ```
51
+
52
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: codex-review
3
+ description: Get a second opinion from OpenAI Codex on your current code changes. Analyzes staged/unstaged diffs and returns prioritized findings. Use when user asks to "review with Codex", "Codex code review", or "ask Codex to check my code".
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Gather the relevant staged, unstaged, and untracked code changes; build a bounded context brief; request a read-only Codex review at high reasoning effort; verify each reported finding against source; and return only prioritized, source-supported findings. Preserve the configured Sol-to-Terra fallback and disclose it.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Call the native `ask-codex` tool with `reasoningEffort: "high"` and apply only the `Portable contract` section of `../../agents/codex-reviewer.md`. The review runs inline in the current host context; do not claim subagent isolation.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # Codex Code Review
26
+
27
+ Review current code changes by delegating to the `codex-reviewer` agent.
28
+
29
+ ## When to use this vs codex-pair
30
+
31
+ This skill is **precision-first**: confidence ≥ 80, "don't flag style/linter-catchable" filter. Optimized for low false-alarm rate on diff review — appropriate default for routine PRs.
32
+
33
+ For **recall-first** review on hot-path code (money handling, security paths, spec-implementing code), see the [`codex-pair`](../codex-pair/SKILL.md) sibling — a PostToolUse hook that opts in per-project via a `.codex-pair/context.md` marker file. The 4-task benchmark in ADR-077 shows codex-pair catches domain-level "wrong but won't crash" issues (float-money precision, cross-cutting validation gaps, edge clamping) that this skill's confidence filter structurally suppresses. Different classes of bug, not the same class with different completeness.
34
+
35
+ | Use this skill | Use codex-pair |
36
+ |---|---|
37
+ | Routine PR review (cheap, high precision) | Money/billing/security/spec code (deeper, costlier) |
38
+ | You want one comprehensive report | You want every concern flagged with severity |
39
+ | Cost-sensitive (~$0.04/PR) | Acceptable cost (~$0.20/edit pass) |
40
+
41
+ ## Instructions
42
+
43
+ 1. Gather the diff to review:
44
+ - Run `git diff` to get unstaged changes
45
+ - Run `git diff --cached` to get staged changes
46
+ - Combine both into a single diff
47
+
48
+ 2. If the diff is empty, inform the user there are no changes to review.
49
+
50
+ 3. Launch the `codex-reviewer` agent with the diff content. The agent handles the Codex prompt structure and output formatting, using GPT-5.6 Sol at `high` reasoning effort with automatic Terra fallback.
51
+
52
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: codex-verify
3
+ description: Verifies what the assistant claims to have done — proves the work against actual state using OpenAI Codex with a read-only tool surface. Use when the user asks to "verify with Codex", "check the assistant's claims", "did Codex actually do what it said", "verify this turn", "prove the work", or wants a trust check distinct from issue review. Different from `/codex-review`, which finds new issues.
4
+ ---
5
+
6
+ <!-- PORTABLE-CONTRACT:START -->
7
+ ## Portable contract
8
+
9
+ Capture the prior assistant message verbatim, decompose it into atomic claims, and verify those claims against actual repository state with a read-only Codex consultation where useful. This is claim verification, not issue hunting. Preserve the Report block, five-grade confidence ladder, parser fallback, and explicit unverifiable state.
10
+ <!-- PORTABLE-CONTRACT:END -->
11
+
12
+ ## Host adapters
13
+
14
+ ### Pi adapter
15
+
16
+ Apply only the portable contract in `../../agents/codex-verifier.md` inline and call native `ask-codex` for focused claim checks. Do not claim an isolated verifier context.
17
+
18
+ <!-- HOST-ADAPTER:CLAUDE-CODE:START -->
19
+ ### Claude Code adapter
20
+
21
+ The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
22
+
23
+
24
+
25
+ # Codex Claim Verification
26
+
27
+ Prove or disprove what the assistant agent claims to have done in the current turn, independently. This is a **trust check**, not an issue hunt — separate from `/codex-review`.
28
+
29
+ ## Why this is separate from `/codex-review`
30
+
31
+ - `/codex-review` looks for new bugs in the diff (issue hunt).
32
+ - `/codex-verify` proves the assistant's claims against actual state (trust verification).
33
+
34
+ A single tool would dilute both contracts. The verifier is **structurally narrowed by design**: it does not propose fixes, does not list issues outside the assistant's claims, does not drift into "while I'm here let me also...". That narrowness is the feature — it forces every "verified" verdict to be backed by a deterministic tool output.
35
+
36
+ The two skills compose. Run both when you want both questions answered. Do not merge their outputs.
37
+
38
+ ## Instructions
39
+
40
+ ### Phase 1: Gather inputs
41
+
42
+ 1. Combine the diff:
43
+ - `git diff` (unstaged changes)
44
+ - `git diff --cached` (staged changes)
45
+ 2. **If the diff is empty**, stop and tell the user "no changes to verify."
46
+ 3. Capture the assistant's last message — the message in the prior turn where the assistant stated what it did. This is the source of claims to verify. Pass it through verbatim — do not summarize, do not paraphrase. The agent decomposes claims directly from this text.
47
+
48
+ If the conversation has no prior assistant message stating what was done (e.g., the diff exists but came from a manual edit), tell the user: "no assistant claim to verify — run `/codex-review` for issue review instead."
49
+
50
+ ### Phase 2: Dispatch the verifier agent
51
+
52
+ Launch the `codex-verifier` agent with two inputs:
53
+ - The combined diff
54
+ - The assistant's last message (verbatim)
55
+
56
+ The agent owns the contract: read-only tool surface, claim decomposition, per-claim deterministic verification, and the `## Report` output block. Wait for its output.
57
+
58
+ ### Phase 3: Defensive parse of the Report block
59
+
60
+ Find the `## Report` block in the agent's output. Extract:
61
+
62
+ - **`STATUS:`** — one of `verified`, `failed`, `unsure`. If missing, treat as `unsure`.
63
+ - **`CONFIDENCE:`** — one of `PERFECT`, `VERIFIED`, `PARTIAL`, `FEEDBACK`, `FAILED`. **If missing, derive from STATUS:**
64
+ - `verified → VERIFIED`
65
+ - `failed → FEEDBACK`
66
+ - `unsure → FAILED`
67
+
68
+ This fallback mirrors the Pi verifier's defensive parser — LLMs occasionally drop the second adjacent metadata line, and the consumer should not abort on that.
69
+ - The five sections: "What did you verify?", "What could you not verify?", "Corrective feedback", "What do you need to verify this next time?", "Verification metadata".
70
+
71
+ ### Phase 4: Present the result
72
+
73
+ ```markdown
74
+ ## Codex Verification — <CONFIDENCE>
75
+
76
+ **Status:** <verified | failed | unsure>
77
+ **Atomic claims:** <total> total · <V> verified · <F> failed · <U> unverifiable
78
+
79
+ ### Verified
80
+ - <claim> — <evidence: file:line, command output>
81
+
82
+ ### Failed
83
+ - <claim> — <evidence>
84
+
85
+ ### Unverifiable
86
+ - <claim> — <reason: missing oracle/fixture/runtime>
87
+
88
+ ### Corrective feedback (when STATUS=failed)
89
+ > <verbatim from the agent's report — the user can paste this back to the assistant>
90
+
91
+ ### What's missing for next time
92
+ <from "What do you need to verify this next time?" — these gaps are templates/fixtures/scripts the operator should add to the project to make future verifications stronger>
93
+ ```
94
+
95
+ ### Phase 5: Surface the right signal for each grade
96
+
97
+ - **PERFECT / VERIFIED** — Brief output. Don't bury the lede; one or two sentences confirming the claims are true.
98
+ - **PARTIAL** — **Surface the gaps loudly.** PARTIAL is the most actionable grade for project-level investment: every unverifiable claim is a fixture or script you should consider adding. Highlight the "what's missing for next time" section.
99
+ - **FEEDBACK** — Surface the corrective feedback verbatim. The operator can paste it back to start the next turn with a concrete fix.
100
+ - **FAILED** — The verification harness itself is the bottleneck. Tell the user explicitly: "Codex couldn't verify — the gap is in our verification surface, not in the work." Suggest the missing pieces.
101
+
102
+ ## Important rules
103
+
104
+ - **Do not merge `/codex-verify` and `/codex-review` outputs.** They answer different questions. If a user wants both, run them separately and present them separately.
105
+ - **Do not rewrite the corrective feedback.** Pass it through verbatim. The agent wrote it precisely; paraphrasing dilutes the actionability.
106
+ - **PARTIAL is a real verdict, not a softer VERIFIED.** Surface the unverifiable claims clearly — those gaps are the next thing the operator templates into the project.
107
+ - **Don't reuse the verifier for "review my code."** That's `/codex-review`'s job. The verifier is structurally narrowed by design and will not return useful issue-hunt output.
108
+ - **No silent drops.** If parsing the Report block fails (e.g., agent didn't emit the block, output truncated), surface that to the user with the raw agent output rather than fabricating a verdict.
109
+
110
+ <!-- HOST-ADAPTER:CLAUDE-CODE:END -->