agentleFS
devnomad-bytedevnomad-byte/techneering/skills/redgreen/SKILL.md

redgreen

Skill13 starsChanged 5 months agoMITView on GitHub

Use when implementing any feature or bugfix, before writing implementation code

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    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. Distinctive:

    Write code before the test?

    line 22
  2. Distinctive:

    Write one minimal test showing what should happen.

    line 50
  3. Distinctive:

    Write simplest code to pass the test.

    line 63
  4. Distinctive:

    After green only: Remove duplication, improve names, extract helpers.

    line 71
  5. Very specific:

    Read testing-anti-patterns.md in this directory for detailed guidance on:

    line 75
  6. Distinctive:

    Before marking work complete:

    line 108
  7. Distinctive:

    No production code without a failing test first — delete and start over if violated

    line 128
  8. Distinctive:

    Verify RED is MANDATORY — never skip watching the test fail

    line 129
  9. Distinctive:

    Verify GREEN is MANDATORY — never skip watching the test pass

    line 130
  10. Distinctive:

    Use real code in tests — mocks only when unavoidable

    line 132
  11. Very specific:

    Read testing-anti-patterns.md for detailed anti-pattern guidance

    line 133

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Test-Driven Development (TDD)

Core Principle

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
If you didn't watch the test fail, you don't know if it tests the right thing.
Violating the letter of the rules is violating the spirit of the rules.

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Write code before the test? Delete it. Start over.

Red-Green-Refactor

digraph tdd_cycle {
    rankdir=LR;
    red [label="RED\nWrite failing test", shape=box];
    verify_red [label="Verify fails\ncorrectly", shape=diamond];
    green [label="GREEN\nMinimal code", shape=box];
    verify_green [label="Verify passes\nAll green", shape=diamond];
    refactor [label="REFACTOR\nClean up", shape=box];
    next [label="Next", shape=ellipse];

    red -> verify_red;
    verify_red -> green [label="yes"];
    verify_red -> red [label="wrong failure"];
    green -> verify_green;
    verify_green -> refactor [label="yes"];
    verify_green -> green [label="no"];
    refactor -> verify_green [label="stay green"];
    verify_green -> next;
    next -> red;
}

RED - Write Failing Test

Write one minimal test showing what should happen.

  • One behavior
  • Clear name
  • Real code (no mocks unless unavoidable)

Verify RED - Watch It Fail

MANDATORY. Never skip.

Confirm: Test fails (not errors), failure message is expected, fails because feature missing.

GREEN - Minimal Code

Write simplest code to pass the test. Don't add features, refactor other code, or "improve" beyond the test.

Verify GREEN - Watch It Pass

MANDATORY. Confirm test passes, other tests still pass, output pristine.

REFACTOR - Clean Up

After green only: Remove duplication, improve names, extract helpers. Keep tests green.

Testing Anti-Patterns

Read testing-anti-patterns.md in this directory for detailed guidance on:

  • Testing mock behavior instead of real behavior
  • Adding test-only methods to production classes
  • Mocking without understanding dependencies

Common Rationalizations

ExcuseReality
"Too simple to test"Simple code breaks. Test takes 30 seconds.
"I'll test after"Tests passing immediately prove nothing.
"Deleting X hours is wasteful"Sunk cost fallacy. Keeping unverified code is technical debt.
"TDD will slow me down"TDD faster than debugging.

Red Flags - STOP and Start Over

  • Code before test
  • Test passes immediately
  • Can't explain why test failed
  • Rationalizing "just this once"

Quick Reference

DimensionKey point
CycleRED → Verify RED → GREEN → Verify GREEN → REFACTOR
Red phaseOne behavior, one test, watch it fail first
Green phaseMinimal code to pass, no extra features
RefactorOnly after GREEN, keep tests green
ForbiddenCode before test / skip Verify / "just this once"

Verification Checklist

Before marking work complete:

  • Every new function/method has a test
  • Watched each test fail before implementing
  • Wrote minimal code to pass each test
  • All tests pass
  • Output pristine (no errors, warnings)
  • Tests use real code (mocks only if unavoidable)

Can't check all boxes? You skipped TDD. Start over.

Next Step

When done:

  • Normal case → return to caller (usually tn:assemble or tn:diagnose)
  • Tests still failing after 3 RED→GREEN attempts on the same behavior → invoke tn:diagnose for systematic root-cause investigation (matches tn:diagnose's 3-attempt limit — do not keep guessing past 3)
  • User requests stop → end the current flow

Guardrails

  • No production code without a failing test first — delete and start over if violated
  • Verify RED is MANDATORY — never skip watching the test fail
  • Verify GREEN is MANDATORY — never skip watching the test pass
  • Violating the letter of the rules is violating the spirit of the rules
  • Use real code in tests — mocks only when unavoidable
  • Read testing-anti-patterns.md for detailed anti-pattern guidance

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.