agentleFS
cachewraithcachewraith/cachewraith-skills/skills/testing/SKILL.md

testing

Skill0 starsChanged 3 months agoMITView on GitHub

Run, write, and debug tests — unit, integration, and end-to-end — in whatever framework the project already uses (Jest, Vitest, PHPUnit, Pytest, Go test, cargo test, RSpec, JUnit). Invoke when the user asks to test something, run the suite, add or fix tests, check coverage, or investigate a failing test. Skip when they want a code review rather than tests, or are asking how a test framework works in the abstract.

123 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use oss-pr, pr-automation and 10 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.
  • CES-LtdSkill

    oss-pr

    Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.

    Also in 3 projects that use this

  • CES-LtdSkill

    pr-automation

    PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

    Also in 3 projects that use this

  • ffsshhttiikkSkill

    cicd

    Continuous integration and delivery pipelines

    Also in 4 projects that use this

  • ffsshhttiikkSkill

    networking

    Practical application and coding skills for Networking

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 9 projects that use this

  • Cogni-AI-OUSkill

    dotfiles

    Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.

    Also in 3 projects that use this

  • +2 more from CES-Ltd
  • +1 more from ffsshhttiikk

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 105 edited versions we read keep these.

  • 2

    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:

    Never guess the runner or invent a command:

    line 13
  2. Very specific:

    Use the project's own command — npm test, composer test, pytest, go test ./..., cargo test — not a hand-rolled invocation.

    line 32
  3. Distinctive:

    Read the actual failure output before changing anything.

    line 85

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

Testing

Find the project's test setup, use it, and write tests that would actually catch a regression.

1. Find the setup before writing anything

Never guess the runner or invent a command:

ls package.json composer.json pyproject.toml pytest.ini Cargo.toml go.mod Gemfile pom.xml 2>/dev/null
sed -n '/"scripts"/,/}/p' package.json          # JS/TS, then jest/vitest/playwright config
ls phpunit.xml* tox.ini setup.cfg 2>/dev/null   # PHP / Python

Read CLAUDE.md, README.md, and CONTRIBUTING.md for test rules first. Projects routinely have non-obvious requirements — a real database instead of an in-memory one, an env file to source, serial execution, a fixture reset between cases. Those override every default here.

Then read one existing test in full and match its structure, naming, helpers, and assertion style. A test that doesn't look like its neighbours is a worse test even when it passes.

2. Run the suite

Use the project's own command — npm test, composer test, pytest, go test ./..., cargo test — not a hand-rolled invocation; the script usually carries required flags (config path, serial workers, env loading).

Narrow down while iterating, then run the full suite before declaring done — a narrow run hides cross-test breakage.

npx jest --config test/jest-e2e.json -t "sends a friend request"
pytest tests/test_auth.py::test_login -x
go test ./internal/auth -run TestLogin -v

3. What to write

Pick the level that matches what you're protecting:

  • Unit — pure logic, edge cases, branching. Fast, no I/O. Validators, formatters, calculations, state machines.
  • Integration — a service against a real database or dependency. Queries, transactions, locking — anything where the ORM's behaviour is the risk.
  • End-to-end — a real request over the real stack. Status codes, response shape, auth, guard ordering, rate limits.

Where a project has one dominant style, follow it rather than introducing a parallel testing culture nobody maintains.

Test behaviour, not implementation. Assert on what a caller observes — return value, response body, status code, database state, emitted event. A test asserting a private method was called breaks on every refactor and catches nothing.

Cover what actually breaks: the happy path once, then every error path (invalid input, missing auth, wrong owner, not found, conflict), boundaries (empty/one/many, zero/negative/max, first and last page), idempotency (doing it twice, out of order, after it already happened), and concurrency where an invariant depends on it. Error paths are where the bugs are; a suite that only tests success is decorative.

Assertions: one behaviour per test, named for what it guarantees (rejects login for an unverified email, not test login 2). Assert exact wire strings, status codes, and shapes when they are a contract — loose matchers let breaking changes through. No conditional logic in a test; an if tests two things badly.

Fixtures and isolation: each test must pass alone and in any order — shared mutable state is a defect in the suite. Follow the project's reset mechanism exactly (truncate helper, transaction rollback, fresh container); note that a wrapping transaction cannot work when the code under test runs over real HTTP on its own connection. Reset the things that produce mystifying failures elsewhere: rate limiters, caches, recorded mail, clocks, in-memory queues. Build fixtures with a factory, not copy-pasted literals. Mock at the system boundary — third-party HTTP, payments, clocks, randomness — and do not mock your own database into meaninglessness.

4. When a test fails

  1. Read the actual failure output before changing anything; the diff usually names it.
  2. Decide honestly which side is wrong. Fix the code when the test encodes the intended behaviour.
  3. Never weaken an assertion, add a retry, or bump a timeout to turn red green. If a test is genuinely obsolete, say so and delete it deliberately.
  4. Flaky? Find the shared state, ordering assumption, or real timing dependency. Do not paper over it with a sleep.
  5. Reproduce with the narrowest run, fix, then re-run the full suite.

5. Report

The command and the pass/fail counts. If anything failed, the failing test names and the real output — never round a failing run up to "done". What you added coverage for, what you deliberately left uncovered and why, and anything you could not run (missing database, absent credentials) with what it would take to run it.

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.