--- name: self-correction-loop description: Use when a hook/tool returns a warning, lint/type/build error, or test failure after your edit. Iterate evidence-first; stop when verification passes. --- # Self-Correction Loop When your edit produces a warning/error signal, you're in a **correction loop**. This skill is the discipline that keeps the loop productive instead of thrashing. ## Trigger signals You should engage this loop when ANY of these happen after your edit: - `PostToolUse` hook injected `clang-tidy warnings:` / `lint warnings:` / similar - A `Bash` command you ran returned non-zero exit - A test runner reports failures - A type-checker reports errors - The user says "that broke X" / "it's failing now" ## The Loop (RED → diagnose → minimal-fix → GREEN) This is **TDD's RED-GREEN-REFACTOR adapted for correction**: ``` 1. CAPTURE the signal - What is the EXACT error message? - Which file / line? - What was my last change? 2. DIAGNOSE root cause (not symptom) - Read the error carefully — the answer is often in it - Check if my change broke an invariant elsewhere - Do NOT guess. If unclear, narrow with prints / smaller test cases 3. MINIMAL FIX - Smallest possible change that resolves THE specific issue - No "while I'm here" tangents (that's scope creep — see scope-jump) - Do NOT mask the error (e.g. catch-and-ignore) without explicit reason 4. RE-VERIFY - Run the same command that produced the signal - Observe the new output - Capture it as evidence ``` ## Loop budget This loop is for **surface signals** that a quick minimal fix resolves. If a minimal fix doesn't clear the signal within **1–2 iterations** — or the failure spans components / needs backward root-cause tracing — **switch to `superpowers:systematic-debugging`** (its 4-phase root-cause process). Don't keep thrashing minimal fixes here. If you've iterated 3 times on the same signal without resolving it, **stop and escalate**: - Switch to `superpowers:systematic-debugging` for structured root-cause investigation (its budget also caps at 3 fixes → then question the architecture; the two thresholds are intentionally aligned) - Read more of the surrounding code than you have so far - Invoke `docs-lookup` skill for the specific error class (Context7 → WebSearch fallback) - Tell the user: *"I've tried 3 approaches to . Latest output: <...>. I need more context. Recommend either