agentleFS
rohitgollarahallirohitgollarahalli/claude-skills/skills/test-author/SKILL.md

test-author

Skill0 starsChanged 5 months agoMITView on GitHub

Write meaningful automated tests for existing code — tests that assert real behavior and cover the risky paths, not filler that only inflates coverage. Use this whenever the user asks to "write tests", "add unit tests", "add test coverage", "test this function/module", set up a test suite, or asks "how do I test this?"; or when they've just written code and want it covered — even if they don't name a test framework.

4 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

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 5

    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:

    Understand the contract: Read the code under test and determine what it promises: inputs, outputs, side effects, error conditions.

    line 20
  2. Very specific:

    Make each test independent and deterministic: No shared mutable state, no reliance on test order, no real network/clock/filesystem unless …

    line 32
  3. Distinctive:

    Don't chase 100% coverage with trivial tests.

    line 48
  4. Distinctive:

    Don't assert on incidental details (log strings, exact float equality, dict ordering) that will break spuriously.

    line 49
  5. Distinctive:

    If the code is hard to test, that's a design signal — say so and suggest the seam (dependency injection, pure function extraction) rather …

    line 50
  6. Distinctive:

    Prefer a few sharp tests over many shallow ones.

    line 51

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

Tests exist to catch regressions and document intended behavior. A test that can't fail is worse than no test, because it gives false confidence. Write tests that would actually break if the code broke.

Process

  1. Understand the contract. Read the code under test and determine what it promises: inputs, outputs, side effects, error conditions. Test the contract, not the implementation details — tests coupled to internals break on every refactor.
  2. Pick the framework the project already uses. Match the existing convention (pytest, jest/vitest, go test, cargo test, JUnit, etc.) and file layout. Don't introduce a new framework unless asked.
  3. Cover the cases that matter, in priority order:
    • The happy path (the main thing it's supposed to do)
    • Boundaries and edges: empty, zero, one, many, max, null/None, negative, unicode
    • Error paths: invalid input, failures, exceptions — assert they're handled as promised
    • Known-tricky logic surfaced by reading the code
  4. Make each test independent and deterministic. No shared mutable state, no reliance on test order, no real network/clock/filesystem unless that's the point — inject or mock those. A flaky test erodes trust in the whole suite.
  5. Run the tests. Confirm they pass against correct code. Where practical, sanity-check that a test fails if you break the code — that's how you know it has teeth.

What makes a test good

  • Named for behavior, not mechanics: test_rejects_expired_token, not test_func2.
  • Arrange–Act–Assert structure, one logical behavior per test.
  • Asserts outcomes, not just "it ran without throwing".
  • Readable as documentation — someone should learn how the code behaves by reading the tests.

Guardrails

  • Don't chase 100% coverage with trivial tests. Coverage is a means, not the goal.
  • Don't assert on incidental details (log strings, exact float equality, dict ordering) that will break spuriously.
  • If the code is hard to test, that's a design signal — say so and suggest the seam (dependency injection, pure function extraction) rather than writing a tortured test.
  • Prefer a few sharp tests over many shallow ones.

Example

Input: "Write tests for this parse_duration('1h30m') helper." Output: pytest cases covering a normal value (1h30m → 5400s), units alone (45m, 2h), zero, missing units, garbage input (asserts it raises ValueError), and whitespace — each named for the behavior it pins down, all passing, with one deliberately checked to fail if the parser regresses.

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.