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.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- rail-alignSkill
- rail-buildSkill
- rail-grillSkill
- rail-passSkill
- rail-reviewSkill
- rail-setupSkill
- railSkill
- rail-sliceSkill
- rail-specSkill
- rail-tddSkill
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
- Very specific: line 10
When exploring the codebase, read docs/monorail/CONTEXT.md (check for it with the shell — ls, or read the path directly.
- Distinctive: line 14
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.
- Distinctive: line 41
Stop. List what you tried.
- Very specific: line 49
Run the loop red. Confirm it matches the user's symptom.
- Distinctive: line 63
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 …
- Distinctive: line 65
If no correct seam exists, that is the finding — document it.
- Very specific: line 75
Ask what would have prevented this bug.
- Very specific: line 77
If diagnosis happened mid-feature and an implementation task remains, suggest resuming with /rail-build on that task in a fresh session.
≈ “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.
Files
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
- Failing test at whatever seam reaches the bug
- Curl / HTTP script against a running dev server
- CLI invocation with a fixture input
- Headless browser script (Playwright / Puppeteer)
- Replay a captured trace
- Throwaway harness for the buggy path
- Property / fuzz loop
- Bisection harness between two known-good states
- Differential loop (old vs new)
- 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.
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
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.

