Systematic debugging

From RedWoodOG/Hermes-Desktop · View interactive version

Systematic debugging is an AI agent skill from the GitHub repository RedWoodOG/Hermes-Desktop. Structured debugging - reproduce, isolate, hypothesize, verify, and fix bugs.

How to use this skill

Skill file

Systematic Debugging

You are a senior engineer debugging a problem systematically. You do NOT guess-and-check. You follow a disciplined process: reproduce, isolate, hypothesize, verify, then fix.

The Debugging Process

Step 1: Understand the Symptom

Gather all available information about the bug:

# Check recent changes that might have introduced the bug
git log --oneline -20
git log --oneline --since="3 days ago"

Step 2: Reproduce the Bug

Before diagnosing, confirm you can trigger the bug reliably:

# Run the failing test, command, or scenario
# Capture the EXACT error message and stack trace

If there is a stack trace, read it carefully. The most important line is usually the FIRST frame in YOUR code (not in library code).

If the bug is intermittent, look for:

Step 3: Isolate the Problem

Narrow down WHERE the bug is. Use binary search on the codebase:

# If you suspect a recent commit
git bisect start
git bisect bad HEAD
git bisect good <known-good-commit>
# Then test at each point git bisect offers

# Search for relevant code
grep -r "errorMessage\|functionName\|relevantTerm" --include="*.{ts,js,py,cs}" .

Read the relevant source files. Trace the execution path from the entry point to where the error occurs.

The Five Whys: For each finding, ask "why does this happen?" until you reach the root cause:

  1. Why did the request fail? -> The response was null
  2. Why was the response null? -> The API returned 404
  3. Why did it return 404? -> The URL was constructed incorrectly
  4. Why was the URL wrong? -> The base path config was missing a trailing slash
  5. Root cause: Missing trailing slash in configuration

Step 4: Form a Hypothesis

Based on your investigation, state a specific, falsifiable hypothesis:

A good hypothesis predicts additional observable facts you can verify.

Step 5: Verify the Hypothesis

Test your hypothesis WITHOUT fixing the bug yet:

# Add temporary logging or assertions
# Run with specific inputs that should trigger the bug
# Check that the hypothesis predicts the exact error

Read the code path again with your hypothesis in mind. Does every step of the logic confirm it?

If your hypothesis is wrong, go back to Step 3. Do NOT proceed with a fix you're not confident about.

Step 6: Implement the Fix

Fix the root cause, not just the symptom:

Use edit_file to make the change.

Step 7: Verify the Fix

# Run the original reproduction steps
# Confirm the bug no longer occurs

# Run the full test suite
# Confirm no regressions

Step 8: Prevent Recurrence

Step 9: Report

Summarize:

  1. Symptom: What was observed
  2. Root cause: Why it happened
  3. Fix: What was changed
  4. Prevention: Test or safeguard added

Common Bug Patterns

| Pattern | Symptoms | Investigation |

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

| Null/undefined | TypeError, NullRef | Trace data flow backward from crash |

| Off-by-one | Wrong count, missing item | Check loop bounds and array indices |

| Race condition | Intermittent, timing-dependent | Look for shared mutable state |

| State mutation | Works first time, fails on repeat | Check for unintended side effects |

| Encoding | Garbled text, wrong characters | Check encoding at every boundary |

| Scope/closure | Wrong variable value | Check variable capture in closures/callbacks |

Principles

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.