Repro case minimizer
Goal
Produce the smallest self-contained example that still fails in the same way. A good result runs from a clean folder with one command, has no unrelated code, and is easy for someone else to read in a minute.
When to use
- A bug report needs a reproduction for a maintainer.
- A failure only happens inside a big project and the cause is unclear.
- A large input file, config or data set triggers a failure and the trigger is unknown.
- A maintainer asked for a reproduction before they will look.
- A failing input file is thousands of lines long.
- A bug only shows with one combination of options.
For finding the cause in the full project, use use_skill with systematic-debugging. For finding the commit, bisect-regression.
Steps
- Capture the failure signature. Run the original with
run_command and record the exact error text, exit code or wrong output. This is the test for "still fails the same way".
- Script the check. Write a small script with
create_file that runs the case and exits non-zero only when the signature appears. Every later step uses it.
- Copy to a scratch directory. Work on a copy, never on the original project. Use
ls to see what you are cutting.
- Cut big pieces first. Remove half of the files, routes, config blocks, dependencies or input rows. Run the check. If it still fails, keep the cut; if not, restore and cut the other half. Halving beats removing line by line.
- Cut finer. Remove functions, options, fields, plugins and imports one at a time. Replace real data with literals. Replace services with constants.
- Simplify values. Shorten strings, reduce numbers to the smallest failing size, rename to plain names.
- Stop at a floor. When removing anything changes the failure, you are done. Note which parts proved necessary.
- Verify clean. Place the case in a fresh empty folder, install only what it declares, and run the check. Pin the versions in use by reading them from the tool output.
- Write the report with the steps, expected result, actual result and versions.
- Compare the failure of the final case with step 1 once more, character by character where it matters.
Gotchas
- Removing a part can change the failure into a different error. The check must test the exact signature and match the exact error text.
- Stopping at "smaller" leaves unrelated code that distracts the reader. Keep cutting until each part is needed.
- A repro that depends on files in your home directory or local services does not reproduce elsewhere.
- Secrets, private data and company code must not go into a shared repro. Replace them with dummies.
- Unpinned dependencies make the repro fail differently next week. Record versions.
Output
The minimal files (paths in the scratch directory), the one-line run command, the expected and actual result, versions used, and the list of things proven unnecessary.
Add a line telling the reader how to run it on their machine.
1---2name: repro-case-minimizer3description: Shrinks a failing program, input or configuration step by step to the smallest version that still shows the bug, and checks it in a clean directory. Use when the user wants a minimal reproduction, a small repro for a bug report, or to narrow down which input breaks something.4metadata:5 source: https://skillmd.com/skills/lucki74/repro-case-minimizer6---78# Repro case minimizer910## Goal1112Produce the smallest self-contained example that still fails in the same way. A good result runs from a clean folder with one command, has no unrelated code, and is easy for someone else to read in a minute.1314## When to use1516- A bug report needs a reproduction for a maintainer.17- A failure only happens inside a big project and the cause is unclear.18- A large input file, config or data set triggers a failure and the trigger is unknown.19- A maintainer asked for a reproduction before they will look.20- A failing input file is thousands of lines long.21- A bug only shows with one combination of options.2223For finding the cause in the full project, use `use_skill` with `systematic-debugging`. For finding the commit, `bisect-regression`.2425## Steps26271. **Capture the failure signature.** Run the original with `run_command` and record the exact error text, exit code or wrong output. This is the test for "still fails the same way".282. **Script the check.** Write a small script with `create_file` that runs the case and exits non-zero only when the signature appears. Every later step uses it.293. **Copy to a scratch directory.** Work on a copy, never on the original project. Use `ls` to see what you are cutting.304. **Cut big pieces first.** Remove half of the files, routes, config blocks, dependencies or input rows. Run the check. If it still fails, keep the cut; if not, restore and cut the other half. Halving beats removing line by line.315. **Cut finer.** Remove functions, options, fields, plugins and imports one at a time. Replace real data with literals. Replace services with constants.326. **Simplify values.** Shorten strings, reduce numbers to the smallest failing size, rename to plain names.337. **Stop at a floor.** When removing anything changes the failure, you are done. Note which parts proved necessary.348. **Verify clean.** Place the case in a fresh empty folder, install only what it declares, and run the check. Pin the versions in use by reading them from the tool output.359. **Write the report** with the steps, expected result, actual result and versions.3610. Compare the failure of the final case with step 1 once more, character by character where it matters.3738## Gotchas3940- Removing a part can change the failure into a different error. The check must test the exact signature and match the exact error text.41- Stopping at "smaller" leaves unrelated code that distracts the reader. Keep cutting until each part is needed.42- A repro that depends on files in your home directory or local services does not reproduce elsewhere.43- Secrets, private data and company code must not go into a shared repro. Replace them with dummies.44- Unpinned dependencies make the repro fail differently next week. Record versions.4546## Output4748The minimal files (paths in the scratch directory), the one-line run command, the expected and actual result, versions used, and the list of things proven unnecessary.4950Add a line telling the reader how to run it on their machine.