unit-test-writer

unit-test-writer is a skill for Claude Code from matteocervelli/llms. It costs 27 tokens per session (3,935 once invoked), scanned A, original, MIT.

A guide for writing unit tests, which check small pieces of code separately from the rest of an application. It covers test structure, mocking, fixtures, and coverage.

In plain words
What is it for?
Creating tests for new code, improving existing coverage, and organizing tests with the Arrange-Act-Assert pattern across programming languages.
Why use it?
It gives developers a consistent way to check code behavior and find gaps in their tests. TDD, or test-driven development, means writing tests before the code they describe.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Creating tests for new code, improving existing coverage, and organizing tests with the Arrange-Act-Assert pattern across programming languages.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/matteocervelli/llms/unit-test-writer
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 matteocervelli/llms --skill unit-test-writer
Clone the repo
git clone --depth 1 https://github.com/matteocervelli/llms

Made for: Claude Code.

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 unit-test-writer

README.md
[![agentmods](https://agentmods.dev/badge/skills/matteocervelli/llms/unit-test-writer/github.svg)](https://agentmods.dev/skills/matteocervelli/llms/unit-test-writer)
Your own site
<a href="https://agentmods.dev/skills/matteocervelli/llms/unit-test-writer"><img src="https://agentmods.dev/badge/skills/matteocervelli/llms/unit-test-writer/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 unit-test-writer

Your own site · 80×15
<a href="https://agentmods.dev/skills/matteocervelli/llms/unit-test-writer"><img src="https://agentmods.dev/badge/skills/matteocervelli/llms/unit-test-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,935 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.00027 $0.03935
Opus 5 $0.00014 $0.01968
Sonnet 5 $0.00005 $0.00787
Haiku 4.5 $0.00003 $0.00394

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

Security

Grade A, and why

unit-test-writer 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 5d 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.

.archive/claude-v1/skills/unit-test-writer/SKILL.md · 747 lines

How it starts

The opening of the file, as written. The whole thing — 747 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Unit Test Writer Skill

Purpose

This skill provides systematic guidance for writing comprehensive, maintainable unit tests that achieve high coverage and follow best practices across multiple programming languages.

When to Use

  • Need to create unit tests for new code
  • Want to improve existing test coverage
  • Need guidance on test structure and organization
  • Writing tests following TDD methodology
  • Ensuring proper mocking and fixtures

Unit Testing Principles

Test Structure: Arrange-Act-Assert (AAA)

Every test should follow this clear pattern:

def test_feature_condition_expected():
    """Clear test description."""
    # Arrange: Setup test data and dependencies
    input_data = create_test_data()
    mock_dependency = setup_mock()

    # Act: Execute the code under test
    result = function_under_test(input_data, mock_dependency)

    # Assert: Verify expected outcomes
    assert result.status == "success"
    mock_dependency.method.assert_called_once()

Test Naming Conventions

Python (pytest):

  • Pattern: test_<function>_<condition>_<expected_result>
  • File: test_<source_file_name>.py
  • Examples:
    • test_create_user_valid_data_returns_user
    • test_validate_email_invalid_format_raises_error
    • test_process_data_empty_input_returns_empty_list

JavaScript/TypeScript (Jest):

  • Pattern: should <expected behavior> when <condition>
  • File: <source_file_name>.test.ts or <source_file_name>.test.js
  • Examples:
    • should return user when valid data provided
    • should throw error when email format is invalid
    • should return empty list when input is empty

Coverage Goals

  • Overall coverage: ≥ 80%
  • Critical business logic: ≥ 90%
  • Error handling paths: 100%
  • Utility functions: ≥ 85%

Unit Testing Workflow

1. Analyze Code to Test

Read and understand the source:

# Read the source file
cat src/module/feature.py

# Identify:
# - Functions and classes to test
# - Dependencies and external calls
# - Error conditions and edge cases
# - Input validation requirements

Read the full file on GitHub · 747 lines

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. 5d ago First seen · 747 lines · 27 tokens per session scan A 27d2c87ff54a

Subscribe to this mod's changes

unit-test-writer is a skill published in the GitHub repository matteocervelli/llms (25 stars, last pushed 3mo ago), licensed MIT. It adds 27 tokens to every session and 3,935 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.