agentleFS
leekleek/agent-skills/skills/tdd/SKILL.md

tdd

Skill3 starsChanged 2 months agoMITView on GitHub

The red → green loop tuned for Pest/PHPUnit in a Laravel codebase: seams, what a good test is, and the anti-patterns to refuse. Use when building features test-first or when another skill needs the loop.

193 other projects use a version of this, 45 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use make-bot-ui, Poteto Mode and 9 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.
  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 8 projects that use this

  • jtarorehSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 5 projects that use this

  • TheOnlyFusionCubeSkill

    principle-attack-the-premise

    Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.

    Also in 11 projects that use this

  • TheOnlyFusionCubeSkill

    principle-test-behavior-not-implementation

    Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.

    Also in 11 projects that use this

  • shreyT19Skill

    principle-laziness-protocol

    Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.

    Also in 22 projects that use this

  • shreyT19Skill

    principle-make-operations-idempotent

    Apply when designing commands, lifecycle steps, or processing loops that run amid crashes, restarts, and retries. Converge to the same end state regardless of partial prior runs.

    Also in 22 projects that use this

  • +4 more from shreyT19

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read CONTEXT.md if it exists so test names and interface vocabulary match the project's domain language, and respect ADRs in the area …

    line 10
  2. Very specific:

    Before writing or reviewing tests, read references/testing-best-practices.md and apply its value gate and rejection rules throughout the …

    line 12
  3. Distinctive:

    Red before green: Write the failing test first, watch it fail for the right reason (a missing route 404s, not a typo'd import), then write …

    line 18
  4. Very specific:

    Database: use whichever refresh trait the suite already uses (RefreshDatabase/LazilyRefreshDatabase), don't introduce a second convention.

    line 41
  5. Very specific:

    Factories: all test data via model factories.

    line 42
  6. Very specific:

    Fast loops without TIA (Pest v4, or no coverage driver): run the suite with --parallel (--processes=N to override the one-per-core default).

    line 47

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

TDD in Laravel

The red → green loop, tuned for Pest/PHPUnit in a Laravel codebase. Consult before and during the loop, not after.

Read CONTEXT.md if it exists so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.

Before writing or reviewing tests, read references/testing-best-practices.md and apply its value gate and rejection rules throughout the loop.

Rules of the loop

  • Red before green. Write the failing test first, watch it fail for the right reason (a missing route 404s, not a typo'd import), then write only enough code to pass. No speculative features.
  • One slice at a time. One seam, one test, one minimal implementation per cycle. Each next test responds to what the last cycle taught you: never all tests up front, then all implementation (bulk tests verify imagined behavior and go insensitive to real changes).
  • Refactoring is not part of the loop. It belongs to the review step (code-review).

What a good test is

Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification (user cannot view another users invoice says exactly what rule exists) and survives refactors because it doesn't care about internal structure.

Seams: where tests go

A seam is the public boundary you test at (codebase-design holds the full deep-module vocabulary). Test at the chosen seams: the caller (to-spec or implement) picks them from the ranking below and states the choice rather than asking; test at the highest seam that can observe the behavior, prefer a seam the codebase already has over cutting a new one, and use as few as possible, one is the target. Ask only on a genuine fork the rules rank equally.

Highest first:

  1. HTTP boundary: feature test: actingAs($user)->post(route(...)) + response and assertDatabaseHas assertions. Default for anything with an endpoint.
  2. Livewire / Filament component: Livewire::test(...) / Filament testing helpers, when behavior lives in the component.
  3. Console command: $this->artisan('...')->assertExitCode(0) plus side-effect assertions.
  4. Queued job / listener: instantiate and handle(), or dispatch with real execution, asserting side effects.
  5. Action / service class: direct test at its public API, for logic shared by several entry points.
  6. Model: non-trivial scopes, casts, derived attributes only.

Laravel specifics

  • Database: use whichever refresh trait the suite already uses (RefreshDatabase/LazilyRefreshDatabase), don't introduce a second convention. Never point tests at a real environment's database.
  • Factories: all test data via model factories; encode meaningful variants as factory states (Invoice::factory()->overdue()), not inline attribute soup repeated across tests.
  • Side effects via fakes: Queue::fake(), Mail::fake(), Notification::fake(), Event::fake(), Storage::fake(), Http::fake(): then assert the effect (Mail::assertQueued), not the internal call path. Fake the boundary, never mock your own classes' internals.
  • Time: $this->travel(...) / travelTo(...) for anything date-dependent; never sleep().
  • Authorization is behavior: for every "user can X" test, write the "user cannot X on someone else's record" test, record-level scoping is the most error-prone rule in a multi-tenant app.
  • Fast loops with TIA (Pest v5): if the project is on Pest v5, use the Tia engine so each red → green cycle replays only impacted tests instead of the whole suite, ./vendor/bin/pest --parallel --tia, or enable it project-wide with pest()->tia()->locally() in tests/Pest.php. Requires PCOV or Xdebug. Local only, CI still runs the full suite.
  • Fast loops without TIA (Pest v4, or no coverage driver): run the suite with --parallel (--processes=N to override the one-per-core default). Tests must be order-independent and not share database state, which the refresh-trait + factories rules above already guarantee.

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.