agentleFS
Sagargupta16Sagargupta16/craftsmanship/skills/debug/SKILL.md

debug

Skill2 starsChanged 29 days agoMITView on GitHub

Use when a test fails, a bug is reported, an error is pasted in, or a fix did not work. Enforces reproduce-before-theorize, reading the actual error, narrowing by bisection, one falsifiable hypothesis at a time, and a stop rule instead of guess-loops.

190 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use update-nanoclaw, add-atomic-chat-tool 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

    update-nanoclaw

    Efficiently bring upstream NanoClaw updates into a customized install, with preview, selective cherry-pick, and low token usage.

    Also in 9 projects that use this

  • MicrosoftSkill

    add-atomic-chat-tool

    Add Atomic Chat MCP server so the container agent can call local models served by the Atomic Chat desktop app via its OpenAI-compatible API.

    Also in 8 projects that use this

  • +10 more from microsoft

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 15 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 176 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write down the exact steps, input, and environment that trigger it

    line 38
  2. Distinctive:

    If it only fails in CI or production, find the difference: version, env var, data volume, timezone, concurrency, file system, locale

    line 40
  3. Distinctive:

    If it is intermittent, run it in a loop and record what differs between pass and fail

    line 41
  4. Distinctive:

    No reproduction means no verification later.

    line 43
  5. Distinctive:

    Read the full message, not the first line -- the cause is often in a nested or wrapped error

    line 49
  6. Distinctive:

    Read the stack from the top frame in your own code, not the framework frames above it

    line 50
  7. Distinctive:

    Check the line number against the file you are actually running (stale build, wrong virtualenv, cached bundle)

    line 51
  8. Distinctive:

    If the message contradicts the code, suspect what you are running, not what you are reading

    line 53
  9. Distinctive:

    Write the hypothesis down for anything that takes more than a few minutes

    line 83
  10. Distinctive:

    When you do not know a value, measure it.

    line 87
  11. Distinctive:

    Use a debugger or breakpoint when state is complex.

    line 90
  12. Distinctive:

    Remove the instrumentation before you ship, or promote it to real logging on purpose

    line 94
  13. Distinctive:

    After two failed fix attempts, stop editing code.

    line 111
  14. Distinctive:

    Write the regression test -- the one that fails before the fix and passes after

    line 125
  15. Distinctive:

    Check for the same mistake elsewhere in the codebase (same wrong pattern, other call sites)

    line 126

“Common” is measured: kept by at least 6 in 10 of the 176 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

Systematic Debugging

Quick Reference

SituationFirst Move
Error message pasted inRead the whole message and the top of the stack, not the first line
"It doesn't work"Get a reproduction before touching any code
Intermittent failureFind what varies between runs (order, timing, state, data)
Worked before, broken nowBisect history to the first bad commit
Fix didn't fix itYour model of the cause is wrong -- go back to reproducing
Two fixes already failedStop. State your assumptions and what would disprove them

The Loop

1. Reproduce -- make the failure happen on demand
2. Read -- the actual error, the actual stack, the actual input
3. Narrow -- bisect until the failure is in a small known region
4. Hypothesize -- one falsifiable statement about the cause
5. Test the hypothesis -- instrument or probe, do not fix yet
6. Fix -- the cause, not the symptom
7. Confirm -- same reproduction steps now pass
8. Regression-test -- a test that would have caught this

Steps 1-5 are the work. Skipping to 6 is why bugs get "fixed" twice.

Reproduce Before You Theorize

A bug you cannot trigger on demand is a bug you cannot confirm you fixed.

  • Write down the exact steps, input, and environment that trigger it
  • Reduce to the smallest reproduction that still fails (fewer files, less data, fewer steps)
  • If it only fails in CI or production, find the difference: version, env var, data volume, timezone, concurrency, file system, locale
  • If it is intermittent, run it in a loop and record what differs between pass and fail

No reproduction means no verification later. Say so instead of guessing.

Read the Actual Error

Pattern-matching an error to a familiar shape is the most common wrong turn.

  • Read the full message, not the first line -- the cause is often in a nested or wrapped error
  • Read the stack from the top frame in your own code, not the framework frames above it
  • Check the line number against the file you are actually running (stale build, wrong virtualenv, cached bundle)
  • Distinguish the error that surfaced from the error that caused it -- "connection refused" is a symptom, not a cause
  • If the message contradicts the code, suspect what you are running, not what you are reading

Narrow by Bisection

Halve the search space instead of scanning it.

UnknownBisection
Which commit broke itgit bisect start / git bisect bad / git bisect good <sha>
Which code pathComment out or short-circuit half, re-run
Which input rowBinary-search the dataset until one record fails
Which dependencyPin half the upgrades back, re-run
Which configStart from empty config, add settings until it breaks
Which layerProbe each boundary (client, network, handler, query, DB) in turn

Ten halvings cover a thousand candidates. Reading a thousand lines does not.

One Hypothesis at a Time

State the cause as a sentence that can be proven wrong, then try to prove it wrong.

Weak:   "something is wrong with the cache"
Strong: "the cache key omits the tenant id, so tenant B reads tenant A's row"
        Disproof: log the computed key for two tenants -- if they differ, wrong.
  • One hypothesis per experiment, or you cannot tell which change mattered
  • Change one variable at a time and re-run between changes
  • Predict the result before you run it -- a surprise means your model is wrong, which is information
  • Write the hypothesis down for anything that takes more than a few minutes

Instrument, Don't Guess

When you do not know a value, measure it.

  • Log or print the actual values at the boundary you suspect -- types, not just values
  • Use a debugger or breakpoint when state is complex; use logs when timing or ordering matters
  • Assert your assumptions inline so a wrong one fails loudly instead of flowing downstream
  • For performance bugs, profile before optimizing -- the slow part is rarely where it feels
  • For concurrency bugs, log with timestamps and thread/task ids, or the ordering stays invisible
  • Remove the instrumentation before you ship, or promote it to real logging on purpose

Fix the Cause, Not the Symptom

Symptom FixCause Fix
Wrap in try/except and continueHandle the condition that made it throw
Add a null check at the crash siteFind why the value is null there
Add a retryFind why the first attempt fails
Increase the timeoutFind what got slow
Add a sleep before the assertionWait on the actual condition
Silence the warningFix what it is warning about

Symptom fixes are sometimes the right call under pressure. When you take one, say it is a mitigation and leave the real cause written down.

The Stop Rule

After two failed fix attempts, stop editing code.

1. State what you believed the cause was
2. State what you changed and what actually happened
3. List the assumptions you have not verified
4. Ask for the missing information, or start over from reproduction

A third guess after two wrong ones is not debugging, it is shotgunning. The cost of shotgunning is a diff nobody can review and a bug that comes back.

After the Fix

  • Confirm with the original reproduction steps, not a variant of them
  • Write the regression test -- the one that fails before the fix and passes after
  • Check for the same mistake elsewhere in the codebase (same wrong pattern, other call sites)
  • Note the root cause in the commit body, not just the change

Anti-Patterns

Anti-PatternProblemDo Instead
Fixing before reproducingCannot tell whether the fix workedReproduce first, always
Changing several things at onceNo idea which one matteredOne variable per run
Reading the first line of the stack onlyReal cause is deeper in the traceRead the whole error
Assuming the error means what it usually meansSame message, different causeVerify against this run's data
Guess-and-check loopsBurns time, produces unreviewable diffsStop after two failures, state assumptions
Deleting the failing testBug still ships, now silentlyFix the code or fix the wrong assertion
print() archaeology with no planNoise without a hypothesisInstrument the specific boundary you suspect
Blaming the framework firstUsually your code, occasionally notProve it with a minimal reproduction
Fixing without a regression testSame bug returns next quarterTest that fails before, passes after

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.