test-generation-patterns

test-generation-patterns is a skill for Claude Code from latestaiagents/agent-skills. It costs 52 tokens per session (2,374 once invoked), scanned A, original, MIT.

A guide for using AI to create unit, integration, and end-to-end tests. It explains test cases for normal inputs, edge cases, errors, and state changes, following common Arrange-Act-Assert structure.

In plain words
What is it for?
Use it to generate tests, improve coverage, add edge-case checks, and establish testing patterns with tools such as Vitest, Jest, or pytest.
Why use it?
It helps turn existing code or new features into test coverage that checks both expected behavior and failure cases.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the developer-toolkit plugin — 19 skills shipped together

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 skills/latestaiagents/agent-skills/test-generation-patterns
Any agent
npx skills add latestaiagents/agent-skills --skill test-generation-patterns
Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install developer-toolkit, the plugin that ships this one along with the rest of its 19 skills.

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 test-generation-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/latestaiagents/agent-skills/test-generation-patterns.svg)](https://agentmods.dev/skills/latestaiagents/agent-skills/test-generation-patterns)
Your own site
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/test-generation-patterns"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/test-generation-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,374 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.1 $0.00052 $0.02374
Opus 5 $0.00026 $0.01187
Sonnet 5 $0.00010 $0.00475
Haiku 4.5 $0.00005 $0.00237

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

Security

Grade A, and why

test-generation-patterns 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.

plugins/developer-toolkit/skills/code-intelligence/test-generation-patterns/SKILL.md · 392 lines

How it starts

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

Test Generation Patterns

Generate comprehensive tests with AI assistance following 2026 best practices.

When to Use

  • Adding tests to existing code
  • Creating test suites for new features
  • Improving test coverage
  • Setting up testing patterns for a project
  • Generating edge case tests

The Testing Pyramid (2026)

        ┌─────────┐
        │   E2E   │  Few, slow, high confidence
        ├─────────┤
        │ Integr. │  Some, medium speed
        ├─────────┤
        │  Unit   │  Many, fast, isolated
        └─────────┘

Unit Test Generation

Step 1: Identify Test Cases

For any function, test:

  1. Happy path - Normal expected input
  2. Edge cases - Boundaries, empty, null
  3. Error cases - Invalid input, failures
  4. State changes - If function has side effects

AI Prompt Template

Generate comprehensive unit tests for this function:

```[paste function]```

Include tests for:
1. Happy path with typical inputs
2. Edge cases (empty, null, boundary values)
3. Error handling
4. Any state changes or side effects

Use [Vitest/Jest/pytest] with [testing-library if applicable].
Follow AAA pattern (Arrange, Act, Assert).

Example: Testing a Utility Function

Code to test:

function parseAmount(input: string): number | null {
  if (!input || typeof input !== 'string') return null;
  const cleaned = input.replace(/[$,]/g, '').trim();
  const num = parseFloat(cleaned);
  return isNaN(num) ? null : Math.round(num * 100) / 100;
}

Generated tests:

import { describe, it, expect } from 'vitest';
import { parseAmount } from './parseAmount';

describe('parseAmount', () => {
  describe('happy path', () => {
    it('parses plain number', () => {
      expect(parseAmount('123.45')).toBe(123.45);
    });

    it('parses number with dollar sign', () => {
      expect(parseAmount('$99.99')).toBe(99.99);
    });

    it('parses number with commas', () => {
      expect(parseAmount('1,234.56')).toBe(1234.56);
    });

Read the full file on GitHub · 392 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. 6d ago First seen · 392 lines · 52 tokens per session scan A d82be0b645f8

Subscribe to this mod's changes

test-generation-patterns is a skill published in the GitHub repository latestaiagents/agent-skills (5 stars, last pushed 4mo ago), licensed MIT. It adds 52 tokens to every session and 2,374 once invoked, about $0.0003 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-31.