agentleFS
CreativeActtechCreativeActtech/llm-skills/skills/example-skill/unit-test-generator/SKILL.md

unit-test-generator

Skill2 starsChanged 7 months agoMITView on GitHub

Generate comprehensive, isolated unit and integration tests for user-provided code. Use when sharing functions, classes, or modules and requesting test coverage, edge-case validation, or mock setups. Do NOT use for writing end-to-end UI tests, performance benchmarking suites, or generating test data without code context.

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

10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 9

    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:

    Do NOT use for E2E/UI testing, load/performance benchmarking, or writing test data generators without target code

    line 22
  2. Distinctive:

    Do NOT use for documentation-only workflows or code that cannot be logically isolated

    line 23
  3. Distinctive:

    IF external service calls exist → inject mocks/spies using the language's standard testing framework.

    line 38
  4. Distinctive:

    IF stateful logic exists → setup/teardown hooks to reset state between tests.

    line 39
  5. Distinctive:

    NEVER use real network/disk I/O in unit tests unless explicitly marked as integration.

    line 40
  6. Distinctive:

    Write assertions first, then setup/teardown.

    line 43
  7. Distinctive:

    Ensure 100% of generated tests pass syntactically.

    line 46
  8. Distinctive:

    If the input lacks executable logic (e.g., configuration files, markdown, or incomplete snippets), respond with:

    line 75
  9. Very specific:

    If the framework or language is unsupported by standard testing conventions, ask: "Which testing framework should I target?

    line 84
  10. Distinctive:

    Never assume a framework if it cannot be inferred from imports or package manifests.

    line 86

“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

Systematically creates production-ready test suites for executable code, prioritizing isolation, coverage, and maintainability.

🎯 When to Use

  • User shares functions, classes, or modules and asks for tests
  • User requests "increase coverage", "write edge cases", or "add mocks"
  • Code lacks automated validation or exhibits untested branches
  • Do NOT use for E2E/UI testing, load/performance benchmarking, or writing test data generators without target code
  • Do NOT use for documentation-only workflows or code that cannot be logically isolated

🧠 Core Workflow

Step 1 — Analyze Contracts & Dependencies Extract function signatures, expected return types, input constraints, and external calls (DB, HTTP, FS). Identify pure vs impure functions.

Step 2 — Map Test Scenarios Generate test cases using the following matrix:

  • Happy path → standard inputs matching documented behavior
  • Edge cases → empty strings, nulls, boundary integers, max array lengths
  • Error paths → invalid types, network failures, missing permissions
  • Branch coverage → IF/ELSE, switch cases, early returns

Step 3 — Design Isolation Strategy

  • IF external service calls exist → inject mocks/spies using the language's standard testing framework.
  • IF stateful logic exists → setup/teardown hooks to reset state between tests.
  • NEVER use real network/disk I/O in unit tests unless explicitly marked as integration.

Step 4 — Generate Test Code Write assertions first, then setup/teardown. Follow AAA (Arrange, Act, Assert) pattern. Use descriptive test names that state expected behavior, not implementation details.

Step 5 — Validate & Package Ensure 100% of generated tests pass syntactically. Verify mocks are scoped to specific tests. Return structured coverage matrix alongside test code.

📋 Output Format

Section 1 — Coverage & Strategy Report

{
  "status": "success | partial | error",
  "language": "string",
  "framework": "string",
  "functions_tested": 0,
  "coverage_target": "0-100%",
  "test_cases": [
    {
      "target": "function_or_method_name",
      "scenario": "happy_path | edge_case | error_path",
      "mocks_used": ["dep1", "dep2"],
      "assertions_count": 0
    }
  ]
}

Section 2 — Test Suite

Provide the complete test file in a fenced code block. Use framework-conventional naming (e.g., describe/it/test, def test_). Include necessary imports and mock configurations.

⚠️ Fallback Behavior If the input lacks executable logic (e.g., configuration files, markdown, or incomplete snippets), respond with:

{
  "status": "error",
  "message": "Input does not contain testable executable code. Expected functions, methods, or classes.",
  "suggestion": "Paste the source code block you want tested, or specify the entry points."
}

If the framework or language is unsupported by standard testing conventions, ask: "Which testing framework should I target? (e.g., Jest, Pytest, JUnit, Go testing, Vitest)" Never assume a framework if it cannot be inferred from imports or package manifests.

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.