agentleFS
BULDEEBULDEE/ai-craftsman-superpowers/skills/debug/SKILL.md

debug

Skill35 starsChanged 52 days agoApache-2.0View on GitHub

Systematic debugging using ReAct pattern. Use when encountering bugs, errors, unexpected behavior, test failures, or performance issues. Never guess - investigate methodically.

192 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use add-discord, add-slack and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    add-discord

    Add Discord bot channel integration via Chat SDK.

    Also in 11 projects that use this

  • MicrosoftSkill

    add-slack

    Add Slack channel integration via Chat SDK.

    Also in 11 projects that use this

  • +10 more from microsoft

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 175 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before investigating, CLARIFY with the user:

    line 33
  2. Distinctive:

    WAIT for answers if unclear: Do not assume.

    line 45
  3. Distinctive:

    Use the Bash tool to query recent corrections from the metrics database:

    line 65
  4. Distinctive:

    If after 2 investigation cycles the root cause is unclear:

    line 93
  5. Distinctive:

    Use WebSearch with the exact error message

    line 96
  6. Distinctive:

    Use WebFetch on library docs for the specific API/method involved

    line 100
  7. Distinctive:

    Check changelogs for recent breaking changes

    line 101
  8. Very specific:

    Check dependency versions: composer show | grep <package> or npm list <package>

    line 105
  9. Distinctive:

    If you catch yourself thinking:

    line 148
  10. Distinctive:

    When the reproduction is a long build, a soak test or a log to tail, the native Monitor tool streams the process's events back into the …

    line 208

“Common” is measured: kept by at least 6 in 10 of the 175 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/craftsman:debug - Systematic Investigation

Outcome Contract

  • Outcome: the root cause of the observed behaviour, proven by a reproduction, not a plausible hypothesis.
  • Done when: the failure reproduces on demand, the cause is located at file:line, the fix makes the reproduction pass, and no other test regresses.
  • Evidence: the failing command output before, the same command after, and the reproduction steps.

You are a Senior Engineer debugging systematically. Never guess - investigate methodically.

The Iron Law

┌─────────────────────────────────────────────────────────────────┐
│                                                                  │
│         NO FIXES WITHOUT ROOT CAUSE INVESTIGATION               │
│                                                                  │
│   If you haven't completed Phase 1-3, you CANNOT propose fixes  │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Process (ReAct Pattern)

Phase 1: Understand the Problem

Before investigating, CLARIFY with the user:

## Problem Clarification

1. **Expected behavior:** What SHOULD happen?
2. **Observed behavior:** What ACTUALLY happens?
3. **Reproduction:** Steps to reproduce?
4. **Timeline:** When did it start? What changed?
5. **Environment:** Dev/Staging/Prod? Versions?

WAIT for answers if unclear. Do not assume.

Phase 2: Form Hypotheses

Based on symptoms, rank hypotheses by probability:

## Hypotheses

| # | Hypothesis | Probability | Why |
|---|------------|-------------|-----|
| 1 | [Most likely cause] | 60% | [Evidence] |
| 2 | [Second option] | 25% | [Evidence] |
| 3 | [Less likely] | 15% | [Evidence] |

Phase 3: Investigate (ReAct Loop)

Recent Corrections

Use the Bash tool to query recent corrections from the metrics database:

DB=$(bash "$(craftsman-path bin/craftsman-runtime)" metrics) || exit 1
sqlite3 "$DB" "SELECT rule, file_pattern, action, context FROM corrections WHERE timestamp > datetime('now','-7 days') ORDER BY timestamp DESC LIMIT 10;" 2>/dev/null || echo "No recent corrections"

Execute investigation cycles:

## Investigation Log

### Cycle 1
**THOUGHT:** Based on [observation], I suspect [cause]. I need to check [X].
**ACTION:** [Read file X / Run command Y / Check logs Z]
**OBSERVATION:** [What I found]
**CONCLUSION:** [Confirms/refutes hypothesis #N]

### Cycle 2
**THOUGHT:** [Updated thinking based on Cycle 1]
**ACTION:** [Next investigation step]
**OBSERVATION:** [Results]
**CONCLUSION:** [Updated hypothesis]

Repeat until root cause is confirmed with evidence.

Web Research (when stuck)

If after 2 investigation cycles the root cause is unclear:

  1. Search for the error message or symptom:
    • Use WebSearch with the exact error message
    • Filter results for: Stack Overflow, GitHub Issues, official docs
  2. Fetch relevant documentation:
    • Use WebFetch on library docs for the specific API/method involved
    • Check changelogs for recent breaking changes
  3. Cross-reference findings with local code:
    • Compare documentation behavior vs observed behavior
    • Check dependency versions: composer show | grep <package> or npm list <package>

Phase 4: Root Cause Identification

## Root Cause

**Location:** [File:Line]
**Cause:** [Clear explanation]
**Evidence:** [What proves this is the cause]
**Why it wasn't caught:** [Missing test? Edge case?]

Phase 5: Fix

Apply a minimal, targeted fix:

## Fix

**Change:**
```diff
- old code
+ new code

Why this fixes it: [Explanation] Side effects: [None / List them]


### Phase 6: Prevent

```markdown
## Prevention

- [ ] **Test added:** `test_[scenario]` that would have caught this
- [ ] **Static analysis:** Rule added to catch similar issues
- [ ] **Documentation:** Updated if API/behavior changed
- [ ] **Monitoring:** Alert added if applicable

Red Flags - STOP Immediately

If you catch yourself thinking:

ThoughtReality
"Quick fix for now"You'll forget. Fix properly.
"Just try changing X"That's guessing, not debugging.
"It's probably X"Probably ≠ Confirmed. Investigate.
"I don't fully understand but..."Then you can't fix it safely.
"It's flaky, it passes when I run it alone"Red in the suite and green alone is a defect: shared state, test order, time or the filesystem. A run of that test alone is evidence of the dependency, not of a pass.
"It was already failing, it's not mine"Pre-existing is a fact about the past, not a verdict. Fix it, or open a ticket and name its identifier in the report.

→ STOP. Return to Phase 1.

Common Debugging Commands

# PHP
tail -f var/log/dev.log
bin/console debug:container ServiceName
vendor/bin/phpunit --filter=TestName --debug

# Node.js
node --inspect app.js
DEBUG=* npm start

# Database
EXPLAIN ANALYZE SELECT ...;

# Memory
valgrind --leak-check=full ./program

Output Format

# Investigation: [Issue Title]

## Summary
- **Status:** [Investigating | Root Cause Found | Fixed]
- **Severity:** [Critical | High | Medium | Low]
- **Time spent:** [Duration]

## Problem
[Description]

## Root Cause
[Explanation with evidence]

## Fix
[Code changes]

## Prevention
[Tests and safeguards added]

## Lessons Learned
[What to remember for next time]

Long-Running Reproductions

When the reproduction is a long build, a soak test or a log to tail, the native Monitor tool streams the process's events back into the session, so the investigation reacts to output as it lands instead of polling with sleep-and-recheck. Prefer it whenever the harness offers it.

Bias Protection

Acceleration: "Just fix it quickly" → Quick fixes become permanent bugs. Follow the process.

Dispersion: "While debugging, I noticed this other issue..." → Note it. Stay focused on THIS bug. One problem at a time.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.