{"slug":"systematic-debugging-10","title":"systematic-debugging","summary":"Use when encountering a bug, test failure, or unexpected behavior, before proposing fixes","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-15T18:23:36.039953Z","repo":{"url":"https://github.com/GanyuanRan/Aegis","stars":1224,"forks":53,"license":"MIT","updatedAt":"2026-09-20T11:25:37Z"},"bodyHtml":"<hr>\n<h2>name: systematic-debugging\ndescription: \"Use when encountering a bug, test failure, or unexpected behavior, before proposing fixes\"</h2>\n<h1>Execute</h1>\n<p>Bug, failure, or unexpected behavior:</p>\n<ol>\n<li><strong>Isolate</strong> — read error, reproduce, inspect the diff, and drill upward through diagnostic layers:\nL1 symptom → L2 logic → L3 system → L4 architecture → L5 cross-system\ncontract → L6 platform → L7 spec gap. Layers are observation altitudes,\nnot one causal chain; the causal shape at the stop altitude is classified\nexplicitly before any root claim. Stop only when causal proof accounts\nfor the recurrence generator or reaches a T-class boundary.</li>\n<li><strong>Identify owner</strong> — compare working behavior, trace the bad value, locate the\ncanonical owner, and treat duplicate owners as a finding.</li>\n<li><strong>Decide before editing</strong> — Before fixing, run Patch-Shape Triage and Ripple Signal Triage when shared logic,\ncontracts, fallbacks, adapters, producer/consumer seams, or source-of-truth\nboundaries are involved. Surface Change Necessity for any new source-code\npath or non-trivial source edit. Run Minimality Check for a new branch,\nfallback, adapter, owner, or compatibility path, and Pre-Edit Complexity\nCheck for an overloaded owner or complexity growth. After Change Necessity\nselects <code>code-change</code> and before the first repair edit, own the TDD Route for\nthe repair slice per <code>test-driven-development</code> (<code>off</code> default; <code>strict</code> on\nbehavior/bugfix/shared/contract/persistence/permission/migration risk).</li>\n<li><strong>Prove</strong> — test one hypothesis with the smallest reproduction or\nverification. A failing test first is required only by a recorded\n<code>TDD Route: strict</code>; with <code>TDD Mode: off</code>, do not require a failing test or\nRED/GREEN cycle. Three failed fixes means stop and question architecture.</li>\n<li><strong>Repair and close</strong> — fix minimally at the canonical owner, verify in\nproportion to risk, review architecture, and close both repair and\nretirement tracks. If any symptom remains, stop and diagnose it separately.</li>\n</ol>\n<p>Done: confidence ≥ B, causal status matches recurrence evidence or an external\nterminal, tracks explicit, no H signal, and required D evidence passes.</p>\n<h2>Core invariant</h2>\n<p>Find root cause and fix the bug class at its canonical owner. A minimal fix is\nnot the smallest textual diff; it is the smallest sufficient owner-level repair.</p>\n<h2>Quick bug lane</h2>\n<p>For a low-risk, reproducible, single-owner bug with no patch-shape signal, keep\nthe readback compact: <code>Symptom</code>, <code>Reproduction</code>, <code>Root Cause</code>, <code>Change Necessity</code>, <code>Fix Boundary</code>, and <code>Verification</code>. Skip the causal card only when\nthe causal-proof owner's <code>Quick Exit Proof</code> passes.\nQuick bug lane must surface Change Necessity before source edits. One sentence\nmay cover the user-visible need, no-change/non-code option, why code must\nchange, minimum boundary, and an explicit decision token such as\n<code>Decision: code-change</code>. If shared logic, a contract, fallback, duplicate\nowner, consumer patch, or cross-module behavior appears, leave this lane.</p>\n<p><code>Aegis Visibility</code> names the evidence/owner/patch-shape/verification effect.\nPass root cause, avoided misfix, boundary, evidence, complexity, and risk to\n<code>verification-before-completion</code>; no separate receipt.</p>\n<h2>Diagnose before repair</h2>\n<ol>\n<li>Read the complete error/stack and record inputs, environment, versions, and\nsuccess criteria.</li>\n<li>Reproduce consistently. If unstable, read\n<code>feedback-loop-construction.md</code> <strong>only when evidence shows intermittent or\ntiming-dependent reproduction</strong> and build a bounded loop. Shrink the repro\nto load-bearing elements as the test input, never the fix scope: still drill\nupward; test at the correct seam.</li>\n<li>Inspect recent changes and compare a working example. Code is evidence; if\nauthority, glossary, code, and tests disagree, compose\n<code>establishing-project-context</code> rather than silently redefining a term.</li>\n<li>Instrument component boundaries, then trace the bad value toward its source.\nRead <code>root-cause-tracing.md</code> <strong>only when the observed bad value is several\ncalls or components downstream from its origin</strong>.</li>\n<li>State one hypothesis and falsify it with one-variable evidence. Do not stack\nspeculative fixes. End each loop with <code>Goal | DeeperCause | Evidence | Risk/Unknown | Decision</code>.</li>\n</ol>\n<h3>Canonical-owner and patch-shape gate</h3>\n<p>Before editing, continue upward unless evidence proves the local site is the\ncanonical owner when the candidate is any of these signals:</p>\n<ul>\n<li>keyword, phrase, regex, negation-word list, or sample-text exception;</li>\n<li>local guard, extra conditional, <code>try</code>/<code>catch</code>, early return, or one-off branch;</li>\n<li>fallback, adapter, compatibility branch, prompt branch, or legacy path expansion;</li>\n<li>consumer/caller/readiness/presentation-layer patch;</li>\n<li>downstream logic re-parses raw text or re-infers action/state while typed intent, normalized state, contract, or another source-of-truth exists;</li>\n<li>artifact/download/export/readback/cache patch without producer/owner proof.</li>\n</ul>\n<pre><code>PatchShape:\nCanonicalOwner:\nUpwardDrillSignal:\nDecision: fix owner | continue investigation | escalate\n</code></pre>\n<p>A locally green test does not erase triage; a renamed carrier is not a new direction.</p>\n<p>When a repair may reinterpret or retire existing semantics, responsibility,\ncontract, or relationship, name the behavior to preserve, highest-risk\ncounterexample, and material unknown. For each known explicit anchor or\nupstream/downstream reference, state its role and disposition: preserve, rebind\nto the canonical owner, retire with reason, or reject because of conflict.\nLeave unresolved relationships unknown; do not re-infer them downstream.\nBind role before value and retire invalid responsibility, not evidenced carrier\ncapability. This bounded reminder is not a behavior matrix, relationship graph,\nreferential-integrity proof, or exhaustive discovery claim. It adds no artifact,\nTDD risk signal, or regression scope; the existing TDD route owner and\nconfigured/default mode still apply.</p>\n<p>If the diagnosis crosses L3, a patch-shape signal fires, a user disputes the\nroot claim, a prior fix leaves a symptom, compound/root topology is plausible,\ntwo or more anchored manifestations of one incident exist, reproduction\nconditions diverge across occurrences, or an\nupstream producer/config/default/contract/spec remains unexcluded, read\n<code>root-cause-claim-contract.md</code> <strong>before claiming a root cause</strong>. It is the sole\nowner of the Pre-Claim Gate, causal-closure/falsifier proof, layer-ceiling\nproof, and Causal Topology Gate.</p>\n<h3>Change Necessity</h3>\n<p>This decision is behavior-triggered, not prompt-triggered. It applies to any new source-code path. Before that path or a non-trivial source edit, expose the <code>Change Necessity</code> decision (<code>no-change | docs/config-only | code-change | needs-clarification</code>); field detail lives in <code>advanced-debugging-governance.md</code>.</p>\n<h3>Minimality and owner fit</h3>\n<p>For any proposed branch, fallback, adapter, compatibility path, or new owner, run <code>Minimality Check</code> (fields in <code>advanced-debugging-governance.md</code>) with verdict <code>sufficient repair | local patch | needs first-principles review</code>, and retire invalid responsibility: a <code>local patch</code> needs a retention reason and retirement trigger. For a new non-ordinary repair surface, run the <code>Existence Check</code> in <code>docs/current/AEGIS_MINIMALITY_REFERENCE.md</code>. If retirement involves old code,\nexternal compatibility, or persistent-state risk, compose\n<code>anti-entropy-governance</code>; it chooses the retirement path but never grants\ndestructive authority.</p>\n<p>Before editing an overloaded or mixed-purpose owner, complete <code>Pre-Edit Complexity Check</code> and <code>Pre-Edit Owner-Fit Decision</code> (templates in <code>advanced-debugging-governance.md</code>).</p>\n<p>Use <code>using-aegis/references/complexity-governance.md</code> for pressure signals.\nDo not add <code>new-responsibility</code> in place by default. If the safer boundary\nchanges the approved shape, update the plan/spec first.</p>\n<h2>Repair and proportional verification</h2>\n<p>Implement one owner fix; no bundled “while here” work. Under strict TDD, create\nthe smallest failing test first. With TDD off, a reproduction is diagnostic\nevidence, not a RED gate or a prerequisite for production edits.</p>\n<p>Verification must match the risk:</p>\n<ul>\n<li>local single-owner repair: original reproduction plus focused regression;</li>\n<li>shared/contract/cross-module repair: canonical owner plus affected consumers\nand compatibility boundary;</li>\n<li>fallback/owner retirement: main-path, lingering-reference, negative, and\nboundary checks;</li>\n<li>timing/concurrency repair: read <code>condition-based-waiting.md</code> <strong>only when\nevidence identifies polling, sleeps, or race timing as part of the cause</strong>;</li>\n<li>invalid state crossing several trusted boundaries: read\n<code>defense-in-depth.md</code> <strong>only after the root repair is known and evidence shows\na second independent validation boundary is required</strong>.</li>\n</ul>\n<p>Read <code>advanced-debugging-governance.md</code> <strong>before another fix</strong> for failed/\npersistent / divergent repair or three failures; for unclear/disputed stop /\nLayer Stop Card / intervention; or plausible compound root. Closeout triggers:\nrepair-added patch-shape; multi-site/one-regression;\nremaining pattern/anomaly/duplicate/wrong-owner/downstream repair;\nuninspected same-symptom fix; open recurrence/unsupported root status;\nmissing compound topology-specific member/anti-disguise proof;\noutside-repo authority; unmigrated\npublished-contract break; undefined spec; missing permission/info. They route H/T/D;\ndetail is not causal proof.</p>\n<p>For non-trivial debugging with configured workspace support:</p>\n<pre><code>python &lt;aegis-workspace-helper&gt; init --root &lt;target-project-root&gt;\npython &lt;aegis-workspace-helper&gt; new-work --root &lt;target-project-root&gt; ...\npython &lt;aegis-workspace-helper&gt; add-evidence --root &lt;target-project-root&gt; --work &lt;YYYY-MM-DD-slug&gt; ...\npython &lt;aegis-workspace-helper&gt; check --root &lt;target-project-root&gt;\n</code></pre>\n<p>Failed attempts use <code>&lt;aegis-workspace-helper&gt; add-attempt</code>; <code>add-evidence</code> is terminal-only.</p>\n<p>Fast bug fix or quick bug fix pressure does not skip this: if Ripple Signal\nTriage fires, record it before editing and verify the canonical owner plus\naffected downstream path. Records are advisory, not completion authority.</p>\n<h2>Closure</h2>\n<p>Always report:</p>\n<ul>\n<li><strong>Repair</strong> — cause, owner, smallest change, compatibility, verification.</li>\n<li><strong>Retirement</strong> — invalid responsibility status, carrier/capability\ndisposition, retention reason/trigger, removal check.</li>\n</ul>\n<p>Confirm the reproduction, same-pattern handling, authority, complexity, and\nretirement. Prefix debug logs (e.g. <code>[DEBUG-a4f2]</code>); confirm one-grep removal before close. Confidence: A = direct regression evidence; B = strong evidence\nwith bounded unknowns; C = partial and not resolved.</p>\n<p><code>Trace Digest</code> may summarize audit evidence; never expose chain-of-thought or\nreplace root-cause, rule-effect, and verification evidence.</p>\n","files":[{"path":"advanced-debugging-governance.md","sizeBytes":8553,"isText":true},{"path":"condition-based-waiting-example.ts","sizeBytes":5054,"isText":true},{"path":"condition-based-waiting.md","sizeBytes":3516,"isText":true},{"path":"defense-in-depth.md","sizeBytes":3650,"isText":true},{"path":"feedback-loop-construction.md","sizeBytes":2479,"isText":true},{"path":"find-polluter.sh","sizeBytes":1528,"isText":true},{"path":"root-cause-claim-contract.md","sizeBytes":13870,"isText":true},{"path":"root-cause-tracing.md","sizeBytes":5615,"isText":true},{"path":"SKILL.md","sizeBytes":10874,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-21T13:50:27.208531Z","sha256":"6071B3DEFEB5B21A9DAB7E6BA9CEA39C32A47D10A18F44550F80A65DCBBD969C","sizeBytes":23915},"review":null,"source":{"repositoryUrl":"https://github.com/GanyuanRan/Aegis","path":"skills/systematic-debugging","license":"MIT","commit":"60321eda49c3b473a183ca0edef5fbfba91eaad1","subtreeSha":"5DD385DC4B1237731D6300573F1007B9AE998B114F2B1227A900E401A719015C","lastSyncedAt":"2026-09-21T13:50:15.063596Z"},"reviewedAt":"2026-09-21T13:50:30.474245Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/GanyuanRan/Aegis/tree/main/skills/systematic-debugging"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install ganyuanran-aegis@llmmart"},{"target":"git","command":"git clone https://github.com/GanyuanRan/Aegis.git"}]}