Free to read · no account needed

16 min · code

Minimal repro first (then ask for help)

Goal: Shrink a bug to the smallest snippet that still fails—before you ask the model—so answers stay focused and safer to paste.

Best for: Beginners drowning in large files; anyone about to paste a whole repo into chat.

A minimal reproduction is the shortest code + steps that still show the bug. It protects secrets (less surface), helps you learn, and stops the model from “fixing” unrelated code.

A minimal repro is the smallest code that still shows the bug. Models patch faster—and you learn whether the bug is real—when the file is tiny.

Why beginners skip this

Dumping the whole repo into chat feels thorough until answers wander. A minimal failing slice focuses the model and proves you understand the bug.

Habit this week (Asia/Shanghai): shrink one real bug to the smallest failing file before you ask for a fix—date the repro path.

Step 1 — Shrink checklist

Do this step with a real artifact open—not from memory.

Before asking:
1) Remove unrelated files/features until the bug remains
2) Hardcode one failing input
3) Note environment (language version, browser/node)
4) Redact secrets
Then paste ≤30 lines if possible.

Step 2 — Ask with repro

Example

Filled prompt

I have a 900-line component with a double-submit bug on slow networks. Ask the model to propose a minimal repro plan (new tiny file or reduce steps) before any patch. Stack: React. Do not invent APIs.

What good output looks like

  • Repro plan lists the smallest file/test before any patch
  • Scope stays tiny—one failing path, not the monorepo
  • No invented APIs or files you did not mention
  • Steps you can run locally to confirm the failure still shows
  • Patch explicitly deferred until the repro is agreed

Step 3 — If you cannot shrink

Say what you tried. Ask what to delete next—not for a speculative full rewrite.


Scene: help that actually helps

Instead of pasting 2,000 lines, you send 18 lines and an Expected/Actual pair. The explanation names the off-by-one. You understand it before any patch.

Template you can paste forever

Keep this card in your notes. Fill it before every coding ask. If you cannot fill Expected/Actual, you are not ready to ask yet.

Language/runtime:
Expected:
Actual:
Steps:
Snippet (≤30 lines, secrets redacted):
Ask: Step A explain only.
Example

Filled prompt

Bug needs Docker + 3 services in the report.
Shrink ask: single failing unit test name + 8-line setup. Refuse monorepo paste.

What good output looks like

  • Explains why the full-app import is not minimal
  • Lists five concrete cuts (drop UI shell, stub network, etc.)
  • Still withholds patch code in this critique turn
  • Each cut keeps the failure still observable when you re-run
  • You end with a one-file or one-test target

Save this card

Card: shrink to smallest failing slice → then ask. Whole-repo paste is a red flag.

1. What I shipped: ___ 2. What I refused: ___ 3. What I will never-do again: ___ (date: Asia/Shanghai)

  • [ ] Tools/writes paused
  • [ ] Refuse-line dated
  • [ ] Artifact path saved
  • [ ] Next link chosen (or stop)

Before you start

Open the failing test, diff, or ticket for “Shrink a bug to the smallest snippet that.” Keep secrets out of the chat. Have the file path you will name. Guide: code-minimal-repro-first. If you only have a blank practice box, stop and fetch the real job first.

  • Goal in one line: ___
  • Allowed tools: ___
  • Forbidden: ___
  • Human approve needed for: ___

How to use this week

This week in code: shrink one bug to the smallest failing slice before asking for a fix. No whole-repo dump on a live artifact—not a blank demo. Write one refuse-line and date the note (Asia/Shanghai). If you only skimmed code-minimal-repro-first, put 25 minutes on the calendar and redo once.

Calendar block (code-minimal-repro-first, optional): 25 minutes once this week—open the guide, run Practice once, date the refuse-line, then stop. No binge-reading counts as practice.

Time-box the shrink

Twenty minutes to minimal. If still huge, cut again before any patch.

Non-minimal is a smell

If your “repro” still boots the full app or imports half the tree, it is a demo, not a repro. Ask the model to critique why it is not minimal and list five concrete cuts—still no patch in that turn.

Example

Filled prompt

Bug spans API+worker+UI in the report.
Shrink ask: one failing unit test name + 8-line setup. Refuse three-service paste.

What good output looks like

  • Names files/functions you provided for “Shrink a bug to the smallest snippet that still fa”
  • No secrets in logs; no mystery whole-repo rewrite
  • Explain-before-patch or minimal repro respected
  • Pass/fail: you can restate the change in 3 bullets

Red flag

Merging a patch you cannot reproduce; whole-monorepo paste instead of a failing slice—shrink first.

Pitfalls

PitfallFix
Pasting the monorepoShrink first
Secrets in reproPlaceholders
Skipping explain-then-changeA then B

Example

Filled prompt

Temptation: skip the habit for code-minimal-repro-first to “save five minutes.”
Job still: Shrink a bug to the smallest snippet that
Do the smallest correct pass: Done visible · one checkable artifact · Unknowns labeled [?].
Boundaries: draft only; no silent send; no invented metrics.
Return: the artifact + the refuse-line you said aloud.

What good output looks like

  • Names the shortcut you refused (specific to code-minimal-repro-first)
  • Still delivers a checkable artifact for “Minimal repro first”
  • Unknowns labeled; draft-only respected
  • Pass/fail: refuse-line written and dated (code-minimal-repro-first #4)

Practice now

Live card: one real code change under “Minimal repro first (then ask for help)”—diff-only + test note (Asia/Shanghai).

Today: take one real bug. Cut imports and setup until one file (or one test) still fails. Ask the model for a repro plan before a patch. Apply cuts it suggests only if you can still see the failure.

Today card (copy) — code-minimal-repro-first: 1. Artifact I will produce: ___ 2. Pass/fail check: ___ 3. Refuse-line if tempted to skip verify/send: ___ (date: Asia/Shanghai) 4. One never-do from this guide: ___

  • [ ] Artifact path written
  • [ ] Refuse example would say "yes"
  • [ ] Dated Asia/Shanghai

One sentence takeaway

Shrink to the smallest failing slice before you ask for a fix. This week: one dated minimal-repro path (Asia/Shanghai).

Next

Explain then change · Tests first · Code review checklist · Coding agent boundaries · Code path

Pair with today: open the first Next link (code-explain-then-change) only after you dated a refuse-line for this guide (Asia/Shanghai).

← Back to home · Learn · Tools · Compare · Start