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 shipped in a Cursor plugin.

Part of the cursor-commands plugin — 44 skills, 43 commands shipped together

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.

Or install cursor-commands, the plugin that ships this one along with the rest of its 44 skills, 43 commands.

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.5 $0.00004 $0.00165
Sonnet 5.5 $0.00002 $0.00083
Haiku 4.5 $0.00001 $0.00041

Measured 1mo ago against content hash 7b63769b9c64, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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. 1mo 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 5d ago), licensed MIT. It adds 11 tokens to every session and 413 once invoked, about $0.0000 per session on Opus 5.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

iterate-agent-harness

Turn an agent failure (premature stop, false completion, gamed check, missed file) into a rule, hook, or CI guard with a regression test. Use when "the agent stopped early again", "it gamed the test", or "add a guard so this doesn't recur".

kensaurus/cursor-kenji · 64 tokens

review-coverage

Use when the user asks for a coverage review, test coverage analysis, coverage gap analysis, uncovered code review, or wants to know what new/changed Go code is missing tests. Runs go test -coverprofile against the resolved scope and reports uncovered functions in changed Go files, grouped by package, with severity…

paultyng/skill-issue · 73 tokens

testing

Use when the user writes or runs tests, sets up the Test Runner, needs Edit Mode or Play Mode tests, test assembly definitions, mocks, or async tests, or runs tests in CI. Covers Unity Test Framework, NUnit assertions, UnityTest coroutines, async Task tests, and test asmdef setup.

TMHSDigital/Unity-Developer-Tools · 62 tokens

web3-testing

Test smart contracts comprehensively using Hardhat and Foundry with unit tests, integration tests, and mainnet forking. Use when testing Solidity contracts, setting up blockchain test suites, or validating DeFi protocols.

wshobson/agents · 46 tokens

temporal-python-testing

Test Temporal workflows with pytest, time-skipping, and mocking strategies. Covers unit testing, integration testing, replay testing, and local development setup. Use when implementing Temporal workflow tests or debugging test failures.

wshobson/agents · 45 tokens

data-quality-frameworks

Implement data quality validation with Great Expectations, dbt tests, and data contracts. Use when building data quality pipelines, implementing validation rules, or establishing data contracts.

wshobson/agents · 37 tokens