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
- Distinctive: line 22
Write code before the test?
- Distinctive: line 50
Write one minimal test showing what should happen.
- Distinctive: line 63
Write simplest code to pass the test.
- Distinctive: line 71
After green only: Remove duplication, improve names, extract helpers.
- Very specific: line 75
Read testing-anti-patterns.md in this directory for detailed guidance on:
- Distinctive: line 108
Before marking work complete:
- Distinctive: line 128
No production code without a failing test first — delete and start over if violated
- Distinctive: line 129
Verify RED is MANDATORY — never skip watching the test fail
- Distinctive: line 130
Verify GREEN is MANDATORY — never skip watching the test pass
- Distinctive: line 132
Use real code in tests — mocks only when unavoidable
- Very specific: line 133
Read testing-anti-patterns.md for detailed anti-pattern guidance
≈ “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.
Files
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 FIRSTWrite 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
| Excuse | Reality |
| "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
| Dimension | Key point |
| Cycle | RED → Verify RED → GREEN → Verify GREEN → REFACTOR |
| Red phase | One behavior, one test, watch it fail first |
| Green phase | Minimal code to pass, no extra features |
| Refactor | Only after GREEN, keep tests green |
| Forbidden | Code 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:assembleortn:diagnose) - Tests still failing after 3 RED→GREEN attempts on the same behavior → invoke
tn:diagnosefor systematic root-cause investigation (matchestn: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.mdfor detailed anti-pattern guidance
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
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.

