write-unit-tests

write-unit-tests is a skill for Claude Code, Cursor from emaraschio/cursor-commands. It costs 11 tokens per session (413 once invoked), scanned A, original, MIT.

A guide for writing meaningful unit tests for existing code. It covers public functions, normal and negative cases, errors, edge conditions, test isolation, and project conventions.

In plain words
What is it for?
Use it when adding tests for current code, choosing test cases, arranging mocks, or following an Arrange-Act-Assert structure.
Why use it?
It helps build a dependable test suite instead of checking only the most obvious successful case.

Skill for Claude CodeCursor

Written for Claude Code and Cursor: user-invocable in frontmatter, but also installed under .cursor/.

Good fit Use it when adding tests for current code, choosing test cases, arranging mocks, or following an Arrange-Act-Assert structure.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/emaraschio/cursor-commands/write-unit-tests
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add emaraschio/cursor-commands --skill write-unit-tests
Clone the repo
git clone --depth 1 https://github.com/emaraschio/cursor-commands

Made for: Claude Code, Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for write-unit-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/emaraschio/cursor-commands/write-unit-tests/github.svg)](https://agentmods.dev/skills/emaraschio/cursor-commands/write-unit-tests)
Your own site
<a href="https://agentmods.dev/skills/emaraschio/cursor-commands/write-unit-tests"><img src="https://agentmods.dev/badge/skills/emaraschio/cursor-commands/write-unit-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for write-unit-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/emaraschio/cursor-commands/write-unit-tests"><img src="https://agentmods.dev/badge/skills/emaraschio/cursor-commands/write-unit-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 413 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00011 $0.00413
Opus 5 $0.00005 $0.00206
Sonnet 5 $0.00002 $0.00083
Haiku 4.5 $0.00001 $0.00041

Measured 6d ago against content hash 7b63769b9c64, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

write-unit-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/skill-contracts/write-unit-tests/SKILL.md · 52 lines

What it actually says

Overview

Create comprehensive unit tests for the current code and generate the test file with proper imports and setup according to the project's testing conventions.

Steps

  1. Test Coverage
    • Test all public methods and functions
    • Cover edge cases and error conditions
    • Test both positive and negative scenarios
    • Aim for high code coverage
  2. Test Structure
    • Use the project's testing framework conventions
    • Write clear, descriptive test names
    • Follow the Arrange-Act-Assert pattern
    • Group related tests logically
  3. Test Cases to Include
    • Happy path scenarios
    • Edge cases and boundary conditions
    • Error handling and exception cases
    • Mock external dependencies appropriately
  4. Test Quality
    • Make tests independent and isolated
    • Ensure tests are deterministic and repeatable
    • Keep tests simple and focused on one thing
    • Add helpful assertion messages

Write Unit Tests Checklist

  • Tested all public methods and functions
  • Covered edge cases and error conditions
  • Tested both positive and negative scenarios
  • Used the project's testing framework conventions
  • Written clear, descriptive test names
  • Followed the Arrange-Act-Assert pattern
  • Included happy path scenarios
  • Included edge cases and boundary conditions
  • Mocked external dependencies appropriately
  • Made tests independent and isolated
  • Ensured tests are deterministic and repeatable

Guardrails

  • Test observable behavior and public contracts, not implementation trivia.
  • Mock only external boundaries (network, clock, filesystem); use real objects for the rest.
  • Do not commit, push, merge, or run destructive commands without explicit user consent.
  • Do not print, log, or commit secrets or credentials found in the code or test fixtures; flag any exposure instead.
Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 52 lines · 11 tokens per session scan A 7b63769b9c64

Subscribe to this mod's changes

write-unit-tests is a skill published in the GitHub repository emaraschio/cursor-commands (9 stars, last pushed 1mo ago), licensed MIT. It adds 11 tokens to every session and 413 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

go-testing

Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.

Gentleman-Programming/gentle-ai · 26 tokens

testing

To write thorough, isolated, idempotent tests — 80%+ coverage, external-only mocking, scenario-driven.

griddynamics/rosetta · 26 tokens

Add executable smoke tests for shell scripts and CLIs before refactors ship

Use Bats-core when an agent needs to turn fragile shell scripts or command-line workflows into something it can verify repeatedly after edits. The agent writes focused Bash tests for success paths, failure paths, and output contracts, then runs them locally or in CI before a refactor, release, or incident fix goes out.

agentskillexchange/skills · 78 tokens

test-writer

Writes tests for code that already exists: behaviour over implementation, arrange-act-assert structure, mocks only at real boundaries, and no time- or order-dependent flakiness. Use when asked to add tests, close a coverage gap on a function, component, or endpoint, or write a regression test for a bug just fixed. Not…

Ozzeron/prompt-pack · 95 tokens

iterate-agent-harness

Turn an agent failure—premature stop, false completion, gamed check, missed file, broken handoff—into a durable rule/skill/hook/CI guard plus regression test. Use when "the agent stopped early again", "it gamed the test", or "add a guard so this doesn't recur". App bugs → workflow-fix-and-ship.

kensaurus/cursor-kenji · 79 tokens

dev-testing

A testing guide that defines when to use unit, integration, API, and end-to-end tests. Unit tests check small pieces of code, while end-to-end tests check a full user flow.

devcodex-labs/devcodex · 27 tokens