agentleFS
aneja5aneja5/forge-skills/skills/debugging-and-recovery/SKILL.md

debugging-and-recovery

Skill3 starsChanged 7 months agoMITView on GitHub

Use when something is broken, a test is failing, behavior is wrong, when investigating a production incident, when a user reports a bug, when a feature works locally but not in another environment, or when the system behaves differently than the contract specifies.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    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:

    No regression test added — the bug will return

    line 39
  2. Distinctive:

    Run the full test suite. Confirm:

    line 75
  3. Distinctive:

    No previously passing tests now fail

    line 77
  4. Very specific:

    If the bug was non-obvious: add a comment explaining WHY the fix is correct, not what it does.

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Debugging and Recovery

Overview

Reproduce → localize → fix → guard. Never guess at root cause. The fix is not done until a regression test guards it. For bugs with GitHub issues, see triage-issue for the full investigation + issue creation flow.

When to Use

  • Something broke or behaves unexpectedly
  • A test is failing and the cause is not obvious
  • A bug has been reported and needs diagnosis before a fix
  • An error is ambiguous — multiple possible causes

When NOT to Use

  • The fix is obvious and well-understood — just implement with tdd
  • The bug is a missing feature, not broken behavior — use spec-driven-development
  • You want to preemptively prevent bugs — use code-review-and-quality

Common Rationalizations

ThoughtReality
"I know what the bug is"You think you do. Reproduce it first.
"I'll just try this fix and see"Untested fixes introduce new bugs
"The root cause is obvious from the stack trace"Stack traces show symptoms, not causes
"A unit test would be too hard to write for this"Write an integration test — the behavior is observable
"The fix is one line, no test needed"One-line bugs are re-introduced in one line

Red Flags

  • Fixing before reproducing — you might be fixing the wrong thing
  • Fix that passes all tests but doesn't change observable behavior
  • No regression test added — the bug will return
  • Root cause described as "it just wasn't working" — not a cause
  • Fix modifies more than what the bug report describes

Core Process

Step 1: Reproduce

Get the minimal reproduction: exact steps, inputs, environment. If you can't reproduce it, you don't understand it. Run the failing scenario manually or via test before writing any fix.

Step 2: Write a failing test

Before fixing:

RED: Write a test that reproduces the bug
     → The test must fail
     → If it passes, your reproduction is wrong

The test proves you understand the bug.

Step 3: Localize

With a failing test, trace the code path:

  • Where does the expected behavior diverge from actual?
  • What invariant is being violated?
  • What recently changed in this code path? (git log -p <files>)
  • Is it the logic, the data, or the interface contract?

Step 4: Fix — minimum change

Implement the smallest change that makes the failing test pass. Do not refactor adjacent code. Do not fix other bugs you notice. Do not add features.

Step 5: Guard

Run the full test suite. Confirm:

  • The specific regression test passes
  • No previously passing tests now fail
  • The fix doesn't silently break adjacent behavior

Step 6: Document

If the bug was non-obvious: add a comment explaining WHY the fix is correct, not what it does. Consider whether the bug points to a missing contract invariant in .forge/contracts/.

Verification

  • Bug reproduced before any fix was written
  • Failing test written that specifically captures the bug
  • Root cause identified (not just symptom)
  • Fix is the minimum change to make the test pass
  • Regression test passes after fix
  • Full test suite still passes
  • If contract was violated: .forge/contracts/ updated with the missing invariant

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.