agentleFS
osouthgateosouthgate/agent-plus/.claude/skills/test-writer/SKILL.md

test-writer

Skill4 starsChanged 5 months agoMITView on GitHub

Expert test writer for unit, component, E2E, and integration tests. Writes only high-value tests — branching, side effects, transactions, corner cases. Use for TDD or filling coverage gaps. Never writes tests for constants, single pass-throughs, or thin wrappers. Adapts to the project's test framework and conventions.

24 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

8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 24 edited versions we read keep these.

  • 7

    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:

    Ask when unclear: code under test.

    line 28
  2. Very specific:

    Every describe and it string MUST state a business/domain outcome, not implementation.

    line 62
  3. Distinctive:

    Must not: HTTP method or route.

    line 64
  4. Distinctive:

    Must: name so a reader understands the business outcome.

    line 65
  5. Distinctive:

    When writing tests before or alongside implementation:

    line 77
  6. Distinctive:

    After writing, run the project's test command and confirm all new tests pass before stopping.

    line 89
  7. Distinctive:

    Write tests; don't refactor the code under test unless it's untestable as-is.

    line 93
  8. Distinctive:

    If the code has no meaningful branches or side effects, say so and skip rather than padding the suite.

    line 94

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

Writes tests that would fail if someone removed a branch or changed a real decision. Every test must answer: would this fail if the behavior broke? If not, don't write it.

Adapts to the project's test framework (Jest, Vitest, Cypress, Playwright, pytest, etc.) and conventions.

Test layers

LayerUse forAvoid
UnitServer/utils logic; branching; side effects; transactions; corner casesSingle call-and-return with no decisions
ComponentSingle component or small tree; form validation with mocked API; rendering; error/loading states. Cover validation and error messages here, not in E2EFull router/loader behavior; real API/DB
E2EFull user journeys; redirects; cross-page navigation; presence of key UI elementsFine-grained validation messages (flaky)
IntegrationReal DB; auth; transactions; rollbacks; conflicts. Names state business outcomes onlyBroad "click around" coverage

Rule of thumb: Component = "does this form/component behave when I mock deps?" E2E = "does this flow work in a real browser?" Integration = "does this flow behave against a real DB?"

When invoked

  1. Read the code under test (function, module, or file the user indicated). Identify branches (if/else, early return, switch), side effects (DB, email, external calls), and inputs (params, env).
    • Ask when unclear: code under test; TDD vs after-the-fact; mock boundary; which layer.
  2. For component tests — enumerate before writing. List all conditional branches, steps, submit/action handlers, disabled/gated states, and conditional UI. Map tests to code paths. Component tests are not complete until every branch/step/handler has a test or a documented skip.
  3. List testable behaviors — One line per behavior: e.g. "when user not found → return error", "when status accepted → send email".
  4. Drop low-value behaviors — Remove any that are just "call DB/API and return result" with no branching or side-effect decision.
  5. Choose the right layer — Unit for server/utils; component for UI + validation with mocked API; E2E for journeys and presence; integration for real DB flows.
  6. Write tests for the remaining behaviors only. Each test name: scenario and expected outcome. Integration test names must state business outcome only (no HTTP methods, status codes, or DB column names).
  7. Verify — Work is not done until all relevant test runs pass. Run the project's test commands. Passing only one suite is not enough when other layers exist. If the test runner is unavailable or not configured, state that clearly and stop rather than silently skipping verification.

What to test

KindWhat to assert
BranchesDifferent inputs → different outcomes. One test per meaningful branch.
Side effectsRight function called (or not) with right args. Use expect(mock).toHaveBeenCalledWith(...) and expect(mock).not.toHaveBeenCalled().
TransactionsOperations run in right order with right data; failure doesn't leave partial state.
ValidationInvalid or edge inputs → error or correct shape. Empty, null, boundary values.
Conflicting state"Already accepted", "no settings", etc. → correct behavior.

What not to test

KindWhy skip
Single call and returnMock returns X, assert X — no decision tested.
Constants or config in isolationOnly tests that a literal is correct. Test the code that uses it.
Thin wrappersSame as single call: dependency in, same out. No behavior.

Integration tests

  • Response + DB state — Assert response (status, body) and verify persisted data when the flow writes to the DB. Use a query runner or DB helper to fetch created/updated rows.
  • Scope — High-value flows only: auth, transactions, rollbacks, conflict paths (e.g. 409). Run against local or test DB.
  • Isolation — Clean up test data in beforeEach/afterEach; avoid order-dependent state.

Integration test naming

Every describe and it string MUST state a business/domain outcome, not implementation.

  • Must not: HTTP method or route; status codes; DB column or event type constants.
  • Must: name so a reader understands the business outcome. E.g. "Login is rejected when password is wrong", "User list is returned for authenticated admin".

Test isolation

Tests must be order-independent.

  • Reset shared mocks in beforeEach — one test's overrides must not leak to another.
  • Restore module mocks in afterEach or afterAll if a test overrides a module.
  • Dynamic import after mocks — if the framework requires it, import the module under test only after mocks are set.

TDD: what to add first

When writing tests before or alongside implementation:

  1. Branches — one test per branch that changes outcome or side effects.
  2. Side effects — for each external call: one test that it is called (with correct args) in the right scenario, and one that it is not called when it shouldn't be.
  3. Edge inputs — empty, null, zero, invalid enum, too long.
  4. Order / rollback — if the code does A then B then C, add a test that failure at B doesn't leave A committed.

Output format

  • Emit only test code (and minimal setup) that fits the project's existing style and framework.
  • One focused test per behavior; clear describe/test names (scenario → outcome; for integration, business outcome only).
  • For "must not run" branches, assert the relevant mock was not called.
  • After writing, run the project's test command and confirm all new tests pass before stopping.

Stay in your lane

  • Write tests; don't refactor the code under test unless it's untestable as-is.
  • If the code has no meaningful branches or side effects, say so and skip rather than padding the suite.
  • For E2E setup (Playwright/Cypress config, auth helpers), check the project's existing test infrastructure before creating new files.

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.