agentleFS
eeshsaxenaeeshsaxena/agent-skills/skills/test-first/SKILL.md

test-first

Skill2 starsChanged 3 months agoMITView on GitHub

Drive changes with a failing test before writing implementation. Use when adding a feature or fixing a bug in a codebase that has tests.

24 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use refactor, api-design and 2 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.
  • GitHubSkill

    refactor

    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

    Also in 4 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 4 projects that use this

  • SentrySkill

    skill-creator

    Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 20 edited versions we read keep these.

  • 5

    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:

    Write the test before the code.

    line 8
  2. Distinctive:

    Red: Write the smallest test that captures the desired behavior and watch it fail for the right reason.

    line 13
  3. Distinctive:

    Green: Write the least code that makes the test pass.

    line 16
  4. Distinctive:

    Deterministic: No real network, no wall-clock sleeps, no shared mutable state between tests.

    line 27
  5. Distinctive:

    Run the full suite, not just your new test.

    line 38

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

Write the test before the code. Not for dogma, but because a failing test proves you understand the requirement and gives you a definition of done you cannot fool.

The rhythm

  1. Red. Write the smallest test that captures the desired behavior and watch it fail for the right reason. A test that passes before you write code is testing nothing.
  2. Green. Write the least code that makes the test pass. Resist gold-plating.
  3. Refactor. Clean up now that the test protects you. Run the suite again.

What makes a good test

  • Tests behavior, not implementation. Assert on outputs and observable effects, not private internals, so refactors do not break it needlessly.
  • One reason to fail. Each test pins one behavior. When it breaks, the name alone tells you what regressed.
  • Descriptive names. returns_401_when_token_expired beats test_auth_2.
  • Arrange, act, assert, with the interesting value obvious at a glance.
  • Deterministic. No real network, no wall-clock sleeps, no shared mutable state between tests. Fake the clock and the network.

For bug fixes specifically

Reproduce the bug as a failing test first. When it goes green, you have both the fix and a permanent guard against the bug returning. A bug fix without a regression test is half a fix.

Before finishing

  • Run the full suite, not just your new test.
  • Confirm your new test actually fails when you break the code (sabotage it once to be sure it has teeth, then restore).
  • Match the project's existing test framework, folder layout, and naming.

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.