Systematic Debugging & Verification Discipline
Adapted for ApexCluster from obra/superpowers (skills/systematic-debugging, skills/requesting-code-review, and skills/verification-before-completion, MIT).
Purpose
Eliminate guess-and-patch debugging loops by enforcing scientific root-cause isolation, minimal targeted fixes, independent diff review, and fresh verification evidence before declaring any issue solved.
Phase 1: Reproduce & Gather Evidence First
Never propose a code edit until you have directly observed the failure:
- Read the Exact Failure: Capture the full error message, stack trace, failing assertion, HTTP status, or exit code—do not paraphrase from intuition.
- Minimal Reproduction: Identify the smallest deterministic command or test case that triggers the bug reliably.
- Trace Recent Changes & Boundaries: Inspect recent git diffs, data boundaries, config/env inputs, and cross-module contracts around the failing path.
Phase 2: Pattern Analysis & Single-Hypothesis Testing
- Compare Working vs. Failing Paths: Find a similar working code path or passing test in the repository and diff every assumption (types, encoding, async timing, path resolution, permissions, state initialization).
- Form One Falsifiable Hypothesis: State explicitly: "I believe root cause X produces symptom Y because of code path Z."
- Verify the Hypothesis: Confirm X with targeted inspection, logging, or a minimal test—never stack three speculative edits at once. If three consecutive hypotheses fail, step back and question the underlying architectural assumption.
Phase 3: Minimal Fix & Regression Test
- Write a Failing Regression Test First: Capture the exact bug in an automated test and confirm it fails for the expected reason.
- Apply the Smallest Clean Root-Cause Fix: Fix the cause at the true boundary rather than adding brittle downstream band-aids or swallowing errors.
- Audit Scope & Side Effects: Review the full diff (
git diff) for unintended edits, edge cases, concurrency/cleanup leaks, and security regressions.
Phase 4: Verification Before Completion (Iron Law)
- No Claims Without Fresh Evidence: Run the full relevant test suite, typecheck, and build after the final edit and inspect real command exit codes and outputs.
- Request Independent Review (When Multi-Agent): Hand off a clean diff summary (intent, root cause, changed files, test commands run) to an independent reviewer seat without polluting their context with noisy trial logs.
- Honest Failure Reporting: If a check cannot be run (for example, missing optional service or offline constraint), report exactly what was verified and what remains unverified.


