agentleFS
mrlemoosmrlemoos/galicia/unit-test/SKILL.md

unit-test

Skill1 starsChanged 6 days agoMITView on GitHub

Writes isolated unit tests for a named file using Arrange-Act-Assert. Use when user requests unit tests, test coverage, or missing test cases for a file.

14 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

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

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 7

    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:

    Read target file, its direct collaborators, nearest existing unit tests.

    line 12
  2. Distinctive:

    Test public behaviour, not private internals or call order, unless call itself is contract.

    line 18
  3. Distinctive:

    No logic in tests: no loops, conditionals, or recomputing expected value with production algorithm.

    line 21
  4. Distinctive:

    No fixed sleeps; await condition or use fake timers.

    line 23
  5. Distinctive:

    Do not change production code to make tests pass.

    line 24
  6. Distinctive:

    Run new tests alone; show invocation + result.

    line 25
  7. Distinctive:

    Run project lint and type checks on test file.

    line 26

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

Unit test

Short evidence, no emojis. No target file named: reply "Please mention the file that you want me to help you write the unit tests for." and stop.

Sphere: one function, class, or component; most isolated of three. Cross-layer data flow belongs in behavioural-test; full user journey in e2e-test. Case fits another sphere: say so, do not write it here.

  1. Read target file, its direct collaborators, nearest existing unit tests. Reuse project's runner, assertion library, file naming, test location, helpers, mock style. No existing tests: use runner in project config; none configured: ask user, add no dependency without approval.
  2. List cases before writing: every exported function/method, each branch, boundary values (empty, zero, one, max, null/undefined), invalid input, thrown/rejected errors, async ordering. Unreachable or untestable case: state why, do not fake coverage.
  3. Write tests. Rules:
    • Arrange-Act-Assert: three blocks in that order, blank line between. Label with // Arrange, // Act, // Assert only if project tests already do. One Act per test.
    • One behaviour per test. Several asserts allowed only when they describe same outcome.
    • Name states unit, condition, expected result. Group by unit under test.
    • Test public behaviour, not private internals or call order, unless call itself is contract.
    • Mock every collaborator outside unit: network, filesystem, clock, randomness, environment, other modules with side effects. Pure helpers stay real. Pin time and randomness. Never mock unit under test.
    • Independent tests: no shared mutable state, no order dependence, reset mocks between tests. Setup hooks only for identical Arrange.
    • No logic in tests: no loops, conditionals, or recomputing expected value with production algorithm. Literal expected values. Table-driven cases allowed when runner supports them.
    • Assert specific value or error type/message, not merely truthy or "did not throw".
    • No fixed sleeps; await condition or use fake timers.
    • Do not change production code to make tests pass. Suspected bug: keep failing test, report to user, ask before fixing.
  4. Run new tests alone; show invocation + result. Failure: decide whether test or code wrong, fix test only when test wrong. Rerun until green.
  5. Run project lint and type checks on test file; fix every error. Run full relevant suite; new tests must not break others.
  6. Repeat 4-5 after each edit. Report cases covered, cases skipped with reason, suspected bugs, commands run. Never claim passing without run output.

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.