Skill library / For developers
Cursor skill for writing unit tests
For developers who want better test coverage without writing every case by hand.
Tests are the first thing skipped under deadline. This skill makes Cursor write meaningful tests in your framework and style, focusing on edge cases rather than restating the implementation.
Use this skill nowSee the SKILL.md
Answer up to 4 quick questions, add your email, and get a version written around you, ready to paste into Cursor. Free, no account needed.
What it's good for
- Backfilling tests on legacy code
- TDD: writing tests before an implementation
- Raising coverage before a refactor
The SKILL.md file
Save as unit-test-writer/SKILL.md. It follows the open Agent Skills format.
---
name: unit-test-writer
description: "Writes unit tests for selected functions covering happy paths, edge cases and error handling, using the project's existing test framework. Use when the user asks to add tests, improve coverage, or test a function."
---
# Unit Test Writer
## Workflow
1. Detect the framework (Jest, Vitest, pytest, Go test) from config
2. List behaviours: happy path, boundaries, invalid input, errors
3. Write one focused test per behaviour with descriptive names
4. Mock only external I/O, never the unit under test
5. Run the tests and fix failures caused by the test itself
## Rules
- Don't change production code to make tests pass without asking
- Avoid snapshot tests for logic
- Each test should fail for exactly one reason
How to install it in Cursor
Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.
Example
Illustrative example. This shows the kind of request and result to expect. It is not a real conversation, and your result will depend on what you give it.
You ask: “Write tests for parsePrice()”
What you get back: 9 Vitest cases including currency symbols, commas, negatives, empty strings and NaN input.
Pro tip
Scope the rule with globs like **/*.test.ts so Cursor applies it when test files are open.
Make your own version
This prompt is a good start, but it doesn't know you. Answer a few quick questions about your situation and how you like things done, and we'll write a version that does. It appears on screen with a Copy button and setup steps for your AI, and we email you a copy. Free, up to 10 a month.
Make my own version freeQuestions
Which test framework does it use?
The one your project already uses, such as Jest, Vitest or pytest.
Does it cover edge cases?
Yes. Happy paths, edge cases and error handling are all part of its checklist.
How do I install it in Cursor?
Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.
Is it free?
Yes. You can copy the prompt on this page for free, with no sign-up. If you want a version written around you, our generator is free too (up to 10 a month, no account needed): answer a few questions and we email you a copy.