Fix
fix
[Implementation] Use when you need to analyze and fix issues [INTELLIGENT ROUTING]. Flag: --target={ci|issue|logs|test|types|ui} scopes the fix; --target=types resolves TypeScript errors inline.
SKILL.md
Full skill instructions
<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->[BLOCKING] Execute skill steps in declared order. NEVER skip, reorder, merge steps without explicit user approval. [BLOCKING] Before each step or sub-skill call, update task tracking:
in_progresson start,completedon end. [BLOCKING] Every completed/skipped step MUST include evidence or explicit skip reason. [BLOCKING] If Task tools unavailable, maintain equivalent step-by-step plan tracker with same status transitions.
Quick Summary
Goal: Eliminate the root cause of an issue using parallel subagent investigation — traced end-to-start with file:line evidence and fixed at the lowest invariant-owning layer (never the crash site) — then prove the fix with /prove-fix so the disease is cured, not just the symptom.
Workflow:
- Scout — Use scout/researcher subagents to explore issue in parallel
- Diagnose — Trace root cause through code paths with evidence
- Plan — Create fix plan with impact analysis
- Fix — Implement and verify the fix
Key Rules:
- Debug Mindset: every claim needs
file:lineevidence - Use subagents for parallel investigation of multiple hypotheses
- Always create a plan before implementing complex fixes
- Target flag (see Target Routing):
--target={ci|issue|logs|test|types|ui}selects a self-contained inline branch that scopes the fix to that domain. No flag = full diagnose→fix spine below.
Default Mode Policy
Default mode HARD (full rigor). Every section below — parallel scout/researcher subagents, root-cause tracing with
file:lineevidence, Confidence & Evidence Gate, fix plan with impact analysis, preservation tests for the bug — applies by default.Opt out to fast mode ONLY when ALL true (bug genuinely trivial):
- Root cause obvious from error message AND already located (no diagnosis needed)
- Single-file fix, ≤10 lines changed
- No cross-service impact, no contract change
- Test for bug already exists OR bug non-functional (typo, log message)
- Confidence in fix ≥95% without further investigation
Any condition fails → use full protocol below. When in doubt, default hard. Skipping diagnosis on non-trivial bug fixes symptom and leaves disease.
Fast mode skips (and only skips): parallel subagent investigation (direct read/grep instead), separate fix plan (inline change), regression-test authoring (only if covering test exists). Does NOT skip Confidence & Evidence Gate, Behavioral Delta Matrix, or running existing test suite.
Debug Mindset (NON-NEGOTIABLE)
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
- Verify each hypothesis against an actual code trace before acting — do NOT assume first hypothesis correct — why: the first guess is usually the nearest-attention trap, not the cause
- Every root cause claim must include
file:lineevidence - If you cannot prove root cause with code trace, state "hypothesis, not confirmed"
- Question assumptions: "Is this really the cause?" → trace actual execution path
- Challenge completeness: "Are there other contributing factors?" → check related code paths
- No "should fix it" without proof — verify fix addresses traced root cause
⚠️ MANDATORY: Confidence & Evidence Gate
MANDATORY IMPORTANT MUST ATTENTION declare Confidence: X% with evidence list + file:line proof for EVERY claim.
95%+ recommend freely | 80-94% with caveats | 60-79% list unknowns | <60% STOP — gather more evidence.
Ultrathink plan and start fixing these issues; follow Orchestration Protocol, Core Responsibilities, Subagents Team, Development Rules: <issues>$ARGUMENTS</issues>
Target Routing (--target=)
/fix is an intelligent router. With no flag it runs the full diagnose→fix spine below. Pass --target= to scope the run to a self-contained inline branch:
--target | Behavior |
|---|---|
types | Inline branch (below) — TypeScript / type-error resolution. |
ci | Inline branch (below) — CI / pipeline failure triage. |
issue | Inline branch (below) — tracked issue / ticket resolution. |
logs | Inline branch (below) — log / stack-trace-driven debugging. |
test | Inline branch (below) — failing-test repair. |
ui | Inline branch (below) — UI / visual-defect fixes. |
No --target (or an unrecognized value) → run the full Workflow spine below; infer the right specialization from <issues>.
Formerly standalone skills.
--target=ci|issue|logs|test|uiwere previously the separate skills/fix-ci,/fix-issue,/fix-logs,/fix-test,/fix-ui; they are now inline branches of/fix(folded — the standalone names no longer exist).
--target=types — TypeScript / type-error branch
Run tsc --noEmit (or nx build / bun run typecheck / npx tsc) to gather all type errors, then:
- Collect — Capture every type error with
file:line. - Classify — Group by cause: missing types, wrong signatures, import/export issues.
- Fix at root — Give each value its real, specific type (or
unknown+ a narrowing guard). Do NOT useanyto silence the checker —anyships the underlying type defect. Fix the root cause (wrong interface, missing export), not the symptom site. — why:anysilences the checker and lets the type defect ship. - Repeat until
tsc --noEmitis clean — zero type errors. - 🛑 Validate Before Fix: present errors + root cause via
AskUserQuestion, get approval before code changes (skip if inside a workflow). - After fixing, run
/prove-fix— build code proof traces per change with confidence scores. Never skip.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
--target=ci — CI / pipeline-failure branch
Goal: Analyze CI/CD pipeline logs to identify and fix build/test failures in the configured CI provider/tooling.
Key Rules:
- Infrastructure context: read
docs/project-config.json→infrastructure.cicd.toolto identify the CI provider/tooling (e.g.azure-devops,github-actions,gitlab-ci); target that provider's pipeline config files. - Focus on CI-specific issues (env vars, Docker, dependencies, build order).
- Verify the fix does not break local development.
Workflow:
- Use the
debuggersubagent to read the CI logs via the configured CI tool/API (fromdocs/project-config.json), analyze the final failing log/error backward to the root cause, and report back. Write findings to.ai/workspace/analysis/{ci-issue}.analysis.md; re-read before implementing. - 🛑 Present root cause + proposed fix →
AskUserQuestion→ wait for approval. - Implement the fix from the report.
- Use the
testersubagent to verify; report back. - If tests fail, repeat from step 2.
- Report a summary of changes; suggest next steps. Then run
/prove-fix.
Notes: Use the CLI/API for the configured CI provider. If it is GitHub Actions and gh is unavailable, instruct the user to install and authorize GitHub CLI first.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
--target=issue — tracked-issue / ticket branch
Goal: Investigate and fix bugs reported as tracked issues (e.g. GitHub issues) with full traceability.
Active-goal read (BEFORE root-cause work): resolve the active Goal Contract per SYNC:goal-contract-satisfaction-loop (active plan goal.md → plans/goals/{YYMMDD-HHmm}-{slug}/goal.md → create from the issue). Map the ticket's acceptance criteria to the saved success criteria; after the fix, append proof evidence and remaining gaps to the Iteration Log. Closure is blocked while any required criterion remains FAIL.
Key Rules:
- Link the fix back to the issue for traceability.
- Verify the fix addresses the specific reproduction steps from the issue.
Workflow:
- Activate the
debug-investigateskill and follow its workflow. See.claude/docs/AI-DEBUGGING-PROTOCOL.mdfor comprehensive guidelines. - Use external memory at
.ai/workspace/analysis/issue-[number].analysis.mdfor structured analysis. Re-read the ENTIRE analysis file before proposing any fix. - 🛑 Present root cause + proposed fix →
AskUserQuestion→ wait for approval before implementing. - Implement, then run
/prove-fix.
Standalone Review Gate (non-workflow only): if
/fix --target=issueruns outside a workflow, add a/review-changesTaskCreatetodo as the last task. Inside a workflow, skip — the sequence handles/review-changes.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
--target=logs — log / stack-trace branch
Goal: Analyze application logs to diagnose and fix runtime errors or unexpected behavior.
Key Rules:
- Focus on log patterns: stack traces, error codes, timing anomalies.
- Cross-reference logs with source code to find the actual root cause.
Workflow:
- Check whether
./logs.txtexists. If missing, set up permanent log piping in the project's script config (package.json,Makefile,pyproject.toml, …): Bash/Unix append2>&1 | tee logs.txt; PowerShell append*>&1 | Tee-Object logs.txt. Run the command to generate logs. - Use the
debuggersubagent to analyze./logs.txt: read withGrephead_limit: 30(last 30 lines; increase if needed — avoid loading the whole file). Write analysis to.ai/workspace/analysis/{issue-name}.analysis.md; re-read before fixing. - Use the
scoutsubagent to locate the exact source of the issue; report back. - Use the
plannersubagent to create an implementation plan; report back. - 🛑 Present root cause + fix plan →
AskUserQuestion→ wait for approval. - Implement the fix.
- Use the
testersubagent to verify; report back. - Use the
code-reviewersubagent to review the changes; report back. - If tests fail, repeat from step 3.
- Report a summary; suggest next steps. Then run
/prove-fix.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
--target=test — failing-test branch
Goal: Run test suites, analyze failures, and fix the underlying code or test issues.
Active-goal read (BEFORE fixing): resolve the active Goal Contract per SYNC:goal-contract-satisfaction-loop (active plan goal.md → plans/goals/{YYMMDD-HHmm}-{slug}/goal.md → create from the reported test failure). Map failing-test evidence (before) and passing-test evidence (after) to the saved success criteria in the Iteration Log — a passing suite that misses a saved required criterion does NOT close the loop.
Key Rules:
- Distinguish between code bugs and flawed test expectations.
- Re-run tests after the fix to confirm all pass.
- Read
docs/project-reference/integration-test-reference.mdbefore reviewing/writing integration tests; consultdocs/specs/for expected-behavior context when diagnosing failures.
Workflow:
- Use the
testersubagent to compile the code and fix any syntax errors. - Use the
testersubagent to run the tests; report back. Write failure analysis to.ai/workspace/analysis/{test-issue}.analysis.md; re-read before fixing. - If tests fail, use the
debuggersubagent to find the root cause; report back. - Use the
plannersubagent to create an implementation plan; report back. - 🛑 Present root cause + fix plan →
AskUserQuestion→ wait for approval. - Implement the plan step by step.
- Use the
testersubagent to verify; report back. - Use the
code-reviewersubagent to review the changes; report back. - If tests fail, repeat from step 2.
- Report a summary; suggest next steps. Then run
/prove-fix.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
--target=ui — UI / visual-defect branch
Goal: Diagnose and fix UI/UX issues — layout, styling, responsiveness, and visual bugs.
Key Rules:
- Always use BEM classes on template elements.
- Check responsive breakpoints when fixing layout issues.
- Pre-read (design system): load
designSystem.canonicalDoc+tokenFilesfromdocs/project-config.jsonso fixes use real token names (--brand-*,$brand-*) and canonical component classes — not invented values.
Required skills (priority order): ui-ux-pro-max (design-intelligence DB) → web-design-guidelines (principles) → frontend-design (implementation patterns).
Workflow:
FIRST — run ui-ux-pro-max searches to understand context and common issues:
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "<product-type>" --domain product
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "<style-keywords>" --domain style
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "accessibility" --domain ux
python3 $HOME/.claude/skills/ui-ux-pro-max/scripts/search.py "z-index animation" --domain ux
If the user provides screenshots/videos, use the visual analysis tooling skill to describe the issue in detail so developers can predict the root causes.
🛑 After identifying the UI root cause, present findings + proposed fix →
AskUserQuestion→ wait for approval before any code change.
- Use the
ui-ux-designersubagent to implement the fix step by step (against the design guideline —designSystem.canonicalDoc). - Capture screenshots (at the exact parent container, not the whole page) and analyze with the appropriate Gemini skill (
visual analysis tooling,video-analysis, ordocument-extraction) so the result matches the design guideline and addresses all issues. Repeat until addressed. - Use the browser automation tooling to verify the fix matches the design guideline.
- Use the
testersubagent to compile and test; report back. Repeat until all tests pass. - If the user approves: run the
project-manageranddocs-managersubagents in parallel to update plan progress and./docs; haveproject-manageralso create/update a project roadmap at./docs/project-roadmap.md. - Report a summary; suggest next steps. Then run
/prove-fix.
The Debug Mindset, Confidence & Evidence Gate, and all SYNC gates below apply to this branch unchanged.
Workflow:
If user provides screenshots or videos, use visual analysis tooling skill to describe issue in detail; ensure developers can predict root causes from description.
Fulfill the request
Question Everything: Use AskUserQuestion tool to ask probing questions to fully understand user's request, constraints, true objectives. Don't assume — clarify until 100% certain.
- Use
AskUserQuestionto clarify any open questions. - Ask 1 question at a time; wait for answer before next question.
- No questions → start next step.
⚠️ Validate Before Fix (NON-NEGOTIABLE): After root cause + plan creation, MUST ATTENTION present findings + proposed fix plan to user via
AskUserQuestionand get explicit approval BEFORE any code changes. No silent fixes. End-to-Start Trace Gate: For non-trivial bugs, failed verification, stale/incorrect final outputs, or behavior-changing fixes, the root-cause plan MUST ATTENTION includeDebugger Trace: End -> Start, feeder paths, hypothesis matrix, owning fix layer, and forward convergence proof. If missing, STOP and run/debug-investigateor/investigatebefore planning code changes.
Fix the issue
Active-goal read (BEFORE root-cause work): resolve the active Goal Contract per SYNC:goal-contract-satisfaction-loop — active plan goal.md → plans/goals/{YYMMDD-HHmm}-{slug}/goal.md → create from the reported issue via .claude/templates/goal-contract-template.md. The saved success criteria define what "fixed" means — a proven local fix that misses a saved required criterion is NOT complete. After proof, append root cause, proof evidence, and remaining goal gaps to the Iteration Log. Tiny fixes may skip deeper gates ONLY with user-accepted reason recorded in the goal file.
Use sequential-thinking skill to break complex problems into sequential thought steps.
Use problem-solving skills to tackle issues.
Analyze skills catalog and activate other needed skills during the process.
- Use
debuggersubagent to find root cause and report back to main agent. 1.5. Write investigation results to.ai/workspace/analysis/{issue-name}.analysis.md. Re-read ENTIRE file before planning fix. 1.6. Confirm the report contains final symptom -> reader -> storage/projection -> writer -> consumer/job -> producer/origin, all feeder paths, hypothesis matrix, owning fix layer, and forward convergence proof. - Use
researchersubagent to research root causes on internet (if needed) and report back. - Use
plannersubagent to create implementation plan based on reports; report back. - 🛑 Present root cause + fix plan →
AskUserQuestion→ wait for user approval. - Use
/codeSlashCommand to implement plan step by step. - Final Report:
- Report back to user with summary of changes; explain briefly; guide user to get started; suggest next steps.
- Ask user whether to commit and push to git; if yes, use
git-managersubagent.
- IMPORTANT: Sacrifice grammar for concision when writing reports.
- IMPORTANT: List unresolved questions at end of reports, if any.
REMEMBER:
-
Generate images with
visual analysis toolingskills on the fly for visual assets. -
Read and analyze generated assets with
visual analysis toolingskills to verify they meet requirements. -
For image editing (removing background, adjusting, cropping), use media processing tooling as needed.
-
After fixing, MUST ATTENTION run
/prove-fix— build code proof traces per change with confidence scores. Never skip.
Next Steps (Standalone: MUST ATTENTION ask user via AskUserQuestion. Skip if inside workflow.)
MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS: If this skill was called outside a workflow, MUST ATTENTION use
AskUserQuestionto present these options. Do NOT skip because task seems "simple" or "obvious" — user decides:
- "Proceed with full workflow (Recommended)" — Detect best workflow to continue from here (fix applied). Ensures prove-fix, review, testing, docs steps aren't skipped.
- "/prove-fix" — Prove fix correctness with code traces
- "/test" — Run tests to verify fix
- "Skip, continue manually" — user decides
If already inside a workflow, skip — workflow handles sequencing.
[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting — including tasks for each file read. Prevents context loss from long files. For simple tasks, MUST ATTENTION ask user whether to skip.
docs/project-reference/domain-entities-reference.md— Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models) (read directly when relevant; do not rely on hook-injected conversation text)
<!-- /SYNC:end-to-start-debugger-trace --> <!-- SYNC:root-cause-debugging -->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.
- 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:lineevidence.- 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.
- 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.
- 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.- 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.
- 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.
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.
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.
<!-- /SYNC:root-cause-debugging --> <!-- SYNC:nested-task-creation -->Root Cause Debugging — Systematic approach, never guess-and-check.
- Reproduce — Confirm the issue exists with evidence (error message, stack trace, screenshot)
- Isolate — Narrow to specific file/function/line using binary search + graph trace
- Trace — Follow data flow from input to failure point. Read actual code, don't infer.
- Hypothesize — Form theory with confidence %. State what evidence supports/contradicts it
- Verify — Test hypothesis with targeted grep/read. One variable at a time.
- Fix — Address root cause, not symptoms. Verify fix doesn't break callers via graph
connectionsNEVER: Guess without evidence. Fix symptoms instead of cause. Skip reproduction step.
<!-- /SYNC:nested-task-creation --> <!-- SYNC:project-reference-docs-guide -->Nested Task Expansion Contract — For workflow-step invocation, the
[Workflow] ...row is only a parent container; the child skill still creates visible phase tasks.
- Call
TaskListfirst. If a matching active parent workflow row exists, setnested=trueand recordparentTaskId; otherwise run standalone.- Create one task per declared phase before phase work. When nested, prefix subjects
[N.M] $skill-name — phase.- When nested, link the parent with
TaskUpdate(parentTaskId, addBlockedBy: [childIds]).- Orchestrators must pre-expand a child skill's phase list and link the workflow row before invoking that child skill or sub-agent.
- Mark exactly one child
in_progressbefore work andcompletedimmediately after evidence is written.- Complete the parent only after all child tasks are completed or explicitly cancelled with reason.
Blocked until:
TaskListdone, child phases created, parent linked when nested, first child markedin_progress.
<!-- /SYNC:project-reference-docs-guide --> <!-- SYNC:task-tracking-external-report -->Project Reference Docs Gate — Run after task-tracking bootstrap and before target/source file reads, grep, edits, or analysis. Project docs override generic framework assumptions.
- Identify scope: file types, domain area, and operation.
- Required docs by trigger: always
docs/project-reference/lessons.md; doc lookupdocs-index-reference.md; reviewcode-review-rules.md; backend/CQRS/APIbackend-patterns-reference.md; domain/entitydomain-entities-reference.md; frontend/UIfrontend-patterns-reference.md; styles/designscss-styling-guide.md+design-system/design-system-canonical.md; integration testsintegration-test-reference.md; E2Ee2e-test-reference.md; feature docs/specsfeature-spec-reference.md+spec-system-reference.md+spec-principles.md; behavior/public-contract/spec-test-code syncworkflow-spec-test-code-cycle-reference.md; derived spec index/ERD/reimplementation guidesspec-system-reference.md+ source Feature Specs underdocs/specs/; architecture/new areaproject-structure-reference.md.- Read every required doc. 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-initor the narrow lower-level route (/project-config,/docs-init,/scan-all,/scan --target=<key>,/claude-md-init) before ordinary project-specific work. If Codex mirrors orAGENTS.mdare missing/stale, ask the user to run/sync-codex; do not auto-run it.- Before target work, state:
Reference docs read: ... | Not applicable: ....Ready when: scope evaluated, required docs checked/read or setup route completed,
lessons.mdconfirmed, citation emitted.
<!-- /SYNC:task-tracking-external-report --> <!-- SYNC:critical-thinking-mindset -->Task Tracking & External Report Persistence — Bootstrap this before execution; then run project-reference doc prefetch before target/source work.
- Create a small task breakdown before target file reads, grep, edits, or analysis. On context loss, inspect the current task list first.
- Mark one task
in_progressbefore work andcompletedimmediately after evidence; never batch transitions.- For plan/review work, create
plans/reports/{skill}-{YYMMDD}-{HHmm}-{slug}.mdbefore first finding.- Append findings after each file/section/decision and synthesize from the report file at the end.
- Final output cites
Full report: plans/reports/{filename}.Blocked until: task breakdown exists, report path declared for plan/review work, first finding persisted before the next finding.
<!-- /SYNC:critical-thinking-mindset --> <!-- SYNC:understand-code-first -->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.
<!-- /SYNC:understand-code-first --> <!-- SYNC:evidence-based-reasoning -->Understand Code First — HARD-GATE: Do NOT write, plan, or fix until you READ existing code.
- Search 3+ similar patterns (
grep/glob) — citefile:lineevidence- Read existing files in target area — understand structure, base classes, conventions
- Run
python .claude/scripts/code_graph trace <file> --direction both --jsonwhen.code-graph/graph.dbexists- Map dependencies via
connectionsorcallers_of— know what depends on your target- Write investigation to
.ai/workspace/analysis/for non-trivial tasks (3+ files)- Re-read analysis file before implementing — never work from memory alone. — why: long context drifts from the file; the file is ground truth
- NEVER invent new patterns when existing ones work — match exactly or document deviation. — why: divergent patterns fragment the codebase and slow every future reader
BLOCKED until:
- [ ]Read target files- [ ]Grep 3+ patterns- [ ]Graph trace (if graph.db exists)- [ ]Assumptions verified with evidence
<!-- /SYNC:evidence-based-reasoning --> <!-- SYNC:fix-layer-accountability -->Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs proof.
- Cite
file:line, grep results, or framework docs for EVERY claim- Declare confidence: >80% act freely, 60-80% verify first, <60% DO NOT recommend
- Cross-service validation required for architectural changes
- "I don't have enough evidence" is valid and expected output
BLOCKED until:
- [ ]Evidence file path (file:line)- [ ]Grep search performed- [ ]3+ similar patterns found- [ ]Confidence level statedForbidden without proof: "obviously", "I think", "should be", "probably", "this is because" If incomplete → output:
"Insufficient evidence. Verified: [...]. Not verified: [...]."
<!-- /SYNC:fix-layer-accountability --> <!-- SYNC:source-test-drift-check -->Fix-Layer Accountability — NEVER fix at the crash site. Trace the full flow, fix at the owning layer.
AI default behavior: see error at Place A → fix Place A. This is WRONG. The crash site is a SYMPTOM, not the cause.
MANDATORY before ANY fix:
- 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.
- 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.
- 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.
- 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.
BLOCKED until:
- [ ]Full data flow traced (origin → crash)- [ ]Invariant owner identified withfile:lineevidence- [ ]All access sites audited (grep count)- [ ]Fix layer justified (lowest layer that protects most consumers)Anti-patterns (REJECT these):
- "Fix it where it crashes" — Crash site ≠ cause site. Trace upstream.
- "Add defensive checks at every consumer" — Scattered defense = wrong layer. One authoritative fix > many scattered guards.
- "Both fix is safer" — Pick ONE authoritative layer. Redundant checks across layers send mixed signals about who owns the invariant.
<!-- /SYNC:source-test-drift-check --> <!-- SYNC:ai-mistake-prevention -->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.
<!-- /SYNC:ai-mistake-prevention --> <!-- SYNC:fix-layer-accountability:reminder -->AI Mistake Prevention — Failure modes to avoid on every task:
Check downstream references before deleting. Deleting components causes documentation and code staleness cascades. Map all referencing files before removal. Verify AI-generated content against actual code. AI hallucinates APIs, class names, and method signatures. Always grep to confirm existence before documenting or referencing. Trace full dependency chain after edits. Changing a definition misses downstream variables and consumers derived from it. Always trace the full chain. Trace ALL code paths when verifying correctness. Confirming code exists is not confirming it executes. Always trace early exits, error branches, and conditional skips — not just happy path. When debugging, ask "whose responsibility?" before fixing. Trace whether bug is in caller (wrong data) or callee (wrong handling). Fix at responsible layer — never patch symptom site. Assume existing values are intentional — ask WHY before changing. Before changing any constant, limit, flag, or pattern: read comments, check git blame, examine surrounding code. Verify ALL affected outputs, not just the first. Changes touching multiple stacks require verifying EVERY output. One green check is not all green checks. Holistic-first debugging — resist nearest-attention trap. When investigating any failure, list EVERY precondition first (config, env vars, DB names, endpoints, DI registrations, data preconditions), then verify each against evidence before forming any code-layer hypothesis. Surgical changes — apply the diff test. Bug fix: every changed line must trace directly to the bug. Don't restyle or improve adjacent code. Enhancement task: implement improvements AND announce them explicitly. Surface ambiguity before coding — don't pick silently. If request has multiple interpretations, present each with effort estimate and ask. Never assume all-records, file-based, or more complex path. Keep domain concepts out of generic/shared/infrastructure layers. A reusable layer (shared library, framework, infra module) must reference NO consumer-specific domain concept — tenant/customer/product IDs, business entities, feature rules. The leak compiles and runs, so it passes review silently while coupling the "reusable" layer to one consumer. Push domain fields/logic down into the consumer via subclass or composition.
IMPORTANT MUST ATTENTION trace full data flow and fix at the owning layer, not the crash site. Audit all access sites before adding ?..
IMPORTANT MUST ATTENTION search 3+ existing patterns and read code BEFORE any modification. Run graph trace when graph.db exists.
<!-- /SYNC:understand-code-first:reminder --> <!-- SYNC:evidence-based-reasoning:reminder -->IMPORTANT MUST ATTENTION cite file:line evidence for every claim. Confidence >80% to act, <60% = do NOT recommend.
MUST ATTENTION apply critical thinking — every claim needs traced proof, confidence >80% to act. Anti-hallucination: never present guess as fact.
<!-- /SYNC:critical-thinking-mindset:reminder --> <!-- SYNC:ai-mistake-prevention:reminder -->MUST ATTENTION apply AI mistake prevention — holistic-first debugging, fix at responsible layer, surface ambiguity before coding, re-read files after compaction.
<!-- /SYNC:ai-mistake-prevention:reminder --> <!-- SYNC:task-tracking-external-report:reminder -->- MANDATORY Bootstrap task tracking before target work; transition one task at a time.
- MANDATORY Persist plan/review findings to
plans/reports/incrementally and synthesize from disk.
- MANDATORY After task-tracking bootstrap and before target/source work, read required project-reference docs and cite
Reference docs read: .... - MANDATORY Always include
lessons.md; project conventions override generic defaults. - MANDATORY If project config, root instruction files, or any required reference doc is missing, stop and run or ask the user to run
/project-init.
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.
<!-- /SYNC:end-to-start-debugger-trace:reminder --> <!-- SYNC:nested-task-creation:reminder -->- MANDATORY Parent workflow rows do not replace child phase tracking; expand phases and link the parent when nested.
- MANDATORY Orchestrators pre-expand child skill phases before invocation; use
[N.M] $skill-name — phaseprefixes and one-in_progressdiscipline.
- 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.
Closing Reminders
IMPORTANT MUST ATTENTION Goal: Eliminate the root cause of an issue — traced end-to-start with file:line evidence and fixed at the lowest invariant-owning layer (never the crash site) — then prove the fix with /prove-fix so the disease is cured, not just the symptom.
IMPORTANT MUST ATTENTION default mode HARD — opt out to fast mode ONLY when bug is genuinely trivial (all 5 conditions met)
IMPORTANT MUST ATTENTION break work into small todo tasks via TaskCreate BEFORE starting
IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
IMPORTANT MUST ATTENTION cite file:line evidence for every claim (confidence >80% to act)
IMPORTANT MUST ATTENTION trace data flow and fix at owning layer — NEVER at crash site
IMPORTANT MUST ATTENTION STOP after 3 failed fix attempts — report outcomes, ask user before #4
IMPORTANT MUST ATTENTION add a final review todo task to verify work quality
[TASK-PLANNING] Before acting, analyze task scope and systematically break into small todo tasks and sub-tasks via TaskCreate.
