All articles
Workflow

The Habit That Killed Our 'Fixed' Bugs That Kept Coming Back

PA
PromptDock AIVerified creator — vouched by Prompt Dock
Jun 22, 2026 · 6 min read
promptdock.ai/blog

For about a year our team had a recurring ghost: a date-rollover bug in a billing function that we 'fixed' three separate times. Each fix made the symptom go away in manual testing and then quietly came back the next time the clock did something inconvenient. The third time it resurfaced — on the 1st of a month, naturally, during invoicing, while a customer was watching — I finally admitted the obvious thing I'd been avoiding. We never actually proved we'd reproduced it. We patched the line that looked guilty, ran the app once by hand, saw the right number, and called it a day. Three times. We were fixing our guess about the bug and then celebrating when the guess stopped complaining.

The reason we kept doing this is that writing a reproduction by hand is genuinely fiddly. You have to mock the clock, pick the exact cursed date, set up the fixture, and get the assertion right — and at 5pm with a customer waiting, 'it works when I click it' is a very seductive substitute for all that.

Reversing the order

The fix wasn't more willpower from me at 5pm; it was making the right thing cheap enough that I'd actually do it. I started every bug with the Write a Failing Test That Reproduces This Bug Before I Fix It prompt. I described the rollover bug, pasted the function, set the framework to 'Jest / TypeScript', and noted observed-vs-expected: 'on the last day of February, billing_period_end lands in January, expected March 1.' GPT 5.2 came back with one test — not a suite, one surgical test — that pinned the clock to 2025-02-28 with fake timers, called the function, and asserted the period end. It failed for exactly the reason I'd described, and it printed the line I now consider the whole point: 'This fails because: billing_period_end asserts 2025-03-01 but receives 2025-01-31.'

That one red test was worth more than all three previous green deploys combined, because for the first time I had proof I was looking at the actual bug. I fixed the off-by-one in the month arithmetic — we were adding a month by setting the month field, which wraps weirdly on the 31st — the test went green, and the bug has not been back since. I can say 'has not been back' with real confidence because the reproduction is sitting in CI, ready to scream the instant anyone reintroduces it.

Why GPT 5.2 and why exactly one test

I deliberately wrote this prompt in the numbered-system-rule style — 'RULE 1: produce exactly ONE failing test', 'RULE 2: it must fail today' — because GPT 5.2 follows an explicit do-this-not-that list with almost legalistic literalness. If you tell it 'one test, must be red against current code,' it gives you one red test, full stop. A vaguer model or a vaguer prompt tends to hand you a whole speculative suite, half of which passes, and now you're auditing the AI's test suite instead of fixing your bug. The 'This fails because' output line is the secret sauce: it forces the model to name the exact assertion that trips, which is how I verify in two seconds that it reproduced MY bug and not some adjacent one it found interesting.

The honest caveat

It is only ever as good as your observed-vs-expected. The very first time I tried it I was lazy and wrote 'dates are wrong sometimes,' and it correctly refused to play along — it asked me to give it a concrete case, which felt annoying for about four seconds until I realized it was right and I was the problem. A reproduction needs a specific input and a specific expected output; if you can't state those, you don't understand the bug well enough to fix it yet, and the prompt politely forces that reckoning. Garbage in, courteous request for less garbage out.

This is now literally step one of every bug ticket on our board, enforced before anyone is allowed to touch the fix. The cultural shift was bigger than the tooling: 'show me the red test' became a normal thing to say in standup, and our reopened-bug rate dropped to nearly nothing. Grab the Write a Failing Test That Reproduces This Bug Before I Fix It prompt on Prompt Dock and run it on the next bug you're tempted to patch on a hunch — and when a confusing stack trace is what's blocking you in the first place, pair it with my Explain a Stack Trace and Give Me the Minimal Safe Fix prompt to find the cause before you write the reproduction.

The prompt behind this post
Free
Write a Failing Test That Reproduces This Bug Before I Fix It

Describe a bug and paste the function and the framework. Get a single focused failing test that reproduces it deterministically — the right assertion, the right fixture, no flakiness — so you fix the bug, not your guess about the bug.

View promptGPT 5.2
Keep reading
Our Support Bot Confidently Made Up Enterprise Pricing — One System Prompt Fixed It

The agent wasn't hallucinating wildly, it was extrapolating plausibly. That's worse. Here's the exact system prompt that taught it to know its own limits.

Elite Prompting: Why Better Prompts Beat Random AI Instructions
I Designed Branded Wrapping Paper for My Candle Business for $28, Not $400

Packaging is part of my product, but a custom print run starts around $400. Print-on-demand plus one seamless-tile prompt got me there for the price of lunch.

Related prompts
Start in two minutes

Find a verified prompt for the job.