tdd-workflow
TDD Workflow Skill
This skill standardizes the Test-Driven Development process to achieve high code quality and maintainability.
The TDD Cycle
Follow these 4 steps strictly for every new feature or bug fix:
1. RED: Write a Failing Test
- Action: Create a new test file or add a case to an existing one.
- Requirement: The test must fail (showing that the feature is missing or the bug is present).
- Goal: Define the expected behavior before writing implementation code.
2. GREEN: Make it Pass
- Action: Write the minimal implementation code necessary to make the test pass.
- Requirement: Don't worry about code elegance yet. Correctness is the only priority.
- Goal: Confirm the solution works as intended.
3. REFACTOR: Clean Up
- Action: Optimize implementation and test code while ensuring tests remain green.
- Requirement: Remove duplication, improve naming, optimize performance, and follow project standards.
- Goal: Ensure the code is maintainable and efficient.
4. VERIFY: Final Validation
- Action: Run the full test suite and check coverage.
- Requirement:
- Ensure all tests (not just the new ones) pass.
- Target coverage: >80% for the new/modified component.
- Verify edge cases (null values, network failures, out-of-bounds, etc.).
Best Practices
Test First, Always
Never write implementation code before its corresponding test. If you find yourself implementing logic first, stop and write a test that covers it.
One Test at a Time
Don't write multiple tests at once. Follow the cycle: one test → implementation → refactor → next test.
Keep Tests Simple
Tests should be easy to read and understand. Use the Arrange-Act-Assert pattern:
- Arrange: Set up the initial state and dependencies.
- Act: Invoke the function or method being tested.
- Assert: Verify the output or state change.
Test Behavior, Not Implementation
Focus on what the code does, not how it does it. This makes your tests more resilient to internal refactoring.
Common Pitfalls
- Skipping RED: Writing a test that accidentally passes (e.g., because it doesn't assert anything) provides no value.
- The "Big Bang" implementation: Writing too much code in the GREEN phase. Keep it minimal.
- Ignoring REFACTOR: Leaving "quick and dirty" code in the codebase after tests pass.
- Incomplete Mocks: Using real dependencies (databases, APIs) in unit tests, making them slow and flaky.
Integration with other Agents
- dev-planner: Provides the feature breakdown that informs which tests to write.
- code-reviewer: Verifies that the TDD process was followed and that tests are high-quality.
- bug-analyzer: Uses tests to reproduce bugs before implementing fixes.
Helper Scripts
scripts/run-tests.sh- Run the test suite and generate coverage report.scripts/init-test.sh- Scaffold a new test file based on project templates.
Mastery Checklist
- Does every new feature have a failing test first?
- Is implementation minimal in the GREEN phase?
- Was the code refactored and linted after passing?
- Is test coverage >80% for the modified areas?
- Are all tests passing after the final implementation?
More from jochenyang/jochen-ai-rules
ui-ux-pro-max
UI/UX design-system reasoning and UX quality audit skill. Use when user needs style direction, palette/typography selection, UX review, or design optimization before implementation. Do NOT use for backend logic or database design.
24devops-engineer
CI/CD pipeline design, containerization, and infrastructure management. Handles Docker, Kubernetes, monitoring setup (Prometheus/Grafana), and infrastructure-as-code (Terraform/Pulumi). Use when user asks to deploy, configure CI/CD, set up Docker/K8s, or manage infrastructure.
19handoff
Create and resume structured manual session handoffs for long-running development work. Use when approaching context limits, before manual reset, before switching models or IDEs, after a milestone, or when automatic compact would lose important implementation state.
1reflect
Review current conversation, analyze tasks, errors, and user feedback, extract learning opportunities for skill improvement. Use when user says "reflect", "review session", "what did we learn", "session summary", or after completing a complex task.
1developer
Comprehensive full-stack development for web, mobile, and game projects. Handles frontend (React/Vue/Angular), backend (Node.js/Python/Go/Java), mobile (Flutter/React Native/Swift/Kotlin), and game development (Unity/Unreal/Godot). Use when user asks to build, create, develop, implement, debug, or fix any web, mobile, or game project. Do NOT use for design-only tasks (use frontend-design or ui-ux-pro-max instead).
1mcp-builder
MCP server development for AI agents. Designs tool schemas, implements Python/TypeScript servers, creates evaluation tests. Use when user asks to build MCP server, create tool integration, or develop Claude plugins. Supports GitHub/Notion/Slack integrations.
1