Write tests for existing code
Add tests that pin down current behaviour, following the project’s test conventions.
Free to use and change. Filling in and copying happen in your browser.
How it is built
- Goal: Add tests for {{target}}.
- Context: Follow the conventions of the existing tests in {{test_location}}.
- Task: Cover the main behaviour, edge cases ({{edge_cases}}) and error handling. Test behaviour through public functions, not private details.
- Constraints: Do not change the code under test. If you find a bug, write a failing test for it, mark it as expected to fail, and report it.
- Done when: {{test_command}} passes and each new test fails if the behaviour it describes breaks.
Tips
- Ask the agent to show each new test failing against a deliberately broken copy of the code, then revert it.
Adapting it? Check your version with the prompt checker.
More coding-agent templates
- Bug fix brief for a coding agent
Find the root cause of a bug, fix it minimally and prove it with a regression test.
- Plan a feature before coding
Get an implementation plan with files, steps and tests to review before the agent writes code.
- Review a change before merging
A focused review of a diff for bugs, security and missing tests, ranked by severity.
- Refactor without changing behaviour
Simplify code in small, safe steps while keeping the tests green.