unit-testing

unit-testing is a skill for Claude Code, Codex from kid-sid/codex-spellbook. It costs 44 tokens per session (5,103 once invoked), scanned A, original, MIT.

Unit-testing guidance for checking individual functions or modules in isolation. It also explains test structure, dependency mocking, test-driven development (writing tests before code), and coverage.

In plain words
What is it for?
Use it to add unit tests, mock external services, choose between unit and integration tests, organise test cases, improve coverage, or practise TDD.
Why use it?
It helps developers write tests that are focused, understandable, and less likely to fail for unrelated reasons.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to add unit tests, mock external services, choose between unit and integration tests, organise test cases, improve coverage, or practise TDD.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kid-sid/codex-spellbook/unit-testing
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 kid-sid/codex-spellbook --skill unit-testing
Clone the repo
git clone --depth 1 https://github.com/kid-sid/codex-spellbook

Made for: Claude Code, Codex.

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-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/kid-sid/codex-spellbook/unit-testing/github.svg)](https://agentmods.dev/skills/kid-sid/codex-spellbook/unit-testing)
Your own site
<a href="https://agentmods.dev/skills/kid-sid/codex-spellbook/unit-testing"><img src="https://agentmods.dev/badge/skills/kid-sid/codex-spellbook/unit-testing/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-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/kid-sid/codex-spellbook/unit-testing"><img src="https://agentmods.dev/badge/skills/kid-sid/codex-spellbook/unit-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,103 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.00044 $0.05103
Opus 5 $0.00022 $0.02551
Sonnet 5 $0.00009 $0.01021
Haiku 4.5 $0.00004 $0.00510

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

Security

Grade A, and why

unit-testing 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.

skills/unit-testing/SKILL.md · 678 lines

How it starts

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

Unit Testing

Structured guidance for writing reliable, maintainable unit tests — covering test anatomy, mocking strategies, parameterized tests, TDD workflow, coverage strategy, and test organization across Python, TypeScript, and Go.

When to Activate

  • Writing tests for a function, class, or module
  • Setting up a test framework for a new project
  • Mocking or stubbing external dependencies in tests
  • Deciding what to unit test vs integration test
  • Practising TDD (test-driven development) on a new feature
  • Achieving or enforcing a coverage target
  • Debugging a flaky or unclear test failure

Test Anatomy

Arrange / Act / Assert (AAA)

Every test has three distinct phases:

  • Arrange — set up the inputs, dependencies, and state needed for the test
  • Act — call the unit under test (exactly once)
  • Assert — verify the outcome matches expectations

One assertion per logical concern means each test validates one observable behaviour. Multiple assert statements are fine as long as they all verify the same thing (e.g., both fields of a returned object).

Test Naming

Language Convention Example
Python test_<unit>_<scenario>_<expected_result> test_divide_by_zero_raises_value_error
TypeScript describe('Unit') / it('should ...') it('should throw when dividing by zero')
Go TestXxx with t.Run("SubtestName", ...) TestDivide/ByZero

Well-Structured Test Examples

# Python — pytest
def test_calculate_total_with_discount_returns_reduced_price():
    # Arrange
    cart = Cart(items=[Item(price=100)])
    discount = PercentageDiscount(rate=0.10)

    # Act
    total = calculate_total(cart, discount)

    # Assert
    assert total == 90.0
// TypeScript — Jest / Vitest
describe('calculateTotal', () => {
  it('should return reduced price when discount is applied', () => {
    // Arrange
    const cart = { items: [{ price: 100 }] };
    const discount = { rate: 0.10 };

    // Act
    const total = calculateTotal(cart, discount);

    // Assert
    expect(total).toBe(90.0);
  });
});

Read the full file on GitHub · 678 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 · 678 lines · 44 tokens per session scan A 35ab5012fb73

Subscribe to this mod's changes

unit-testing is a skill published in the GitHub repository kid-sid/codex-spellbook (21 stars, last pushed 4mo ago), licensed MIT. It adds 44 tokens to every session and 5,103 once invoked, about $0.0002 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.