Skill metadata
Reference: full SKILL.md
The following is the complete skill definition that Mibyan loads when this skill is triggered. This is what the agent sees as instructions when the skill is active.
Test-Driven Development (TDD)
Overview
Write the test first. Watch it fail. Write minimal code to pass. Core principle: 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.When to Use
Always:- New features
- Bug fixes
- Refactoring
- Behavior changes
- Throwaway prototypes
- Generated code
- Configuration files
The Iron Law
- Don’t keep it as “reference”
- Don’t “adapt” it while writing tests
- Don’t look at it
- Delete means delete
Red-Green-Refactor Cycle
RED — Write Failing Test
Write one minimal test showing what should happen. Good test:- One behavior per test
- Clear descriptive name (“and” in name? Split it)
- Real code, not mocks (unless truly unavoidable)
- Name describes behavior, not implementation
Verify RED — Watch It Fail
MANDATORY. Never skip.- Test fails (not errors from typos)
- Failure message is expected
- Fails because the feature is missing
GREEN — Minimal Code
Write the simplest code to pass the test. Nothing more. Good:- Hardcode return values
- Copy-paste
- Duplicate code
- Skip edge cases
Verify GREEN — Watch It Pass
MANDATORY.- Test passes
- Other tests still pass
- Output pristine (no errors, warnings)
REFACTOR — Clean Up
After green only:- Remove duplication
- Improve names
- Extract helpers
- Simplify expressions
Repeat
Next failing test for next behavior. One cycle at a time.Avoid Horizontal Slices
Do not write all tests first and then all implementation. That is horizontal slicing: RED becomes “write a pile of imagined tests” and GREEN becomes “make the pile pass.” It produces brittle tests because the tests are designed before the implementation has taught you what behavior and interface actually matter. Use vertical tracer bullets instead:Why Order Matters
“I’ll write tests after to verify it works” Tests written after code pass immediately. Passing immediately proves nothing:- Might test the wrong thing
- Might test implementation, not behavior
- Might miss edge cases you forgot
- You never saw it catch the bug
- No record of what you tested
- Can’t re-run when code changes
- Easy to forget cases under pressure
- “It worked when I tried it” ≠ comprehensive
- Delete and rewrite with TDD (high confidence)
- Keep it and add tests after (low confidence, likely bugs)
- Finds bugs before commit (faster than debugging after)
- Prevents regressions (tests catch breaks immediately)
- Documents behavior (tests show how to use code)
- Enables refactoring (change freely, tests catch breaks)
Common Rationalizations
Red Flags — STOP and Start Over
If you catch yourself doing any of these, delete the code and restart with TDD:- Code before test
- Test after implementation
- Test passes immediately on first run
- Can’t explain why test failed
- Tests added “later”
- Rationalizing “just this once”
- “I already manually tested it”
- “Tests after achieve the same purpose”
- “Keep as reference” or “adapt existing code”
- “Already spent X hours, deleting is wasteful”
- “TDD is dogmatic, I’m being pragmatic”
- “This is different because…”
Verification Checklist
Before marking work complete:- Every new function/method has a test
- Watched each test fail before implementing
- Each test failed for expected reason (feature missing, not typo)
- Wrote minimal code to pass each test
- All tests pass
- Output pristine (no errors, warnings)
- Tests use real code (mocks only if unavoidable)
- Edge cases and errors covered
When Stuck
Mibyan Integration
Running Tests
Use theterminal tool to run tests at each step:
With delegate_task
When dispatching subagents for implementation, enforce TDD in the goal:With systematic-debugging
Bug found? Write failing test reproducing it. Follow TDD cycle. The test proves the fix and prevents regression. Never fix bugs without a test.Testing Anti-Patterns
- Testing mock behavior instead of real behavior — mocks should verify interactions, not replace the system under test
- Testing implementation details — test behavior/results, not internal method calls
- Happy path only — always test edge cases, errors, and boundaries
- Brittle tests — tests should verify behavior, not structure; refactoring shouldn’t break them

