[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ADHC930BX6YWTB5FF128KG":3,"skill-same:01M7ADHC930BX6YWTB5FF128KG":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":34,"install":35,"resources":48},"01M7ADHC930BX6YWTB5FF128KG","diagnosing-bugs",null,"Use when the user says 'diagnose', 'debug this', reports something broken, throwing, failing, or slow, or when encountering a bug, test failure, or unexpected behavior and a fix is not yet obvious.","Leostruka\u002Fdevin-bundle","Leostruka","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F81370685?v=4","01M7AD8MAK63VDNAWRDRRRW04N","leandro ostruka","01M7AD8MBS65YDS1KMMV7YPM07",0,"MIT","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: diagnosing-bugs\ndescription: Use when the user says 'diagnose', 'debug this', reports something broken, throwing, failing, or slow, or when encountering a bug, test failure, or unexpected behavior and a fix is not yet obvious.\ntriggers: [user, model]\n---\n# Diagnosing Bugs (Unified)\n\nA discipline for hard bugs. Skip phases only when explicitly justified.\n\n**Core principle:** ALWAYS find root cause before attempting fixes. Symptom\nfixes are failure. **Violating the letter of this process is violating the\nspirit of debugging.**\n\n```\nNO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST\n```\n\nWhen exploring the codebase, read `.devin\u002FCONTEXT.md` (if it exists) to get a clear\nmental model of the relevant modules, and check `.devin\u002Fadr\u002F` in the area you're\ntouching. If the bug spans multiple files, modules, or a data flow you cannot trace in one pass, invoke `deep-mode` before Phase 1.\n\n## Redact\n\nShow commands, outputs and captured artifacts. **Redact every secret first**\n- write `\u003CREDACTED>` in its place. Build loops against env vars, so the\ncredential stays in the environment rather than in what you show. Captured\nartifacts carry auth headers: quote only the lines that carry the signal.\n\nIf the redacted output is not enough to diagnose the bug, say so and ask.\n\n## The Iron Law\n\nIf you haven't completed Phase 1, you cannot propose fixes.\n\n**Red flags - STOP and return to Phase 1:**\n- \"Quick fix for now, investigate later\"\n- \"Just try changing X and see if it works\"\n- \"Add multiple changes, run tests\"\n- \"It's probably X, let me fix that\"\n- Proposing solutions before tracing data flow\n- **\"One more fix attempt\" (when already tried 2+)**\n- **Each fix reveals new problem in different place**\n\n## Phase 1 - Build a feedback loop\n\n**This is the skill.** Everything else is mechanical. If you have a **tight**\npass\u002Ffail signal for the bug - one that goes red on _this_ bug - you will find\nthe cause; bisection, hypothesis-testing, and instrumentation all just\nconsume it. If you don't have one, no amount of staring at code will save you.\n\nSpend disproportionate effort here. **Be aggressive. Be creative. Refuse to\ngive up.**\n\n### 1. Read error messages carefully\n\n- Don't skip past errors or warnings. They often contain the exact solution.\n- Read stack traces completely. Note line numbers, file paths, error codes.\n\n### 2. Construct a feedback loop - try in roughly this order\n\n1. **Failing test** at whatever seam reaches the bug - unit, integration, e2e.\n2. **Curl \u002F HTTP script** against a running dev server.\n3. **CLI invocation** with a fixture input, diffing stdout against known-good.\n4. **Headless browser script** (Playwright \u002F Puppeteer) - drives the UI.\n5. **Replay a captured trace.** Save a real network request \u002F payload \u002F event\n   log to disk; replay it through the code path in isolation.\n6. **Throwaway harness.** Spin up a minimal subset (one service, mocked deps).\n7. **Property \u002F fuzz loop.** If \"sometimes wrong output\", run 1000 random\n   inputs and look for the failure mode.\n8. **Bisection harness.** If the bug appeared between two known states,\n   automate \"boot at state X, check, repeat\" so you can `git bisect run` it.\n9. **Differential loop.** Run same input through old vs new version, diff.\n10. **HITL script.** Last resort. Drive the human with\n    `scripts\u002Fhitl-loop.template.py` so the loop is still structured.\n\nBuild the right feedback loop, and the bug is 90% fixed.\n\n### 3. Check recent changes\n\n- What changed that could cause this? Git diff, recent commits.\n- New dependencies, config changes, environmental differences.\n\n### 4. Gather evidence in multi-component systems\n\n**WHEN system has multiple components (CI → build → signing, API → service →\ndatabase):**\n\n```\nFor EACH component boundary:\n  - Log what data enters component\n  - Log what data exits component\n  - Verify environment\u002Fconfig propagation\n  - Check state at each layer\n\nRun once to gather evidence showing WHERE it breaks\nTHEN analyze evidence to identify failing component\nTHEN investigate that specific component\n```\n\n### 5. Trace data flow\n\n**WHEN error is deep in call stack:**\n\n- Where does bad value originate?\n- What called this with bad value?\n- Keep tracing up until you find the source.\n- Fix at source, not at symptom.\n\nSee `root-cause-tracing.md` in this directory for the complete\nbackward tracing technique.\n\n### Tighten the loop\n\nTreat the loop as a product. Once you have _a_ loop, **tighten** it:\n\n- Can I make it faster? (Cache setup, skip unrelated init, narrow scope.)\n- Can I make the signal sharper? (Assert on the specific symptom, not \"didn't crash\".)\n- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem.)\n\nA 30-second flaky loop is barely better than no loop; a 2-second deterministic\none is tight - a debugging superpower.\n\n### Non-deterministic bugs\n\nThe goal is not a clean repro but a **higher reproduction rate**. Loop the\ntrigger 100×, parallelise, add stress, narrow timing windows, inject sleeps.\nA 50%-flake bug is debuggable; 1% is not - keep raising the rate.\n\n### When you genuinely cannot build a loop\n\nStop and say so explicitly. List what you tried. Ask the user for: (a) access\nto whatever environment reproduces it, (b) a redacted captured artifact (HAR\nfile, log dump, core dump, screen recording with timestamps), or (c)\npermission to add temporary production instrumentation. Do **not** proceed to\nhypothesise without a loop.\n\n### Completion criterion - a tight loop that goes red\n\nPhase 1 is done when the loop is **tight** and **red-capable**: you can name\n**one command** - a script path, a test invocation, a curl - that you have\n**already run at least once** (show the invocation and its output, redacted),\nand that is:\n\n- [ ] **Red-capable** - drives the actual bug code path and asserts the\n      **user's exact symptom**, so it can go red on this bug and green once\n      fixed. Not \"runs without erroring\" - it must be able to _catch this\n      specific bug_.\n- [ ] **Deterministic** - same verdict every run (flaky bugs: high repro rate).\n- [ ] **Fast** - seconds, not minutes.\n- [ ] **Agent-runnable** - you can run it unattended; human only via\n      `scripts\u002Fhitl-loop.template.py`.\n\nIf you catch yourself reading code to build a theory before this command\nexists, **stop - jumping straight to a hypothesis is the exact failure this\nskill prevents.** No red-capable command, no Phase 2.\n\n## Phase 2 - Reproduce + minimise + pattern analysis\n\nRun the loop. Watch it go red - the bug appears.\n\nConfirm:\n\n- [ ] The loop produces the failure mode the **user** described - not a\n      different failure nearby. Wrong bug = wrong fix.\n- [ ] The failure is reproducible across multiple runs (or at high enough rate).\n- [ ] You have captured the exact symptom (error message, wrong output, slow\n      timing) so later phases can verify the fix.\n\n### Minimise\n\nOnce it's red, shrink the repro to the **smallest scenario that still goes\nred**. Cut inputs, callers, config, data, and steps **one at a time**,\nre-running the loop after each cut - keep only what's load-bearing.\n\nDone when **every remaining element is load-bearing** - removing any one makes\nthe loop go green.\n\n### Pattern analysis\n\n1. **Find working examples** - locate similar working code in same codebase.\n2. **Compare against references** - read reference implementation COMPLETELY.\n   Don't skim. Understand the pattern fully before applying.\n3. **Identify differences** - list every difference, however small. Don't\n   assume \"that can't matter\".\n4. **Understand dependencies** - what components, settings, config, env, assumptions.\n\n## Phase 3 - Hypothesise\n\nGenerate **3–5 ranked hypotheses** before testing any of them. Single-\nhypothesis generation anchors on the first plausible idea.\n\nEach hypothesis must be **falsifiable**: state the prediction it makes.\n\n> Format: \"If \u003CX> is the cause, then \u003Cchanging Y> will make the bug disappear\n> \u002F \u003Cchanging Z> will make it worse.\"\n\nIf you cannot state the prediction, the hypothesis is a vibe - discard or\nsharpen it.\n\n**Show the ranked list to the user before testing.** They often have domain\nknowledge that re-ranks instantly (\"we just deployed a change to #3\"), or know\nhypotheses they've already ruled out. Don't block on it - proceed with your\nranking if the user is AFK.\n\n## Phase 4 - Instrument\n\nEach probe must map to a specific prediction from Phase 3. **Change one\nvariable at a time.**\n\nTool preference:\n\n1. **Debugger \u002F REPL inspection** if the env supports it. One breakpoint\n   beats ten logs.\n2. **Targeted logs** at the boundaries that distinguish hypotheses.\n3. Never \"log everything and grep\".\n\n**Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at\nthe end becomes a single grep. Untagged logs survive; tagged logs die.\n\n**Perf branch.** For performance regressions, logs are usually wrong. Instead:\nestablish a baseline measurement (timing harness, `performance.now()`,\nprofiler, query plan), then bisect. Measure first, fix second.\n\n## Phase 5 - Fix + regression test\n\nWrite the regression test **before the fix** - but only if there is a\n**correct seam** for it.\n\nA correct seam is one where the test exercises the **real bug pattern** as it\noccurs at the call site. If the only available seam is too shallow (single-\ncaller test when the bug needs multiple callers, unit test that can't\nreplicate the chain), a regression test there gives false confidence.\n\n**If no correct seam exists, that itself is the finding.** Note it. The\ncodebase architecture is preventing the bug from being locked down. Flag this\nfor the next phase.\n\nIf a correct seam exists:\n\n1. Turn the minimised repro into a failing test at that seam. Watch it fail.\n2. Apply the fix. **ONE change at a time.** No \"while I'm here\" improvements.\n3. Watch it pass. Re-run the Phase 1 feedback loop against the original\n   (un-minimised) scenario.\n4. No other tests broken? Issue actually resolved?\n\n### If fix doesn't work\n\n- **\u003C 3 attempts:** Return to Phase 1, re-analyze with new information. Form\n  NEW hypothesis. DON'T add more fixes on top.\n- **≥ 3 attempts:** STOP. Question the architecture (see below).\n\n### If 3+ fixes failed: question architecture\n\n**Pattern indicating architectural problem:**\n- Each fix reveals new shared state\u002Fcoupling\u002Fproblem in different place\n- Fixes require \"massive refactoring\" to implement\n- Each fix creates new symptoms elsewhere\n\n**STOP and question fundamentals:**\n- Is this pattern fundamentally sound?\n- Are we \"sticking with it through sheer inertia\"?\n- Should we refactor architecture vs. continue fixing symptoms?\n\n**Discuss with user before attempting more fixes.** This is NOT a failed\nhypothesis - this is a wrong architecture.\n\n## Phase 6 - Cleanup + post-mortem\n\nRequired before declaring done:\n\n- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)\n- [ ] Regression test passes (or absence of seam is documented)\n- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)\n- [ ] Throwaway prototypes deleted (or moved to clearly-marked debug location)\n- [ ] The hypothesis that turned out correct is stated in the commit \u002F PR\n      message - so the next debugger learns\n\n**Then ask: what would have prevented this bug?** If the answer involves\narchitectural change (no good test seam, tangled callers, hidden coupling)\nhand off to `improve-codebase-architecture` with the specifics. Make the\nrecommendation **after** the fix is in, not before.\n\n## Stopping Criterion (VRR-Stop)\n\nIf after 2+ repair rounds the true validity decreases (not just the proxy),\nstop and escalate. Don't keep repairing if each round makes it worse.\n\n**Signs you should stop:**\n- Each fix introduces new failures\n- Test count goes up but pass rate goes down\n- The fix addresses a symptom but creates a new one elsewhere\n- You've applied 3+ fixes to the same function without convergence\n\n**What to do instead:**\n1. Stop fixing. Revert to last known-good state.\n2. Re-read the original error with fresh eyes.\n3. Consider that the approach is wrong, not the implementation.\n4. Escalate: \"I've attempted N fixes. Each made it worse. The root cause may\n   be architectural, not implementation-level.\"\n\n**Source:** VRR-Stop (arXiv:2607.17641). 60.6pp improvement over fixed\nfive-round repair.\n\n## When Process Reveals \"No Root Cause\"\n\nIf systematic investigation reveals issue is truly environmental,\ntiming-dependent, or external:\n\n1. You've completed the process.\n2. Document what you investigated.\n3. Implement appropriate handling (retry, timeout, error message).\n4. Add monitoring\u002Flogging for future investigation.\n\n**But:** 95% of \"no root cause\" cases are incomplete investigation.\n\n## Interaction-Centric Failure Dimension\n\nBeyond \"what\" (bug type), identify \"where\" - which component interaction\nfailed. 41 failure modes mapped to component edges with Cohen's κ=0.76\n(arXiv:2607.28802).\n\n| Edge | Common failure modes |\n|---|---|\n| Model → Tool | Hallucinated arguments, wrong tool selection, invalid syntax |\n| Model → Memory | Stale context, forgotten constraints (Governance Decay), wrong retrieval |\n| Tool → Tool | Output format mismatch, missing dependency, timeout cascade |\n| Agent → Environment | Permission denied, file not found, network unreachable |\n\nWhen diagnosing, classify on both dimensions:\n1. **What** - the failure type (syntax, logic, timeout, permission, etc.)\n2. **Where** - the component edge that failed\n\nIf multiple bugs cluster on the same edge, the architecture at that edge needs\nimprovement, not just the individual bug fixes.\n\n## Common Rationalizations\n\n| Excuse | Reality |\n|--------|---------|\n| \"Issue is simple, don't need process\" | Simple issues have root causes too. Process is fast for simple bugs. |\n| \"Emergency, no time for process\" | Systematic debugging is FASTER than guess-and-check thrashing. |\n| \"Just try this first, then investigate\" | First fix sets the pattern. Do it right from the start. |\n| \"I'll write test after confirming fix works\" | Untested fixes don't stick. Test first proves it. |\n| \"Multiple fixes at once saves time\" | Can't isolate what worked. Causes new bugs. |\n| \"Reference too long, I'll adapt the pattern\" | Partial understanding guarantees bugs. Read it completely. |\n| \"I see the problem, let me fix it\" | Seeing symptoms ≠ understanding root cause. |\n| \"One more fix attempt\" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |\n\n## Supporting Techniques\n\nAvailable in this directory:\n\n- **`root-cause-tracing.md`** - Trace bugs backward through call stack\n- **`defense-in-depth.md`** - Add validation at multiple layers after finding root cause\n- **`condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling\n","# Diagnosing Bugs (Unified)\n\nA discipline for hard bugs. Skip phases only when explicitly justified.\n\n**Core principle:** ALWAYS find root cause before attempting fixes. Symptom\nfixes are failure. **Violating the letter of this process is violating the\nspirit of debugging.**\n\n```\nNO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST\n```\n\nWhen exploring the codebase, read `.devin\u002FCONTEXT.md` (if it exists) to get a clear\nmental model of the relevant modules, and check `.devin\u002Fadr\u002F` in the area you're\ntouching. If the bug spans multiple files, modules, or a data flow you cannot trace in one pass, invoke `deep-mode` before Phase 1.\n\n## Redact\n\nShow commands, outputs and captured artifacts. **Redact every secret first**\n- write `\u003CREDACTED>` in its place. Build loops against env vars, so the\ncredential stays in the environment rather than in what you show. Captured\nartifacts carry auth headers: quote only the lines that carry the signal.\n\nIf the redacted output is not enough to diagnose the bug, say so and ask.\n\n## The Iron Law\n\nIf you haven't completed Phase 1, you cannot propose fixes.\n\n**Red flags - STOP and return to Phase 1:**\n- \"Quick fix for now, investigate later\"\n- \"Just try changing X and see if it works\"\n- \"Add multiple changes, run tests\"\n- \"It's probably X, let me fix that\"\n- Proposing solutions before tracing data flow\n- **\"One more fix attempt\" (when already tried 2+)**\n- **Each fix reveals new problem in different place**\n\n## Phase 1 - Build a feedback loop\n\n**This is the skill.** Everything else is mechanical. If you have a **tight**\npass\u002Ffail signal for the bug - one that goes red on _this_ bug - you will find\nthe cause; bisection, hypothesis-testing, and instrumentation all just\nconsume it. If you don't have one, no amount of staring at code will save you.\n\nSpend disproportionate effort here. **Be aggressive. Be creative. Refuse to\ngive up.**\n\n### 1. Read error messages carefully\n\n- Don't skip past errors or warnings. They often contain the exact solution.\n- Read stack traces completely. Note line numbers, file paths, error codes.\n\n### 2. Construct a feedback loop - try in roughly this order\n\n1. **Failing test** at whatever seam reaches the bug - unit, integration, e2e.\n2. **Curl \u002F HTTP script** against a running dev server.\n3. **CLI invocation** with a fixture input, diffing stdout against known-good.\n4. **Headless browser script** (Playwright \u002F Puppeteer) - drives the UI.\n5. **Replay a captured trace.** Save a real network request \u002F payload \u002F event\n   log to disk; replay it through the code path in isolation.\n6. **Throwaway harness.** Spin up a minimal subset (one service, mocked deps).\n7. **Property \u002F fuzz loop.** If \"sometimes wrong output\", run 1000 random\n   inputs and look for the failure mode.\n8. **Bisection harness.** If the bug appeared between two known states,\n   automate \"boot at state X, check, repeat\" so you can `git bisect run` it.\n9. **Differential loop.** Run same input through old vs new version, diff.\n10. **HITL script.** Last resort. Drive the human with\n    `scripts\u002Fhitl-loop.template.py` so the loop is still structured.\n\nBuild the right feedback loop, and the bug is 90% fixed.\n\n### 3. Check recent changes\n\n- What changed that could cause this? Git diff, recent commits.\n- New dependencies, config changes, environmental differences.\n\n### 4. Gather evidence in multi-component systems\n\n**WHEN system has multiple components (CI → build → signing, API → service →\ndatabase):**\n\n```\nFor EACH component boundary:\n  - Log what data enters component\n  - Log what data exits component\n  - Verify environment\u002Fconfig propagation\n  - Check state at each layer\n\nRun once to gather evidence showing WHERE it breaks\nTHEN analyze evidence to identify failing component\nTHEN investigate that specific component\n```\n\n### 5. Trace data flow\n\n**WHEN error is deep in call stack:**\n\n- Where does bad value originate?\n- What called this with bad value?\n- Keep tracing up until you find the source.\n- Fix at source, not at symptom.\n\nSee `root-cause-tracing.md` in this directory for the complete\nbackward tracing technique.\n\n### Tighten the loop\n\nTreat the loop as a product. Once you have _a_ loop, **tighten** it:\n\n- Can I make it faster? (Cache setup, skip unrelated init, narrow scope.)\n- Can I make the signal sharper? (Assert on the specific symptom, not \"didn't crash\".)\n- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem.)\n\nA 30-second flaky loop is barely better than no loop; a 2-second deterministic\none is tight - a debugging superpower.\n\n### Non-deterministic bugs\n\nThe goal is not a clean repro but a **higher reproduction rate**. Loop the\ntrigger 100×, parallelise, add stress, narrow timing windows, inject sleeps.\nA 50%-flake bug is debuggable; 1% is not - keep raising the rate.\n\n### When you genuinely cannot build a loop\n\nStop and say so explicitly. List what you tried. Ask the user for: (a) access\nto whatever environment reproduces it, (b) a redacted captured artifact (HAR\nfile, log dump, core dump, screen recording with timestamps), or (c)\npermission to add temporary production instrumentation. Do **not** proceed to\nhypothesise without a loop.\n\n### Completion criterion - a tight loop that goes red\n\nPhase 1 is done when the loop is **tight** and **red-capable**: you can name\n**one command** - a script path, a test invocation, a curl - that you have\n**already run at least once** (show the invocation and its output, redacted),\nand that is:\n\n- [ ] **Red-capable** - drives the actual bug code path and asserts the\n      **user's exact symptom**, so it can go red on this bug and green once\n      fixed. Not \"runs without erroring\" - it must be able to _catch this\n      specific bug_.\n- [ ] **Deterministic** - same verdict every run (flaky bugs: high repro rate).\n- [ ] **Fast** - seconds, not minutes.\n- [ ] **Agent-runnable** - you can run it unattended; human only via\n      `scripts\u002Fhitl-loop.template.py`.\n\nIf you catch yourself reading code to build a theory before this command\nexists, **stop - jumping straight to a hypothesis is the exact failure this\nskill prevents.** No red-capable command, no Phase 2.\n\n## Phase 2 - Reproduce + minimise + pattern analysis\n\nRun the loop. Watch it go red - the bug appears.\n\nConfirm:\n\n- [ ] The loop produces the failure mode the **user** described - not a\n      different failure nearby. Wrong bug = wrong fix.\n- [ ] The failure is reproducible across multiple runs (or at high enough rate).\n- [ ] You have captured the exact symptom (error message, wrong output, slow\n      timing) so later phases can verify the fix.\n\n### Minimise\n\nOnce it's red, shrink the repro to the **smallest scenario that still goes\nred**. Cut inputs, callers, config, data, and steps **one at a time**,\nre-running the loop after each cut - keep only what's load-bearing.\n\nDone when **every remaining element is load-bearing** - removing any one makes\nthe loop go green.\n\n### Pattern analysis\n\n1. **Find working examples** - locate similar working code in same codebase.\n2. **Compare against references** - read reference implementation COMPLETELY.\n   Don't skim. Understand the pattern fully before applying.\n3. **Identify differences** - list every difference, however small. Don't\n   assume \"that can't matter\".\n4. **Understand dependencies** - what components, settings, config, env, assumptions.\n\n## Phase 3 - Hypothesise\n\nGenerate **3–5 ranked hypotheses** before testing any of them. Single-\nhypothesis generation anchors on the first plausible idea.\n\nEach hypothesis must be **falsifiable**: state the prediction it makes.\n\n> Format: \"If \u003CX> is the cause, then \u003Cchanging Y> will make the bug disappear\n> \u002F \u003Cchanging Z> will make it worse.\"\n\nIf you cannot state the prediction, the hypothesis is a vibe - discard or\nsharpen it.\n\n**Show the ranked list to the user before testing.** They often have domain\nknowledge that re-ranks instantly (\"we just deployed a change to #3\"), or know\nhypotheses they've already ruled out. Don't block on it - proceed with your\nranking if the user is AFK.\n\n## Phase 4 - Instrument\n\nEach probe must map to a specific prediction from Phase 3. **Change one\nvariable at a time.**\n\nTool preference:\n\n1. **Debugger \u002F REPL inspection** if the env supports it. One breakpoint\n   beats ten logs.\n2. **Targeted logs** at the boundaries that distinguish hypotheses.\n3. Never \"log everything and grep\".\n\n**Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at\nthe end becomes a single grep. Untagged logs survive; tagged logs die.\n\n**Perf branch.** For performance regressions, logs are usually wrong. Instead:\nestablish a baseline measurement (timing harness, `performance.now()`,\nprofiler, query plan), then bisect. Measure first, fix second.\n\n## Phase 5 - Fix + regression test\n\nWrite the regression test **before the fix** - but only if there is a\n**correct seam** for it.\n\nA correct seam is one where the test exercises the **real bug pattern** as it\noccurs at the call site. If the only available seam is too shallow (single-\ncaller test when the bug needs multiple callers, unit test that can't\nreplicate the chain), a regression test there gives false confidence.\n\n**If no correct seam exists, that itself is the finding.** Note it. The\ncodebase architecture is preventing the bug from being locked down. Flag this\nfor the next phase.\n\nIf a correct seam exists:\n\n1. Turn the minimised repro into a failing test at that seam. Watch it fail.\n2. Apply the fix. **ONE change at a time.** No \"while I'm here\" improvements.\n3. Watch it pass. Re-run the Phase 1 feedback loop against the original\n   (un-minimised) scenario.\n4. No other tests broken? Issue actually resolved?\n\n### If fix doesn't work\n\n- **\u003C 3 attempts:** Return to Phase 1, re-analyze with new information. Form\n  NEW hypothesis. DON'T add more fixes on top.\n- **≥ 3 attempts:** STOP. Question the architecture (see below).\n\n### If 3+ fixes failed: question architecture\n\n**Pattern indicating architectural problem:**\n- Each fix reveals new shared state\u002Fcoupling\u002Fproblem in different place\n- Fixes require \"massive refactoring\" to implement\n- Each fix creates new symptoms elsewhere\n\n**STOP and question fundamentals:**\n- Is this pattern fundamentally sound?\n- Are we \"sticking with it through sheer inertia\"?\n- Should we refactor architecture vs. continue fixing symptoms?\n\n**Discuss with user before attempting more fixes.** This is NOT a failed\nhypothesis - this is a wrong architecture.\n\n## Phase 6 - Cleanup + post-mortem\n\nRequired before declaring done:\n\n- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)\n- [ ] Regression test passes (or absence of seam is documented)\n- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)\n- [ ] Throwaway prototypes deleted (or moved to clearly-marked debug location)\n- [ ] The hypothesis that turned out correct is stated in the commit \u002F PR\n      message - so the next debugger learns\n\n**Then ask: what would have prevented this bug?** If the answer involves\narchitectural change (no good test seam, tangled callers, hidden coupling)\nhand off to `improve-codebase-architecture` with the specifics. Make the\nrecommendation **after** the fix is in, not before.\n\n## Stopping Criterion (VRR-Stop)\n\nIf after 2+ repair rounds the true validity decreases (not just the proxy),\nstop and escalate. Don't keep repairing if each round makes it worse.\n\n**Signs you should stop:**\n- Each fix introduces new failures\n- Test count goes up but pass rate goes down\n- The fix addresses a symptom but creates a new one elsewhere\n- You've applied 3+ fixes to the same function without convergence\n\n**What to do instead:**\n1. Stop fixing. Revert to last known-good state.\n2. Re-read the original error with fresh eyes.\n3. Consider that the approach is wrong, not the implementation.\n4. Escalate: \"I've attempted N fixes. Each made it worse. The root cause may\n   be architectural, not implementation-level.\"\n\n**Source:** VRR-Stop (arXiv:2607.17641). 60.6pp improvement over fixed\nfive-round repair.\n\n## When Process Reveals \"No Root Cause\"\n\nIf systematic investigation reveals issue is truly environmental,\ntiming-dependent, or external:\n\n1. You've completed the process.\n2. Document what you investigated.\n3. Implement appropriate handling (retry, timeout, error message).\n4. Add monitoring\u002Flogging for future investigation.\n\n**But:** 95% of \"no root cause\" cases are incomplete investigation.\n\n## Interaction-Centric Failure Dimension\n\nBeyond \"what\" (bug type), identify \"where\" - which component interaction\nfailed. 41 failure modes mapped to component edges with Cohen's κ=0.76\n(arXiv:2607.28802).\n\n| Edge | Common failure modes |\n|---|---|\n| Model → Tool | Hallucinated arguments, wrong tool selection, invalid syntax |\n| Model → Memory | Stale context, forgotten constraints (Governance Decay), wrong retrieval |\n| Tool → Tool | Output format mismatch, missing dependency, timeout cascade |\n| Agent → Environment | Permission denied, file not found, network unreachable |\n\nWhen diagnosing, classify on both dimensions:\n1. **What** - the failure type (syntax, logic, timeout, permission, etc.)\n2. **Where** - the component edge that failed\n\nIf multiple bugs cluster on the same edge, the architecture at that edge needs\nimprovement, not just the individual bug fixes.\n\n## Common Rationalizations\n\n| Excuse | Reality |\n|--------|---------|\n| \"Issue is simple, don't need process\" | Simple issues have root causes too. Process is fast for simple bugs. |\n| \"Emergency, no time for process\" | Systematic debugging is FASTER than guess-and-check thrashing. |\n| \"Just try this first, then investigate\" | First fix sets the pattern. Do it right from the start. |\n| \"I'll write test after confirming fix works\" | Untested fixes don't stick. Test first proves it. |\n| \"Multiple fixes at once saves time\" | Can't isolate what worked. Causes new bugs. |\n| \"Reference too long, I'll adapt the pattern\" | Partial understanding guarantees bugs. Read it completely. |\n| \"I see the problem, let me fix it\" | Seeing symptoms ≠ understanding root cause. |\n| \"One more fix attempt\" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |\n\n## Supporting Techniques\n\nAvailable in this directory:\n\n- **`root-cause-tracing.md`** - Trace bugs backward through call stack\n- **`defense-in-depth.md`** - Add validation at multiple layers after finding root cause\n- **`condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling\n",{"name":5,"triggers":24,"description":7},[25,26],"user","model","main","02b95ddb62959a00b3c31442c2046aca0d19563c","skills\u002Fdiagnosing-bugs",1,"https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle","https:\u002F\u002Fleostruka.github.io\u002Fdevin-bundle\u002F","https:\u002F\u002Fgithub.com\u002FLeostruka","2026-11-15 05:19:58",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add Leostruka\u002Fdevin-bundle --skill diagnosing-bugs",{"tool":41,"command":42},"bunx","bunx skills add Leostruka\u002Fdevin-bundle --skill diagnosing-bugs",{"tool":44,"command":45},"pnpm","pnpm dlx skills add Leostruka\u002Fdevin-bundle --skill diagnosing-bugs","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002FSKILL.md",true,[49,55,59,63],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"condition-based-waiting.md","REFERENCE","参考文档",3516,"https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002Fcondition-based-waiting.md",{"path":56,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":57,"sourceHtmlUrl":58},"defense-in-depth.md",3650,"https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002Fdefense-in-depth.md",{"path":60,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":61,"sourceHtmlUrl":62},"root-cause-tracing.md",5321,"https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002Froot-cause-tracing.md",{"path":64,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":68},"scripts\u002Fhitl-loop.template.py","SCRIPT","脚本",1209,"https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fdiagnosing-bugs\u002Fscripts\u002Fhitl-loop.template.py",[70,77,84,91,98,105],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7E0K3MG2XC4FSRV0MK6SFR1","montador-de-ideias","Use when assembling, expanding, or elevating a raw project idea or initial prompt into an ultra-detailed, first-principles dossier and compiled master prompt with journalistic OSINT market research, Tech Lead and Staff Architect justifications, atomic and modular hardening\u002Foptimization, and high-impact contact surfaces.","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fmontador-de-ideias\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7E0J7JJWZ8QMK01RZ3B3C9Z","git-github-adaptive-engineering","Use when any task touches git history, GitHub issues\u002FPRs\u002Freleases\u002FCI, repo governance, or branch and merge decisions. Runs the Fase Zero situational-awareness battery, picks one of five delivery flows via the adaptive decision engine, and enforces commit\u002FPR information-density standards. Orchestrates the gh, git-workflows, github-actions, pr, and debug\u002Ffinish skills.","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fgit-github-adaptive-engineering\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7E0GJFRPFEVQQMXEM58EWDM","adaptive-agenda-calendar-routine-engine","Use when planning or executing work across hours, days, weeks, or sprints. Turns the calendar into a strict time-blocked agenda (HH:MM-HH:MM blocks carrying a routine profile, expected inputs, and a handoff output artifact), runs the 5-stage cognitive flow (Radar and Hunt -> Triage plus Steve Jobs conception -> workbench manifest -> >=32-cycle loop -> Close plus Open-Minded Scrum), and unfolds macro calendar milestones into micro agenda blocks through extensions\u002Fgcal\u002Fwrapper.py.","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Fskills\u002Fadaptive-agenda-calendar-routine-engine\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7AE2K9FTY0BVS48N0A9JFKF","demo","Use when demonstrating a skill in a fixture project.","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fdevin-config\u002Fproject\u002F.devin\u002Fskills\u002Fdemo\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7AE2G3DP38PTV3B1N7MW5TS","duplicate-skill","Use when testing duplicate skill name detection.","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fdevin-config\u002Fproject\u002F.devin\u002Fskills\u002Fbeta\u002FSKILL.md",[],[],{"skillNo":106,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7AE2DBR8ZHT6T875MJ392GK","https:\u002F\u002Fgithub.com\u002FLeostruka\u002Fdevin-bundle\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fdevin-config\u002Fproject\u002F.devin\u002Fskills\u002Falpha\u002FSKILL.md",[],[]]