test

A command that creates tests for specified code, including unit tests, integration tests, and edge-case tests. It detects common test tools such as Vitest, Jest, Pytest, and Go testing.

In plain words
What is it for?
Use it with a file, function, or recently changed code to generate tests, optionally focused on unit tests, integration tests, edge cases, or coverage.
Why use it?
It saves time identifying what should be tested and which test style the project already uses. It covers normal inputs, boundaries, errors, side effects, and dependencies.

Command

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.

agentmods
npx agentmods add commands/thedecipherist/claude-code-mastery/test
Clone the repo
git clone --depth 1 https://github.com/TheDecipherist/claude-code-mastery
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 654 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00014 $0.00654
Opus 5 $0.00007 $0.00327
Sonnet 5 $0.00003 $0.00131
Haiku 4.5 $0.00001 $0.00065

Measured 2d ago against content hash 98d947e5c479, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test 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 2d 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.

commands/test.md · 119 lines

How it starts

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

Generate Tests

Generate comprehensive tests for the specified code.

Input

The user will provide one of:

  • A file path: /test src/utils/validators.ts
  • A function name: /test validateEmail
  • Just /test — generate tests for recently changed files

Optional flags via $ARGUMENTS:

  • --unit — unit tests only (default)
  • --integration — integration tests
  • --edge — focus on edge cases
  • --coverage — aim for high coverage

Process

1. Detect Test Framework

Check the project for:

  • vitest.config.* → Vitest
  • jest.config.* → Jest
  • *.test.ts patterns → Match existing style
  • pytest.ini or conftest.py → Pytest
  • go.mod → Go testing

If unclear, ask the user.

2. Analyze the Code

Identify:

  • Public functions/methods to test
  • Input types and valid ranges
  • Expected outputs
  • Error conditions
  • Side effects (mocking needed?)
  • Dependencies (what to mock?)

3. Generate Test Cases

For each function, create tests for:

Happy Path

  • Normal input → expected output
  • Common use cases

Edge Cases

  • Empty input ([], "", null, undefined)
  • Boundary values (0, -1, MAX_INT)
  • Single element collections
  • Very large inputs

Error Cases

  • Invalid input types
  • Out of range values
  • Missing required fields
  • Network/IO failures (if applicable)

4. Test Structure

Follow AAA pattern:

describe('functionName', () => {
  it('should return X when given Y', () => {
    // Arrange
    const input = { ... };

    // Act
    const result = functionName(input);

    // Assert
    expect(result).toEqual(expected);
  });
});

5. Naming Convention

Test names should be readable as sentences:

  • should return empty array when input is empty
  • should throw ValidationError when email is invalid
  • should call API once per unique user

NOT:

  • test1
  • works
  • validateEmail test

Output

  1. Create test file at conventional location:
    • src/foo.tssrc/foo.test.ts or __tests__/foo.test.ts
    • foo.pytest_foo.py or tests/test_foo.py

Read the full file on GitHub · 119 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. 2d ago First seen · 119 lines · 14 tokens per session scan A 98d947e5c479

Subscribe to this mod's changes

test is a command published in the GitHub repository TheDecipherist/claude-code-mastery (545 stars, last pushed 3mo ago), licensed MIT. It adds 14 tokens to every session and 654 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-08-30.