agentleFS
himanshi-28himanshi-28/coding-agent-skills/skills/lock-tests-first/SKILL.md

lock-tests-first

Skill1 starsChanged 4 months agoMITView on GitHub

Explicit-invocation workflow for test-first implementation that defines behavior, proves new tests fail correctly, protects those tests from implementation-time edits, implements production code, and verifies the final red-to-green result. Use only when the user directly invokes the lock-tests-first skill.

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    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:

    Treat tests as the behavioral contract.

    line 9
  2. Distinctive:

    Start from approved acceptance criteria or derive observable inputs, outputs, errors, state changes, and invariants.

    line 14
  3. Distinctive:

    Read repository instructions, test commands, nearby tests, fixtures, and production interfaces.

    line 17
  4. Distinctive:

    Prefer behavior-level assertions over implementation details, excessive mocks, or broad snapshots.

    line 21
  5. Distinctive:

    Write the contract tests only.

    line 22
  6. Distinctive:

    Do not write or change production behavior yet.

    line 24
  7. Distinctive:

    Run the smallest relevant test command.

    line 26
  8. Distinctive:

    If a test passes unexpectedly, determine whether the behavior already exists or the assertion is ineffective.

    line 28
  9. Distinctive:

    Check that assertions are meaningful, deterministic, and capable of detecting a wrong implementation.

    line 30
  10. Distinctive:

    Commit a test-only baseline only when the user requested or approved committing.

    line 32
  11. Distinctive:

    Do not modify protected tests, their expected values, or test selection.

    line 34
  12. Distinctive:

    If a protected test is genuinely incorrect, stop and explain the flaw.

    line 35
  13. Distinctive:

    Run the focused tests, then relevant surrounding tests and available type, lint, or build checks in proportion to risk.

    line 37

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Lock Tests First

Treat tests as the behavioral contract. Do not weaken or rewrite protected tests merely to make implementation pass.

Workflow

  1. Confirm the contract.
    • Start from approved acceptance criteria or derive observable inputs, outputs, errors, state changes, and invariants.
    • Resolve any ambiguity that would change expected behavior before editing files.
  2. Inspect the test system.
    • Read repository instructions, test commands, nearby tests, fixtures, and production interfaces.
    • Match existing test levels and conventions.
  3. Design coverage.
    • Cover the happy path, meaningful boundaries, failures, regression cases, and relevant authorization or security behavior.
    • Prefer behavior-level assertions over implementation details, excessive mocks, or broad snapshots.
  4. Write the contract tests only.
    • Modify only tests and the minimum test-only fixtures or infrastructure required to express the contract.
    • Do not write or change production behavior yet.
  5. Prove the red state.
    • Run the smallest relevant test command.
    • Confirm each new test fails because the behavior is missing or wrong, not because of syntax, setup, import, fixture, or unrelated failures.
    • If a test passes unexpectedly, determine whether the behavior already exists or the assertion is ineffective. Do not proceed with a false red state.
  6. Audit and protect the tests.
    • Check that assertions are meaningful, deterministic, and capable of detecting a wrong implementation.
    • Record the protected test paths and their exact pre-implementation diff or content hash.
    • Commit a test-only baseline only when the user requested or approved committing. Otherwise state that the freeze is procedural and keep the baseline for comparison.
  7. Implement the smallest production change.
    • Do not modify protected tests, their expected values, or test selection.
    • If a protected test is genuinely incorrect, stop and explain the flaw; obtain approval before changing the contract.
  8. Prove the green state.
    • Run the focused tests, then relevant surrounding tests and available type, lint, or build checks in proportion to risk.
    • Compare protected tests to the baseline and confirm they were not altered during implementation.
  9. Review the result.
    • Inspect the production diff for overfitting, hard-coded test values, bypassed code paths, weakened validation, or unrelated changes.

Output

Report the red evidence, protected test files, implementation summary, green evidence, broader checks, and anything not verified. Never report success from a passing test whose pre-implementation failure was not established. Use the review-changes skill before packaging commits.

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.