1---
2name: prove-fix
3description: '[Code Quality] Use when you need to prove fix correctness with adversarial code proof traces — a skeptic tries to DISPROVE the fix and trace all related paths first, with confidence scoring and stack-trace-style evidence chains, so confidence is earned by surviving attack, not by confirming it works.'
4metadata:
5 source: https://skillmd.com/skills/duc01226/prove-fix
6---
7
8> Codex compatibility note:
9>
10> - Invoke repository skills with `$skill-name` in Codex; this mirrored copy rewrites legacy Claude `/skill-name` references.
11> - Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
12> - User-question prompts mean to ask the user directly in Codex.
13> - Ignore Claude-specific mode-switch instructions when they appear.
14> - Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
15> - 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.
16> - Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
17> - For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
18> - If a required step/tool cannot run in this environment, stop and ask the user before adapting.
19
20<!-- CODEX:PROJECT-REFERENCE-LOADING:START -->
21
22## Codex Project-Reference Loading (No Hooks)
23
24Codex uses static project-reference loading instead of runtime-injected project docs.
25When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
26
27**Always read:**
28
29- `docs/project-config.json` (project-specific paths, commands, modules, and workflow/test settings)
30- `docs/project-reference/docs-index-reference.md` (routes to the full `docs/project-reference/*` catalog)
31- `docs/project-reference/lessons.md` (always-on guardrails and anti-patterns)
32
33**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.
34
35**Situation-based docs:**
36
37- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra): `project-structure-reference.md`
38- Backend/CQRS/API/domain/entity changes: `backend-patterns-reference.md`, `domain-entities-reference.md`
39- Frontend/UI/styling/design-system: `frontend-patterns-reference.md`, `scss-styling-guide.md`, `design-system/README.md`
40- Spec authoring, `docs/specs/` pathing, or TC format: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`
41- Behavior/public-contract changes or spec-test-code sync: `workflow-spec-test-code-cycle-reference.md` plus the spec docs above
42- Derived spec indexes/ERDs/reimplementation guides: `spec-system-reference.md` and source Feature Specs under `docs/specs/`
43- Integration test implementation/review: `integration-test-reference.md`
44- E2E test implementation/review: `e2e-test-reference.md`
45- Code review/audit work: `code-review-rules.md` plus domain docs above based on changed files
46
47Do not read all docs blindly. Start from `docs-index-reference.md`, then open only relevant files for the task.
48
49<!-- CODEX:PROJECT-REFERENCE-LOADING:END -->
50
51<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:START -->
52
53> **[BLOCKING]** Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
54> **[BLOCKING]** Before each step or sub-skill call, update task tracking: set `in_progress` when step starts, set `completed` when step ends.
55> **[BLOCKING]** Every completed/skipped step MUST include brief evidence or explicit skip reason.
56> **[BLOCKING]** If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
57
58<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->
59
60## Quick Summary
61
62**Goal:** Block shipping an unproven fix — adopt a SKEPTIC's stance and try to DISPROVE the fix first, then build a code proof trace (like a debugger stack trace) for each change with confidence percentages, so every code change carries a `file:line` evidence chain that survived a genuine refutation attempt and a fix ships only when its correctness is proven (≥80%), never assumed.
63
64**Summary:**
65
66- **Purpose / default stance is SKEPTIC, not validator** — find why the fix is WRONG or INCOMPLETE, never confirm it works. Skill name ("prove-fix") + post-`$fix` context + points rubric all bias toward confirmation; the Adversarial Verification Mindset forces a reset so confidence is _earned by surviving attack_, not awarded for coherence.
67- **The 5 main steps (run in order, NEVER skip):** (1) **Change Inventory** — list EVERY change (file:line, before/after, type: root-cause/secondary/defensive/cleanup); (2) **Proof Trace per change** — stack-trace chain symptom → trigger path → root cause → fix mechanism → why-correct → **refutation attempt** → related paths → edge cases → side effects, every arrow `file:line`; (3) **Confidence Scoring** — points rubric + SKEPTIC caps; (4) **Cross-Verification** — Anti-Bias Gate FIRST, then interaction/completeness/regression/dependency/performance (paging+index DB protocol); (5) **Final Verdict** + Goal Satisfaction update.
68- Runs AFTER `$fix` (NEVER before) — the non-negotiable verification gate between `$fix` and `$code-simplifier`; ≥80% ship · 60-79% flag · <60% BLOCK (route back to `$debug-investigate` or `$fix`).
69- For EACH change, run a **Refutation Pass** FIRST (strongest case the fix is wrong/incomplete: counter-cases, unclosed feeder paths, wrong layer, regression risk, "test passes for the wrong reason") before scoring — an un-attacked change cannot exceed 79%.
70- **Trace ALL related things** — every caller, consumer, sibling/alternate path, feeder path, downstream dependent, shared-state writer the change touches; an un-enumerated related path is an unproven path and caps confidence below 80%. — why: the reproduction exercises one path; the bug survives through paths you never traced.
71- Score with the points rubric (root cause +25, fix mechanism +20, pattern precedent +15, framework +10, edge cases +5 each, side effects +10, no regressions +5); pattern precedent (1+ working example), edge cases (error/null/concurrent), survived refutation, and spec-loop evidence (property TC + mutation-kill + Dual-Feedback) are REQUIRED, not optional.
72- Map every fix part to a primary/contributing/latent root cause from the hypothesis matrix and prove ALL feeder paths closed; finish with the **Anti-Bias Gate** + cross-change checks + final verdict, then resolve the active Goal Contract (map each proof trace to its success criterion, emit the PASS/FAIL/BLOCKED matrix) — a SHIP verdict does NOT close work while any required criterion remains FAIL.
73
74**Workflow:**
75
761. **Inventory** — List every code change made by the fix (file:line, before/after)
772. **Trace + Refute** — For each change, build a proof chain (symptom → root cause → fix) AND run a refutation pass that tries to break it before believing it
783. **Score** — Assign confidence percentage per change with evidence; confidence is earned by surviving refutation, not awarded for coherence
794. **Verify** — Anti-Bias Gate + cross-check fix against edge cases, side effects, and ALL related paths
805. **Verdict** — Overall fix confidence and any remaining risks
81
82**Key Rules:**
83
84- **Default stance is SKEPTIC, not validator** — actively try to DISPROVE each change before scoring it; "looks correct" is the bias this gate exists to break
85- Every claim MUST ATTENTION have `file:line` evidence — no exceptions
86- Each change gets its OWN proof trace, refutation pass, and confidence score
87- A change that has not been genuinely attacked (refutation pass) cannot exceed 79%
88- If ANY change scores below 80%, flag it and recommend additional investigation
89- Always run this proof-trace step after `$fix` — **non-negotiable**, never skip it
90
91### Frontend/UI Context (if applicable)
92
93> When this task involves frontend or UI changes,
94
95- Component patterns: `docs/project-reference/frontend-patterns-reference.md`
96- Styling/BEM guide: `docs/project-reference/scss-styling-guide.md`
97- Design system tokens: `docs/project-reference/design-system/README.md`
98
99**Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).**
100
101# Prove Fix
102
103Post-fix verification skill building evidence-based proof chains for every code change. A code debugger's stack trace, but for proving WHY a fix is correct.
104
105---
106
107## When to Use
108
109- **After `$fix`** in bugfix, hotfix, or any fix workflow
110- After applying code changes that fix a reported bug
111- Verify fix correctness before review/commit
112
113## When NOT to Use
114
115- Before fix applied (use `$debug-investigate` instead)
116- New feature verification (use `$test` instead)
117- Code quality review (use `$code-review` instead)
118
119---
120
121## Adversarial Verification Mindset (NON-NEGOTIABLE)
122
123**Default stance: SKEPTIC, not validator. Your job is to prove the fix is WRONG or INCOMPLETE — and only conclude it is correct when every attack fails.**
124
125> **Confirmation-bias trap (acute for THIS skill):** The skill is literally named "prove-fix", you arrive immediately after `$fix` (you may have written the fix yourself), and the scoring rubric _awards points for verified items_ — three forces that all pull toward confirming the fix works. A reviewer who already endorsed the fix cannot also be its skeptic without a forced reset. This section is that reset. — why: "build a proof FOR X" silently becomes "find reasons X is right"; real verification is "try to break X and report what survived".
126
127**Reframe the goal:** Do NOT set out to demonstrate the fix is correct. Set out to demonstrate it is BROKEN. Confidence is whatever is left standing _after_ a genuine attempt to break it — never a tally of agreements.
128
129### Refutation Techniques (apply ALL per change before scoring)
130
131| Technique | Think (try to make the fix FAIL) |
132| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133| Counter-case hunt | Find ONE input/state/timing where the "fixed" code still produces the symptom. If you cannot, prove the input domain is exhausted — don't assume it. |
134| Test-passes-for-wrong-reason | Does the regression test pass because the fix is correct, or because the test is weak (asserts the example, not the invariant; mocks away the bug; never executes the fixed line)? |
135| Unclosed feeder path | Name every OTHER producer/caller/event/job/cache that can write the observed final state. Did the fix close ALL of them, or just the one you reproduced? |
136| Wrong-layer challenge | Argue the fix patches a symptom site, not the invariant owner. Would the bug recur through a sibling path that bypasses this fix? |
137| Regression injection | Assume the fix introduced a NEW bug. Where would it be? (changed scope, broadened catch, altered ordering, new query without paging/index.) |
138| Steel-man "no fix" | Argue the original code was actually correct and the real bug is elsewhere. If that argument has any legs, the root cause is unproven. |
139| Contrarian verdict | Before writing the score, argue in 2 sentences that this change should be BLOCKED. Then choose the stronger of ship-vs-block. |
140
141### Forbidden Patterns
142
143| Forbidden | Required correction |
144| ----------------------------------- | ----------------------------------------------------------------------------- |
145| "Fix is obviously correct" | Obviousness is the illusion this gate breaks. Run the refutation pass anyway. |
146| "Reproduction test passes → proven" | A passing example ≠ a closed invariant. Attack the test before trusting it. |
147| Award points for coherence | Points require _survived attack_, not a plausible-sounding chain. |
148| "I wrote the fix, I know it works" | Author ≠ reviewer. Reset to skeptic; attack your own change hardest. |
149| Stop at the path you reproduced | Enumerate ALL feeder/related paths; an un-attacked path is an unproven path. |
150
151### Anti-Bias Gate (MANDATORY before any SHIP/SHIP-WITH-CAVEATS verdict)
152
153Complete ALL of these — per change — before writing the final verdict (MUST ATTENTION):
154
155- [ ] Ran the Refutation Pass (≥1 genuine counter-case attempt, recorded with `file:line` evidence of why it fails to reproduce)
156- [ ] Attacked the regression test itself — confirmed it fails on the _un-fixed_ code and asserts the invariant, not the example
157- [ ] Enumerated ALL related/feeder paths and proved each is closed or explicitly listed as unverified
158- [ ] Stated the strongest argument the fix is at the WRONG layer, and rebutted it with evidence
159- [ ] Named ≥1 plausible NEW regression the change could introduce, and ruled it out with evidence
160- [ ] Wrote the contrarian (BLOCK) argument and explained why ship still wins
161
162Any box unchecked → verification is NOT complete; confidence is capped at 79% (flag, do not ship). NEVER round an un-refuted change up to 80%.
163
164---
165
166## Step 1: Change Inventory
167
168List ALL changes made by the fix. For each change, document:
169
170```
171CHANGE #N: [short description]
172 File: [path/to/file.ext]
173 Lines: [start-end]
174 Before: [code snippet — the broken version]
175 After: [code snippet — the fixed version]
176 Type: [root-cause-fix | secondary-fix | defensive-fix | cleanup]
177```
178
179**Change types:**
180
181- **root-cause-fix** — Directly addresses the root cause of the bug
182- **secondary-fix** — Fixes a related issue discovered during investigation
183- **defensive-fix** — Prevents the same class of bug from recurring
184- **cleanup** — Removed dead code or simplified logic (no behavior change)
185
186---
187
188## Step 2: Proof Trace (per change)
189
190For EACH change, build a **stack-trace-style proof chain** — the core of the skill.
191
192### Proof Trace Format
193
194```
195PROOF TRACE — Change #N: [description]
196━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
197
198SYMPTOM (what the user sees):
199 → [Observable behavior, e.g., "UI doesn't refresh after assigning PIC"]
200
201TRIGGER PATH (how the symptom occurs):
202 1. [file:line] User action → [method/event]
203 2. [file:line] → calls [method]
204 3. [file:line] → dispatches [action/event]
205 4. [file:line] → handler/effect [name]
206 5. [file:line] ← BUG HERE: [exact broken behavior]
207
208ROOT CAUSE (proven):
209 → [One sentence: what exactly is wrong and why]
210 → Evidence: [file:line] shows [specific code proving the bug]
211 → Hypothesis matrix mapping: RC-[N] status [primary/contributing/latent] from [report path/section]
212 → Feeder paths closed: [path names or "single path verified"]; unresolved paths: [none/list]
213
214FIX MECHANISM (how the change fixes it):
215 → [One sentence: what the fix does differently]
216 → Before: [broken code path with file:line]
217 → After: [fixed code path with file:line]
218 → Owning fix layer: [layer/component] — why this is the lowest shared owner
219
220WHY THIS FIX IS CORRECT:
221 → [Reasoning backed by code evidence]
222 → Pattern precedent: [file:line] shows same pattern working elsewhere
223 → Framework behavior: [file:line or doc reference] confirms expected behavior
224 → Forward convergence: [origin/trigger] -> [corrected transformations] -> [observed final output no longer stale/wrong]
225
226RELATED PATHS TRACED (all related things — none left un-attacked):
227 → Callers/consumers of changed symbol: [file:line list] — [each unaffected/updated, with evidence]
228 → Other feeder paths that write the final state: [file:line list] — [each closed / explicitly unverified]
229 → Sibling/alternate paths (retry, async, cache, background, alternate UI/API): [file:line] — [status]
230 → Downstream dependents (graph trace --direction downstream when graph.db exists): [evidence]
231
232REFUTATION ATTEMPT (try to break it — REQUIRED before scoring):
233 → Strongest counter-case attempted: [input/state/timing] → [why it does NOT reproduce, with file:line]
234 → Test attacked: [does the regression test fail on un-fixed code? assert invariant or just the example?] — [file:line]
235 → Wrong-layer challenge: [strongest argument this is a symptom patch] → [rebuttal with file:line, or CONCEDED]
236 → New-regression hunt: [most plausible bug the change could introduce] → [ruled out with file:line, or OPEN]
237 → Contrarian verdict (2 sentences arguing BLOCK): [...] → [why ship still wins, or why it does not]
238 → Survived attack? [YES — all attacks failed / NO — finding(s): ...]
239
240EDGE CASES CHECKED:
241 → [edge case 1]: [verified/not-verified] — [evidence]
242 → [edge case 2]: [verified/not-verified] — [evidence]
243
244SIDE EFFECTS:
245 → [None / List of potential side effects with evidence]
246
247CONFIDENCE: [X%] (earned by surviving the refutation pass, NOT by tallying agreements)
248 Survived attacks: [list of attacks attempted that failed to break the fix]
249 Verified: [list of verified items]
250 Not verified / un-attacked: [list of unverified items — each caps confidence below 80%]
251```
252
253### Proof Trace Rules
254
2551. **Every arrow (→) MUST ATTENTION have a `file:line` reference** — no exceptions
2562. **TRIGGER PATH must be traceable** — someone should be able to follow it step-by-step in the code
2573. **REFUTATION ATTEMPT is REQUIRED and must be GENUINE** — you MUST try to break the fix (counter-case, weak-test, wrong-layer, new-regression, contrarian) before scoring. A trace with an empty or token refutation pass is INCOMPLETE and caps confidence at 79%. Default to "broken until proven otherwise", not "correct until disproven".
2584. **RELATED PATHS must be fully traced ("all related things")** — enumerate every caller, consumer, sibling/alternate path, feeder path, downstream dependent, and shared-state writer the change touches; an un-enumerated related path is an unproven path and caps confidence below 80%.
2595. **Hypothesis matrix mapping is REQUIRED for bugfixes** — every fix part maps to a primary/contributing/latent root cause or is flagged as unrelated scope
2606. **Feeder paths must be accounted for** — prove the fix closes every path that can write the final observed state, or explicitly list remaining unverified paths
2617. **Pattern precedent is REQUIRED** — find at least 1 working example of the same pattern elsewhere in the codebase
2628. **Edge cases MUST ATTENTION be enumerated** — at minimum: error path, null/empty input, concurrent access
2639. **Side effects MUST ATTENTION be assessed** — what else could this change affect?
26410. **The regression test MUST be attacked, not trusted** — confirm it FAILS on the un-fixed code and asserts the protected invariant (not just the reproduction example, not a mock that hides the bug, and the fixed line actually executes). A test you did not try to break is not evidence.
26511. **Spec-loop evidence is REQUIRED for a complete proof** (canonical: `SYNC:spec-loop-discipline`) — the proof MUST carry, with `file:line`: (a) the **regression property TC** guarding the fixed invariant — a universally-quantified property ("for ALL inputs in {domain}, {invariant} holds") + boundary counter-case, not just the reproduction example; (b) **mutation-kill evidence** for the fixed core-logic line — show a surviving mutant on that line is now killed (MUTATION-SCORE bar, not line-coverage %); (c) a **Dual-Feedback entry** — the spec rule restored/added AND the guarding test that feeds it back. A proof trace missing any of (a)/(b)/(c) is INCOMPLETE — cap its confidence below the 80% ship threshold until the spec-loop evidence is supplied.
266
267---
268
269## Step 3: Confidence Scoring
270
271Each change gets an individual confidence score:
272
273| Score | Meaning | Action Required |
274| ----------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
275| **95-100%** | Full proof trace complete, all edge cases verified, pattern precedent found | Ship it |
276| **80-94%** | Main proof trace complete, some edge cases unverified | Ship with caveats noted |
277| **60-79%** | Proof trace partial, some links unverified | Flag to user — recommend additional investigation |
278| **<60%** | Insufficient evidence | **BLOCK** — do not proceed until evidence gathered |
279
280### Scoring Criteria
281
282Award points for each verified item:
283
284| Criterion | Points | Evidence Required |
285| ----------------------------------------- | ------- | ----------------------------- |
286| Root cause identified with file:line | +25 | Code reference |
287| Fix mechanism explained with before/after | +20 | Code diff |
288| Pattern precedent found in codebase | +15 | Working example at file:line |
289| Framework behavior confirmed | +10 | Framework source or docs |
290| Edge cases checked (per case) | +5 each | Verification result |
291| Side effects assessed | +10 | Impact analysis |
292| No regressions identified | +5 | Test results or code analysis |
293
294**Total possible: 100+** (normalize to percentage)
295
296> **[SKEPTIC GATE — applied AFTER the additive score]** The rubric measures evidence _gathered_; it does not measure whether the fix _survived attack_. Apply these caps regardless of the additive total — a high tally never overrides a failed/missing attack:
297>
298> - Refutation Pass not genuinely attempted, or any related/feeder path left un-enumerated → **cap at 79%** (flag, do not ship).
299> - Any refutation attack succeeded (counter-case reproduces, test is weak, wrong layer, open regression) → that is a **finding**: score reflects the unresolved defect (typically <60%, BLOCK) until the finding is closed.
300> - Contrarian (BLOCK) argument is stronger than the ship argument → **BLOCK**, route back to `$debug-investigate` or `$fix`.
301>
302> Confidence is what remains _after_ the attack — never the additive tally alone.
303
304---
305
306## Step 4: Cross-Verification
307
308After individual proof traces, perform cross-change verification:
309
3100. **Anti-Bias Gate (MANDATORY first)** — Complete every box of the Anti-Bias Gate (from the Adversarial Verification Mindset section) for the change set as a whole before any SHIP verdict. An unchecked box means verification is incomplete — go back, do not ship.
3111. **Interaction check** — Do the changes interact with each other? Could one change break another?
3122. **Completeness check** — Does the combined fix address ALL reported symptoms? Steel-man "the bug is still present somewhere" — what would prove it?
3133. **Regression check** — Could the combined changes introduce new bugs? Assume they did; where?
3144. **Dependency check** — Are there other code paths that depend on the changed behavior?
3155. **Performance regression check** — Does the fix introduce performance issues?
316
317> **[IMPORTANT] Database Performance Protocol (MANDATORY):**
318>
319> 1. **Paging Required** — ALL list/collection queries MUST ATTENTION use pagination. NEVER load all records into memory. Verify: no unbounded `GetAll()`, `ToList()`, or `Find()` without `Skip/Take` or cursor-based paging.
320> 2. **Index Required** — ALL query filter fields, foreign keys, and sort columns MUST ATTENTION have database indexes configured. Verify: entity expressions match index field order, database collections have index management methods, migrations include indexes for WHERE/JOIN/ORDER BY columns.
321
322---
323
324## Step 5: Final Verdict
325
326Produce a summary verdict:
327
328```
329FIX VERIFICATION VERDICT
330━━━━━━━━━━━━━━━━━━━━━━━
331
332Overall Confidence: [X%]
333
334Anti-Bias Gate: [ALL boxes checked? YES/NO — if NO, verdict CANNOT be SHIP]
335
336Changes Summary:
337 #1: [description] — [X%] ✅/⚠️/❌ — refutation: [survived / finding: ...]
338 #2: [description] — [X%] ✅/⚠️/❌ — refutation: [survived / finding: ...]
339 #N: [description] — [X%] ✅/⚠️/❌ — refutation: [survived / finding: ...]
340
341Symbols: ✅ ≥80% (ship) | ⚠️ 60-79% (flag) | ❌ <60% (block)
342
343Attacks that FAILED to break the fix (these earn the confidence):
344 - [attack]: [why it could not reproduce — file:line]
345
346Attacks that SUCCEEDED (open findings — block until closed):
347 - [attack]: [the defect it exposed — file:line] (or "none")
348
349Remaining Risks:
350 - [risk 1]: [likelihood] × [impact] — [mitigation]
351 - [risk 2]: [likelihood] × [impact] — [mitigation]
352
353Verification Method:
354 - [Manual testing required? Which scenarios?]
355 - [Automated tests cover this? Which tests?]
356 - [Additional monitoring needed post-deploy?]
357
358Recommendation: [SHIP / SHIP WITH CAVEATS / INVESTIGATE FURTHER / BLOCK]
359```
360
361**Goal Satisfaction update (MANDATORY after verdict):** resolve the active Goal Contract per `SYNC:goal-contract-satisfaction-loop` and map each proof trace to the saved success criterion it satisfies. Append proof evidence and remaining gaps to the goal file's Iteration Log and update its Goal Satisfaction matrix (PASS/FAIL/BLOCKED per criterion). A SHIP recommendation does NOT close the work while any required goal criterion remains FAIL — route the validated gap into another bounded fix loop or escalate a blocker.
362
363---
364
365## Example: Proof Trace for NgRx Effect Fix
366
367```
368PROOF TRACE — Change #1: Move catchError inside switchMap
369━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
370
371SYMPTOM:
372 → UI doesn't refresh after assigning PIC, Job Opening, or changing stage
373
374TRIGGER PATH:
375 1. candidate-quick-card-v2.component.ts:445 — User clicks "Assign PIC"
376 2. candidate-card.container.component.ts:892 — onPersonInChargeChange($event)
377 3. candidate-card.effect.ts:275 — SavePersonInCharge effect
378 4. candidate-card.effect.ts:284 — dispatches LoadCandidateDetailsAction
379 5. candidate-card.effect.ts:48 ← EFFECT IS DEAD — never processes the action
380
381ROOT CAUSE:
382 → catchError at outer pipe level (effect.ts:64) causes effect completion on ANY error
383 → Evidence: effect.ts:43-69 shows catchError OUTSIDE switchMap
384 → Evidence: ngrx-effects.js:156-165 confirms defaultEffectsErrorHandler
385 only catches errors, not completions
386
387FIX MECHANISM:
388 → Move catchError INSIDE switchMap so errors are caught per-request
389 → Before: effect.ts:64 — catchError at outer pipe → effect COMPLETES → DEAD
390 → After: effect.ts:52 — catchError inside switchMap → inner obs completes → outer SURVIVES
391
392WHY THIS FIX IS CORRECT:
393 → RxJS: catchError inside switchMap catches per-emission, outer stream continues
394 → Pattern precedent: effect.ts:120 (moveApplicationToNextState) uses same inner pattern
395 → Framework: NgRx effects auto-resubscribe on ERROR but NOT on COMPLETION
396
397RELATED PATHS TRACED:
398 → Callers of SavePersonInCharge effect: container:892 only — verified no other dispatcher
399 → Other effects sharing the dead-stream bug: grep catchError outside switchMap →
400 effect.ts:300 (SaveJobOpening), effect.ts:355 (ChangeStage) have SAME bug —
401 ⚠ NOT fixed by this change; listed as unverified/out-of-scope feeder paths
402 → Downstream consumers of LoadCandidateDetailsAction: reducer.ts:88 — unaffected (no contract change)
403
404REFUTATION ATTEMPT:
405 → Counter-case: a SECOND error after the fix → inner catchError re-catches; outer survives (verified effect.ts:52)
406 → Test attacked: spec fails on un-fixed code (effect completes, no SetCandidateDetails emitted) AND asserts
407 the effect still emits on the 2nd call — invariant, not just the one example (effect.spec.ts:140-176)
408 → Wrong-layer challenge: could fix at component? NO — effect owns the stream lifetime invariant; component patch
409 would leave SaveJobOpening/ChangeStage broken. Layer confirmed correct.
410 → New-regression hunt: broadened catch could swallow a real error → ruled out, same error branch returns
411 same action, only scope moved (effect.ts:52 vs :64)
412 → Contrarian: "BLOCK — two sibling effects still carry the bug." → Ship THIS change (correct + tested) but
413 the sibling paths are a SEPARATE finding to route back to $fix, not a reason to block this one.
414 → Survived attack? YES for this change — but surfaced 2 un-fixed sibling feeder paths as findings.
415
416EDGE CASES:
417 → 403 Forbidden: verified — returns SetCandidateDetails with isAllowDisplayed=false
418 → Network timeout: verified — returns EMPTY, effect survives
419 → Multiple rapid requests: verified — switchMap cancels previous (unchanged)
420
421SIDE EFFECTS:
422 → None for this effect — same error handling logic, only scope changed
423
424CONFIDENCE: 90% (this change), with a BLOCKING completeness finding
425 Survived attacks: counter-case, weak-test, wrong-layer, new-regression all failed to break it
426 Verified: root cause, fix mechanism, pattern precedent, framework source, all edge cases
427 Not verified / open finding: SaveJobOpening (effect.ts:300) and ChangeStage (effect.ts:355) share the
428 identical bug and are NOT fixed — the original symptom ("UI doesn't refresh after ... changing stage")
429 is only PARTIALLY resolved. Completeness check FAILS until those are fixed too.
430```
431
432> **What the skeptic stance bought here:** a confirmation-biased pass would have scored this 95% ("root cause found, test passes, ship it") and shipped a fix that leaves two-thirds of the reported symptom alive. The refutation pass + "trace all related things" caught the sibling feeder paths the reproduction never exercised.
433
434---
435
436> Run `python .claude/scripts/code_graph trace <file> --direction downstream --json` to prove fix doesn't break downstream.
437
438## Graph Intelligence (RECOMMENDED if graph.db exists)
439
440If `.code-graph/graph.db` exists, enhance analysis with structural queries:
441
442- **Verify test coverage:** `python .claude/scripts/code_graph query tests_for <function> --json`
443- **Trace affected code paths:** `python .claude/scripts/code_graph query callers_of <function> --json`
444- **Batch analysis:** `python .claude/scripts/code_graph batch-query file1 file2 --json`
445
446### Graph-Trace for Fix Verification
447
448When graph DB is available, use `trace` to PROVE the fix doesn't break downstream consumers:
449
450- `python .claude/scripts/code_graph trace <fixed-file> --direction downstream --json` — verify all downstream consumers, event handlers, and bus message listeners are unaffected
451- `python .claude/scripts/code_graph trace <fixed-file> --direction both --json` — full context: what triggered the bug (upstream) + what the fix affects (downstream)
452- Include trace results as evidence in the proof chain
453
454## Integration with Other Skills
455
456This skill is the **mandatory verification gate** between `$fix` and `$code-simplifier` in fix workflows.
457
458**Workflow position:**
459
460```
461... → $fix → $prove-fix → $code-simplifier → $changes-review → ...
462```
463
464**If proof trace reveals issues:**
465
466- Score ≥80%: proceed to next step
467- Score 60-79%: ask user whether to proceed or investigate further
468- Score <60%: BLOCK — return to `$debug-investigate` or `$fix` step
469
470---
471
472<prove-context>$ARGUMENTS</prove-context>
473
474---
475
476## Workflow Recommendation
477
478> **MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS:** If you are NOT already in a workflow, you MUST ATTENTION use ask the user directly to ask the user. Do NOT judge task complexity or decide this is "simple enough to skip" — the user decides whether to use a workflow, not you:
479>
480> 1. **Activate `workflow-bugfix` workflow** (Recommended) — scout → investigate → debug → plan → fix → prove-fix → review → test
481> 2. **Execute `$prove-fix` directly** — run this skill standalone
482
483---
484
485## Next Steps
486
487**MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS** after completing this skill, you MUST ATTENTION use ask the user directly to present these options. Do NOT skip because the task seems "simple" or "obvious" — the user decides:
488
489- **"$code-simplifier (Recommended)"** — Clean up fix implementation
490- **"$integration-test"** — Generate/update regression integration tests
491- **"$workflow-review-changes"** — Review all changes before commit
492- **"Skip, continue manually"** — user decides
493
494> **[IMPORTANT]** Use task tracking to break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ATTENTION ask user whether to skip.
495
496**Prerequisites:** **MUST ATTENTION READ** before executing:
497
498- `docs/project-reference/domain-entities-reference.md` — Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models)
499
500> **External Memory:** For complex or lengthy work (research, analysis, scan, review), write intermediate findings and final results to a report file in `plans/reports/` — prevents context loss and serves as deliverable.
501
502> **Evidence Gate:** MANDATORY IMPORTANT MUST ATTENTION — every claim, finding, and recommendation requires `file:line` proof or traced evidence with confidence percentage (>80% to act, <80% must verify first).
503
504<!-- SYNC:end-to-start-debugger-trace -->
505
506> **End-to-Start Debugger Trace** — For non-trivial bugs, failed verification, regression fixes, behavior-changing code, or unclear code flow, start from the observed final state and walk backward before proposing a fix.
507>
508> 1. **Frame 0: observed end state** — Name the exact user-visible output, failing assertion, log line, persisted value, API response, rendered UI, or aggregate bucket. Record the reader/query/renderer that produced it with `file:line` evidence.
509> 2. **Walk backward one hop at a time** — Trace final reader -> projection/cache/storage -> writer -> consumer/handler/job -> producer/caller -> original trigger. At every hop record: input, transformation, output, owner, and evidence.
510> 3. **Enumerate all feeder paths** — Find every upstream producer/caller/event/job that can write into the final path, including retry, async, cache, background, and alternate UI/API paths. Mark each path verified, ruled out, or still unknown.
511> 4. **Build the hypothesis matrix** — For each plausible cause, list evidence for, evidence against, how to reproduce/verify, blast radius, and status (`primary`, `contributing`, `ruled out`, `latent`). Do not fix until competing causes are explicitly resolved or bounded.
512> 5. **Choose the owning fix layer** — Identify the invariant owner and the lowest shared point that protects all downstream consumers. A fix at the symptom site is rejected unless the symptom site owns the invariant.
513> 6. **Prove convergence forward** — After choosing the fix, walk start -> end again and show how the corrected state reaches the observed final output. Map each root cause to a fix part and each fix part to a test/proof.
514>
515> **BLOCKED until:** final state named · backward trace written · all feeder paths enumerated · hypothesis matrix completed · owning fix layer justified · forward convergence proof mapped to tests.
516>
517> **NEVER:** Start at the first suspicious code path. Collapse multiple producers into one "flow". Treat duplicate symptoms as duplicate records without proving the read model. Skip ruled-out hypotheses.
518
519<!-- /SYNC:end-to-start-debugger-trace -->
520
521<!-- SYNC:ui-system-context -->
522
523> **UI System Context** — For ANY task touching `.ts`, `.html`, `.scss`, or `.css` files:
524>
525> **MUST ATTENTION READ before implementing:**
526>
527> 1. `docs/project-reference/frontend-patterns-reference.md` — component base classes, stores, forms
528> 2. `docs/project-reference/scss-styling-guide.md` — BEM methodology, SCSS variables, mixins, responsive
529> 3. `docs/project-reference/design-system/README.md` — design tokens, component inventory, icons
530>
531> Reference `docs/project-config.json` for project-specific paths.
532
533<!-- /SYNC:ui-system-context -->
534
535<!-- SYNC:graph-assisted-investigation -->
536
537> **Graph-Assisted Investigation** — MANDATORY when `.code-graph/graph.db` exists.
538>
539> **HARD-GATE:** MUST ATTENTION run at least ONE graph command on key files before concluding any investigation.
540>
541> **Pattern:** Grep finds files → `trace --direction both` reveals full system flow → Grep verifies details
542>
543> | Task | Minimum Graph Action |
544> | ------------------- | -------------------------------------------- |
545> | Investigation/Scout | `trace --direction both` on 2-3 entry files |
546> | Fix/Debug | `callers_of` on buggy function + `tests_for` |
547> | Feature/Enhancement | `connections` on files to be modified |
548> | Code Review | `tests_for` on changed functions |
549> | Blast Radius | `trace --direction downstream` |
550>
551> **CLI:** `python .claude/scripts/code_graph {command} --json`. Use `--node-mode file` first (10-30x less noise), then `--node-mode function` for detail.
552
553<!-- /SYNC:graph-assisted-investigation -->
554
555<!-- SYNC:critical-thinking-mindset -->
556
557> **Critical Thinking Mindset** — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
558> **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.
559
560<!-- /SYNC:critical-thinking-mindset -->
561
562<!-- SYNC:understand-code-first -->
563
564> **Understand Code First** — HARD-GATE: Do NOT write, plan, or fix until you READ existing code.
565>
566> 1. Search 3+ similar patterns (`grep`/`glob`) — cite `file:line` evidence
567> 2. Read existing files in target area — understand structure, base classes, conventions
568> 3. Run `python .claude/scripts/code_graph trace <file> --direction both --json` when `.code-graph/graph.db` exists
569> 4. Map dependencies via `connections` or `callers_of` — know what depends on your target
570> 5. Write investigation to `.ai/workspace/analysis/` for non-trivial tasks (3+ files)
571> 6. Re-read analysis file before implementing — never work from memory alone. — why: long context drifts from the file; the file is ground truth
572> 7. NEVER invent new patterns when existing ones work — match exactly or document deviation. — why: divergent patterns fragment the codebase and slow every future reader
573>
574> **BLOCKED until:** `- [ ]` Read target files `- [ ]` Grep 3+ patterns `- [ ]` Graph trace (if graph.db exists) `- [ ]` Assumptions verified with evidence
575
576<!-- /SYNC:understand-code-first -->
577
578<!-- SYNC:fix-layer-accountability -->
579
580> **Fix-Layer Accountability** — NEVER fix at the crash site. Trace the full flow, fix at the owning layer.
581>
582> AI default behavior: see error at Place A → fix Place A. This is WRONG. The crash site is a SYMPTOM, not the cause.
583>
584> **MANDATORY before ANY fix:**
585>
586> 1. **Trace full data flow** — Map the complete path from data origin to crash site across ALL layers (storage → backend → API → frontend → UI). Identify where the bad state ENTERS, not where it CRASHES.
587> 2. **Identify the invariant owner** — Which layer's contract guarantees this value is valid? That layer is responsible. Fix at the LOWEST layer that owns the invariant — not the highest layer that consumes it.
588> 3. **One fix, maximum protection** — Ask: "If I fix here, does it protect ALL downstream consumers with ONE change?" If fix requires touching 3+ files with defensive checks, you are at the wrong layer — go lower.
589> 4. **Verify no bypass paths** — Confirm all data flows through the fix point. Check for: direct construction skipping factories, clone/spread without re-validation, raw data not wrapped in domain models, mutations outside the model layer.
590>
591> **BLOCKED until:** `- [ ]` Full data flow traced (origin → crash) `- [ ]` Invariant owner identified with `file:line` evidence `- [ ]` All access sites audited (grep count) `- [ ]` Fix layer justified (lowest layer that protects most consumers)
592>
593> **Anti-patterns (REJECT these):**
594>
595> - "Fix it where it crashes" — Crash site ≠ cause site. Trace upstream.
596> - "Add defensive checks at every consumer" — Scattered defense = wrong layer. One authoritative fix > many scattered guards.
597> - "Both fix is safer" — Pick ONE authoritative layer. Redundant checks across layers send mixed signals about who owns the invariant.
598
599<!-- /SYNC:fix-layer-accountability -->
600
601<!-- SYNC:source-test-drift-check -->
602
603> **Source/test drift check.** For coding, fix, debug, investigation, test, or review work: when source behavior changes, inspect affected unit/integration/E2E tests and decide from evidence whether tests should change to match intended behavior or the source change is an unintended bug to fix. Do not write tests for migration code; schema/data migrations are one-time execution paths, not core application logic.
604
605<!-- /SYNC:source-test-drift-check -->
606
607<!-- SYNC:test-failure-fault-adjudication -->
608
609> **Test-Failure Fault Adjudication** — When a test fails (or you are debugging or fixing a failure), the job is to determine _who is at fault — the source code or the test code_. Getting that verdict right matters more than turning the suite green. Binds every debug / fix / test skill identically.
610>
611> 1. **Provisional verdict before touching either side.** Classify the observed evidence as SOURCE-WRONG, TEST-WRONG, TEST-NOT-OPTIMAL, ENVIRONMENT-BLOCKED, or AMBIGUOUS; then `$debug-investigate` and trace end-to-start before editing. A green-again suite is NOT the goal.
612> 2. **Triangulate against the spec AND the source.** If a governing Feature Spec covers the behavior (e.g. `docs/specs/**` — §3 ACs / §4 BRs / §5 invariants / §8 TCs), it is the tiebreaker for _intended_ behavior — compare BOTH the production source and the failing test against it. With no spec, the documented intent / acceptance criteria / caller contract is the reference. Decide from this evidence whether the SOURCE is wrong or the TEST is wrong.
613> 3. **Classify who is at fault, then fix the wrong side at its root:**
614> - **SOURCE-WRONG** — production code violates the spec's intended behavior or a clear invariant → fix the source at the owning layer; keep or strengthen the test that caught it.
615> - **TEST-WRONG** — the test encodes a stale or incorrect assertion, setup, or expectation that contradicts intended behavior → fix the test at its root. NEVER weaken an assertion, add a skip, or relax a timeout to force green.
616> - **TEST-NOT-OPTIMAL** — intended behavior is valid but the test seam, timing, or assertion signal is fragile → improve the test without weakening the invariant.
617> - **ENVIRONMENT-BLOCKED** — infrastructure or external state prevents a source/test verdict → preserve diagnostics and stop mutation until the environment is healthy.
618> - **AMBIGUOUS** — evidence or intended behavior does not safely select an owner → ask the user or canonical owner before editing.
619> - NEVER change a test to match broken source, and NEVER change source to satisfy a broken test. (Migration code excluded — schema/data migrations are one-time execution paths, not core application logic.)
620> 4. **Ask the user when intended behavior is unclear.** If no spec covers the behavior, the spec is silent, or the spec is ambiguous about which side is correct, STOP and ask the user directly (or consult the canonical spec owner) before editing either side — never silently pick source or test just to make the suite pass.
621>
622> Reconcile to intended behavior, never to whichever side currently passes — green can encode the very bug.
623
624<!-- /SYNC:test-failure-fault-adjudication -->
625
626<!-- SYNC:ai-mistake-prevention -->
627
628> **AI Mistake Prevention** — Failure modes to avoid on every task:
629>
630> **Re-read files after context changes.** Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
631> **Verify generated content against source evidence.** AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
632> **Check downstream references before deleting or renaming.** Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
633> **Trace the full impact chain after edits.** Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
634> **Verify ALL affected outputs, not just the first.** One green check is not all green checks; validate every output surface the change can affect.
635> **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.
636> **Surface ambiguity before acting — don't pick silently.** Multiple valid interpretations require an explicit question or stated assumption with risk.
637> **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.
638> **Keep shared guidance role-relevant.** Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
639
640<!-- /SYNC:ai-mistake-prevention -->
641
642<!-- SYNC:understand-code-first:reminder -->
643
644**IMPORTANT MUST ATTENTION** search 3+ existing patterns and read code BEFORE any modification. Run graph trace when graph.db exists.
645
646<!-- /SYNC:understand-code-first:reminder -->
647
648<!-- SYNC:evidence-based-reasoning:reminder -->
649
650- **MANDATORY IMPORTANT MUST ATTENTION** cite `file:line` evidence for every claim. Confidence >80% to act, <60% = do NOT recommend.
651 <!-- /SYNC:evidence-based-reasoning:reminder -->
652
653<!-- SYNC:ui-system-context:reminder -->
654
655**IMPORTANT MUST ATTENTION** read frontend-patterns-reference, scss-styling-guide, design-system/README before any UI change.
656
657<!-- /SYNC:ui-system-context:reminder -->
658
659<!-- SYNC:graph-assisted-investigation:reminder -->
660
661**IMPORTANT MUST ATTENTION** run at least ONE graph command on key files when graph.db exists. Pattern: grep → graph trace → grep verify.
662
663<!-- /SYNC:graph-assisted-investigation:reminder -->
664
665<!-- SYNC:fix-layer-accountability:reminder -->
666
667**IMPORTANT MUST ATTENTION** trace full data flow and fix at the owning layer, not the crash site. Audit all access sites before adding `?.`.
668
669<!-- /SYNC:fix-layer-accountability:reminder -->
670
671<!-- SYNC:critical-thinking-mindset:reminder -->
672
673**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.
674
675<!-- /SYNC:critical-thinking-mindset:reminder -->
676
677<!-- SYNC:ai-mistake-prevention:reminder -->
678
679**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.
680
681<!-- /SYNC:ai-mistake-prevention:reminder -->
682
683<!-- SYNC:end-to-start-debugger-trace:reminder -->
684
685**IMPORTANT MUST ATTENTION** debugger trace gate: for non-trivial bug/fix/investigation/review work, start at the observed final output and trace backward through reader -> storage/projection -> writer -> consumer/job -> producer/trigger. Enumerate all feeder paths and hypotheses before fixing. **BLOCKED until** trace, hypothesis matrix, owning fix layer, and forward convergence proof exist.
686
687<!-- /SYNC:end-to-start-debugger-trace:reminder -->
688
689<!-- SYNC:goal-contract-satisfaction-loop:reminder -->
690
691- **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.
692- **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.
693
694<!-- /SYNC:goal-contract-satisfaction-loop:reminder -->
695
696<!-- PROMPT-ENHANCE:STEP-TASK-CLOSING:START -->
697
698## Prompt-Enhance Closing Anchors
699
700**IMPORTANT MUST ATTENTION** follow declared step order for this skill; NEVER skip, reorder, or merge steps without explicit user approval
701**IMPORTANT MUST ATTENTION** for every step/sub-skill call: set `in_progress` before execution, set `completed` after execution
702**IMPORTANT MUST ATTENTION** every skipped step MUST include explicit reason; every completed step MUST include concise evidence
703**IMPORTANT MUST ATTENTION** if Task tools unavailable, maintain an equivalent step-by-step plan tracker with synchronized statuses
704
705<!-- PROMPT-ENHANCE:STEP-TASK-CLOSING:END -->
706
707<!-- SYNC:project-protocol-overlay -->
708
709> **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`.
710>
711> 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.
712
713<!-- /SYNC:project-protocol-overlay -->
714
715<!-- SYNC:project-protocol-overlay:reminder -->
716
717**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 ADDITIVE ONLY (they never replace this skill's own rules) and are a brief, NEVER an authority escalation; an equal-specificity contradiction goes to the user.
718
719<!-- /SYNC:project-protocol-overlay:reminder -->
720
721## Closing Reminders
722
723**IMPORTANT MUST ATTENTION Goal:** block shipping an unproven fix — adopt a SKEPTIC's stance and try to DISPROVE the fix first, then build a `file:line` proof trace (debugger-style: symptom → root cause → fix mechanism → why-correct → refutation attempt → edge cases → side effects) and confidence score per change, so a fix ships only when correctness SURVIVES a genuine attack (≥80%), never when it merely looks correct.
724
725**IMPORTANT MUST ATTENTION** default stance is SKEPTIC, NOT validator — your job is to find why the fix is WRONG/INCOMPLETE, not confirm it works; run the Refutation Pass (counter-case, weak-test, wrong-layer, new-regression, contrarian) and complete the Anti-Bias Gate per change BEFORE any SHIP verdict; a change that has not been genuinely attacked is capped at 79%. — why: the skill name, the post-`$fix` context, and the points rubric all bias toward confirmation; confidence must be earned by surviving attack, not awarded for coherence.
726**IMPORTANT MUST ATTENTION** trace ALL related things — every caller, consumer, sibling/alternate path, feeder path, downstream dependent, and shared-state writer the change touches; an un-enumerated related path is an unproven path and caps confidence below 80%. — why: the reproduction exercises one path; the bug often survives through the paths you never traced.
727**IMPORTANT MUST ATTENTION** execute the 5 steps in order, NEVER skip or merge: (1) **Change Inventory** — every change with file:line, before/after, type → (2) **Proof Trace per change** — symptom → trigger path → root cause → fix mechanism → why-correct → refutation attempt → related paths → edge cases → side effects (every arrow `file:line`) → (3) **Confidence Scoring** — points rubric + SKEPTIC caps → (4) **Cross-Verification** — Anti-Bias Gate FIRST, then interaction/completeness/regression/dependency/DB-performance → (5) **Final Verdict** + Goal Satisfaction update. — why: AI forgets the skill's own steps and ad-libs a partial verification that ships an unproven fix.
728
729**Protocols in force (concise digest of the SYNC/shared blocks this skill carries):**
730
731- **End-to-Start Trace:** start at observed output, trace backward, hypothesis matrix before fixing.
732- **UI System Context:** read frontend-patterns, scss-styling, design-system before any UI change.
733- **Graph Investigation:** run ≥1 graph command on key files when graph.db exists.
734- **Critical Thinking:** traced `file:line` proof per claim; confidence >80% to act.
735- **Understand Code First:** grep 3+ patterns and read code before any modification.
736- **Fix-Layer Accountability:** trace full data flow, fix at owning layer not crash site.
737- **Source/Test Drift:** when source behavior changes, reconcile affected unit/integration/E2E tests from evidence.
738- **AI Mistake Prevention:** verify generated content against evidence, trace downstream references, verify all affected outputs, re-read after context loss, surface ambiguity.
739
740**IMPORTANT MUST ATTENTION** every arrow (→) in every proof trace MUST ATTENTION carry a `file:line` reference — no exceptions; a claim without traced evidence is speculation and BLOCKS the ship. — why: a proof chain with an unproven link proves nothing.
741**IMPORTANT MUST ATTENTION** score each change with the points rubric (root cause +25, fix mechanism +20, pattern precedent +15, framework +10, edge cases +5 each, side effects +10, no regressions +5) → ≥80% ship · 60-79% flag to user · <60% BLOCK; NEVER ship a <80% change — route it back to `$debug-investigate` or `$fix`. — why: the threshold is the gate; bypassing it defeats the skill.
742**IMPORTANT MUST ATTENTION** run AFTER `$fix`, never before — this is the non-negotiable verification gate between `$fix` and `$code-simplifier`; NEVER skip it because the fix "looks obviously right". — why: obviousness is the exact illusion this gate exists to break.
743
744**Domain protocols this proof MUST NOT skip:**
745
746**IMPORTANT MUST ATTENTION** pattern precedent is REQUIRED, not optional — cite at least 1 working example of the same pattern at `file:line` elsewhere in the codebase; "no precedent found" caps confidence below 80%. — why: a fix with no precedent is an unproven invention.
747**IMPORTANT MUST ATTENTION** edge cases are REQUIRED — enumerate at minimum error path, null/empty input, concurrent access, each verified with evidence; assess side effects (what else this change touches). — why: the happy path passing is not the change being correct.
748**IMPORTANT MUST ATTENTION** spec-loop evidence is REQUIRED for a complete proof (`SYNC:spec-loop-discipline`) — (a) a regression PROPERTY TC (∀ inputs in {domain}, invariant holds) + boundary counter-case, (b) mutation-kill evidence on the fixed line (MUTATION-SCORE, not line-coverage %), (c) a Dual-Feedback entry (spec rule restored + guarding test); missing any one caps confidence below 80%. — why: line coverage and a single reproduction example let the original defect class survive.
749**IMPORTANT MUST ATTENTION** map every fix part to a primary/contributing/latent root cause from the hypothesis matrix and prove ALL feeder paths are closed; fix at the LOWEST shared owning layer, NEVER patch the crash/symptom site. — why: a symptom-site patch leaves the real cause writing bad state through other paths.
750**IMPORTANT MUST ATTENTION** for non-trivial bug/fix work, start at the observed final output and trace BACKWARD (reader → storage/projection → writer → consumer/job → producer/trigger) before proposing a fix; build the hypothesis matrix first. — why: starting at the first suspicious line fixes a symptom, not the cause.
751**IMPORTANT MUST ATTENTION** run the Database Performance Protocol in cross-verification — ALL list/collection queries paginated (no unbounded `GetAll/ToList/Find`), ALL filter/FK/sort columns indexed. — why: a correct fix that degrades query performance ships a new regression.
752**IMPORTANT MUST ATTENTION** when `.code-graph/graph.db` exists, run a `trace --direction downstream` on the fixed file to prove no downstream consumer breaks; include trace output as proof evidence. — why: a green local change can silently break a distant caller.
753**IMPORTANT MUST ATTENTION** resolve the active Goal Contract AFTER the verdict (`SYNC:goal-contract-satisfaction-loop`) — map each proof trace to its success criterion, emit the PASS/FAIL/BLOCKED matrix; a SHIP verdict does NOT close work while any required criterion remains FAIL. — why: a verified change is not a satisfied goal.
754**MANDATORY IMPORTANT MUST ATTENTION** break work into small task tracking todos BEFORE starting (one task per change/proof), keep exactly one `in_progress`, add a final review todo; on context loss the current task list first — resume, never duplicate.
755
756**Anti-Rationalization:**
757
758| Evasion | Rebuttal |
759| ---------------------------------------------- | ------------------------------------------------------------------------------------------------ |
760| "Fix is obviously correct, skip the proof" | Obviousness is the illusion this gate breaks. Build the trace anyway — every arrow `file:line`. |
761| "No precedent, but it's clearly right" | No precedent caps confidence <80%. Find a working example or mark the change unproven. |
762| "Reproduction test passes, that's enough" | A single example ≠ a property. Add the universally-quantified regression TC + boundary case. |
763| "Line coverage is green" | Coverage ≠ kill. Show the surviving mutant on the fixed line is now killed (mutation score). |
764| "I'll just patch where it crashes" | Crash site ≠ cause site. Trace backward, fix the lowest invariant owner that protects all paths. |
765| "Score is 75%, close enough to ship" | <80% BLOCKS. Flag to user or return to `$debug-investigate` — never round a confidence up. |
766| "I'm building the proof FOR the fix" | That's confirmation bias. Build the proof AGAINST it — attack first, score what survives. |
767| "I wrote this fix, I know it's right" | Author ≠ reviewer. Reset to skeptic and attack your own change hardest of all. |
768| "Didn't really try to break it, but it's fine" | No genuine refutation pass → capped at 79%. An un-attacked fix is unproven, not proven. |
769| "Only traced the path I reproduced" | Trace ALL related/feeder/sibling paths. The bug usually survives where you never looked. |
770
771**IMPORTANT MUST ATTENTION** be a SKEPTIC — try to DISPROVE the fix and trace ALL related paths; run AFTER `$fix` only; every arrow carries `file:line`; confidence is what survives the attack (≥80% to ship, <60% BLOCK) — these are the gate. (primacy-recency echo of the top three)
772
773**[TASK-PLANNING]** Before acting, analyze task scope and break it into small task tracking todos systematically before starting — this is very important.
774
775<!-- CODEX:SYNC-PROMPT-PROTOCOLS:START -->
776
777## Hookless Prompt Protocol Mirror (Auto-Synced)
778
779Source: `.claude/.ck.json` + `.claude/skills/shared/sync-inline-versions.md` (`:full` blocks) + `.claude/scripts/lib/hookless-prompt-protocol.cjs`
780
781## [WORKFLOW-EXECUTION-PROTOCOL] [BLOCKING] Workflow Execution Protocol — MANDATORY IMPORTANT MUST CRITICAL. Do not skip for any reason.
782
783**Generic portability boundary:** Reusable skills and protocol text stay project-neutral; project-specific conventions are discovered from docs/project-config.json and docs/project-reference/. Apply shared AI-SDD from `shared/sdd-artifact-contract.md`. Read `docs/project-config.json` and `docs/project-reference/docs-index-reference.md`, then open the project reference docs named there. For spec, test-case, behavior-change, public-contract, or `docs/specs/` work, route through the local spec docs named by the docs index: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`, and `workflow-spec-test-code-cycle-reference.md` when specs/tests/code must stay synchronized. If either file or a required reference doc is missing or stale, auto-run `$project-init` (or the narrow lower-level route such as `$project-config`, `$docs-init`, `$scan-all`, or `$scan --target=<key>`) before ordinary project-specific work. Any supported AI tool may execute when this shared context and local docs are available.
784
7851. **DETECT:** If the prompt starts with an explicit slash skill/workflow command, execute it directly. Otherwise match the prompt against the workflow catalog and skill list.
7862. **ANALYZE:** Choose the best option: execute directly, invoke a skill, activate a standard workflow, or compose a custom step combination.
7873. **AUTO-SELECT:** Pick the best option yourself. Do not ask the user to choose between direct execution, skill, standard workflow, or custom workflow.
7884. **ACTIVATE:** For a selected workflow, call `$start-workflow <workflowId>`; for a selected skill, invoke that skill; for a custom workflow, sequence custom steps directly; for direct execution, proceed with the task.
7895. **CREATE TASKS:** task tracking for ALL workflow/skill/custom steps before execution when the selected path has multiple steps.
7906. **PARALLELIZE:** Before executing the task list, tag each task `PAR` (independent inputs + write set disjoint from every other `PAR` task) or `SEQ` (name the blocking dependency), group `PAR` tasks into waves, declare the wave plan, and spawn each wave's sub-agents in ONE message — all-return barrier per wave, fan-out one level deep unless a sub-agent's own definition authorizes further fan-out. Sequential-by-default is a defect when tasks are independent; do not parallelize shared write targets, output-consuming tasks, trivial single-file work, ordering a skill or workflow explicitly fixes, or user-approval gates.
7917. **EXECUTE:** Advance per the **Workflow Step Advancement & Parallel Phases** rule in your context instructions — model-driven; a sub-agent completion advances a step identically to an inline call; a parallel-phase group is an all-return barrier (advance only after ALL members return, never serialize it)
792
793## Shared AI-SDD Protocol Markers
794
795Source: `.claude/skills/shared/sync-inline-versions.md`
796
797## SYNC:ai-sdd-artifact-contract
798
799> **AI-SDD Artifact Contract** — Shared spec-driven development rules stay portable and source-owned.
800>
801> 1. Keep reusable AI-SDD principles in `.claude`; put repository-specific paths, commands, owners, products, and formats in project config/reference docs.
802> 2. Preserve cycle: `spec -> plan -> tasks -> implement -> verify -> update spec/docs`.
803> 3. Trace every requirement or invariant through decision, task, TC/test, source evidence, and docs/spec update.
804> 4. Treat code-to-spec extraction as reference-only until accepted by the canonical spec owner.
805> 5. Any supported AI tool may plan, implement, review, or verify with synced context; using multiple tools is optional.
806> 6. Update `.claude` source first, then sync generated mirrors; do not manually edit `.agents`, `.codex`, or `AGENTS.md`. — why: mirrors are generated artifacts; hand-edits are overwritten on the next sync
807> 7. If `docs/project-config.json`, root instruction files, or a required project-reference doc is missing or stale, auto-run `$project-init` or the narrow lower-level route before ordinary project-specific work.
808>
809> **Active reference:** `shared/sdd-artifact-contract.md` in the active skills root.
810
811---
812
813## SYNC:ai-sdd-artifact-contract:reminder
814
815- **MANDATORY** Apply `shared/sdd-artifact-contract.md`; keep reusable AI-SDD in `.claude` and local rules in project docs.
816- **MANDATORY** Code-to-spec extraction is reference-only until canonical acceptance; any supported AI tool may execute with synced context.
817- **MANDATORY** Update `.claude` source before syncing generated mirrors; do not manually edit `.agents`, `.codex`, or `AGENTS.md`.
818- **MANDATORY** Missing or stale project config, root instruction files, or required reference docs route project-specific work through `$project-init` or the narrow setup route automatically.
819 **[TASK-PLANNING] [MANDATORY]** BEFORE executing any workflow or skill step, create/update task tracking for all planned steps, then keep it synchronized as each step starts/completes.
820
821## [LESSON-LEARNED-REMINDER] [BLOCKING] Task Planning & Continuous Improvement — MANDATORY. Do not skip.
822
823Break work into small tasks (task tracking) before starting. Add final task: "Analyze AI mistakes & lessons learned".
824
825**Extract lessons — ROOT CAUSE ONLY, not symptom fixes:**
826
8271. Name the FAILURE MODE (reasoning/assumption failure), not symptom — "assumed API existed without reading source" not "used wrong enum value".
8282. Generality test: does this failure mode apply to ≥3 contexts/codebases? If not, abstract one level up.
8293. Write as a universal rule — strip project-specific names/paths/classes. Useful on any codebase.
8304. Consolidate: multiple mistakes sharing one failure mode → ONE lesson.
8315. **Recurrence gate:** "Would this recur in future session WITHOUT this reminder?" — No → skip `$learn`.
8326. **Auto-fix gate:** "Could `$code-review`/`$code-simplifier`/`$security-review`/`$lint` catch this?" — Yes → improve review skill instead.
8337. BOTH gates pass → ask user to run `$learn`.
834 **[CRITICAL-THINKING-MINDSET]** Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
835 **Anti-hallucination principle:** 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.
836 **AI Attention principle (Primacy-Recency):** Put the 3 most critical rules at both top and bottom of long prompts/protocols so instruction adherence survives long context windows.
837 **Goal-driven execution:** Define success criteria first, loop until verified, and stop only when observable checks pass.
838 **Tests verify intent:** Tests must protect business rules/invariants and fail when the protected intent breaks, not only mirror current behavior.
839
840## Common AI Mistake Prevention (System Lessons)
841
842- **Re-read files after context compaction.** Edit requires prior Read in same context; compaction wipes read state. Re-read before editing.
843- **Grep for old terms after bulk replacements.** AI over-trusts find/replace completeness. Grep full repo after bulk edits for missed refs in docs/configs/catalogs.
844- **Check downstream references before deleting.** Deletions cascade doc/code staleness. Map referencing files before removal.
845- **After memory loss, check existing state before creating new.** Compaction wipes prior-work memory. Query current state to resume — never blindly duplicate.
846- **Verify AI-generated content against actual code.** AI hallucinates APIs, class names, method signatures. Grep to confirm existence before documenting/referencing.
847- **Trace full dependency chain after edits.** Changing a definition misses downstream consumers. Trace the full chain.
848- **When renaming, grep ALL consumer file types.** Some file types silently ignore missing refs (no compile error). Search code, templates, configs, generated files.
849- **Trace ALL code paths when verifying correctness.** Code existing ≠ code executing. Trace early exits, error branches, conditional skips — not just happy path.
850- **Update docs that embed canonical data when source changes.** Docs inlining derived data (workflows, schemas, configs) go stale silently. Update all embedding docs alongside source.
851- **Verify sub-agent results after context recovery.** Background agents may finish while parent compacted — grep-verify output, don't trust assumed completion.
852- **Cross-check full target list against sub-agent assignments.** Parallel sub-agents by category miss boundary items. Reconcile union of assignments against target list before proceeding.
853- **Sub-agents inherit knowledge only from their agent .md definition — use custom agent types, not built-in Explore.** Tool adoption = permission + knowledge + enforcement (numbered workflow step).
854- **Persist sub-agent findings incrementally, not as a final batch.** Long sub-agents hit cutoffs before final write — findings lost. Instruct append-per-section to report file.
855- **When debugging, ask "whose responsibility?" before fixing.** Trace caller (wrong data) vs callee (wrong handling). Fix at responsible layer — never patch symptom site.
856- **Test failure → record a provisional verdict before trace/edit, then investigate.** Use the full five-way taxonomy: SOURCE-WRONG (production violates intent), TEST-WRONG (assertion/setup is stale), TEST-NOT-OPTIMAL (valid but fragile or low-signal test), ENVIRONMENT-BLOCKED (external state prevents a verdict), or AMBIGUOUS (intent/evidence cannot choose safely). Then trace root cause and triangulate against the governing spec (`docs/specs/**` if one exists) AND source. NEVER weaken an assertion, add a skip, relax a timeout, or change source merely to force green.
857- **Grep ALL removed names after extraction/refactoring.** Primary file "done" ≠ secondary files clean. Grep entire scope for every removed symbol before declaring complete.
858- **Assume existing values are intentional — ask WHY before changing OR flagging one as a defect.** Pattern-matching as "wrong" skips context. Before changing or reporting any constant/limit/flag/cutoff: read comments, git blame, the CALLER's ordering (the guarantee that makes the value correct usually lives in code running immediately BEFORE the cited line), and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard — and in a validation pass, an accurate `file:line` citation proves the transcription, never the defect.
859- **Verify ALL affected outputs, not just the first.** One build green ≠ all green. Multi-stack changes (backend/frontend/tests/docs) require verifying EVERY output.
860- **Evaluate fit before copying a nearby pattern.** Closest example ≠ matching preconditions — verify the new context shares the same constraints, base classes, scope, lifetime.
861- **Holistic-first debugging — resist nearest-attention trap.** Don't dive into first plausible cause. List EVERY precondition (config, env vars, paths, DB, endpoints, creds, versions, DI, data). Verify each against evidence (grep/query — not reasoning). Ask "what would falsify this?" — if nothing, it's not a hypothesis. Most expensive failure: going deeper in "obvious" layer while bug sits in layer never questioned.
862- **Surgical changes — apply the diff test (context-aware).** Two modes: (1) Bug fix → every line traces to the bug; no restyling; orphan cleanup only for imports YOUR changes made unused. (2) Review/enhancement → implement improvements AND announce as "Enhancement beyond main request: [what]". Never silently scope-creep. Diff test: "Would this line exist if I wasn't asked to do X?" — if no, delete or announce.
863- **Surface ambiguity before coding — don't pick silently.** Multiple valid interpretations → present each with effort: "[Request] could mean (1) [N h], (2) [N h]. Which matters?" List scope/format/volume/constraints assumptions first. If simpler path exists, say so. Never silently pick.
864- **[MANDATORY FIRST ACTION] ALWAYS activate a suitable skill or workflow BEFORE responding.** Match task against workflow catalog + skill list; invoke via skill invocation or `$start-workflow <workflowId>`. NEVER answer or write code before checking. Skip = protocol violation.
865- **Why-Review adversarial mindset — apply when reviewing any plan, decision, or design.** Default SKEPTIC not VALIDATOR: steel-man a rejected alternative, invert each stated reason ("what does it sacrifice?"), stress-test top 2-3 assumptions, run pre-mortem ("ships, fails in 3 months — what breaks?"), surface 1-2 alternatives author missed. Section presence ≠ quality; quality = causal reasoning + concrete mitigations + evidence, not "it's better" or "monitor closely".
866- **Front-load report-write in sub-agent prompts for large reviews.** Many-file sub-agents hit budget before final write — findings lost. Design prompts so: (1) report-write is first explicit deliverable, (2) append per-file/section (not batched), (3) scope bounded so reads don't exhaust budget. Truncated mid-sentence with no report file → spawn narrower scope, don't retry same prompt.
867- **After context compaction, re-verify all prior phase outcomes before continuing.** Summaries describe intent, not environment state (git index, filesystem, processes). On resume, FIRST audit: git status, re-read modified files, verify filesystem. Every "completed" claim is an untested hypothesis until evidence confirms.
868- **OOM/memory: check row count before row size.** Triage: (1) Unbounded query — no DB filter for trigger? Push filter to DB; eliminates OOM. (2) Large rows? Projection reduces proportionally. Row reduction > projection in ROI.
869- **Assert the outcome your system OWNS, never the intermediate state your INFRASTRUCTURE owns.** When testing anything asynchronous (queue/broker delivery, retries, background jobs, caches, replication), assert the final business/entity state. NEVER assert the delivery bookkeeping — consume/send status, attempt counts, last-error, row existence or counts in a broker, scheduler, or outbox/inbox table. That bookkeeping lives in shared infrastructure that ANY co-running process (a peer worker, a second replica, a leftover local container) can write, usually under a deterministic shared key, so the assertion silently tests the developer's environment instead of the system: green when run alone, flaky the instant anything else shares that broker + database. Gate question for every assertion: "would this hold no matter WHICH process did the work?" — if no, assert the converged data state instead. Corollary: process-local fault injection and in-process telemetry cannot gate work any process may perform — use them as stress amplifiers (arm → bounded window → disarm → assert convergence), never as preconditions.
870- **Keep domain concepts out of generic/shared/infrastructure layers.** Reusable layer (shared library, framework, infra module) must reference NO consumer-specific domain concept — tenant/customer/product IDs, business entities, feature rules. Leak compiles + runs → passes review silently while coupling the "reusable" layer to one consumer. Keep shared type domain-free; push domain fields/logic down into the consumer via subclass/composition. — why: a layer coupled to one consumer's domain is no longer reusable.
871
872<!-- CODEX:SYNC-PROMPT-PROTOCOLS:END -->