Test-First Agent Workflows
A failing test is the cleanest spec you can give an agent.
Use the right surface
After this you can pick Agent plus test runner for the right job and define done.
Done means Agent works against an executable spec instead of a prose wish.

Use planning when a change needs research, files, checks and risk called out before edits begin.
Use Agent plus test runner when the task has behavior that can be captured in an automated check. Keep the boundary narrow.
Start small. Name the job, attach the context that proves the point and decide what evidence would make the output trustworthy.
Read the loop before touching the controls. The first beat frames the work, the second uses Cursor, the third checks the result and the fourth leaves a handoff someone else can inspect.
Interactive diagram. Tab through its regions; each focused region shows its detail in the panel below.
Run this loop in a real repo.
- Entry point
- Agent with test, lint or build commands
- Source
- Agent best practices and working-with-agents guidance
Use the source as the product reference.
Ask Cursor for an output you can inspect.
If the output cannot be checked, narrow the task before you continue.
A good run leaves a file, setting, screenshot, command result or written claim you can verify.
Takeaway. Done means Agent works against an executable spec instead of a prose wish.
Self-check
QWhen should you reach for Agent plus test runner?
Run it
After this you can do the task with clear scope and one proof point.
Treat this as a short practice loop, not a product tour. The task should be small enough that you can inspect the result without trusting the summary.
- 1Ask for the smallest failing test or reproduction first.
- 2Confirm it fails for the right reason before implementation.
- 3Tell Agent not to weaken or delete the test while fixing.
- 4Run the target test and a broader check after the fix.
The exercise is complete only when the proof matches the requested outcome. If the proof is weak, reduce the scope or fix the context instead of adding more instructions.
Keep the task small enough to review.
The implementation changed, not the assertion contract.
Takeaway. Stop when you have proof: The test fails before the fix and passes after..
Self-check
QWhich habit makes this workflow safe to use on a real project?
Check it
After this you can find the first failed check before changing tools.
Verification decides the next move.
Interactive diagram. Tab through its regions; each focused region shows its detail in the panel below.
Pick a row to see what to look for.
Use the first failure signal as the next prompt. Broad retries usually make the run noisier; a narrow retry gives Cursor a concrete repair target.
No proof means more checking.
Use a real repo or admin setting. Save the prompt, context and proof.
Takeaway. If it fails, find the first failed check.
Self-check
QThe workflow failed. What is the best first move?