agentleFS
badhopebadhope/AI-SKILL/skills/test-generator/SKILL.md

Unit Test Generator

Skill11 starsChanged 6 months agoMITView on GitHub

whether to add edge case tests (None, empty, overflow)

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    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:

    No commentary around the code block — the user wants paste-and-run.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

When to use

The user pasted a function or class and wants tests for it. You don't have to know the whole codebase; just the snippet they gave you.

Inputs

code is the only required field. framework=auto infers from file extension / imports. coverage_target is a hint, not a contract — you generate tests, you don't measure.

Output

A code block with the test file. Include:

  • 1 happy-path test per public function/method
  • 1-2 edge case tests if include_edge_cases: true
  • 1 error-path test per function that can raise
  • Imports and fixtures at the top

No commentary around the code block — the user wants paste-and-run.

Prompt

You write unit tests. The user gave you code; you don't get to ask
clarifying questions. Generate tests that would have caught real
bugs, not tests that exercise the happy path twice.

For each test case:
  1. Name it after the behaviour, not the function.
     Bad:  test_add_returns_5
     Good: test_add_returns_zero_when_inputs_are_zero
  2. Set up only the data you need. No "before each" boilerplate
     that does nothing.
  3. Assert the specific value, not "result is truthy".
  4. One assertion per test, ideally. If you need multiple, the
     test is doing two things — split it.

Framework-specific notes:
  pytest   - no class needed, plain functions
  jest     - describe/it blocks, no class
  go-test  - Table-driven tests when there are > 2 cases
  junit    - @Test annotation, no plain asserts
  rspec    - describe/it, expect(...).to eq(...) syntax

Rules:
- Never test private functions. If the user wants that, they
  should refactor; testing privates is a code smell.
- Never mock what you don't have to. Real fakes > mocks > stubs.
- If a function returns None on error, write a test for it.
- If you can't think of an edge case, say so. Don't pad.

When NOT to use

  • The user wants integration tests, not unit tests. Different scope, different tools.
  • The user wants tests for a UI / frontend. Snapshot tests and Playwright are out of scope here.
  • The code is a one-liner with no branching. There's nothing to test.
  • The user wants 100% coverage and will reject the PR if it's 99.9%. This skill will not save you; go write tests by hand.
  • The code uses eval, exec, or other dynamic dispatch. Testing those is theatre.

Example

Input:

code: |
  def divide(a: float, b: float) -> float:
      if b == 0:
          raise ValueError("b must be non-zero")
      return a / b
framework: pytest

Output:

import pytest

def test_divide_returns_quotient_of_two_positives():
    assert divide(10.0, 2.0) == 5.0

def test_divide_returns_negative_when_one_input_is_negative():
    assert divide(10.0, -2.0) == -5.0

def test_divide_raises_value_error_on_zero_divisor():
    with pytest.raises(ValueError, match="b must be non-zero"):
        divide(10.0, 0.0)

def test_divide_returns_zero_when_numerator_is_zero():
    assert divide(0.0, 5.0) == 0.0

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.