Mav systematic debugging

From thermiteau/maverick · View interactive version

Mav systematic debugging is an AI agent skill from the GitHub repository thermiteau/maverick. Use when encountering any bug, test failure, or unexpected behaviour during implementation. Requires root cause investigation before proposing fixes.

How to use this skill

Skill file

Systematic Debugging

Find root cause before attempting fixes. Random fixes waste time, create new bugs, and mask underlying issues.

The Iron Law

NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST

If you have not completed Phase 1, you cannot propose fixes.

When to Use

Use for any technical issue encountered during implementation:

Use this especially when:

The Four Phases

Complete each phase before proceeding to the next.

digraph debugging {
    "Phase 1: Root Cause Investigation" [shape=box];
    "Root cause identified?" [shape=diamond];
    "Phase 2: Pattern Analysis" [shape=box];
    "Phase 3: Hypothesis and Test" [shape=box];
    "Hypothesis confirmed?" [shape=diamond];
    "Phase 4: Fix and Verify" [shape=box];
    "Fix works?" [shape=diamond];
    "Done" [shape=box];
    "Attempts >= 3?" [shape=diamond];
    "Escalate — question architecture" [shape=box];

    "Phase 1: Root Cause Investigation" -> "Root cause identified?";
    "Root cause identified?" -> "Phase 2: Pattern Analysis" [label="yes"];
    "Root cause identified?" -> "Phase 1: Root Cause Investigation" [label="no — gather more evidence"];
    "Phase 2: Pattern Analysis" -> "Phase 3: Hypothesis and Test";
    "Phase 3: Hypothesis and Test" -> "Hypothesis confirmed?";
    "Hypothesis confirmed?" -> "Phase 4: Fix and Verify" [label="yes"];
    "Hypothesis confirmed?" -> "Phase 3: Hypothesis and Test" [label="no — new hypothesis"];
    "Phase 4: Fix and Verify" -> "Fix works?";
    "Fix works?" -> "Done" [label="yes"];
    "Fix works?" -> "Attempts >= 3?" [label="no"];
    "Attempts >= 3?" -> "Phase 1: Root Cause Investigation" [label="no — re-investigate"];
    "Attempts >= 3?" -> "Escalate — question architecture" [label="yes"];
}

Phase 1: Root Cause Investigation

Before attempting any fix:

1. Read error messages carefully

2. Reproduce consistently

3. Check recent changes

4. Gather evidence in multi-component systems

When the system has multiple layers (API → service → database, CI → build → deploy):

For EACH component boundary:
  - Log what data enters the component
  - Log what data exits the component
  - Verify environment/config at each layer

Run once to gather evidence showing WHERE it breaks.
THEN analyse evidence to identify the failing component.
THEN investigate that specific component.

Use the project's logging standards (structured JSON, logger.debug()) for diagnostic instrumentation. Remove diagnostic logging before committing.

5. Trace data flow

Phase 2: Pattern Analysis

Find the pattern before fixing:

  1. Find working examples — locate similar working code in the same codebase
  2. Compare — what is different between working and broken?
  3. List every difference — do not assume "that cannot matter"
  4. Understand dependencies — what settings, config, or environment does this code require?

Phase 3: Hypothesis and Test

Apply the scientific method:

  1. Form a single hypothesis — "I think X is the root cause because Y"
  2. Test minimally — make the smallest possible change to test the hypothesis. One variable at a time.
  3. Verify — did it work?

Phase 4: Fix and Verify

Fix the root cause, not the symptom:

  1. Create a failing test — a test that reproduces the bug. This proves the fix actually addresses the issue and prevents regression.
  2. Implement a single fix — address the root cause identified. One change at a time. No "while I'm here" improvements.
  3. Verify the fix — run the test. Run the full verification suite. Confirm no regressions.
  4. If the fix does not work — count how many fixes you have attempted:

Escalation: 3+ Failed Fixes

If three or more fix attempts have failed, this is likely an architectural problem, not a code bug.

Indicators of an architectural problem:

Action:

Anti-Patterns

| Temptation | Why it fails |

|---|---|

| "Quick fix, investigate later" | Later never comes. The quick fix becomes permanent. |

| "Just try changing X" | Without understanding why, you cannot know if the fix is correct. |

| "Add multiple changes, see what works" | Cannot isolate what helped. Introduces new bugs. |

| "It is probably X, let me fix that" | Seeing symptoms is not understanding root cause. |

| "Skip the test, manually verify" | Manual verification does not prevent regression. |

| "One more fix attempt" (after 2+ failures) | 3+ failures means the problem is architectural. |

| "Increase the timeout" | Timeouts mask the real issue. Find why it is slow. |

Integration with Workflow

When debugging occurs during plan execution (do-issue workflows):

  1. Do not skip the failing step — the mav-plan-execution skill requires verification to pass before moving on
  2. Do not mark the step as complete — the issue plan comment should not be checked off until the step genuinely works
  3. Log diagnostic findings — if the bug reveals a design issue, update the solution design comment on the issue
  4. Time-box debugging — if Phase 1 takes more than 30 minutes without progress, escalate to the user rather than continuing to investigate alone

<!-- maverick-plugin-version: 5.3.1 -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.