deep-debugging
Systematic debugging protocol for bugs that resist quick fixes. Use bisection, hypothesis trees, and scientific method when a bug isn't obvious from the stack trace. Goes beyond bugfix-quick for production-grade root cause analysis.
What this skill does
> **AI-consumed reference.** Optimized for Claude to read during execution.
> Human-readable explanation: see [docs/architecture/HIERARCHICAL_PLANNING.md](../../../docs/architecture/HIERARCHICAL_PLANNING.md)
> or [docs/getting-started/](../../../docs/getting-started/) depending on topic.
# Deep Debugging
For bugs where `bugfix-quick` fails. Apply scientific method, not vibes.
**Escalation path:** `bugfix-quick` (< 15 min, clear cause) → `deep-debugging` (scientific method)
**Uses:** `tree-of-thoughts` skill for hypothesis trees, `chain-of-verification` for claim validation
---
## When to Use vs. bugfix-quick
| Signal | Use |
|--------|-----|
| Stack trace points to clear line | bugfix-quick |
| Reproduces 100% of the time | bugfix-quick |
| Happens in known edge case | bugfix-quick |
| Intermittent / flaky | **deep-debugging** |
| Multiple plausible causes | **deep-debugging** |
| "Works on my machine" class | **deep-debugging** |
| Timing / race conditions | **deep-debugging** |
| Production-only, can't repro locally | **deep-debugging** |
---
## The Protocol
### Step 1 — Reproduce reliably
Cannot debug what you can't reproduce. Goals:
- Minimum reproduction case (strip all non-essential code)
- Document trigger conditions (env, timing, order of operations)
- If intermittent: repeat N times, calculate failure rate
**If can't reproduce: STOP.** You can't debug. Alternative: add observability (logging, metrics, traces) to production to catch the next occurrence. Don't guess.
### Step 2 — Form a hypothesis tree (via tree-of-thoughts)
Don't jump to the first suspicion. Enumerate possibilities:
```
Root: Login fails intermittently in production
├── Branch A: Session store issue
│ ├── A1: Redis connection pool exhausted
│ ├── A2: Cookie domain mismatch
│ └── A3: Session expiry race condition
├── Branch B: Load balancer / infra
│ ├── B1: Sticky session misconfigured
│ └── B2: TLS termination timing
└── Branch C: Auth service
├── C1: JWT clock drift
└── C2: Rate limit hit
```
Score each branch 0-10 on:
- Fits observed symptoms
- Matches recent changes (diff since last known good)
- Matches failure pattern (timing, frequency, environment)
Prune branches below 5/10. Expand survivors.
### Step 3 — Bisect when possible
If bug was introduced recently:
```bash
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
git bisect run ./scripts/reproduce-bug.sh # automated narrowing
```
Bisection narrows to a single commit in O(log n) steps.
If not in git history — **bisect the codebase**:
- Comment out half the suspect module
- Does the bug persist? Narrow to the remaining half.
- Repeat until one file/function isolates it.
### Step 4 — Test hypothesis (one at a time)
For the top-scoring hypothesis:
1. **Predict:** "If A1 is true, then metric X should show pool saturation at failure time"
2. **Observe:** run the experiment or check the metric
3. **Match?**
- Yes → likely cause, go to Step 5
- No → prune this hypothesis, move to next
**Anti-pattern:** changing multiple things at once. You won't know which fix worked.
### Step 5 — Verify root cause (via chain-of-verification)
Before claiming the fix:
1. Draft explanation of root cause + fix
2. Generate 3–5 verification questions:
- "Does the fix change the failure rate from X% to 0%?"
- "Does removing the fix reintroduce the bug?"
- "Do similar code paths have the same issue (broader impact)?"
3. Answer each via tool (test, metrics, code search) — not from memory
4. Revise explanation based on actual results
Outcome: high-confidence claim backed by evidence, not "works on my machine."
### Step 6 — Write the regression test
Bug without a regression test = bug that returns. Add a test that:
- Fails on the unfixed code
- Passes on the fixed code
- Documents the exact scenario (comment the *why* — timing, race, input shape)
---
## Anti-Patterns
- **Blame the flake** — "Just retry the test." 80% of flaky tests are real bugs exposing timing issues; investigate instead of masking.
- **Shotgun fixes** — changing 5 things hoping one works. You learn nothing about root cause.
- **Reasoning from stack trace only** — the stack trace shows *where* it crashed, not *why*.
- **Skipping reproduction** — if you can't reproduce, you can't verify the fix. Get reproduction first.
- **No regression test** — fix without test = bug waiting to come back. Always close with a test.
---
## Output Format
```markdown
## Bug: [short description]
**Symptoms:** [what the user observed]
**Reproduction:** [minimum case, N trials, failure rate]
**Root Cause:** [verified explanation]
**Evidence:** [verification questions answered]
**Fix:** [what changed + commit ref]
**Regression Test:** [test file + name]
**Similar Impact:** [other places checked — immune / also vulnerable]
```
---
## Tie-Ins
- `skills/bugfix-quick/SKILL.md` — escalate here if quick path fails
- `skills/tree-of-thoughts/SKILL.md` — hypothesis branching
- `skills/chain-of-verification/SKILL.md` — verify root cause claim
- `rules/core/no-assumption.md` — don't guess at causes
- `rules/core/verification.md` — prove before shipping
- `rules/core/simplicity-over-complexity.md` — once root cause is known, the fix should be minimal — resist the urge to refactor "while we're here"
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.