agentleFS
guangzanguangzan/monorail/skills/rail-debug/SKILL.md

rail-debug

Skill5 starsChanged 4 months agoMITView on GitHub

Diagnosis loop for hard bugs and performance regressions. Use when the user says "debug this"/"diagnose", or reports something broken/throwing/failing/slow.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When exploring the codebase, read docs/monorail/CONTEXT.md (check for it with the shell — ls, or read the path directly.

    line 10
  2. Distinctive:

    This is the skill: If you have a tight pass/fail signal for the bug — one that goes red on _this_ bug — you will find the cause.

    line 14
  3. Distinctive:

    Stop. List what you tried.

    line 41
  4. Very specific:

    Run the loop red. Confirm it matches the user's symptom.

    line 49
  5. Distinctive:

    If a correct seam exists (exercises the real bug pattern at the call site): write the failing regression test first, then fix, then re-run …

    line 63
  6. Distinctive:

    If no correct seam exists, that is the finding — document it.

    line 65
  7. Very specific:

    Ask what would have prevented this bug.

    line 75
  8. Very specific:

    If diagnosis happened mid-feature and an implementation task remains, suggest resuming with /rail-build on that task in a fresh session.

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Rail Debug

A discipline for hard bugs. Skip phases only when explicitly justified.

When exploring the codebase, read docs/monorail/CONTEXT.md (check for it with the shell — ls, or read the path directly; search tools skip gitignored paths) and check ADRs under docs/monorail/adr/ in the area you're touching.

Phase 1 — Build a feedback loop

This is the skill. If you have a tight pass/fail signal for the bug — one that goes red on this bug — you will find the cause. Without one, staring at code will not save you.

Spend disproportionate effort here. Be aggressive. Be creative. Refuse to give up.

Ways to construct one — try in roughly this order

  1. Failing test at whatever seam reaches the bug
  2. Curl / HTTP script against a running dev server
  3. CLI invocation with a fixture input
  4. Headless browser script (Playwright / Puppeteer)
  5. Replay a captured trace
  6. Throwaway harness for the buggy path
  7. Property / fuzz loop
  8. Bisection harness between two known-good states
  9. Differential loop (old vs new)
  10. Structured HITL checklist as last resort (human clicks; you drive the checklist)

Tighten the loop

Make it faster, sharper (assert the exact symptom), and more deterministic.

Non-deterministic bugs

Raise reproduction rate until the bug is debuggable (loop, stress, pin timing).

When you cannot build a loop

Stop. List what you tried. Ask for environment access, a captured artifact, or temporary instrumentation. Do not hypothesise without a loop.

Completion criterion

Phase 1 is done when you can name one command you have already run, that is red-capable on this bug, deterministic (or high-rate), fast, and agent-runnable. No red-capable command → no Phase 2.

Phase 2 — Reproduce + minimise

Run the loop red. Confirm it matches the user's symptom. Minimise: cut inputs/config/steps one at a time until every remaining element is load-bearing.

Phase 3 — Hypothesise

Generate 3–5 ranked falsifiable hypotheses before testing any. Show the list to the user (don't block if AFK).

Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."

Phase 4 — Instrument

Each probe maps to a Phase 3 prediction. Change one variable at a time. Prefer debugger/REPL, then targeted logs with a unique [DEBUG-xxxx] prefix. For perf: measure first (baseline), then bisect.

Phase 5 — Fix + regression test

If a correct seam exists (exercises the real bug pattern at the call site): write the failing regression test first, then fix, then re-run the Phase 1 loop on the original scenario.

If no correct seam exists, that is the finding — document it; architecture may be blocking lock-down.

Phase 6 — Cleanup + post-mortem

  • Original Phase 1 loop is green
  • Regression test passes (or missing seam documented)
  • All [DEBUG-...] instrumentation removed
  • Throwaway harnesses deleted or clearly marked
  • Correct hypothesis stated for the next debugger

Ask what would have prevented this bug. If the answer is architectural, recommend a follow-up /rail-align (then /rail-spec if the fix is large) — do not invent a skill that is not in the rail pack.

If diagnosis happened mid-feature and an implementation task remains, suggest resuming with /rail-build on that task in a fresh session.

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.