Skill library / Cursor

Unit Test Writer skill for Cursor

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.

Customise this skill free →

What it's good for

How the skill works

  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

Built-in rules

Example

You: “Write tests for parsePrice()”
Result: 9 Vitest cases including currency symbols, commas, negatives, empty strings and NaN input.

SKILL.md template

Save as unit-test-writer/SKILL.md.

---
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 in Cursor

Put the folder in .cursor/skills/ (or .agents/skills/), or copy the included .mdc file into .cursor/rules/.

Pro tip

Scope the rule with globs like **/*.test.ts so Cursor applies it when test files are open.

Want it tailored to how you work?

Answer a few questions and get a customised version with examples, a Cursor rule and GPT/Gem instructions, emailed free.

Make my version →

FAQ

How do I install the unit test writer skill 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 this template, or generate a customised version free (5 per day, no login).

Does it work on other platforms?

Yes. The SKILL.md follows the open Agent Skills standard, and every generated package also includes a Cursor rule and ChatGPT/Gemini instructions.

Related skills