From mthines-agent-skills
Enforces strict RED-GREEN-REFACTOR TDD cycles: writes one failing test, minimal code to pass, then refactors. Delegates to test-provenance-guard and code-quality skills during REFACTOR. Useful for test-first or test-after workflows.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mthines-agent-skills:tdd [after] [<feature-description>][after] [<feature-description>]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Enforce strict RED-GREEN-REFACTOR discipline. One test at a time. Tests describe WHAT the system does, never HOW.
Enforce strict RED-GREEN-REFACTOR discipline. One test at a time. Tests describe WHAT the system does, never HOW.
Check $ARGUMENTS for the feature or behavior description.
$ARGUMENTS contains a feature description, use it directly.$ARGUMENTS contains "after" (e.g., /tdd after), run in Test-After Mode — write tests for existing code. See rules/test-after.md.$ARGUMENTS is empty, ask the user what behavior they want to implement or test.Before writing any tests:
**/*.test.*, **/*.spec.*, **/*_test.*, **/test_*.*, **/tests/** to identify the test framework, naming conventions, and directory structure.package.json scripts, Makefile, pyproject.toml, Cargo.toml, go.mod, or similar for the test command.TEST_CMD for use throughout the cycle. If you can run a single test file or test case, prefer that over the full suite.If no tests exist yet, ask the user which framework to use before proceeding.
Before diving into implementation, identify what matters most:
Present the test list to the user for confirmation before starting the cycle.
For each item in the test list, execute one full cycle. Follow the rules strictly:
See rules/red.md
Write exactly ONE failing test. Run it. Confirm it fails with the expected error. Do NOT write implementation code.
See rules/green.md
Write the MINIMUM code to make the failing test pass. No more. Run the test. Confirm it passes. Run the full relevant test suite to check for regressions.
Even in this phase, apply the basic readability primitives while you write: meaningful names, guard clauses for the cases the test forces, no nesting beyond 2 levels. These cost almost nothing during authoring but are expensive to bolt on later. Don't optimize, abstract, or add unrequested features — REFACTOR will handle deeper improvements via Skill('code-quality').
See rules/refactor.md
Evaluate whether refactoring is needed. If yes, refactor while keeping all tests green. If no, move to the next cycle.
Invoke Skill('code-quality') for this phase. The code-quality skill is the source of truth for what "clean" means — guard clauses, low cognitive complexity, single-responsibility functions, intent-revealing names, single source of truth for union-type metadata, schema-first validation with type inference, total functions, type-driven design, functional core / imperative shell, and the named refactor recipes catalog (R1–R20). Routing through the skill — rather than reading individual rule files — picks up its Review Mode procedure, the structured output contract, and any rules added since this skill was written. Cite recipes by ID in commit messages and PR descriptions (e.g., "R1 Consolidate Parallel Maps", "R10 Total-ise the Function") so reviews are reproducible.
After each RED-GREEN-REFACTOR cycle:
After all items in the test list are complete:
setTimeout works, that React renders, or that Go's http.ListenAndServe starts. Test YOUR code.buildUser(overrides?) patterns instead of inline object literals scattered across tests.Follow the project's existing convention. If none exists, use:
should [expected behavior] when [condition]describe('createOrder') → it('should reject order when inventory is zero')The code-quality skill is the source of truth for what "well-written code" means in this workflow. Apply during GREEN as inline primitives; invoke as a full pass during REFACTOR via Skill('code-quality').
GREEN-phase primitives (apply inline while writing the minimal implementation):
ifs — flat code is easier to read and easier to test.pendingOrders beats arr2.For REFACTOR, invoke Skill('code-quality') so the skill's Review Mode procedure runs against the GREEN output. The skill returns findings under the High / Medium / Low / Maintainability / Correctness / Testability headings; address each as a separate refactoring move (one change at a time per the "Procedure" below). Cite recipe IDs (R1–R20) in commit messages.
| Anti-Pattern | Why It's Bad | What to Do Instead |
|---|---|---|
| Writing tests in bulk | Tests imagined behavior, not observed | One test per cycle |
| Testing and implementing together | Unconsciously designs tests around implementation | Strict phase separation |
| "Make sure tests pass" prompt | Encourages implementation-first thinking | "Write a FAILING test" |
| Changing test expectations to pass | Masks real bugs | Fix the source code |
| Testing private methods | Couples tests to implementation | Test through public API |
| Copy-pasting mock setup | Brittle, hard to maintain | Extract shared fixtures |
npx claudepluginhub mthines/agent-skillsGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.