diagnose-before-editing
Skill25 starsChanged 32 days agoMITView on GitHub
Use when behavior fails, flakes, or slows down, and nobody knows the cause yet. Also use it when the user says "why does this fail?", "it worked yesterday", or "this got slow". Reproduces the failure, makes it smaller, and tests one cause at a time until one cause predicts the symptom. Then fixes the cause at its origin, not the symptom. Not for scoping a fix whose cause you already know (use `scope-confirmed-changes`).
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- evals/AGENTS.mdAGENTS.md
- tooling/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- evals/CLAUDE.mdCLAUDE.md
- tooling/CLAUDE.mdCLAUDE.md
- choose-by-consequenceSkill
- design-deep-modulesSkill
- plan-with-review-pageSkill
- research-primary-sourcesSkill
- resolve-conflicts-by-intentSkill
- scope-confirmed-changesSkill
- shadowclone-build-preferencesSkill
- shadowclone-reviewSkill
- shadowclone-workSkill
- tests-that-catch-bugsSkill
- typescript-type-safetySkill
- verify-and-reviewSkill
- write-plain-englishSkill
- choose-by-consequenceSkill
- data-handlingSkill
- design-deep-modulesSkill
- diagnose-before-editingSkill
- plan-with-review-pageSkill
- research-primary-sourcesSkill
- resolve-conflicts-by-intentSkill
- scope-confirmed-changesSkill
- shadowclone-build-preferencesSkill
- shadowclone-reviewSkill
- shadowclone-workSkill
- tests-that-catch-bugsSkill
- typescript-type-safetySkill
- verify-and-reviewSkill
- write-plain-englishSkill
- choose-by-consequenceSkill
- design-deep-modulesSkill
- diagnose-before-editingSkill
- guided-pr-reviewSkill
- plan-with-review-pageSkill
- research-primary-sourcesSkill
- resolve-conflicts-by-intentSkill
- scope-confirmed-changesSkill
- shadowclone-reviewSkill
- shadowclone-workSkill
- tests-that-catch-bugsSkill
- typescript-type-safetySkill
- verify-and-reviewSkill
- verify-review-findingsSkill
- write-plain-englishSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
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
- Distinctive: line 27
Remove inputs and steps while the failure stays.
- Distinctive: line 30
Test one cause at a time with a debugger, a log line, a timer, or a controlled input.
- Distinctive: line 31
When one cause predicts the symptom, fix it at its origin.
- Distinctive: line 32
Run the small and the original reproductions.
- Distinctive: line 46
Do not turn a theory that you did not test into a production change.
- Distinctive: line 47
Do not add a fallback that only hides invalid state.
- Distinctive: line 48
Remove secrets and private paths from traces before you report them.
- Distinctive: line 49
Do not fix other defects in this change.
- Distinctive: line 50
If you cannot reproduce the failure, report what you tried and what evidence is missing.
≈ “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
Diagnose Before Editing
Use when
Something fails, throws, flakes, or slows down, and nobody has shown the cause yet. A change before the cause is known can hide the bug instead of fixing it.
Gates
- Can you make the failure happen on demand with one command or test?
- Did you write down the input, the actual result, and the expected result?
- For each suspected cause, did you name an observation that would prove it wrong?
- Did you change one variable in each probe?
- Does the cause that you found predict the symptom, and does a controlled change remove it?
- Did you remove each temporary log line and probe before the handoff?
Process
- Find the fastest command that reaches the failing path. Run it until you see the failure.
- Remove inputs and steps while the failure stays. Stop when no further removal keeps it.
- Trace the state from the input. Find the first place where a correct value becomes wrong.
- List the possible causes. For each one, write the observation that would rule it out.
- Test one cause at a time with a debugger, a log line, a timer, or a controlled input.
- When one cause predicts the symptom, fix it at its origin.
- Run the small and the original reproductions. Keep one as a regression test where practical.
For a flaky failure, measure how often it happens. Control the clock, the random values, the concurrency, and the outside responses. For a slow path, measure a baseline first, and measure the suspected cost before you change it.
Example
Situation: A test fails one run in ten on a busy machine. A teammate suggests a longer timeout. Easy route: Raise the timeout from 5 to 30 seconds. The test passes. Hidden cost: The cause stays. The real command can still hang for users, and the slow test now hides other delays. Best route: Measure the failure rate, then control the clock in the test. The failure now shows on each run, when two writes wait for one lock. Evidence: With the clock fixed, the test failed 10 of 10 runs before the fix and passed 10 of 10 after it. The timeout stayed at 5 seconds.
Guardrails
- Do not turn a theory that you did not test into a production change.
- Do not add a fallback that only hides invalid state.
- Remove secrets and private paths from traces before you report them.
- Do not fix other defects in this change. List them in the handoff.
- If you cannot reproduce the failure, report what you tried and what evidence is missing.
Completion
- The reproduction command, with its failing line before the fix.
- The same command after the fix, with its passing line.
- The cause in one sentence, with the
file:linewhere the state first goes wrong. - Each cause that you ruled out, with the observation that ruled it out.
- Anything that you could not reproduce.
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.

