agentleFS
iaintsaketiaintsaket/how-saket-claudes/skills/test-first/SKILL.md

test-first

Skill2 starsChanged 28 days agoMITView on GitHub

Builds a change one assertion at a time: state a testable claim, watch a test fail for the expected reason, write the smallest code that passes, then validate it on the real system, with script-checked proof of the order. Use when implementing a feature or fix from an approved plan, when the user says "TDD", "test first", "red green" or "/test-first", or when fixing a security finding. Not for docs, generated code, or research.

25 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-sweep, refactor and 3 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.
  • n24q02mSkill

    security-sweep

    Graph-driven security sweep -- scan for dangerous sinks, then rank each finding by whether an entry point can actually reach it, and triage the rest into suppressions.

    Also in 3 projects that use this

  • 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

11 rules. 0 are common, 9 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Run one bolt per assertion.

    line 31
  2. Distinctive:

    Reason: Write one assertion in the ledger: a single claim that can be false.

    line 33
  3. Distinctive:

    Act: write the test: Add only test code, then commit it alone.

    line 34
  4. Distinctive:

    Observe: confirm red: Run the test. It must fail for the expected reason, not from a typo, import error or broken setup.

    line 35
  5. Distinctive:

    Act: write the code: Add the smallest change that passes.

    line 36
  6. Distinctive:

    Observe: confirm green: Run the test, then the full suite and linters.

    line 37
  7. Distinctive:

    Record: Add the commits and the evidence to the ledger, then start the next bolt.

    line 44
  8. Distinctive:

    No production code without a test seen failing first.

    line 52
  9. Very specific:

    Don't weaken a test to pass.

    line 53
  10. Distinctive:

    Stop and tell the user if an assertion turns out to need a plan change.

    line 55
  11. Distinctive:

    Never claim "secure" or "bug-free".

    line 57

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

Move from assertion to validation, never from code to hope. Each change starts as a claim that can be false, and ends with evidence that it's true. Good output has a failing test that was seen to fail, and proof a reader can re-run.

This follows AI-DLC's Construction phase, with test-first as the test ordering: the approved plan is the Inception output, and each assertion is a small bolt. Inside each bolt the agent runs a ReAct loop: reason, act, observe. Observation means real output. An expected result is not an observation.

Inputs

$ARGUMENTS / the request:

  • A plan or a list of assertions → use them in order.
  • A finding from blind-pr-review → the assertion is that the attack is refused.
  • Neither → derive assertions from the request, and get approval before building, using the session's normal plan flow.

Workflow

Run one bolt per assertion. Read references/assertions.md before writing the first one.

  1. Reason. Write one assertion in the ledger: a single claim that can be false. For a security change, state what must be refused as well as what must work.
  2. Act: write the test. Add only test code, then commit it alone. This commit is the red commit.
  3. Observe: confirm red. Run the test. It must fail for the expected reason, not from a typo, import error or broken setup. Otherwise fix the test and repeat.
  4. Act: write the code. Add the smallest change that passes. Leave the test alone, and commit. This commit is the green commit.
  5. Observe: confirm green. Run the test, then the full suite and linters. Fix anything you broke.
  6. Refactor. Clean up with the tests green, in a separate commit.
  7. Validate. Prove the order:
    python3 scripts/verify_red_green.py --red RED_SHA --green GREEN_SHA --expect 'REGEX' -- TEST_COMMAND
    Then exercise the real thing wherever a unit test mocks the part that matters, such as a real CLI run, and record the output.
  8. Record. Add the commits and the evidence to the ledger, then start the next bolt.

Output

The ledger goes in the PR description, with a row per assertion. Reply with assertions proven, anything left unproven and why.

Rules

  • No production code without a test seen failing first. If code came first, set it aside and write the test from the assertion.
  • Don't weaken a test to pass. verify_red_green.py rejects any test that changed between red and green.
  • A test that can't fail proves nothing. If you can't make it fail, the assertion is wrong or already true, so say which.
  • Stop and tell the user if an assertion turns out to need a plan change.
  • Exceptions: docs, generated code, and configuration that has its own check. Name the exception in the ledger.
  • Never claim "secure" or "bug-free". Report which assertions were proven.
  • Python projects installed in editable mode import the main checkout, not the clean one: pass env PYTHONPATH=src pytest … so the check tests the right commit.

Files

  • references/assertions.md: read before the first bolt. Holds the ledger format and how to write strong assertions.
  • scripts/verify_red_green.py: run at step 7. Exit 0 means proven and 1 means rejected.
  • scripts/test_verify_red_green.py: the script's own tests.

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.