agentleFS
TylerAkinsTylerAkins/ai-agent-skills/skills/test-authoring/SKILL.md

test-authoring

Skill1 starsChanged 30 days agoMITView on GitHub

Write meaningful tests for requested behavior, boundaries, failures, and state or tenant isolation. Use when adding coverage, reproducing a bug, or writing regression tests. Follow the repository's runner and conventions; do not expand test-authoring requests into unrequested production changes.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 13

    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
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Read anti-ai-writing before drafting names, comments, or reports.

    line 12
  2. Distinctive:

    Read repository instructions, neighboring tests, fixtures, dependency versions, runner configuration, and relevant CI commands.

    line 17
  3. Distinctive:

    Before writing a test, name the behavior or defect its assertion would detect and the production change that would make it fail.

    line 29
  4. Distinctive:

    Use the lowest level that meaningfully exercises the requirement:

    line 35
  5. Distinctive:

    Use real query/database behavior when mocks conceal tenant or scope defects.

    line 46
  6. Distinctive:

    Use manual verification for requirements automation cannot establish, and state that limitation.

    line 47
  7. Distinctive:

    Prefer cheap real collaborators.

    line 70
  8. Distinctive:

    Use bounded waits and clean up background tasks.

    line 77
  9. Distinctive:

    Use snapshots only for meaningful, reviewable output contracts.

    line 80
  10. Distinctive:

    Use focused assertions when a broad snapshot hides the behavior of interest.

    line 82
  11. Distinctive:

    When tests accompany an authorized behavior change or fix, prefer observing the intended assertion fail before implementation and pass …

    line 90
  12. Distinctive:

    Keep before/after conditions comparable.

    line 100
  13. Distinctive:

    Run the intended tests and the configured lint, formatter, and type checks for affected packages using the shared validation procedure …

    line 107

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

Read anti-ai-writing before drafting names, comments, or reports. Keep changes scoped to the requested coverage and preserve unrelated work.

1. Discover the runner and expected behavior

  1. Read repository instructions, neighboring tests, fixtures, dependency versions, runner configuration, and relevant CI commands. Prefer repository wrappers and scripts over assumed global commands. Identify the package directory and focused test selection, then confirm the runner actually executes the selected tests.
  2. For test edits, discover configured lint, formatter, and type checks, including rules for test files. Follow the validation procedure in writing-clean-simple-code. Validation does not authorize production changes.
  3. Derive expected outcomes from authoritative requirements, independently verified examples, or preserved contracts. Do not copy the implementation's formula into the expected result. Resolve behavior-changing ambiguity before asserting a guessed outcome; continue coverage whose intent is settled.
  4. Before writing a test, name the behavior or defect its assertion would detect and the production change that would make it fail. If no meaningful change would fail it, strengthen the assertion or choose a different test boundary.

2. Choose the level that captures the behavior

Use the lowest level that meaningfully exercises the requirement:

LevelAppropriate coverage
UnitIsolated logic with controlled inputs and observable results.
Integration or compositionBehavior across parsing, persistence, services, or other component boundaries.
End-to-endCritical user flows or browser/runtime behavior that lower-level tests cannot establish.

Exercise production code. Do not mock the changed parser, compiler, engine, query, or component whose behavior the test is meant to establish. Textual source checks are appropriate only for an explicitly textual contract, not as runtime coverage. Use real query/database behavior when mocks conceal tenant or scope defects. Use manual verification for requirements automation cannot establish, and state that limitation. Manual checks cannot replace required runner evidence for a behavioral code change. Avoid fixed test-level percentages or unnecessary end-to-end tests when focused coverage establishes the same behavior.

Cover relevant success, negative, boundary, null/empty, and failure cases. Include normalization, repeated operations, partial inputs, and fallbacks where they affect reachability or contracts. For shared repairs, include the original defect and a plausible repair-induced failure from actual producers and consumers. Investigate conflicting expectations across layers even when both suites pass.

For query changes, optimizations, persisted configuration, or asynchronous and interactive state, read scope and state coverage.

3. Write readable, deterministic tests

Organize each test into recognizable setup, action, and assertions without requiring ceremonial comments. Name the behavior and expected outcome. Keep one coherent behavior per test; multiple assertions can establish that behavior. Prefer outcomes over internal call sequences unless the interaction itself is the required contract.

Reuse repository fixtures and builders, but keep distinguishing inputs and expected results visible. Do not add abstraction solely to remove a few lines of setup. Prefer cheap real collaborators; use fakes or mocks for costly, nondeterministic, or unsafe boundaries outside the behavior under test. Verify a fake models the contract being exercised rather than assuming it is equivalent to production.

Control time, randomness, scheduling, and I/O with repository utilities. Prefer explicit synchronization to arbitrary sleeps. Give each test its own state and restore changed globals, clocks, mocks, environment, and resources even after failure. Use bounded waits and clean up background tasks. Do not depend on test order or mutate shared fixtures across cases.

Use snapshots only for meaningful, reviewable output contracts. Inspect expected changes deliberately; do not regenerate snapshots merely to make failures green. Use focused assertions when a broad snapshot hides the behavior of interest.

4. Establish evidence for the requested coverage

  • For a bug reproduction, use a realistic fixture that distinguishes defective behavior. Run it against the defective version when feasible and confirm the intended assertion fails; syntax, import, or setup failures do not count. A reproduction-only request stops there and does not authorize production repair.
  • When tests accompany an authorized behavior change or fix, prefer observing the intended assertion fail before implementation and pass afterward. If the old version cannot be run safely or meaningfully, record why and use the strongest available baseline or reproduction. Do not claim regression sensitivity that was not observed.
  • For coverage of existing correct behavior, run the test and verify it reaches the intended path and asserts an independently justified result. Use a focused mutation in an isolated copy when a consequential gap remains about whether the test could detect a regression; do not require one for every test-only change.

Keep before/after conditions comparable. Use isolated copies or restore only agent-owned edits; never reset or stash mixed user work. A reproduction test may remain failing for a later repair. Report its result without weakening the assertion to obtain a green suite.

5. Execute and report

Run the intended tests and the configured lint, formatter, and type checks for affected packages using the shared validation procedure above. Retain command results, rerun affected checks after edits, and report unavailable checks as incomplete. An intentionally failing reproduction test may remain failing; that exception does not waive lint, formatter, or type checks. Use actual repository commands and working directories. Confirm selected tests ran and inspect failures; zero selected tests is not verification. Broaden or repeat checks only for material changes, failures, or unresolved concerns. Do not skip a flaky test or rerun until green as a substitute for understanding it; use root-cause-debug for unresolved failure investigation.

Report what behavior the tests establish, actual execution results, observed before/after evidence, and material limits. Distinguish authored but unrun tests from verified coverage. Passing tests do not prove absence of defects or that an unexecuted browser/live flow works. Commit, push, and publication require separate authorization through the applicable workflow.

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.