one-pass-debug
npx skills add https://github.com/apexbusiness-systems/apex-omnihub --skill one-pass-debug
Agent 安装分布
Skill 文档
ONE-PASS DEBUG â Omniscient Zero-Iteration Debugging Protocol
“NEVER touch code until you’re 1000% certain. Simulate first. Execute once. Done.”
CONTRACT
Input: Bug report, error message, failing test, broken behavior, stack trace, or “it doesn’t work” Output: Single surgical fix applied with zero guessing, zero iteration, zero rollback needed Success: Problem solved in ONE code change. No “let me try this” loops.
THE GOLDEN RULE
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â â NEVER TOUCH CODE UNTIL PRE-FLIGHT CHECKLIST = 100% GREEN â
â â
â If ANY uncertainty exists â GATHER MORE EVIDENCE â
â If simulation reveals gaps â MAP THE UNKNOWN â
â If root cause is assumed â PROVE IT FIRST â
â â
â CODE CHANGES ARE THE LAST STEP, NOT THE FIRST â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
PHASE 1: SCOPE LOCK (2 minutes max)
Goal: Define EXACT problem boundaries. No scope creep. No tangents.
Checklist
â¡ What EXACTLY is broken? (One sentence, no "and")
â¡ What is the EXPECTED behavior?
â¡ What is the ACTUAL behavior?
â¡ When did it LAST work? (Commit hash, date, or "never")
â¡ What CHANGED since it last worked?
Decision Tree
Can you answer ALL 5 questions with certainty?
ââ YES â Proceed to Phase 2
ââ NO â STOP. Get answers first. DO NOT PROCEED.
Output Template
SCOPE LOCK COMPLETE:
- Broken: [exact symptom]
- Expected: [exact behavior]
- Actual: [exact behavior]
- Last worked: [timestamp/commit]
- Changed since: [specific changes]
PHASE 2: CONTEXT HARVEST (5-15 minutes)
Goal: Gather ALL relevant evidence. Leave no stone unturned.
Mandatory Collection
1. ERROR EVIDENCE
â¡ Full stack trace (not truncated)
â¡ Exact error message (copy-paste, not paraphrased)
â¡ Error code if present
â¡ Line numbers + file paths
2. STATE EVIDENCE
â¡ Input that triggers bug
â¡ Environment (OS, runtime version, config)
â¡ Relevant variable values at crash point
â¡ Database/API state if applicable
3. CODE EVIDENCE
â¡ The failing code block (with 20 lines context above/below)
â¡ Related functions/methods it calls
â¡ Recent changes (git diff or equivalent)
â¡ Test that reproduces the bug
4. TIMELINE EVIDENCE
â¡ When bug first appeared
â¡ Frequency (always/sometimes/rare)
â¡ Conditions that trigger vs don't trigger
Evidence Sufficiency Check
Can you answer these WITHOUT guessing?
ââ What exact line fails? â If NO, add logging/breakpoints
ââ What exact value causes failure? â If NO, inspect state
ââ What exact condition triggers it? â If NO, test variations
ââ ALL YES? â Proceed to Phase 3
PHASE 3: ROOT CAUSE DEDUCTION (The Core)
Goal: Eliminate ALL possibilities until ONE remains. Not guessingâPROVING.
The Deduction Matrix
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â HYPOTHESIS â EVIDENCE â VERDICT â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â H1: [theory] â
â Evidence for: [what supports this] â
â Evidence against: [what contradicts this] â
â Verdict: â PROVEN / â ELIMINATED / ? NEEDS MORE DATA â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â H2: [theory] â
â Evidence for: [...] â
â Evidence against: [...] â
â Verdict: â / â / ? â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â H3: [theory] â
â ... continue until ONE remains proven â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Hypothesis Generation Rules
ALWAYS generate minimum 3 hypotheses:
1. The obvious cause (what it looks like)
2. The upstream cause (what feeds into it)
3. The environmental cause (what surrounds it)
COMMON ROOT CAUSE CATEGORIES:
- Data: null/undefined, wrong type, missing field, stale cache
- Logic: off-by-one, wrong operator, inverted condition, race condition
- State: mutation, async timing, lifecycle order, memory leak
- Config: wrong env var, missing dependency, version mismatch
- Integration: API contract change, network, timeout, auth
Elimination Protocol
For each hypothesis:
1. What would be TRUE if this hypothesis is correct?
2. What would be FALSE if this hypothesis is correct?
3. Check the evidence against both.
4. If evidence contradicts â ELIMINATE
5. If evidence supports â KEEP, gather more proof
6. Continue until ONE hypothesis has overwhelming evidence
Root Cause Certainty Gate
â DO NOT PROCEED UNLESS:
â¡ Only ONE hypothesis remains
â¡ You can explain WHY all others are wrong
â¡ You can predict EXACTLY what the fix will change
â¡ You can describe the bug to a colleague in 30 seconds
PHASE 4: MENTAL SIMULATION (Critical)
Goal: Execute the fix IN YOUR MIND first. Find edge cases before touching code.
Simulation Protocol
1. TRACE FORWARD
- Start at the bug
- Apply your fix mentally
- Trace execution path forward
- What changes? What stays same?
2. TRACE BACKWARD
- Start at desired outcome
- What must be true for fix to work?
- What assumptions are you making?
- Are those assumptions valid?
3. EDGE CASE SWEEP
â¡ What if input is null/empty?
â¡ What if input is maximum size?
â¡ What if called multiple times?
â¡ What if called out of order?
â¡ What if network/IO fails?
â¡ What if concurrent access?
4. BLAST RADIUS CHECK
â¡ What other code calls this function?
â¡ Will fix break any of those callers?
â¡ Are there tests that will now fail?
â¡ Are there dependent systems affected?
Simulation Output
MENTAL SIMULATION COMPLETE:
- Fix location: [file:line]
- Fix action: [exact change]
- Execution path verified: [YES/NO]
- Edge cases checked: [list]
- Blast radius: [none/contained/widespread]
- Side effects: [none/list them]
- Confidence: [must be 100% to proceed]
PHASE 5: PRE-FLIGHT CHECKLIST
â MANDATORY GATE â Code changes BLOCKED until ALL green
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â PRE-FLIGHT CHECKLIST â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â¡ Scope is locked (no creep) â
â â¡ All evidence collected (no gaps) â
â â¡ Root cause PROVEN (not assumed) â
â â¡ Other hypotheses ELIMINATED (with evidence) â
â â¡ Mental simulation passed (all paths traced) â
â â¡ Edge cases checked (no surprises) â
â â¡ Blast radius known (side effects mapped) â
â â¡ Fix is MINIMAL (smallest possible change) â
â â¡ Fix is SURGICAL (touches only what's needed) â
â â¡ Rollback plan exists (if impossible scenario) â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â ALL GREEN? â Execute Phase 6 â
â ANY RED? â Return to appropriate phase. DO NOT PROCEED. â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
PHASE 6: SURGICAL EXECUTION
Goal: One precise cut. No exploratory surgery.
Execution Rules
1. Make the SMALLEST change that fixes the root cause
2. Change ONE thing at a time (even if fix has multiple parts)
3. Each change must be independently testable
4. Comment WHY if the fix is non-obvious
5. NO "while I'm here" improvementsâfix ONLY the bug
Fix Template
// FIX: [ticket/issue number]
// ROOT CAUSE: [one sentence]
// CHANGE: [what you're changing and why]
[minimal code change here]
Post-Fix Validation
â¡ Bug reproduction test now passes
â¡ All existing tests still pass
â¡ Manual verification of expected behavior
â¡ Edge cases from simulation verified
â¡ No new warnings/errors introduced
PHASE 7: CLOSURE PROTOCOL
Goal: Ensure bug CANNOT return. Document for future.
Closure Checklist
â¡ Root cause documented (for future reference)
â¡ Regression test added (catches if bug returns)
â¡ Related code reviewed (same pattern elsewhere?)
â¡ Knowledge shared (team aware of pattern)
Closure Statement
BUG RESOLVED:
- Root cause: [one sentence]
- Fix applied: [file:line, change summary]
- Regression test: [test name/location]
- Pattern risk: [none/low/mediumâwhere else might this exist?]
ANTI-PATTERNS (What Creates Loops)
â “Let me try this”
Changing code to see what happens = GUESSING â You will loop. Go back to Phase 3.
â “It might be…”
Uncertainty = insufficient evidence â Go back to Phase 2. Collect more.
â “I’ll fix this and that”
Multiple changes = unknown cause of success â ONE change. ONE test. ONE conclusion.
â “The stack trace points here”
Stack trace shows WHERE, not WHY â Phase 3 finds WHY. Don’t skip it.
â “Works on my machine”
Environment difference = missing evidence â Add environment to Phase 2 collection.
â “I’ve seen this before”
Pattern matching without proof = assumption â PROVE it’s the same. Evidence required.
UNIVERSAL APPLICABILITY
This protocol works for ALL code because it targets the DEBUG PROCESS, not the language:
| Domain | Phase 2 Additions | Phase 3 Focus |
|---|---|---|
| Frontend | Console logs, network tab, DOM state | State management, async timing, render cycles |
| Backend | Server logs, DB queries, API traces | Request lifecycle, auth flow, data transform |
| Mobile | Device logs, crash reports, memory profile | Lifecycle, threading, platform APIs |
| Database | Query plans, locks, transaction logs | Joins, indexes, constraints, isolation |
| Infra | System logs, metrics, config diffs | Resource limits, network, permissions |
| ML/AI | Training logs, tensor shapes, gradients | Data pipeline, model architecture, hyperparams |
QUICK REFERENCE
PHASE 1: SCOPE LOCK â What EXACTLY is broken?
PHASE 2: CONTEXT HARVEST â Gather ALL evidence
PHASE 3: ROOT CAUSE â Prove ONE cause, eliminate rest
PHASE 4: SIMULATION â Run fix mentally first
PHASE 5: PRE-FLIGHT â ALL checks green?
PHASE 6: EXECUTION â One surgical change
PHASE 7: CLOSURE â Prevent return, document
THE PROMISE
If you complete all phases with discipline:
- ZERO “let me try this” loops
- ZERO “that didn’t work, let me try something else”
- ZERO debugging sessions lasting hours
- ONE pass from bug to fix
- 100% confidence before touching code
This is not debugging. This is SURGERY.
© 2025 APEX Business Systems Ltd. Edmonton, AB, Canada. Licensed for use within Claude AI skills framework. All rights reserved.