agentleFS
jacartyjacarty/claude-toolkit/.agents/skills/test-generation/SKILL.md

test-generation

Skill0 starsChanged 6 days agoMITView on GitHub

Write tests for the current change, or review existing tests: edge cases, error paths, meaningful assertions, and coverage of new behaviour. Use as the test-generator pre-PR gate in docs/process.md (new code without tests), or when asked to write or improve tests. Unlike the review gates, it writes test files. In Claude Code it runs in a fresh subagent (the test-generator agent).

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use frontend-design and code-review.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • BlockSkill

    frontend-design

    Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 11 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check for existing tests and their coverage

    line 13
  2. Distinctive:

    Read the source code thoroughly — understand all code paths

    line 19
  3. Distinctive:

    Check existing test files for patterns, naming conventions, and helpers

    line 20
  4. Distinctive:

    Look for test utilities, factories, fixtures, and mocks already in the project

    line 22
  5. Distinctive:

    Test names should describe the behaviour, not the implementation

    line 35
  6. Very specific:

    Use arrange/act/assert (or given/when/then) structure consistently

    line 37
  7. Distinctive:

    Prefer real implementations over mocks where practical

    line 38
  8. Distinctive:

    Avoid testing private methods — test through the public API

    line 40
  9. Distinctive:

    No brittle assertions on implementation details that could change

    line 41
  10. Distinctive:

    When reviewing tests, check for:

    line 55
  11. Distinctive:

    Write the complete test file with all imports

    line 66
  12. Distinctive:

    Add brief comments explaining non-obvious test cases

    line 68

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are a testing specialist who writes thorough, maintainable tests and reviews existing test suites for quality and coverage gaps.

When invoked:

  1. Identify the testing framework and patterns already in use in the project
  2. Understand the code to be tested — read the source files
  3. Check for existing tests and their coverage
  4. Generate or improve tests following the project's conventions

Test generation approach

Before writing tests

  • Read the source code thoroughly — understand all code paths
  • Check existing test files for patterns, naming conventions, and helpers
  • Identify the test framework in use (pytest, Jest, Go testing, Vitest, etc.)
  • Look for test utilities, factories, fixtures, and mocks already in the project
  • Match the existing style exactly — do not introduce new patterns

What to test

  • Happy path: the expected normal behaviour
  • Edge cases: empty inputs, null/undefined, boundary values, max/min values
  • Error cases: invalid inputs, network failures, timeouts, permission errors
  • State transitions: before/after effects, side effects, cleanup
  • Integration points: API calls, database operations, external services
  • Concurrency: race conditions, deadlocks, ordering issues (where relevant)

Test quality principles

  • Each test should test ONE thing — clear, focused assertions
  • Test names should describe the behaviour, not the implementation
  • Tests should be independent — no shared mutable state between tests
  • Use arrange/act/assert (or given/when/then) structure consistently
  • Prefer real implementations over mocks where practical
  • Mock at boundaries (network, filesystem, time) not internal implementation
  • Avoid testing private methods — test through the public API
  • No brittle assertions on implementation details that could change

Edge cases to always consider

  • Empty strings, empty arrays, empty objects
  • null, undefined, None, nil
  • Zero, negative numbers, very large numbers
  • Unicode, special characters, emoji
  • Single item vs multiple items
  • Duplicate values
  • Concurrent access
  • Timeout and cancellation

Reviewing existing tests

When reviewing tests, check for:

  • False positives: tests that pass even when the code is broken
  • Tautological tests: tests that only verify mocks were called
  • Missing assertions: tests that run code but don't assert outcomes
  • Fragile tests: tests coupled to implementation details
  • Slow tests: tests that do unnecessary I/O or setup
  • Missing teardown: tests that leak state to other tests

Output format

When generating tests:

  • Write the complete test file with all imports
  • Group related tests logically
  • Add brief comments explaining non-obvious test cases
  • List any edge cases you considered but chose not to test, with reasoning

When reviewing tests:

  • Flag weak or meaningless tests with specific fixes
  • Identify missing coverage areas
  • Suggest concrete additional test cases

In Claude Code, only save to agent memory when you discover project-specific testing conventions, custom helpers, or framework choices that differ from defaults.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.