Mastermind debug

From monoes/monomind · View interactive version

Mastermind debug is an AI agent skill from the GitHub repository monoes/monomind. Root-cause debugging protocol to run before any fix: test failures, bugs, unexpected behavior, build failures, performance regressions.

How to use this skill

Skill file

mastermind:debug — Systematic Debugging

Overview

Random fixes waste time and create new bugs. Quick patches mask underlying issues.

Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.

Violating the letter of this process is violating the spirit of debugging.

The Iron Law

NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST

If you haven't completed Phase 1, you cannot propose fixes.

When to Use

Use for ANY technical issue:

Use this ESPECIALLY when:

Don't skip when:

The Four Phases

You MUST complete each phase before proceeding to the next.


Phase 1: Root Cause Investigation

BEFORE attempting ANY fix:

  1. Read Error Messages Carefully
  1. Reproduce Consistently
  1. Check Recent Changes
  1. Gather Evidence in Multi-Component Systems

WHEN the system has multiple components (CI → build → deploy, API → service → database):

BEFORE proposing fixes, add diagnostic instrumentation:

```

For EACH component boundary:

Run once to gather evidence showing WHERE it breaks

THEN analyze evidence to identify the failing component

THEN investigate that specific component

```

Example:

```bash

# Layer 1: entry point

echo "=== Input received: ==="

echo "VAR: ${VAR:+SET}${VAR:-UNSET}"

# Layer 2: processing

echo "=== State after processing: ==="

env | grep VAR || echo "VAR not in environment"

# Layer 3: output/result

echo "=== Final state: ==="

```

  1. Trace Data Flow

WHEN the error is deep in a call stack:


Phase 2: Pattern Analysis

Once you understand WHERE the break is, find existing working examples:

  1. Find working code that solves the same problem
  1. Compare against references
  1. Compare broken vs. working
  1. Understand dependencies

Phase 3: Form and Test a Hypothesis

  1. State your hypothesis explicitly:

> "I believe the root cause is [X] because [evidence Y] and [evidence Z]."

  1. Test the hypothesis minimally
  1. If hypothesis is wrong: Do NOT add more fixes. Return to Phase 1 with the new information.
  1. When you don't know: Say "I don't understand X". Don't pretend to know. Research more or ask the user — a stated unknown beats a confident guess.

Phase 4: Implementation

  1. Write a failing test first (before touching production code)
  1. Implement a single fix
  1. Verify the fix
  1. If the fix doesn't work:

Phase 4.5 — If 3+ Fixes Have Failed: Question the Architecture

Pattern indicating an architectural problem:

STOP and question fundamentals:

Discuss with the user before attempting more fixes. This is not a failed hypothesis — this is the wrong architecture.


Red Flags — STOP and Return to Phase 1

If you catch yourself thinking or doing any of these:

| Thought / Action | What it means |

|---|---|

| "Quick fix for now, investigate later" | You're skipping root cause. Return to Phase 1. |

| "Just try changing X and see if it works" | Guessing. Return to Phase 1. |

| "Add multiple changes, run tests" | Can't isolate what worked. Return to Phase 1. |

| "Skip the test, I'll manually verify" | Untested fixes don't stick. Write the failing test. |

| "Pattern says X but I'll adapt it differently" | Partial understanding guarantees bugs. Read the reference completely. |

| "Here are the main problems: …" (listing fixes without investigation) | Solutions before evidence. Return to Phase 1. |

| "It's probably X, let me fix that" | Assumed root cause. Verify it first. Return to Phase 1. |

| "I don't fully understand but this might work" | You don't have a hypothesis. Return to Phase 1. |

| Proposing solutions before tracing data flow | No root cause. Return to Phase 1. |

| "One more fix attempt" (already tried 2+) | 3+ failures = architectural problem. Phase 4.5. |

| Each fix reveals a new problem in a different place | Architectural problem. Phase 4.5. |

User Signals You're Doing It Wrong

Watch for these redirections from the user:

| Signal | What it means |

|---|---|

| "Is that actually happening?" | You assumed without verifying. Add evidence gathering. |

| "What does the output show?" | You should have checked before proposing a fix. |

| "Stop guessing" | You're proposing fixes without root cause. Phase 1. |

| "We keep going in circles" | 3+ fix attempts = architectural problem. Phase 4.5. |

Common Rationalizations

| Excuse | Reality |

|---|---|

| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |

| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |

| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |

| "I'll write the test after confirming the fix works" | Untested fixes don't stick. Test first proves it. |

| "Multiple fixes at once saves time" | Can't isolate what worked. Creates new bugs. |

| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |

| "I can see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |

| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question the pattern. |

Quick Reference

| Phase | Key Activities | Success Criteria |

|---|---|---|

| 1. Root Cause | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |

| 2. Pattern | Find working examples, compare | Identified differences |

| 3. Hypothesis | Form theory, test minimally | Confirmed or new hypothesis |

| 4. Implementation | Write failing test, fix, verify | Bug resolved, tests pass |

When the Process Reveals "No Root Cause"

If systematic investigation reveals the issue is truly environmental, timing-dependent, or external:

  1. You've completed the process
  2. Document what you investigated
  3. Implement appropriate handling (retry, timeout, clear error message)
  4. Add monitoring/logging for future investigation

But: 95% of "no root cause" cases are incomplete investigation.

Supporting Techniques

Related skills:

Impact

Systematic approach vs random fixing:

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.