A minimal reproducible example is the code equivalent of showing a mechanic the one part that rattles instead of handing over the whole car. You remove everything that is not needed to trigger the problem, then confirm that what remains still fails when someone else runs it. Get those two things right – minimal and reproducible – and most questions answer themselves.
The same idea, four names
You will see the concept under different acronyms depending on the community. They all mean the same thing:
- reprex – common in the R and tidyverse world (from the
reprexpackage). - MCVE – Minimal, Complete, and Verifiable Example, the term Stack Overflow popularized.
- MWE – Minimal Working Example, used heavily in LaTeX and TeX circles.
- SSCCE – Short, Self-Contained, Correct (Compilable) Example, long-standing in the Java community.
If someone asks for any of these, they want the same thing: the shortest runnable snippet that shows the bug.
Before
My data pipeline keeps crashing. Here are all 600 lines of my script. It worked yesterday. What’s wrong?
Nobody can run 600 lines tied to data and credentials they do not have. There is no way to see the failure, so there is no way to help.
After
This 12-line script reproduces the crash on Python 3.12. It builds a 3-row DataFrame inline (no external file) and raises
KeyError: 'price'on the last line. I expected it to print the total. What am I missing?import pandas as pd df = pd.DataFrame({"item": ["a", "b", "c"], "cost": [1, 2, 3]}) print(df["price"].sum()) # KeyError here
Now anyone can paste it, run it, and see the exact error in seconds. The fix (the column is cost, not price) is obvious the moment the example is runnable.
How to build one
- Start fresh. Copy your failing code into a new, empty file.
- Delete everything unrelated until removing one more line would make the error disappear.
- Inline the data. Replace files, databases, and secrets with a few hardcoded rows.
- Run it yourself in a clean environment to confirm it still fails the same way.
- State expected vs. actual behavior and your versions.
When you are reporting a bug rather than asking a how-to question, drop your MRE straight into the bug report template – the “Steps to reproduce” and “Environment” fields are built for exactly this.
For the full walkthrough on technical questions, see our guide on asking good questions on Stack Overflow.