afc-debug
Bug diagnosis and fix — root-cause analysis for errors, crashes, broken behavior
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Bug diagnosis and fix — root-cause analysis for errors, crashes, broken behavior
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Code and component analysis — analyze code, trace flows, audit consistency, inspect components
Architecture analysis and design review
Full auto pipeline — run spec-to-clean cycle automatically for new features
Save session state for later resumption
Resolve spec ambiguities with clarifying questions
Pipeline artifact cleanup and codebase hygiene
| name | afc:debug |
| description | Bug diagnosis and fix — root-cause analysis for errors, crashes, broken behavior |
| argument-hint | [bug description, error message, or reproduction steps] |
| allowed-tools | ["Read","Write","Edit","Bash","Glob","Grep"] |
| model | sonnet |
Analyzes the root cause of a bug and fixes it. Validates the safety and accuracy of the fix with convergence-based Critic Loop.
$ARGUMENTS — (required) Bug description, error message, or reproduction steps!cat .claude/afc.config.md 2>/dev/null || echo "[CONFIG NOT FOUND] .claude/afc.config.md not found. Create it with /afc:init."
Extract from $ARGUMENTS:
Ask user for additional information if needed (max 2 questions)
Proceed in order, applying adaptive skipping based on symptom type:
git log --oneline -10 -- {related files} — skip if bug is clearly pre-existing (user reports it "always" fails)When skipping a step, note: "Skipped: {reason}". Do not skip steps 1 and 2 unless step 1 alone identifies the root cause.
List possible causes as a hypothesis list:
### Hypotheses
0. **[Not a Bug?]** {intended behavior explanation}: {evidence from docs/code/spec}
1. **[High probability]** {cause1}: {evidence}
2. **[Medium probability]** {cause2}: {evidence}
3. **[Low probability]** {cause3}: {evidence}
Always evaluate hypothesis 0 first. Check:
If hypothesis 0 is confirmed (not a bug):
"Not a bug — intended behavior."If hypothesis 0 is rejected: verify remaining hypotheses starting from highest probability.
Precondition: Only proceed if a genuine bug was confirmed in Step 3 (hypothesis 0 rejected).
Always read
${CLAUDE_SKILL_DIR}/../../docs/critic-loop-rules.mdfirst and follow it.
Run the critic loop until convergence. Safety cap: 5 passes.
Fast-path: If the fix is a single-line change (null guard, typo, missing import) with no behavioral side effects: run 1 pass with both criteria. If both PASS on the first pass, converge immediately without adversarial challenge.
| Criterion | Validation |
|---|---|
| SAFETY | Does the fix break any other functionality? Any side effects? |
| CORRECTNESS | Does it actually resolve the root cause? Or just mask the symptom? |
Follow verdict handling and output format per docs/critic-loop-rules.md.
{config.gate}
Retry after fixing on failure (max 3 attempts).
If this debug session reveals a pattern not previously documented in .claude/afc/memory/retrospectives/:
Append to .claude/afc/memory/retrospectives/{YYYY-MM-DD}.md:
## Pattern: {category}
**What happened**: {concrete description}
**Root cause**: {why this bug occurred}
**Prevention rule**: {actionable rule — usable in future plan/implement phases}
**Severity**: Critical | Warning
Only write if the pattern is new and actionable. Generic observations are prohibited.
If bug confirmed and fixed:
Debug complete
├─ Root cause: {one-line summary}
├─ Fixed files: {file list}
├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
├─ Verified: typecheck + lint passed
└─ Impact scope: {affected components/features}
If not a bug (intended behavior):
Debug complete
├─ Verdict: Not a bug — intended behavior
├─ Explanation: {why this behavior is correct}
├─ Evidence: {code path, documentation, or spec reference}
├─ Fixed files: none
└─ Suggestion: {documentation improvement if non-obvious, or "none"}