agentleFS
afu-itafu-it/safe-code/skills/debug-issue/SKILL.md

debug-issue

Skill4 starsChanged 57 days agoMITView on GitHub

Systematically debug a symptom with a red-capable feedback loop, a minimised repro, ranked falsifiable hypotheses, tagged probes, and a regression test at the correct seam. Graph tools accelerate the search when present; they are never required.

20 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use refactor-safely, refactor-code and 6 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.
  • srclightSkill

    refactor-safely

    This skill should be used when the user asks to "refactor", "rename", "move", "change a function signature", "extract a method", "delete unused code", "clean up", or any modification that could break callers or dependents. Provides a pre-change safety checklist using srclight's graph tools to assess blast radius before touching code.

    Also in 6 projects that use this

  • zbruhnkeSkill

    refactor-code

    Refactor code to improve clarity and maintainability without changing behavior. Use when improving readability, reducing complexity, or eliminating duplication.

    Also in 3 projects that use this

  • xfstudioSkill

    reverse-engineer

    Expert reverse engineer specializing in binary analysis,

    Also in 3 projects that use this

  • SentrySkill

    create-pr

    Create pull requests following Sentry conventions. Use when opening PRs, writing PR descriptions, or preparing changes for review. Follows Sentry's code review guidelines.

    Also in 4 projects that use this

  • SentrySkill

    security-review

    Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.

    Also in 3 projects that use this

  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 19 edited versions we read keep these.

  • 3

    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:

    When you have read access, look at the real failing record, user, or job state (read-only) before hypothesising — it often names the cause …

    line 14
  2. Distinctive:

    Never blind-retry a side-effecting call (POST, send, payment, migration) that failed part-way: read the remote state first, because the …

    line 15
  3. Distinctive:

    If you catch yourself reading code to build a theory before that command exists, stop.

    line 25

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

Debug Issue

Reproduce first, theorise second. A hypothesis formed before a failing command exists is a guess dressed as a plan.

Phase 0: Contention and real state

Before any code hypothesis: is another process, agent, worktree, or the user's other tool touching the same branch, database, port, session, or shared credential/token store? (git worktree list, lsof -i :<port>, ask "is another tool on this?"). Rule it out first — flaky behaviour under contention looks exactly like a code bug, and two clients refreshing the same rotating token invalidate each other.

  • When you have read access, look at the real failing record, user, or job state (read-only) before hypothesising — it often names the cause outright.
  • Never blind-retry a side-effecting call (POST, send, payment, migration) that failed part-way: read the remote state first, because the first attempt may have half-succeeded.

Phase 1: Build a red-capable loop

Build one command — a test, curl, CLI + fixture, headless script, replayed trace, or throwaway harness — that you have already run once and that goes red on this exact symptom. It must:

  • assert the user's symptom, not "runs without erroring";
  • be deterministic, seconds-fast, and runnable by you without the user;
  • print only redacted output: secrets become <REDACTED>, credentials stay in env vars, captured artifacts (HAR, request dumps) are quoted only on the lines that carry the signal.

If you catch yourself reading code to build a theory before that command exists, stop. No red-capable command, no hypothesis. If you genuinely cannot build one, say so, list what you tried, and ask for the environment, a redacted artifact, or permission to instrument.

Phase 2: Minimise

Shrink to the smallest scenario that still goes red: cut inputs, callers, config, data, and steps one at a time, re-running after each cut. Done when removing any remaining element turns it green. The minimal repro shrinks the hypothesis space and becomes the regression test.

Phase 3: Ranked, falsifiable hypotheses

Generate 3–5 hypotheses before testing any — one hypothesis anchors on the first plausible idea. For a once-only failure with fixed inputs, rank "what varies between runs" high: clock ties, unordered reads (an ORDER BY that does not end on a unique column), concurrency, cache or retry state. Each must state a prediction: "If X is the cause, then changing Y makes the bug disappear / changing Z makes it worse." No stateable prediction means it is a vibe: sharpen or discard. Show the ranked list to the user before probing (they re-rank instantly with domain knowledge); do not block on the answer if they are away.

Graph accelerators (optional, when a codegraph index is ready): codegraph explore "<symptom>" (or codegraph_explore), codegraph callers|callees <symbol>, codegraph affected <recently changed files> for regressions, codegraph impact <symbol> before touching shared code. Without them: rg, tests, logs, runtime probes.

Phase 4: Probe one variable at a time

Each probe maps to one Phase 3 prediction. Record each falsified hypothesis and each failed fix as one line in MEMORY.md (drafted in SESSION.md under safe-code) so no one re-runs them. Tag every temporary log with a unique prefix, e.g. [DEBUG-a4f2], so cleanup is one grep. Prefer a debugger or REPL breakpoint over ten logs; never "log everything and grep".

Phase 5: Fix at the correct seam

Write the regression test before the fix, at a seam where the test exercises the real bug pattern as it occurs at the call site. A too-shallow seam (a unit test that cannot replicate the chain that triggered the bug) gives false confidence. If no correct seam exists, that is itself a finding: record it in MEMORY.md — the architecture is preventing this bug from being locked down. Then patch only the smallest confirmed cause.

Cleanup gate (before declaring done)

  • the original repro no longer reproduces (run it, do not assume);
  • the regression test was seen failing without the fix (bypass the fix in place -> red -> restore; no destructive git in a shared checkout — the safe-code skill's references/multi-session.md, Shared-checkout rules) and passes with it, or the absence of a seam is documented — a test never seen red proves nothing;
  • grep -rn "\[DEBUG-" <src> is empty and throwaway harnesses are deleted;
  • cleanup closes only the windows, tabs, daemons, and locks this task opened — never the user's; a stale lock is removed only after proving no live process owns it;
  • the winning hypothesis is stated in the commit message so the next debugger learns.

Output

Lead with: root cause (the hypothesis that survived, and which prediction confirmed it) · changed files · the red-capable command and its before/after result · remaining risk or missing coverage (including "no correct seam").

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.