.claude/skills/test-driven-development/SKILL.md
Forces the strict Red-Green-Refactor development cycle. Requires writing a failing test and running it in the terminal before writing any implementation code.
npx skillsauth add tranhieutt/software_development_department test-driven-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
TDD acts as the ultimate truth verifier. It prevents Agents from blindly inserting implementation code based on assumptions. By strictly enforcing the RED-GREEN-REFACTOR cycle, we guarantee that all code changes are demonstrably functional and logically sound before moving on to the next task.
ABSOLUTE DIRECTIVE: Under NO circumstances are you allowed to write the final implementation logic before a test has explicitly failed in the terminal environment.
*.test.ts, *_test.go, test_*.py) to assert the expected behavior.Your final response to the user MUST contain the evidence of your execution in the following format:
# 🧪 TDD Execution: [Feature/Task Name]
## 🔴 RED Phase Evidence
- **Test added**: `[test_function_name]`
- **Terminal Output**:
```bash
[Insert the failing test output trace here - do not fake this]
[file_name][Insert the passing test output trace here]
Status: ✅ Code verified. Awaiting next command.
---
## Anti-Rationalizations
Be aware of lazy logic that an Agent typically uses to skip testing. If a thought on the left occurs, YOU MUST apply the rebuttal on the right:
| Excuse (Agent's Lazy Rationalization) | Rebuttal & Correct Action |
| :--- | :--- |
| "I'll just write the implementation first because it's super easy, and add the tests after." | **CRITICAL REJECTION.** Writing code before a test guarantees brittle code and untested edge cases. You MUST write the failing test first. No exceptions. |
| "The project doesn't seem to have a test framework set up, so I will just skip TDD and do a console.log." | **REJECTED.** `console.log` is not an automated test. If a test runner (Jest, PyTest, Go test, Vitest) is missing, STOP working and ask the User for permission to install and configure one immediately. |
| "I don't need to run the final terminal command to check if it's green. I can read the logic and I know it works." | **REJECTED.** Code does not exist until the compiler/test-runner proves it exists. You cannot hallucinate terminal outputs. Run the actual command. |
---
## Verification Gates
Do not conclude the turn unless you have:
- [ ] Executed the test runner during the **RED** phase and captured a definitive FAILING state log.
- [ ] Executed the test runner during the **GREEN** phase and captured a PASSING log.
- [ ] Displayed both terminal outputs (Red & Green) as indisputable evidence to the User.
---
## Edge Cases
- **[UI / Canvas Rendering]**: If the task involves purely visual UI CSS updates that cannot be easily unit tested, fallback to structured visual DOM tests (e.g., Testing Library query checks) or explicit manual testing steps listed for the user. Do not skip testing entirely.
---
## Related Skills
- `planning-and-task-breakdown` — TDD is the engine used to execute the tasks planned by this skill.
- `spec-driven-development` — TDD uses the spec as its single source of truth for what tests need to be written.
testing
Generates high-fidelity architecture diagrams, sequence flows, and component maps for SDD projects. Use when finalizing a design phase, documenting system architecture, or visualizing agentic workflows. Default style: Style 6 (Claude Official).
data-ai
Provides vector database and semantic search patterns for Pinecone, Weaviate, Qdrant, Milvus, and pgvector in RAG and recommendation systems. Use when implementing vector search or when the user mentions vector database, semantic search, embeddings, or similarity search.
development
Updates docs/technical/CODEMAP.md by scanning the current codebase structure. Run after a significant feature merge, refactor, or when CODEMAP feels stale.
development
Unlocks the codebase after a release freeze or incident freeze period to resume normal development. Use when a freeze period ends or when the user mentions unfreezing or lifting the code freeze.