From devconcept
Test-driven development with red-green-refactor loop. Use for bug fixes and behavior-heavy changes when tests are practical, and whenever the user asks for TDD, red-green-refactor, or integration tests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/devconcept:tddThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
See tests.md for examples and mocking.md for mocking guidelines.
DO NOT write all tests first, then all implementation. This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
This produces crap tests:
Correct approach: Vertical slices via tracer bullets. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
WRONG (horizontal):
RED: test1, test2, test3, test4, test5
GREEN: impl1, impl2, impl3, impl4, impl5
RIGHT (vertical):
RED→GREEN: test1→impl1
RED→GREEN: test2→impl2
RED→GREEN: test3→impl3
...
Before writing any code:
aligning-requirements context if already coveredAnswer from the request and repo context first:
Ask the user only when the answer would change implementation direction or product behavior. If the request and surrounding code already pin both down, do not stop to ask — that is the DevConcept philosophy applied to TDD: not ceremonial by default, but rigorous when the risk justifies it.
You can't test everything. Focus testing effort on critical paths and complex logic, not every possible edge case. Confirm priorities with the user only when the trade-off changes scope or product behavior.
Before editing production code, state the first behavior test you will make fail and the command you expect to run. If no practical behavior test exists, state that before coding and treat later checks as verification rather than TDD.
Write ONE test that confirms ONE thing about the system:
RED: Write test for first behavior → test fails
GREEN: Write minimal code to pass → test passes
This is your tracer bullet - proves the path works end-to-end.
The RED step must be observable in the session: run the narrow test command and record the failing command/result before editing implementation. A test added after the implementation is useful verification, but it does not count as TDD and must be reported as test-after.
For each remaining behavior:
RED: Write next test → fails
GREEN: Minimal code to pass → passes
Rules:
After all tests pass, look for refactor candidates:
Never refactor while RED. Get to GREEN first.
[ ] Test describes behavior, not implementation
[ ] Test uses public interface only
[ ] RED evidence was observed before implementation, or TDD was explicitly marked impractical
[ ] Test would survive internal refactor
[ ] Code is minimal for this test
[ ] No speculative features added
Behavior under test:
RED:
- test/command/result
GREEN:
- change made
- test/command/result
Refactor:
- done | skipped + reason
npx claudepluginhub pewepw/devconcept --plugin devconceptGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.