Codex compatibility note:
- Invoke repository skills with
$skill-name in Codex; this mirrored copy rewrites legacy Claude /skill-name references.
- Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
- User-question prompts mean to ask the user directly in Codex.
- Ignore Claude-specific mode-switch instructions when they appear.
- Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
- Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required
spawn_agent subagent(s) for that task.
- Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
- For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
- If a required step/tool cannot run in this environment, stop and ask the user before adapting.
Codex Project-Reference Loading (No Hooks)
Codex uses static project-reference loading instead of runtime-injected project docs.
When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
Always read:
docs/project-config.json (project-specific paths, commands, modules, and workflow/test settings)
docs/project-reference/docs-index-reference.md (routes to the full docs/project-reference/* catalog)
docs/project-reference/lessons.md (always-on guardrails and anti-patterns)
Missing/stale context route: If docs/project-config.json, the docs index, lessons.md, CLAUDE.md, AGENTS.md, or any task-required reference doc is missing or stale, auto-run $project-init or the narrow setup route ($project-config, $docs-init, $scan-all, $scan --target=<key>, $claude-md-init) before ordinary project-specific work. If Codex mirrors or AGENTS.md are missing/stale, ask the user to run $sync-codex; do not auto-run it.
Situation-based docs:
- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra):
project-structure-reference.md
- Backend/CQRS/API/domain/entity changes:
backend-patterns-reference.md, domain-entities-reference.md
- Frontend/UI/styling/design-system:
frontend-patterns-reference.md, scss-styling-guide.md, design-system/README.md
- Spec authoring,
docs/specs/ pathing, or TC format: feature-spec-reference.md, spec-system-reference.md, spec-principles.md
- Behavior/public-contract changes or spec-test-code sync:
workflow-spec-test-code-cycle-reference.md plus the spec docs above
- Derived spec indexes/ERDs/reimplementation guides:
spec-system-reference.md and source Feature Specs under docs/specs/
- Integration test implementation/review:
integration-test-reference.md
- E2E test implementation/review:
e2e-test-reference.md
- Code review/audit work:
code-review-rules.md plus domain docs above based on changed files
Do not read all docs blindly. Start from docs-index-reference.md, then open only relevant files for the task.
[BLOCKING] Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
[BLOCKING] Before each step or sub-skill call, update task tracking: set in_progress when step starts, set completed when step ends.
[BLOCKING] Every completed/skipped step MUST include brief evidence or explicit skip reason.
[BLOCKING] If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
Quick Summary
Goal: Drive a review target to a clean pass by pairing $why-review with $fix in a recursive loop — each round runs $why-review INLINE to surface validated findings, then $fix to resolve them, then loops again over the CHANGED target — stopping when a complete $why-review pass clears the round's exit bar: zero findings in rounds 1-2, and zero CRITICAL/HIGH/MEDIUM from round 3 (LOW-only ENDS the loop, deferred not fixed).
Summary:
- Each round =
$why-review + $fix — $why-review is review-ONLY and never edits the target, so the loop MUST pair it with a fix half; one without the other never converges.
- Steps (in order): (0) resolve target + Goal Contract → (0b) bind the convergence loop (protocol loop primary + optional
/goal accelerator) → (1) round loop { run $why-review INLINE → clear the Trade-Off Gate on the fix set → run $fix on the VALIDATED findings at the owning layer → log iteration } → (2) converge on a zero-findings round OR escalate on non-progress → (3) recap.
- Convergence: stop ONLY when a fresh full
$why-review over the CURRENT (post-fix) target clears that round's exit bar — not a stale PASS predating the last fix.
- Severity floor — from round 3, LOW stops blocking. Rounds 1-2 converge on an empty validated-finding set (any severity). From round 3 the bar is zero validated CRITICAL/HIGH/MEDIUM — a round whose validated findings are ALL LOW ENDS the loop. Never open another round to fix LOW alone; list every deferred LOW in the recap and Goal Contract instead, and NEVER re-tier a real CRITICAL/HIGH/MEDIUM down to LOW to reach the exit.
- Inline invariant: run
$why-review via the skill invocation, NEVER the spawn_agent tool — it self-binds its OWN review-loop obligation (and a session /goal gate WHEN available, why-review/SKILL.md:57-76), which a sub-agent cannot own or carry back to this loop.
- Apply ONLY validated findings:
$why-review already validates its findings to the ≥85% survival bar; the loop applies THOSE, at the lowest owning layer (Entity > Service > Handler), routed by target type — NEVER unvalidated findings.
- Bounded: round cap default 3; findings not shrinking across 2 rounds, or cap hit with findings still open → STOP & escalate by asking the user directly. Increasing findings → STOP (fixes regressing).
- TRADE-OFF GATE before every fix (ALWAYS ASK): (1) is there any trade-off in this fix? name what it sacrifices — "none" is an unfinished analysis; (2) is it worth it? gain vs cost, who pays, when → WORTH IT / NOT WORTH IT / UNCLEAR — NOT WORTH IT → do NOT apply, report it back instead; (3) is the trade-off material enough to confirm with the user? irreversible · cost shifted elsewhere · quality attribute traded · boundary crossed · high-consequence path · UNCLEAR → STOP the loop and confirm by asking the user directly BEFORE applying. NEVER auto-apply a material-trade-off fix just because the loop wants to converge.
Why this skill exists (READ FIRST — it is the whole justification): $why-review is review-only — why-review/SKILL.md:330 ("Review only — do NOT modify target files or implement changes") and :76 ("why-review fixes its OWN findings set, not code… Code/spec/test fixes remain the caller's job"). Its internal self-recursive /goal loop (why-review/SKILL.md:57-76) converges its own findings REPORT to CLEAN — every surviving finding proof-backed, validated, ≥85% confidence — but it never touches the code and never re-reviews a fixed target. So a finding that demands a code/spec/doc change is validated and handed off, yet nothing loops back to confirm the FIX is correct or that it introduced no new defect. This skill closes that outer loop: it applies the validated fixes and re-runs a fresh full $why-review over the changed target until zero findings remain — catching fix-induced regressions and proving each fix actually resolved its finding. Without it, "why-review passed, then I fixed the findings" ships those fixes unreviewed.
Workflow: resolve target + Goal Contract → bind the convergence loop (protocol loop + optional /goal accelerator) → round loop { run $why-review INLINE → clear the Trade-Off Gate on the fix set (trade-off? worth it? material → confirm with user) → run $fix on the validated findings at owning layer → log iteration } → converge when a fresh full review yields zero findings → recap.
Key Rules:
- Each round pairs
$why-review (find) + $fix (resolve). $why-review is review-only (why-review/SKILL.md:76,330) — it produces validated findings but never edits the target; $fix is the half that lands the change. A round is incomplete until BOTH have run (or the review returned zero findings).
- MUST run INLINE in the main session — NEVER dispatch
$why-review as a sub-agent. It self-binds its own review-loop obligation (and a session /goal gate when available, why-review/SKILL.md:57-76); as a sub-agent that in-session guarantee is silently lost. This loop skill therefore also runs inline.
- Convergence = a fresh full
$why-review over the post-fix target clears the round's exit bar. Rounds 1-2: PASS with an empty validated-finding set. Round 3+: zero validated CRITICAL/HIGH/MEDIUM — LOW-only converges. A PASS produced BEFORE the latest fix landed does NOT count — re-review the changed target.
- The severity floor bounds ITERATION, never the standard. It ends the loop; it never authorizes shipping a known CRITICAL/HIGH/MEDIUM, never lowers
$why-review's ≥85% finding-survival bar, and never applies to a binary gate (a failing test is a failure, not a LOW finding).
$fix applies ONLY validated findings, at the lowest owning layer, routed by target type (code → $fix with its intelligent routing, or a direct edit at Entity/Service; plan/PBI → $refine; spec → $spec [update] + $spec [mode=tests]; docs → $docs-update; tests → $integration-test). NEVER apply an unvalidated or demoted finding.
- The target base is FIXED across rounds; its content changes as fixes land. Re-review the SAME target (same plan/diff/artifact) each round so convergence is measured against a stable subject.
- Round cap (default 3) and findings-not-shrinking / increasing → STOP & escalate by asking the user directly. NEVER loop open-ended.
- ALWAYS ask the 3 trade-off questions before applying ANY fix — is there a trade-off? is it worth it? is it material enough to confirm with the user? A MATERIAL trade-off (irreversible · cost shifted to another team/ops/maintainer/user · one quality attribute traded for another · tier/service/event/library boundary crossed · auth/money/data-integrity/breaking-change path · worth-it verdict UNCLEAR) PAUSES the loop for an ask the user directly before the fix lands — convergence pressure NEVER authorizes walking through a one-way door on the user's behalf. — why: an autonomous fix loop is exactly where an unpriced trade-off ships silently, because each round only asks "did findings shrink?".
First Principle — Convergence, Not Motion
A round that changes the target is progress only if the next fresh review finds fewer things to fix.
The loop exists to reach a fixed point (no blocking findings), not to keep editing the target.
The bar tightens by round: everything blocks in rounds 1-2; from round 3 only CRITICAL/HIGH/MEDIUM block, so a LOW-only round is the fixed point.
If findings stop shrinking, that is a signal to escalate, not to spin another round.
Step 0 — Resolve Target + Goal Contract (FIRST ACTION)
- Parse the review target from the user prompt into a stable, reusable target reference — exactly the kinds
$why-review resolves (why-review/SKILL.md:142-161):
- Plan / PBI / story — a
plan.md + phase-*.md dir, or a named PBI/story artifact.
- Code change — a commit SHA, PR/merge commit, branch-to-branch or PR diff (e.g.
git diff develop...HEAD), or uncommitted working-tree changes.
- Docs / spec / report — a target artifact path whose claims are checked against source evidence.
- Record the target type, its evidence, and confidence. NEVER silently convert target types (
why-review/SKILL.md:160).
- Resolve/create the Goal Contract per
SYNC:goal-contract-satisfaction-loop (plans/goals/{YYMMDD-HHmm}-{slug}/goal.md, template .claude/templates/goal-contract-template.md). Its single required Success Criterion:
A fresh full $why-review over {target} clears the round's exit bar: rounds 1-2 → PASS with zero validated findings (no finding, weakness, or missing item of any severity); round 3+ → zero validated CRITICAL/HIGH/MEDIUM findings, with any remaining LOW findings recorded as deferred rather than fixed.
Record the round cap (default 3), the severity floor (LOW non-blocking from round 3), and the target reference in Constraints.
Step 0b — Bind the Convergence Loop (protocol-first; /goal is an optional accelerator)
The convergence loop is bound by TWO layers. The protocol loop (Steps 1–2) is the BINDING mechanism and MUST be self-driven by you, the running agent, on every host — with or without any command or hook. The /goal command is an OPTIONAL accelerator layered on top; it is never the primary mechanism, and its absence NEVER weakens the loop. This mirrors the project rule that hooks/trackers are accelerators only — correctness must not depend on them.
1. Protocol loop — ALWAYS binding (hook/command-independent). You are personally responsible for not stopping until the loop converges or bounded-escalates. This binds Claude, Codex, and Copilot equally, whether or not /goal exists:
Repeatedly run $why-review INLINE over {target}. After each review, apply every VALIDATED finding's fix at its owning layer, then re-run a FRESH full $why-review over the CHANGED target. Do NOT stop while the last review still produced findings that BLOCK at the current round's bar. Converge when a fresh full $why-review clears that bar: rounds 1-2 → PASS with zero validated findings; round 3+ → zero validated CRITICAL/HIGH/MEDIUM (LOW-only ENDS the loop, with the LOWs recorded as deferred). Cap at {N=5} rounds; if blocking findings do not shrink across 2 consecutive rounds, findings increase, or the cap is hit with CRITICAL/HIGH/MEDIUM still open → STOP and escalate by asking the user directly. Never loop open-ended.
Treat this as a standing obligation you re-read at every Step 2 checkpoint — NOT a one-time note you can rationalize away after the first fix cycle. The Goal Contract's required Success Criterion (Step 0) is its durable, host-independent record.
2. /goal command — invoke as an accelerator WHEN AVAILABLE. If a /goal command exists and you are permitted to run it in this environment, ALSO invoke it (a real tool/command call, NOT a paraphrase, NOT a Goal Contract file substituted for it) with the SAME condition, so a session Stop hook mechanically enforces the loop:
/goal why-review convergence loop: repeatedly run $why-review INLINE over {target}. After each review, apply every VALIDATED finding's fix at its owning layer, then re-run a FRESH full $why-review over the CHANGED target. If findings>0 → apply fixes and run another round; if a fresh full $why-review returns PASS with zero validated findings → CONVERGED, clear the gate. Do NOT stop while the last review still produced findings. Cap at {N=5} rounds; if findings do not shrink across 2 consecutive rounds, findings increase, or the cap is hit with findings still open → STOP and escalate by asking the user directly. Never loop open-ended.
The /goal Stop hook blocks stopping until the condition holds and auto-clears when met — do not tell the user to clear it.
If /goal is unavailable, unregistered, or not permitted (e.g. Codex/Copilot, or a Claude run without the command): DO NOT error, DO NOT block, and DO NOT invent a stand-in gate. Record ONE line in the Goal Contract — /goal accelerator unavailable — loop bound by protocol (Steps 1–2) + this Goal Contract — and proceed. The protocol loop above plus the Goal Contract are the same gate, enforced by discipline instead of a hook.
Nested gates (by design, safe): each inner $why-review round self-binds its OWN review-loop obligation (and installs its own /goal gate WHEN available, why-review/SKILL.md:57-76) that clears when THAT round's findings are all validated CLEAN. This OUTER loop persists across rounds and subsumes the inner ones (a converged loop implies every inner round ended with validated findings). All self-clear on satisfaction — no orphaned gate. Do NOT tell the user to clear either.
Step 1 — Round Loop ($why-review → $fix → log)
Each round couples the two halves — review to find, fix to resolve. For each round R (starting at 1), do ALL of:
- Run
$why-review INLINE on {target} via the skill invocation (NEVER the spawn_agent tool). Let it run its full adversarial review + its own internal Findings Validation Gate, so the findings it returns are already validated (proof-backed, ≥85% survival bar).
- Read the validated finding set from its report (
plans/reports/why-review-*.md). If the verdict is PASS with zero findings → this round converged; go to Step 2 (no fix half needed).
- Trade-Off Gate on the fix set (BLOCKING — before any edit lands). For EACH validated finding's fix, ask the 3 questions: (a) is there any trade-off? name what applying it sacrifices — future change cost, complexity, performance, coupling, reversibility, migration/ops burden, blast radius, security, testability, delivery time; "none" is an unfinished analysis, so state the dimensions checked; (b) is it worth it? gain vs cost, who pays, when → WORTH IT / NOT WORTH IT / UNCLEAR; NOT WORTH IT → do NOT apply — report the finding back as a withdrawn-fix note and count it as still-open, never as fixed; (c) is the trade-off material enough to confirm with the user? MATERIAL when irreversible (one-way door) · cost shifted onto another team/ops/maintainer/user · one quality attribute traded for another · a tier/service/event/library boundary crossed · an auth/money/data-integrity/breaking-change path · or the verdict is UNCLEAR → PAUSE the loop and confirm by asking the user directly BEFORE the edit, stating the trade-off, both options, what each sacrifices, and your recommendation. Log each fix's trade-off verdict in the round's Iteration Log entry. — why: the loop's only convergence signal is "did findings shrink?", so a material trade-off rides in unpriced unless a gate stops the fix half specifically.
- Run
$fix on the validated findings (findings>0 only, trade-off gate cleared) — this is the half $why-review never does. Resolve each validated finding at its owning layer: code → $fix (its --target intelligent routing) or a direct edit at the lowest layer (Entity > Service > Handler); plan/PBI → $refine; spec → $spec [update] + $spec [mode=tests]; docs → $docs-update; behavior-changing → honor the finding's dual-feedback (spec verdict + test action per why-review/SKILL.md:360). Fix ONLY validated findings — never an unvalidated or demoted one.
- Append an Iteration Log entry to the Goal Contract: round number, findings count (validated), files/artifacts changed this round (
file:line), fixes applied, per-fix trade-off verdict (WORTH IT / NOT WORTH IT / UNCLEAR + material? + confirmed?), and remaining gaps.
Step 2 — Convergence & Escalation Gate
Evaluate after every round:
| Condition |
Action |
Fresh full $why-review returned PASS with zero validated findings |
CONVERGED → mark the required criterion PASS in the Goal Satisfaction matrix → clear the /goal gate → go to Step 3. |
Round R ≥ 3 AND the fresh review's validated findings are ALL LOW (zero CRITICAL/HIGH/MEDIUM) |
CONVERGED on the severity floor → do NOT run another round for LOW alone → record every remaining LOW as a deferred finding in the recap + Goal Contract → mark the required criterion PASS → go to Step 3. |
Blocking findings > 0 AND round < N AND blocking findings shrank vs prior round |
Clear the Trade-Off Gate (Step 1.3), apply the validated fixes (Step 1.4), then run round R+1 (fresh full re-review of the changed target). Rounds 1-2 count every severity as blocking; round 3+ counts only CRITICAL/HIGH/MEDIUM. |
| A fix carries a MATERIAL trade-off (irreversible · cost shifted elsewhere · quality attribute traded · boundary crossed · high-consequence path · worth-it UNCLEAR) |
PAUSE the loop → confirm by asking the user directly BEFORE applying that fix. Convergence pressure NEVER authorizes deciding a material trade-off for the user. |
| Findings did not shrink across 2 consecutive rounds (same/increasing count) |
STOP & escalate by asking the user directly — a non-converging loop is a signal, not a reason to spin. |
Round cap N hit with CRITICAL/HIGH/MEDIUM still open |
STOP & escalate by asking the user directly — report the still-open findings; do not silently continue. (LOW-only at the cap converges via the severity-floor row above.) |
Increasing findings = STOP. If round R surfaces MORE findings than round R-1, the fixes are regressing the target — STOP and escalate immediately. Never trade one fix for two new findings across rounds.
Step 3 — Recap
Emit a concise convergence recap: rounds run, validated findings per round (the shrinking sequence, split by severity), the fixes applied at each round, the final PASS evidence (zero findings, or zero CRITICAL/HIGH/MEDIUM when the loop ended on the round-3+ severity floor), a ## Deferred LOW Findings (severity floor, round ≥3) list of every LOW left unfixed with file:line, and the Goal Satisfaction matrix (required criterion PASS). Point to each round's $why-review report under plans/reports/ and the Goal Contract Iteration Log. Do NOT commit or push unless the user explicitly asks.
Convergence Detection — Why a Fresh Full Re-Review Is Required
A round converges ONLY when a $why-review that ran over the current, post-fix target returns PASS with an empty validated-finding set. Both properties are required because:
- Fresh over the changed target — a PASS verdict from a review that predates the last fix proves nothing about the fix. Every applied fix invalidates the prior verdict (
why-review/SKILL.md:565); the loop MUST re-review after fixing, never reuse a stale clean verdict.
- Zero blocking validated findings —
$why-review's own gate already dropped inflated/unproven findings below the ≥85% bar (why-review/SKILL.md:361); convergence rides on that validated set, so the loop never chases a nit the review itself would demote. "Blocking" means every severity in rounds 1-2, and CRITICAL/HIGH/MEDIUM only from round 3 — by round 3 the surviving LOWs are polish whose fix cost exceeds the risk of deferring them, so continuing to spin on them buys nothing and burns the round cap that a real defect might need. — why: a loop that cannot exit on nits converges on exhaustion instead of on quality.
When findings remain but cannot be fixed (owner/product input needed) → escalate, do not loop. When a fix lands but the next fresh review still finds issues → run another round. Convergence is a fixed point, not a single clean read.
IMPORTANT MANDATORY sequence: Step 0 (resolve target + Goal Contract) → Step 0b (bind the convergence loop: protocol loop primary + optional /goal accelerator) → Step 1 (round loop: run $why-review INLINE → clear the Trade-Off Gate on the fix set → run $fix on validated findings → log) → Step 2 (converge on a zero-findings fresh review / escalate on non-progress) → Step 3 (recap).
Goal Contract Satisfaction Loop — Persist the user goal in an external file, execute against it, and loop review/fix until every saved required criterion passes or a blocker escalates. Bounded closed loop — NEVER open-ended autonomous exploration.
- Resolve the active goal (in order): active plan
goal.md → plans/goals/{YYMMDD-HHmm}-{slug}/goal.md → create a new Goal Contract from the current user request (template: .claude/templates/goal-contract-template.md).
- Required sections: Original Request, Purpose, Success Criteria (checkboxes; mark required vs optional), Constraints, Evidence Required, Iteration Log, Goal Satisfaction matrix.
- Before work: read the active goal and map planned work to saved success criteria — execution serves the saved criteria, never chat memory alone.
- After execution/verification: append an Iteration Log entry — result, evidence references (
file:line, command output, report path), remaining gaps.
- Review gate: emit a Goal Satisfaction matrix —
| Success Criterion | Evidence | Status | with PASS/FAIL/BLOCKED. Overall PASS requires every required criterion PASS.
- Loop rule (retry): required criterion FAIL → validate the gap is real → fix → re-review only the affected criteria. Stop cleanly when all required criteria PASS.
- Escalation rule (stop): two consecutive iterations with no criterion progressing, or a blocker needing user input → mark the criterion BLOCKED with a user-facing reason and escalate. NEVER loop indefinitely.
- Skip rule: tiny conversational tasks may skip the goal file ONLY with a recorded one-line reason. User-accepted gate skips are recorded in the goal file with reason and scope.
- Security: NEVER store secrets, tokens, credentials, or private customer data in goal files — store evidence references and redact sensitive values.
Blocked until: active goal resolved (or skip reason recorded) · saved success criteria read before edits · iteration evidence appended after execution · Goal Satisfaction matrix emitted before any PASS verdict.
Critical Thinking Mindset — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
Anti-hallucination: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
AI Mistake Prevention — Failure modes to avoid on every task:
Re-read files after context changes. Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
Verify generated content against source evidence. AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
Check downstream references before deleting or renaming. Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
Trace the full impact chain after edits. Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
Verify ALL affected outputs, not just the first. One green check is not all green checks; validate every output surface the change can affect.
Assume existing values are intentional — ask WHY before changing OR flagging one as a defect. Before changing or reporting a constant, limit, flag, cutoff, wording, or pattern, read nearby context and history, the CALLER's ordering, and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard.
Surface ambiguity before acting — don't pick silently. Multiple valid interpretations require an explicit question or stated assumption with risk.
Assert the outcome your system owns, not the intermediate state your infrastructure owns. When verifying async work, assert the final business state — never the delivery/retry bookkeeping held in shared infrastructure that any co-running process can write. Such a check passes when run alone and flakes the moment anything else shares that infrastructure.
Keep shared guidance role-relevant. Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
Trade-Off Interrogation Gate — ALWAYS ask these THREE questions before ANY verdict, score, finding, or recommendation — about the thing under review AND about every recommendation YOU make. — why: naming a benefit without its price is an endorsement, not a review; the costliest trade-offs are the ones nobody wrote down.
- Is there any trade-off? Name what it SACRIFICES. "None" / "pure win" is an unfinished analysis, NOT an answer — to claim none, state which dimensions you checked and why each is unaffected: future change cost · complexity · performance/latency · memory/cost · coupling · reversibility · migration burden · operational load · blast radius · security posture · testability · team skill/ramp · delivery time · UX.
- Is it worth it? Weigh gain against sacrifice EXPLICITLY — what is gained (with a metric) · what it costs · WHO pays · WHEN it comes due — then emit WORTH IT / NOT WORTH IT / UNCLEAR. "Better" with no metric and no cost FAILS this question. NOT WORTH IT → withdraw or replace the recommendation, never keep it as-is.
- Is the trade-off material enough to CONFIRM WITH THE USER? A material trade-off is the user's call, never yours. MATERIAL when ANY holds: irreversible / one-way door (data migration, public contract, storage format, vendor lock-in) · cost shifted onto someone else (another team, ops/on-call, future maintainer, end user) · one quality attribute traded for another (correctness↔speed, security↔convenience, latency↔cost, simplicity↔flexibility) · a boundary crossed (client↔server tier, service contract, event contract, shared library) · a high-consequence path (auth, money, data integrity, breaking change, High/Medium residual risk) · the worth-it verdict is UNCLEAR.
MATERIAL → STOP and confirm by asking the user directly BEFORE the verdict stands — state the trade-off, both options, what each sacrifices, and your recommendation. NOT material → record it inline with a one-line justification and proceed.
Non-asking execution contexts — ESCALATE BY HANDOFF, never by silence. ask the user directly reaches only the main interactive agent: a sub-agent cannot ask the user, and a terminal/verdict-only mode asks nothing by design. When you are running in such a context, the obligation is redirected, never waived — do ALL of: (a) complete questions 1 and 2 normally; (b) decide materiality and record it in the Trade-Off Assessment row with confirmed? = NO — cannot ask from this context; (c) name the unconfirmed MATERIAL trade-off explicitly in your returned summary/verdict so the CALLER (or parent orchestrator) escalates it by asking the user directly on your behalf — a material trade-off mentioned only inside a report file on disk is NOT a handoff; (d) do not emit an unqualified PASS — mark the verdict as carrying an unconfirmed material trade-off, so the caller's gate stays closed until the user answers. The caller inherits the escalation duty the moment it reads your return.
This carve-out is about reachability, not convenience: it applies ONLY where the tool genuinely cannot reach the user (spawned sub-agent, terminal validate/verdict-only mode, non-interactive/headless run). It is NEVER a licence to skip the question, to self-approve a one-way door, or to downgrade materiality because asking is inconvenient — if you CAN ask, you MUST ask.
Emit a Trade-Off Assessment row per reviewed decision and per recommendation: | decision | sacrifices | gain (metric) | who pays, when | WORTH IT/NOT/UNCLEAR | material? | confirmed? |.
BLOCKED until: trade-off named (or dimensions-checked justification given) · worth-it verdict emitted · materiality decided · every MATERIAL trade-off either confirmed with the user OR — in a non-asking context — handed off in the returned verdict for the caller to confirm. A MATERIAL trade-off that is neither confirmed nor handed off can NEVER be PASS, and NEVER gets buried as a Low-severity note.
NEVER answer "no trade-off" without checking · decide a material trade-off silently on the user's behalf · let convergence/delivery pressure authorize walking through a one-way door · bundle several material trade-offs into one vague "proceed?".
- MANDATORY Resolve the active Goal Contract BEFORE work (active plan
goal.md → plans/goals/{YYMMDD-HHmm}-{slug}/goal.md → create from current request) and read saved success criteria before editing.
- MANDATORY Append iteration evidence after execution; emit a Goal Satisfaction matrix (PASS/FAIL/BLOCKED) before reporting PASS; loop on validated FAIL; escalate repeated no-progress or blockers. NEVER store secrets in goal files.
MUST ATTENTION apply critical + sequential thinking — every claim needs appropriate traced evidence (file:line for repo/code claims; source URL or artifact section for research, product, content, and docs claims); confidence >80% to act, <60% DO NOT recommend. Anti-hallucination: never present guess as fact, admit uncertainty freely, cross-reference independently, stay skeptical of own confidence.
MUST ATTENTION apply AI mistake prevention — verify generated content against evidence, trace downstream references before deleting or renaming, verify all affected outputs, re-read files after context loss, and surface ambiguity before acting.
- MANDATORY MUST ATTENTION ALWAYS ASK THE 3 TRADE-OFF QUESTIONS — on the thing under review AND on every recommendation you make: (1) is there any trade-off? name what it SACRIFICES (change cost · complexity · perf · coupling · reversibility · migration · ops load · blast radius · security · testability · delivery time · UX) — "none"/"pure win" is an unfinished analysis, so state the dimensions checked; (2) is it worth it? gain (with a metric) vs cost, WHO pays, WHEN → emit WORTH IT / NOT WORTH IT / UNCLEAR; NOT WORTH IT → withdraw or replace it; (3) is it material enough to confirm with the user? irreversible/one-way door · cost shifted onto another team/ops/maintainer/user · one quality attribute traded for another · a tier/service/event/library boundary crossed · auth/money/data-integrity/breaking-change/High-or-Medium-risk path · verdict UNCLEAR → STOP and confirm by asking the user directly BEFORE the verdict.
- MANDATORY A MATERIAL trade-off with no user confirmation can NEVER be PASS; NEVER bury one as a Low-severity note, NEVER decide it silently, and NEVER let delivery or convergence pressure authorize a one-way door. — why: an un-walked-back one-way door is the user's call to make, not the reviewer's.
- MANDATORY — non-asking contexts escalate BY HANDOFF, never by silence. ask the user directly reaches only the main interactive agent: a sub-agent cannot ask the user, and a terminal/verdict-only mode asks nothing by design. There the duty is REDIRECTED, not waived — still name the trade-off, still decide materiality, record
confirmed? = NO — cannot ask from this context, state the unconfirmed MATERIAL trade-off in your RETURNED verdict/summary so the CALLER escalates it (a note only in an on-disk report is not a handoff), and never emit an unqualified PASS. Applies ONLY where the user is genuinely unreachable (spawned sub-agent, terminal validate mode, headless run) — if you CAN ask, you MUST ask.
Project Protocol Overlay — Before executing this skill, resolve any PROJECT overlay rules layered onto it: match this skill's name against the Target column of the project's skill-protocol index (docs/project-reference/skill-protocols-reference.md by default; a referenceDocs entry in docs/project-config.json overrides the path), taking the most specific matching tier ONLY — exact name > glob > *. That precedence orders overlays against EACH OTHER, never against this skill. Read ONLY the matched bodies, resolved as <protocols-dir>/<Name>.md; a row's Body link is display text, never a read path. A matched body that is missing or malformed is REPORTED and skipped — never reconstructed from the index Description. No index, or no match -> proceed with no overlay, silently. Full contract: .claude/skills/project-skill-protocol/references/registry.md.
Overlays are ADDITIVE ONLY: they ADD rules on top of this skill's own protocol and NEVER replace, override, disable, or reinterpret a rule it already states — removing every overlay must return this skill to exactly its documented behavior. An overlay is a BRIEF, not an authority escalation: it can NEVER waive a workflow gate, git discipline, a review gate, or a user-confirmation gate. A genuine overlay-vs-skill conflict, or two equally-specific overlays that directly contradict -> surface both to the user; NEVER resolve silently.
MUST ATTENTION resolve project protocol overlays for this skill BEFORE executing — most specific matching tier only (exact > glob > *, which ranks overlays against each other, NEVER against this skill), read only matched bodies at <protocols-dir>/<Name>.md; a missing or malformed body is reported, never reconstructed. Overlays are ADDITI
…(truncated)
1---2name: why-review-loop3description: [Code Quality] Use when you need to combine /why-review + /fix in a recursive loop — each round runs /why-review to find validated findings then /fix to resolve them, then loops again over the CHANGED target until a fresh full /why-review produces zero findings (nothing left to fix).4---5
6> Codex compatibility note:
7>
8> - Invoke repository skills with `$skill-name` in Codex; this mirrored copy rewrites legacy Claude `/skill-name` references.
9> - Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
10> - User-question prompts mean to ask the user directly in Codex.
11> - Ignore Claude-specific mode-switch instructions when they appear.
12> - Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
13> - Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required `spawn_agent` subagent(s) for that task.
14> - Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
15> - For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
16> - If a required step/tool cannot run in this environment, stop and ask the user before adapting.
17
18<!-- CODEX:PROJECT-REFERENCE-LOADING:START -->
19
20## Codex Project-Reference Loading (No Hooks)
21
22Codex uses static project-reference loading instead of runtime-injected project docs.
23When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
24
25**Always read:**
26
27- `docs/project-config.json` (project-specific paths, commands, modules, and workflow/test settings)
28- `docs/project-reference/docs-index-reference.md` (routes to the full `docs/project-reference/*` catalog)
29- `docs/project-reference/lessons.md` (always-on guardrails and anti-patterns)
30
31**Missing/stale context route:** If `docs/project-config.json`, the docs index, `lessons.md`, `CLAUDE.md`, `AGENTS.md`, or any task-required reference doc is missing or stale, auto-run `$project-init` or the narrow setup route (`$project-config`, `$docs-init`, `$scan-all`, `$scan --target=<key>`, `$claude-md-init`) before ordinary project-specific work. If Codex mirrors or `AGENTS.md` are missing/stale, ask the user to run `$sync-codex`; do not auto-run it.
32
33**Situation-based docs:**
34
35- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra): `project-structure-reference.md`
36- Backend/CQRS/API/domain/entity changes: `backend-patterns-reference.md`, `domain-entities-reference.md`
37- Frontend/UI/styling/design-system: `frontend-patterns-reference.md`, `scss-styling-guide.md`, `design-system/README.md`
38- Spec authoring, `docs/specs/` pathing, or TC format: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`
39- Behavior/public-contract changes or spec-test-code sync: `workflow-spec-test-code-cycle-reference.md` plus the spec docs above
40- Derived spec indexes/ERDs/reimplementation guides: `spec-system-reference.md` and source Feature Specs under `docs/specs/`
41- Integration test implementation/review: `integration-test-reference.md`
42- E2E test implementation/review: `e2e-test-reference.md`
43- Code review/audit work: `code-review-rules.md` plus domain docs above based on changed files
44
45Do not read all docs blindly. Start from `docs-index-reference.md`, then open only relevant files for the task.
46
47<!-- CODEX:PROJECT-REFERENCE-LOADING:END -->
48
49<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:START -->
50
51> **[BLOCKING]** Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
52> **[BLOCKING]** Before each step or sub-skill call, update task tracking: set `in_progress` when step starts, set `completed` when step ends.
53> **[BLOCKING]** Every completed/skipped step MUST include brief evidence or explicit skip reason.
54> **[BLOCKING]** If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
55
56<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->
57
58## Quick Summary
59
60**Goal:** Drive a review target to a **clean pass** by pairing `$why-review` with `$fix` in a recursive loop — each round runs `$why-review` INLINE to surface validated findings, then `$fix` to resolve them, then loops again over the CHANGED target — stopping when a complete `$why-review` pass clears the round's exit bar: **zero findings** in rounds 1-2, and **zero CRITICAL/HIGH/MEDIUM** from round 3 (LOW-only ENDS the loop, deferred not fixed).
61
62**Summary:**
63
64- **Each round = `$why-review` + `$fix`** — `$why-review` is review-ONLY and never edits the target, so the loop MUST pair it with a fix half; one without the other never converges.
65- **Steps (in order):** (0) resolve target + Goal Contract → (0b) bind the convergence loop (protocol loop primary + optional `/goal` accelerator) → (1) round loop { run `$why-review` INLINE → clear the **Trade-Off Gate** on the fix set → run `$fix` on the VALIDATED findings at the owning layer → log iteration } → (2) converge on a zero-findings round OR escalate on non-progress → (3) recap.
66- **Convergence:** stop ONLY when a **fresh full** `$why-review` over the CURRENT (post-fix) target clears that round's exit bar — not a stale PASS predating the last fix.
67- **Severity floor — from round 3, LOW stops blocking.** Rounds 1-2 converge on an **empty validated-finding set** (any severity). **From round 3 the bar is zero validated CRITICAL/HIGH/MEDIUM — a round whose validated findings are ALL LOW ENDS the loop.** Never open another round to fix LOW alone; list every deferred LOW in the recap and Goal Contract instead, and NEVER re-tier a real CRITICAL/HIGH/MEDIUM down to LOW to reach the exit.
68- **Inline invariant:** run `$why-review` via the skill invocation, NEVER the `spawn_agent` tool — it self-binds its OWN review-loop obligation (and a session `/goal` gate WHEN available, `why-review/SKILL.md:57-76`), which a sub-agent cannot own or carry back to this loop.
69- **Apply ONLY validated findings:** `$why-review` already validates its findings to the ≥85% survival bar; the loop applies THOSE, at the lowest owning layer (Entity > Service > Handler), routed by target type — NEVER unvalidated findings.
70- **Bounded:** round cap default 3; findings not shrinking across 2 rounds, or cap hit with findings still open → **STOP & escalate** by asking the user directly. Increasing findings → STOP (fixes regressing).
71- **TRADE-OFF GATE before every fix (ALWAYS ASK):** (1) **is there any trade-off in this fix?** name what it sacrifices — "none" is an unfinished analysis; (2) **is it worth it?** gain vs cost, who pays, when → WORTH IT / NOT WORTH IT / UNCLEAR — NOT WORTH IT → do NOT apply, report it back instead; (3) **is the trade-off material enough to confirm with the user?** irreversible · cost shifted elsewhere · quality attribute traded · boundary crossed · high-consequence path · UNCLEAR → **STOP the loop and confirm by asking the user directly BEFORE applying**. NEVER auto-apply a material-trade-off fix just because the loop wants to converge.
72
73**Why this skill exists (READ FIRST — it is the whole justification):** `$why-review` is **review-only** — `why-review/SKILL.md:330` (_"Review only — do NOT modify target files or implement changes"_) and `:76` (_"why-review fixes its OWN findings set, not code… Code/spec/test fixes remain the caller's job"_). Its internal self-recursive `/goal` loop (`why-review/SKILL.md:57-76`) converges its own **findings REPORT** to CLEAN — every surviving finding proof-backed, validated, ≥85% confidence — but it **never touches the code and never re-reviews a fixed target**. So a finding that demands a code/spec/doc change is validated and handed off, yet **nothing loops back to confirm the FIX is correct or that it introduced no new defect**. This skill closes that outer loop: it applies the validated fixes and re-runs a **fresh full** `$why-review` over the changed target until zero findings remain — catching fix-induced regressions and proving each fix actually resolved its finding. Without it, "why-review passed, then I fixed the findings" ships those fixes unreviewed.
74
75**Workflow:** resolve target + Goal Contract → bind the convergence loop (protocol loop + optional `/goal` accelerator) → **round loop** { run `$why-review` INLINE → clear the Trade-Off Gate on the fix set (trade-off? worth it? material → confirm with user) → run `$fix` on the validated findings at owning layer → log iteration } → converge when a fresh full review yields zero findings → recap.
76
77**Key Rules:**
78
79- **Each round pairs `$why-review` (find) + `$fix` (resolve).** `$why-review` is review-only (`why-review/SKILL.md:76,330`) — it produces validated findings but never edits the target; `$fix` is the half that lands the change. A round is incomplete until BOTH have run (or the review returned zero findings).
80- **MUST run INLINE in the main session — NEVER dispatch `$why-review` as a sub-agent.** It self-binds its own review-loop obligation (and a session `/goal` gate when available, `why-review/SKILL.md:57-76`); as a sub-agent that in-session guarantee is silently lost. This loop skill therefore also runs inline.
81- **Convergence = a fresh full `$why-review` over the post-fix target clears the round's exit bar.** Rounds 1-2: PASS with an empty validated-finding set. **Round 3+: zero validated CRITICAL/HIGH/MEDIUM — LOW-only converges.** A PASS produced BEFORE the latest fix landed does NOT count — re-review the changed target.
82- **The severity floor bounds ITERATION, never the standard.** It ends the loop; it never authorizes shipping a known CRITICAL/HIGH/MEDIUM, never lowers `$why-review`'s ≥85% finding-survival bar, and never applies to a binary gate (a failing test is a failure, not a LOW finding).
83- **`$fix` applies ONLY validated findings**, at the lowest owning layer, routed by target type (code → `$fix` with its intelligent routing, or a direct edit at Entity/Service; plan/PBI → `$refine`; spec → `$spec [update]` + `$spec [mode=tests]`; docs → `$docs-update`; tests → `$integration-test`). NEVER apply an unvalidated or demoted finding.
84- **The target base is FIXED across rounds; its content changes as fixes land.** Re-review the SAME target (same plan/diff/artifact) each round so convergence is measured against a stable subject.
85- **Round cap (default 3)** and **findings-not-shrinking / increasing → STOP & escalate** by asking the user directly. NEVER loop open-ended.
86- **ALWAYS ask the 3 trade-off questions before applying ANY fix** — is there a trade-off? is it worth it? is it material enough to confirm with the user? A MATERIAL trade-off (irreversible · cost shifted to another team/ops/maintainer/user · one quality attribute traded for another · tier/service/event/library boundary crossed · auth/money/data-integrity/breaking-change path · worth-it verdict UNCLEAR) **PAUSES the loop for an ask the user directly before the fix lands** — convergence pressure NEVER authorizes walking through a one-way door on the user's behalf. — why: an autonomous fix loop is exactly where an unpriced trade-off ships silently, because each round only asks "did findings shrink?".
87
88---
89
90## First Principle — Convergence, Not Motion
91
92> A round that changes the target is progress **only if** the next fresh review finds fewer things to fix.
93> The loop exists to reach a fixed point (no blocking findings), not to keep editing the target.
94> The bar tightens by round: everything blocks in rounds 1-2; from round 3 only CRITICAL/HIGH/MEDIUM block, so a LOW-only round is the fixed point.
95> If findings stop shrinking, that is a signal to **escalate**, not to spin another round.
96
97---
98
99## Step 0 — Resolve Target + Goal Contract (FIRST ACTION)
100
1011. **Parse the review target** from the user prompt into a stable, reusable target reference — exactly the kinds `$why-review` resolves (`why-review/SKILL.md:142-161`):
102 - **Plan / PBI / story** — a `plan.md` + `phase-*.md` dir, or a named PBI/story artifact.
103 - **Code change** — a commit SHA, PR/merge commit, branch-to-branch or PR diff (e.g. `git diff develop...HEAD`), or uncommitted working-tree changes.
104 - **Docs / spec / report** — a target artifact path whose claims are checked against source evidence.
105 - Record the target type, its evidence, and confidence. **NEVER silently convert target types** (`why-review/SKILL.md:160`).
1062. **Resolve/create the Goal Contract** per `SYNC:goal-contract-satisfaction-loop` (`plans/goals/{YYMMDD-HHmm}-{slug}/goal.md`, template `.claude/templates/goal-contract-template.md`). Its single **required** Success Criterion:
107 > _A fresh full `$why-review` over `{target}` clears the round's exit bar: **rounds 1-2** → PASS with **zero validated findings** (no finding, weakness, or missing item of any severity); **round 3+** → **zero validated CRITICAL/HIGH/MEDIUM findings**, with any remaining LOW findings recorded as deferred rather than fixed._
108 > Record the round cap (default 3), the severity floor (LOW non-blocking from round 3), and the target reference in **Constraints**.
109
110## Step 0b — Bind the Convergence Loop (protocol-first; `/goal` is an optional accelerator)
111
112The convergence loop is bound by TWO layers. The **protocol loop (Steps 1–2) is the BINDING mechanism** and MUST be self-driven by you, the running agent, on every host — with or without any command or hook. The **`/goal` command is an OPTIONAL accelerator** layered on top; it is never the primary mechanism, and its absence NEVER weakens the loop. This mirrors the project rule that hooks/trackers are accelerators only — correctness must not depend on them.
113
114**1. Protocol loop — ALWAYS binding (hook/command-independent).** You are personally responsible for not stopping until the loop converges or bounded-escalates. This binds Claude, Codex, and Copilot equally, whether or not `/goal` exists:
115
116> Repeatedly run `$why-review` INLINE over `{target}`. After each review, apply every VALIDATED finding's fix at its owning layer, then re-run a FRESH full `$why-review` over the CHANGED target. Do NOT stop while the last review still produced findings that BLOCK at the current round's bar. Converge when a fresh full `$why-review` clears that bar: **rounds 1-2** → PASS with zero validated findings; **round 3+** → zero validated CRITICAL/HIGH/MEDIUM (LOW-only ENDS the loop, with the LOWs recorded as deferred). Cap at `{N=5}` rounds; if blocking findings do not shrink across 2 consecutive rounds, findings increase, or the cap is hit with CRITICAL/HIGH/MEDIUM still open → STOP and escalate by asking the user directly. Never loop open-ended.
117
118Treat this as a standing obligation you re-read at every Step 2 checkpoint — NOT a one-time note you can rationalize away after the first fix cycle. The Goal Contract's required Success Criterion (Step 0) is its durable, host-independent record.
119
120**2. `/goal` command — invoke as an accelerator WHEN AVAILABLE.** If a `/goal` command exists and you are permitted to run it in this environment, ALSO invoke it (a real tool/command call, NOT a paraphrase, NOT a Goal Contract file substituted for it) with the SAME condition, so a session Stop hook mechanically enforces the loop:
121
122```
123/goal why-review convergence loop: repeatedly run $why-review INLINE over {target}. After each review, apply every VALIDATED finding's fix at its owning layer, then re-run a FRESH full $why-review over the CHANGED target. If findings>0 → apply fixes and run another round; if a fresh full $why-review returns PASS with zero validated findings → CONVERGED, clear the gate. Do NOT stop while the last review still produced findings. Cap at {N=5} rounds; if findings do not shrink across 2 consecutive rounds, findings increase, or the cap is hit with findings still open → STOP and escalate by asking the user directly. Never loop open-ended.
124```
125
126The `/goal` Stop hook blocks stopping until the condition holds and auto-clears when met — do not tell the user to clear it.
127
128**If `/goal` is unavailable, unregistered, or not permitted** (e.g. Codex/Copilot, or a Claude run without the command): DO NOT error, DO NOT block, and DO NOT invent a stand-in gate. Record ONE line in the Goal Contract — `/goal accelerator unavailable — loop bound by protocol (Steps 1–2) + this Goal Contract` — and proceed. The protocol loop above plus the Goal Contract are the same gate, enforced by discipline instead of a hook.
129
130> **Nested gates (by design, safe):** each inner `$why-review` round self-binds its OWN review-loop obligation (and installs its own `/goal` gate WHEN available, `why-review/SKILL.md:57-76`) that clears when THAT round's findings are all validated CLEAN. This OUTER loop persists across rounds and **subsumes** the inner ones (a converged loop implies every inner round ended with validated findings). All self-clear on satisfaction — no orphaned gate. Do NOT tell the user to clear either.
131
132## Step 1 — Round Loop (`$why-review` → `$fix` → log)
133
134Each round couples the two halves — **review to find, fix to resolve.** For each round `R` (starting at 1), do ALL of:
135
1361. **Run `$why-review` INLINE** on `{target}` via the skill invocation (NEVER the `spawn_agent` tool). Let it run its full adversarial review + its own internal Findings Validation Gate, so the findings it returns are already **validated** (proof-backed, ≥85% survival bar).
1372. **Read the validated finding set** from its report (`plans/reports/why-review-*.md`). If the verdict is PASS with **zero** findings → this round converged; go to Step 2 (no fix half needed).
1383. **Trade-Off Gate on the fix set (BLOCKING — before any edit lands).** For EACH validated finding's fix, ask the 3 questions: (a) **is there any trade-off?** name what applying it sacrifices — future change cost, complexity, performance, coupling, reversibility, migration/ops burden, blast radius, security, testability, delivery time; "none" is an unfinished analysis, so state the dimensions checked; (b) **is it worth it?** gain vs cost, who pays, when → **WORTH IT / NOT WORTH IT / UNCLEAR**; NOT WORTH IT → do NOT apply — report the finding back as a withdrawn-fix note and count it as still-open, never as fixed; (c) **is the trade-off material enough to confirm with the user?** MATERIAL when irreversible (one-way door) · cost shifted onto another team/ops/maintainer/user · one quality attribute traded for another · a tier/service/event/library boundary crossed · an auth/money/data-integrity/breaking-change path · or the verdict is UNCLEAR → **PAUSE the loop and confirm by asking the user directly BEFORE the edit**, stating the trade-off, both options, what each sacrifices, and your recommendation. Log each fix's trade-off verdict in the round's Iteration Log entry. — why: the loop's only convergence signal is "did findings shrink?", so a material trade-off rides in unpriced unless a gate stops the fix half specifically.
1394. **Run `$fix` on the validated findings** (findings>0 only, trade-off gate cleared) — this is the half `$why-review` never does. Resolve each validated finding at its owning layer: code → `$fix` (its `--target` intelligent routing) or a direct edit at the lowest layer (Entity > Service > Handler); plan/PBI → `$refine`; spec → `$spec [update]` + `$spec [mode=tests]`; docs → `$docs-update`; behavior-changing → honor the finding's dual-feedback (spec verdict + test action per `why-review/SKILL.md:360`). Fix ONLY validated findings — never an unvalidated or demoted one.
1405. **Append an Iteration Log entry** to the Goal Contract: round number, findings count (validated), files/artifacts changed this round (`file:line`), fixes applied, per-fix trade-off verdict (WORTH IT / NOT WORTH IT / UNCLEAR + material? + confirmed?), and remaining gaps.
141
142## Step 2 — Convergence & Escalation Gate
143
144Evaluate after every round:
145
146| Condition | Action |
147| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
148| Fresh full `$why-review` returned **PASS with zero validated findings** | **CONVERGED** → mark the required criterion PASS in the Goal Satisfaction matrix → clear the `/goal` gate → go to Step 3. |
149| Round `R ≥ 3` AND the fresh review's validated findings are **ALL LOW** (zero CRITICAL/HIGH/MEDIUM) | **CONVERGED on the severity floor** → do NOT run another round for LOW alone → record every remaining LOW as a deferred finding in the recap + Goal Contract → mark the required criterion PASS → go to Step 3. |
150| Blocking findings > 0 AND round `< N` AND blocking findings shrank vs prior round | Clear the Trade-Off Gate (Step 1.3), apply the validated fixes (Step 1.4), then run round `R+1` (fresh full re-review of the changed target). Rounds 1-2 count every severity as blocking; round 3+ counts only CRITICAL/HIGH/MEDIUM. |
151| A fix carries a **MATERIAL** trade-off (irreversible · cost shifted elsewhere · quality attribute traded · boundary crossed · high-consequence path · worth-it UNCLEAR) | **PAUSE the loop → confirm by asking the user directly BEFORE applying that fix.** Convergence pressure NEVER authorizes deciding a material trade-off for the user. |
152| Findings did **not shrink** across 2 consecutive rounds (same/increasing count) | **STOP & escalate** by asking the user directly — a non-converging loop is a signal, not a reason to spin. |
153| Round cap `N` hit with CRITICAL/HIGH/MEDIUM still open | **STOP & escalate** by asking the user directly — report the still-open findings; do not silently continue. (LOW-only at the cap converges via the severity-floor row above.) |
154
155> **Increasing findings = STOP.** If round `R` surfaces MORE findings than round `R-1`, the fixes are regressing the target — STOP and escalate immediately. Never trade one fix for two new findings across rounds.
156
157## Step 3 — Recap
158
159Emit a concise convergence recap: rounds run, validated findings per round (the shrinking sequence, split by severity), the fixes applied at each round, the final PASS evidence (zero findings, or zero CRITICAL/HIGH/MEDIUM when the loop ended on the round-3+ severity floor), a `## Deferred LOW Findings (severity floor, round ≥3)` list of every LOW left unfixed with `file:line`, and the Goal Satisfaction matrix (required criterion PASS). Point to each round's `$why-review` report under `plans/reports/` and the Goal Contract Iteration Log. Do NOT commit or push unless the user explicitly asks.
160
161---
162
163## Convergence Detection — Why a Fresh Full Re-Review Is Required
164
165A round converges ONLY when a `$why-review` that ran over the **current, post-fix** target returns PASS with an empty validated-finding set. Both properties are required because:
166
167- **Fresh over the changed target** — a PASS verdict from a review that predates the last fix proves nothing about the fix. Every applied fix invalidates the prior verdict (`why-review/SKILL.md:565`); the loop MUST re-review after fixing, never reuse a stale clean verdict.
168- **Zero _blocking_ validated findings** — `$why-review`'s own gate already dropped inflated/unproven findings below the ≥85% bar (`why-review/SKILL.md:361`); convergence rides on that validated set, so the loop never chases a nit the review itself would demote. "Blocking" means every severity in rounds 1-2, and CRITICAL/HIGH/MEDIUM only from round 3 — by round 3 the surviving LOWs are polish whose fix cost exceeds the risk of deferring them, so continuing to spin on them buys nothing and burns the round cap that a real defect might need. — why: a loop that cannot exit on nits converges on exhaustion instead of on quality.
169
170When findings remain but cannot be fixed (owner/product input needed) → **escalate**, do not loop. When a fix lands but the next fresh review still finds issues → run another round. Convergence is a fixed point, not a single clean read.
171
172---
173
174**IMPORTANT MANDATORY sequence:** Step 0 (resolve target + Goal Contract) → Step 0b (bind the convergence loop: protocol loop primary + optional `/goal` accelerator) → Step 1 (round loop: run `$why-review` INLINE → clear the Trade-Off Gate on the fix set → run `$fix` on validated findings → log) → Step 2 (converge on a zero-findings fresh review / escalate on non-progress) → Step 3 (recap).
175
176<!-- SYNC:goal-contract-satisfaction-loop -->
177
178> **Goal Contract Satisfaction Loop** — Persist the user goal in an external file, execute against it, and loop review/fix until every saved required criterion passes or a blocker escalates. Bounded closed loop — NEVER open-ended autonomous exploration.
179>
180> 1. **Resolve the active goal** (in order): active plan `goal.md` → `plans/goals/{YYMMDD-HHmm}-{slug}/goal.md` → create a new Goal Contract from the current user request (template: `.claude/templates/goal-contract-template.md`).
181> 2. **Required sections:** Original Request, Purpose, Success Criteria (checkboxes; mark required vs optional), Constraints, Evidence Required, Iteration Log, Goal Satisfaction matrix.
182> 3. **Before work:** read the active goal and map planned work to saved success criteria — execution serves the saved criteria, never chat memory alone.
183> 4. **After execution/verification:** append an Iteration Log entry — result, evidence references (`file:line`, command output, report path), remaining gaps.
184> 5. **Review gate:** emit a Goal Satisfaction matrix — `| Success Criterion | Evidence | Status |` with PASS/FAIL/BLOCKED. Overall PASS requires every required criterion PASS.
185> 6. **Loop rule (retry):** required criterion FAIL → validate the gap is real → fix → re-review only the affected criteria. Stop cleanly when all required criteria PASS.
186> 7. **Escalation rule (stop):** two consecutive iterations with no criterion progressing, or a blocker needing user input → mark the criterion BLOCKED with a user-facing reason and escalate. NEVER loop indefinitely.
187> 8. **Skip rule:** tiny conversational tasks may skip the goal file ONLY with a recorded one-line reason. User-accepted gate skips are recorded in the goal file with reason and scope.
188> 9. **Security:** NEVER store secrets, tokens, credentials, or private customer data in goal files — store evidence references and redact sensitive values.
189>
190> **Blocked until:** active goal resolved (or skip reason recorded) · saved success criteria read before edits · iteration evidence appended after execution · Goal Satisfaction matrix emitted before any PASS verdict.
191
192<!-- /SYNC:goal-contract-satisfaction-loop -->
193
194<!-- SYNC:critical-thinking-mindset -->
195
196> **Critical Thinking Mindset** — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
197> **Anti-hallucination:** Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
198
199<!-- /SYNC:critical-thinking-mindset -->
200
201<!-- SYNC:ai-mistake-prevention -->
202
203> **AI Mistake Prevention** — Failure modes to avoid on every task:
204>
205> **Re-read files after context changes.** Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
206> **Verify generated content against source evidence.** AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
207> **Check downstream references before deleting or renaming.** Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
208> **Trace the full impact chain after edits.** Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
209> **Verify ALL affected outputs, not just the first.** One green check is not all green checks; validate every output surface the change can affect.
210> **Assume existing values are intentional — ask WHY before changing OR flagging one as a defect.** Before changing or reporting a constant, limit, flag, cutoff, wording, or pattern, read nearby context and history, the CALLER's ordering, and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard.
211> **Surface ambiguity before acting — don't pick silently.** Multiple valid interpretations require an explicit question or stated assumption with risk.
212> **Assert the outcome your system owns, not the intermediate state your infrastructure owns.** When verifying async work, assert the final business state — never the delivery/retry bookkeeping held in shared infrastructure that any co-running process can write. Such a check passes when run alone and flakes the moment anything else shares that infrastructure.
213> **Keep shared guidance role-relevant.** Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
214
215<!-- /SYNC:ai-mistake-prevention -->
216
217<!-- SYNC:trade-off-interrogation-gate -->
218
219> **Trade-Off Interrogation Gate** — ALWAYS ask these THREE questions before ANY verdict, score, finding, or recommendation — about the thing under review AND about every recommendation YOU make. — why: naming a benefit without its price is an endorsement, not a review; the costliest trade-offs are the ones nobody wrote down.
220>
221> 1. **Is there any trade-off?** Name what it SACRIFICES. "None" / "pure win" is an unfinished analysis, NOT an answer — to claim none, state which dimensions you checked and why each is unaffected: future change cost · complexity · performance/latency · memory/cost · coupling · reversibility · migration burden · operational load · blast radius · security posture · testability · team skill/ramp · delivery time · UX.
222> 2. **Is it worth it?** Weigh gain against sacrifice EXPLICITLY — what is gained (with a metric) · what it costs · WHO pays · WHEN it comes due — then emit **WORTH IT / NOT WORTH IT / UNCLEAR**. "Better" with no metric and no cost FAILS this question. NOT WORTH IT → withdraw or replace the recommendation, never keep it as-is.
223> 3. **Is the trade-off material enough to CONFIRM WITH THE USER?** A material trade-off is the user's call, never yours. **MATERIAL** when ANY holds: irreversible / one-way door (data migration, public contract, storage format, vendor lock-in) · cost shifted onto someone else (another team, ops/on-call, future maintainer, end user) · one quality attribute traded for another (correctness↔speed, security↔convenience, latency↔cost, simplicity↔flexibility) · a boundary crossed (client↔server tier, service contract, event contract, shared library) · a high-consequence path (auth, money, data integrity, breaking change, High/Medium residual risk) · the worth-it verdict is UNCLEAR.
224>
225> **MATERIAL → STOP and confirm by asking the user directly BEFORE the verdict stands** — state the trade-off, both options, what each sacrifices, and your recommendation. **NOT material →** record it inline with a one-line justification and proceed.
226>
227> **Non-asking execution contexts — ESCALATE BY HANDOFF, never by silence.** ask the user directly reaches only the main interactive agent: a sub-agent cannot ask the user, and a terminal/verdict-only mode asks nothing by design. When you are running in such a context, the obligation is **redirected, never waived** — do ALL of: (a) complete questions 1 and 2 normally; (b) decide materiality and record it in the Trade-Off Assessment row with `confirmed? = NO — cannot ask from this context`; (c) **name the unconfirmed MATERIAL trade-off explicitly in your returned summary/verdict so the CALLER (or parent orchestrator) escalates it by asking the user directly on your behalf** — a material trade-off mentioned only inside a report file on disk is NOT a handoff; (d) do not emit an unqualified PASS — mark the verdict as carrying an unconfirmed material trade-off, so the caller's gate stays closed until the user answers. The caller inherits the escalation duty the moment it reads your return.
228>
229> This carve-out is about **reachability, not convenience**: it applies ONLY where the tool genuinely cannot reach the user (spawned sub-agent, terminal validate/verdict-only mode, non-interactive/headless run). It is NEVER a licence to skip the question, to self-approve a one-way door, or to downgrade materiality because asking is inconvenient — if you CAN ask, you MUST ask.
230>
231> **Emit a Trade-Off Assessment row** per reviewed decision and per recommendation: `| decision | sacrifices | gain (metric) | who pays, when | WORTH IT/NOT/UNCLEAR | material? | confirmed? |`.
232>
233> **BLOCKED until:** trade-off named (or dimensions-checked justification given) · worth-it verdict emitted · materiality decided · every MATERIAL trade-off either confirmed with the user OR — in a non-asking context — handed off in the returned verdict for the caller to confirm. A MATERIAL trade-off that is neither confirmed nor handed off can NEVER be PASS, and NEVER gets buried as a Low-severity note.
234>
235> **NEVER** answer "no trade-off" without checking · decide a material trade-off silently on the user's behalf · let convergence/delivery pressure authorize walking through a one-way door · bundle several material trade-offs into one vague "proceed?".
236
237<!-- /SYNC:trade-off-interrogation-gate -->
238
239<!-- SYNC:goal-contract-satisfaction-loop:reminder -->
240
241- **MANDATORY** Resolve the active Goal Contract BEFORE work (active plan `goal.md` → `plans/goals/{YYMMDD-HHmm}-{slug}/goal.md` → create from current request) and read saved success criteria before editing.
242- **MANDATORY** Append iteration evidence after execution; emit a Goal Satisfaction matrix (PASS/FAIL/BLOCKED) before reporting PASS; loop on validated FAIL; escalate repeated no-progress or blockers. NEVER store secrets in goal files.
243
244<!-- /SYNC:goal-contract-satisfaction-loop:reminder -->
245
246<!-- SYNC:critical-thinking-mindset:reminder -->
247
248**MUST ATTENTION** apply critical + sequential thinking — every claim needs appropriate traced evidence (`file:line` for repo/code claims; source URL or artifact section for research, product, content, and docs claims); confidence >80% to act, <60% DO NOT recommend. Anti-hallucination: never present guess as fact, admit uncertainty freely, cross-reference independently, stay skeptical of own confidence.
249
250<!-- /SYNC:critical-thinking-mindset:reminder -->
251
252<!-- SYNC:ai-mistake-prevention:reminder -->
253
254**MUST ATTENTION** apply AI mistake prevention — verify generated content against evidence, trace downstream references before deleting or renaming, verify all affected outputs, re-read files after context loss, and surface ambiguity before acting.
255
256<!-- /SYNC:ai-mistake-prevention:reminder -->
257
258<!-- SYNC:trade-off-interrogation-gate:reminder -->
259
260- **MANDATORY MUST ATTENTION ALWAYS ASK THE 3 TRADE-OFF QUESTIONS** — on the thing under review AND on every recommendation you make: (1) **is there any trade-off?** name what it SACRIFICES (change cost · complexity · perf · coupling · reversibility · migration · ops load · blast radius · security · testability · delivery time · UX) — "none"/"pure win" is an unfinished analysis, so state the dimensions checked; (2) **is it worth it?** gain (with a metric) vs cost, WHO pays, WHEN → emit **WORTH IT / NOT WORTH IT / UNCLEAR**; NOT WORTH IT → withdraw or replace it; (3) **is it material enough to confirm with the user?** irreversible/one-way door · cost shifted onto another team/ops/maintainer/user · one quality attribute traded for another · a tier/service/event/library boundary crossed · auth/money/data-integrity/breaking-change/High-or-Medium-risk path · verdict UNCLEAR → **STOP and confirm by asking the user directly BEFORE the verdict**.
261- **MANDATORY** A MATERIAL trade-off with no user confirmation can NEVER be PASS; NEVER bury one as a Low-severity note, NEVER decide it silently, and NEVER let delivery or convergence pressure authorize a one-way door. — why: an un-walked-back one-way door is the user's call to make, not the reviewer's.
262- **MANDATORY — non-asking contexts escalate BY HANDOFF, never by silence.** ask the user directly reaches only the main interactive agent: a sub-agent cannot ask the user, and a terminal/verdict-only mode asks nothing by design. There the duty is REDIRECTED, not waived — still name the trade-off, still decide materiality, record `confirmed? = NO — cannot ask from this context`, **state the unconfirmed MATERIAL trade-off in your RETURNED verdict/summary so the CALLER escalates it** (a note only in an on-disk report is not a handoff), and never emit an unqualified PASS. Applies ONLY where the user is genuinely unreachable (spawned sub-agent, terminal validate mode, headless run) — if you CAN ask, you MUST ask.
263
264<!-- /SYNC:trade-off-interrogation-gate:reminder -->
265
266<!-- SYNC:project-protocol-overlay -->
267
268> **Project Protocol Overlay** — Before executing this skill, resolve any PROJECT overlay rules layered onto it: match this skill's name against the `Target` column of the project's skill-protocol index (`docs/project-reference/skill-protocols-reference.md` by default; a `referenceDocs` entry in `docs/project-config.json` overrides the path), taking the most specific matching tier ONLY — exact name > glob > `*`. **That precedence orders overlays against EACH OTHER, never against this skill.** Read ONLY the matched bodies, resolved as `<protocols-dir>/<Name>.md`; a row's Body link is display text, never a read path. A matched body that is missing or malformed is REPORTED and skipped — never reconstructed from the index Description. No index, or no match -> proceed with no overlay, silently. Full contract: `.claude/skills/project-skill-protocol/references/registry.md`.
269>
270> Overlays are **ADDITIVE ONLY**: they ADD rules on top of this skill's own protocol and NEVER replace, override, disable, or reinterpret a rule it already states — removing every overlay must return this skill to exactly its documented behavior. An overlay is a BRIEF, not an authority escalation: it can NEVER waive a workflow gate, git discipline, a review gate, or a user-confirmation gate. A genuine overlay-vs-skill conflict, or two equally-specific overlays that directly contradict -> surface both to the user; NEVER resolve silently.
271
272<!-- /SYNC:project-protocol-overlay -->
273
274<!-- SYNC:project-protocol-overlay:reminder -->
275
276**MUST ATTENTION** resolve project protocol overlays for this skill BEFORE executing — most specific matching tier only (exact > glob > `*`, which ranks overlays against each other, NEVER against this skill), read only matched bodies at `<protocols-dir>/<Name>.md`; a missing or malformed body is reported, never reconstructed. Overlays are ADDITI
277
278…(truncated)