Unit Test Generator skill for Claude and Codex
Writes a complete, runnable test file for one function in your language and framework: normal cases, edge cases, and error paths, with mocks where the…
Install it once and Claude or Codex runs it for you. When your request matches, your AI loads the skill, asks for anything it is missing, and works through the template itself. Prefer to fill it in by hand? See the full prompt template.
Download the skill (.zip) · View SKILL.md
When it is used
Use when one function needs a ready-to-run test file in your language and framework covering its normal, edge, and error cases. Do not use for planning a whole module's test strategy or reviewing an existing suite's failures and coverage. Related topics: coding, unit.
What it will ask you for
- Programming language (choose one: Python, JavaScript, TypeScript, Java, C#, Go, Ruby)
- Test framework (choose one: pytest, unittest, Jest, Vitest, Mocha, JUnit, NUnit, Go test, RSpec)
- Function signature (free text, e.g. "def parse_price(raw: str) -> Decimal")
- Function body (longer free text)
- Where it lives (free text, e.g. "src/billing/prices.py")
- Coverage level (choose one: Basic (happy path), Moderate (plus edge cases), Full (plus error paths and mocks))
- Include mocking (choose one: Yes, No)
- Number of test cases (number from 1 to 20)
How it works
- List every branch in the function body (conditions, early returns, errors, loop cardinalities) before writing any test.
- Map each branch to a named test case up to the requested count, using the framework's parametrisation for value-only variations.
- Mock only process-crossing dependencies with the framework's tools when mocking is on, and assert each mock's arguments.
- Write the file with imports matching the module path, setup inside the file, and a header comment stating what is covered.
- Check the file would run as pasted: no undefined helpers, correct import path, framework syntax matches the chosen version.
What you get
A single code block with the complete test file, opening with a one-line comment on what is covered, runnable without edits.
What it watches out for
- Deriving cases from the signature instead of the body, which tests the happy path three ways and no error branch.
- Mocking the function's own helpers, so the test passes while the real logic never runs.
- Importing from a guessed path or a project fixture that does not exist, so the file fails before the first test.
How to install
Claude.ai and the Claude desktop app
- Download the skill .zip.
- Open Settings, then Capabilities, and find Skills.
- Choose Upload skill and select the .zip.
- Ask Claude for help with the task. It loads the skill when your request matches.
Claude Code
- Download the skill .zip.
- Unzip it into ~/.claude/skills/ (or .claude/skills/ inside a project).
- Start a new session. Claude Code loads the skill when your request matches.
Codex
- Download the skill .zip.
- Unzip it into ~/.agents/skills/ (or .agents/skills/ inside a project).
- Codex picks it up on its own. Type $ and the skill name to use it, or just ask for the task.
Cursor
- Download the Cursor rule (.mdc).
- Save it in .cursor/rules/ inside your project.
- Cursor's agent applies the rule when your request matches its description.
AGENTS.md (Codex, Cursor, and other coding agents)
- Copy the AGENTS.md section.
- Paste it into AGENTS.md at the root of your repository, creating the file if needed.
- Coding agents that read AGENTS.md follow it when your request fits.