agentleFS
WST2002WST2002/claude-code-skills/skills/test-writer/SKILL.md

test-writer

Skill4 starsChanged 27 days agoMITView on GitHub

Use when asked to write tests, add unit or integration tests, increase test coverage, test existing untested code, or cover a bug fix with a regression test — Jest, Vitest, pytest, JUnit, Go test, Playwright and others.

28 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use debug-fix, readme-generator and 8 more.

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.
  • zebbernSkill

    debug-fix

    Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)

    Also in 4 projects that use this

  • glinckerSkill

    readme-generator

    Generates comprehensive README.md files for software projects by analyzing codebase structure

    Also in 4 projects that use this

  • JohnJBorenSkill

    debugger

    Systematic debugging workflows, root cause analysis, and troubleshooting patterns

    Also in 3 projects that use this

  • get-proofpilotSkill

    context-budget

    Audits Claude Code context window consumption across agents, skills, MCP servers, and rules. Identifies bloat, redundant components, and produces prioritized token-savings recommendations.

    Also in 3 projects that use this

  • GoogleSkill

    code-reviewer

    Also in 4 projects that use this

  • GitHubSkill

    refactor

    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 27 edited versions we read keep these.

  • 2

    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 tests that would fail if the behavior broke.

    line 10
  2. Distinctive:

    Run them: Every new test must pass. Then break the code under test on purpose (or check the assertion against a wrong value) to confirm the …

    line 22

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

Test Writer

Overview

Write tests that would fail if the behavior broke. Match the project's existing test framework and style, test behavior through public interfaces, and run every test you write.

Method

  1. Learn the project's testing setup: framework and runner (from config and package.json/pyproject.toml/pom.xml), where tests live, naming, helpers, fixtures, factories. Read two existing tests and copy their style. If there are no tests, pick the standard for the stack and say so.
  2. Decide what to test for the target code:
    • Main success path.
    • Each branch and error path.
    • Boundaries: empty, zero, one, many, max, null/undefined, invalid types, unicode, time zones.
    • Contracts other code depends on (return shape, thrown errors, emitted events).
  3. Choose the level: unit for pure logic, integration where the risk is in wiring (database, HTTP, queues), end-to-end only for critical user journeys.
  4. Write each test as Arrange / Act / Assert with one behavior per test and a name that states it: returns 0 when the cart is empty.
  5. Run them. Every new test must pass. Then break the code under test on purpose (or check the assertion against a wrong value) to confirm the test can fail. Revert.
  6. Report what is covered and what is not.

Rules

RuleWhy
Assert on outputs and observable effects, not private internalsTests survive refactoring
Mock only what you do not own or what is slow or non-deterministic (network, clock, randomness)Over-mocking tests the mocks
Prefer real collaborators and in-memory or containerized databases for integration testsCatches wiring bugs
Make tests deterministic: fixed clock, seeded randomness, no order dependenceFlaky tests get ignored
Specific assertions (toEqual({ total: 1250 })), not toBeTruthy()Weak assertions pass on wrong results
A bug fix gets a regression test that fails without the fixThe bug stays fixed

Output

The test files, then:

Added: <N> tests in <files>
Covers: <behaviors and edge cases>
Not covered: <what and why>
Run: <command> → <N passed>

Common mistakes

  • Tests that mirror the implementation line by line and break on every refactor.
  • Snapshot tests of large objects that nobody reads.
  • Asserting that a mock was called instead of checking the result.
  • Writing tests and not running them.
  • Testing framework code or trivial getters instead of the logic that can break.

Made by Wageesha Tripathi · LinkedIn · Email · More skills

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.