StoicBuilder

HandbookIV the PraetoriumAsking for tests

IVthe Praetorium, Direct the agent

Asking for tests

1 min readUpdated 28 November

In plain words

A test is a small piece of code that runs your feature and checks the result, so the agent can prove a fix instead of claiming it.

Where you see it

Claude Code or Cursor running npm test and printing a line like "1 failed, 12 passed" in the terminal. The best moment to ask for one is right after a bug: a test that fails now and passes after the fix stops that bug from quietly coming back.

Your promptagent
Before: the QuickBite total ignores promo codes, fix it After: First write a test: a $20 order with code SAVE10should total $18. Run it and show me it failing.Then fix the code, not the test, and show it passing.
Seeing the test fail first proves it can catch this bug.

What goes wrong

  1. The agent edits the test to match the bug

    When a test fails, an agent may change what the test expects instead of fixing the code. A changed number in a test file is worth a second look.

    expect(total).toBe(20) // was 18
  2. Tests that can't fail

    A test that only checks the page loads passes no matter what the feature does. Ask which bug each test would catch.

  3. Asking for full coverage on day one

    "Add tests for everything" gets you hundreds of shallow tests that break on every change. Start with the paths that cost money or data: login, checkout, saving.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Write a test that reproduces this bug and show me it failing. Then fix the code, not the test, and show me the same test passing.

Quick check

Sign in to earn +10 XP for it

A test fails after a fix, and the agent changes the expected total in the test from 18 to 20. What happened?

Got a prompt that touches asking for tests?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.