agentleFS
srikanth-manivannansrikanth-manivannan/claude-agent-factory/skills/testing/unit-test-generator/SKILL.md

unit-test-generator

Skill1 starsChanged 5 months agoMITView on GitHub

Use this to generate thorough unit tests for a unit of code, covering happy, edge, and failure cases.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write isolated, deterministic tests: No reliance on time, order, network, or shared state.

    line 53
  2. Distinctive:

    Assert behavior, not implementation: Test observable outcomes so tests survive refactors.

    line 55
  3. Distinctive:

    Don't change the unit under test: If the code is untestable, report *why* and recommend a refactor rather than silently editing it.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 6 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

Unit Test Generator

Use this to generate thorough unit tests for a unit of code, covering happy, edge, and failure cases.

Tech profile — Technology: any · Language: any · Stack: any test framework · Toolchain: any · Domain: testing (Adapts to the target language/framework via the tech profile; the method is universal.)

When to use this skill

  • Adding tests to new or untested code (a function, class, or module).
  • Backfilling coverage before a refactor (refactor-module workflow).
  • Establishing a regression test for a bug (fix-bug workflow).

When NOT to use this skill

  • End-to-end / integration flows — use testing/e2e-test-builder / integration-test-builder.
  • Assessing existing test quality — use testing/coverage-gap-finder or mutation testing.

Prerequisites

  • The unit under test (code or a precise behavior spec).
  • The target test framework (detected from the project, or stated).

Inputs

InputRequiredDescription
unityesThe function/class/module to test
frameworknoTest framework; inferred from the project if omitted
behavior_specnoIntended behavior, if not obvious from the code

Instructions

  1. Understand the contract. Identify the unit's inputs, outputs, side effects, and error conditions. If behavior is ambiguous, ask rather than assume.
  2. Enumerate cases across three mandatory classes (/standards/testing.md):
    • Happy path — typical valid inputs → expected outputs.
    • Edge / boundary — empty, max, min, null, unusual-but-valid inputs.
    • Failure / refusal — invalid input handled gracefully (no silent failure).
  3. Detect the framework + conventions. Match the project's existing test style, naming, and assertion library. Don't introduce a new framework.
  4. Write isolated, deterministic tests. No reliance on time, order, network, or shared state; stub/mock external dependencies; use generated, non-real data.
  5. Assert behavior, not implementation. Test observable outcomes so tests survive refactors.
  6. Name tests by intent. it("returns 0 for an empty list"), not test1.
  7. Report coverage intent. State which branches/cases are and are not covered, and why any are intentionally omitted.

Output

A test file (or files) in the project's framework: organized, named-by-intent tests covering happy/edge/failure classes, with mocks for external dependencies and a short note on coverage intent.

Constraints & safety

  • No real PII/secrets in fixtures (/standards/security.md).
  • No flaky tests — determinism is non-negotiable.
  • Don't change the unit under test. If the code is untestable, report why and recommend a refactor rather than silently editing it.

Examples

Minimal below; full examples in EXAMPLES.md.

Given: a divide(a, b) function. Produces: tests for normal division (happy), division by zero (failure), and large / negative / zero operands (edge), each named by intent and isolated.

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.