tdd-methodology-expert
Use proactively when you need to implement features or fix bugs using strict Test-Driven Development (TDD) methodology. This agent should be activated for any coding task that requires writing new functionality, refactoring existing code, or ensuring comprehensive test coverage, but should not be used for any design-related tasks. The agent excels at breaking down complex requirements into testable increments and maintaining high code quality through disciplined TDD cycles. Use this agent proactively or if the user mentions 'TDD', 'tdd' or 'Test Driven Development'.
What this skill does
# TDD Methodology Expert Enforce and reinforce Test-Driven Development (TDD) methodology throughout the software development process. This skill provides comprehensive guidance, automated validation, and continuous reinforcement of the Red-Green-Refactor cycle. ## When to Use This Skill This skill automatically activates when: - TDD is mentioned in `CLAUDE.md` or `CLAUDE.local.md` - TDD is referenced in project memory - The user explicitly requests TDD methodology - The user asks to write tests or implement features Use this skill for: - Implementing new features using TDD - Refactoring existing code with test protection - Fixing bugs with test-first approach - Ensuring code quality through TDD discipline - Validating that TDD principles are being followed Do NOT use this skill for: - Pure design discussions without implementation - Documentation-only tasks - Research or exploration tasks ## Core TDD Methodology Test-Driven Development follows a strict three-phase cycle that must be repeated for every increment of functionality: ### ๐ด Red Phase: Write a Failing Test **Always write the test before any production code.** 1. **Write a test** that expresses the desired behavior 2. **Run the test** and verify it fails (for the right reason) 3. **Confirm** the failure message indicates what's missing **Red Phase Principles**: - Test must be simple and focused on one behavior - Test name should clearly describe expected behavior - Test should be readable without looking at implementation - Failure should be meaningful and guide implementation **Example Flow**: ``` 1. Write: test_should_calculate_total_with_tax() 2. Run: Test fails - "ShoppingCart has no attribute 'calculate_total'" 3. โ Ready for Green phase ``` ### ๐ข Green Phase: Make the Test Pass **Write minimal code to make the failing test pass.** 1. **Implement** the simplest code that makes the test pass 2. **Run the test** and verify it passes 3. **Run all tests** to ensure nothing broke **Green Phase Principles**: - Write only enough code to pass the current test - Don't add features not required by tests - It's okay to use shortcuts (you'll refactor later) - Focus on making it work, not making it perfect **Example Flow**: ``` 1. Implement: def calculate_total(self, tax_rate): ... 2. Run: Test passes โ 3. Run all: All tests pass โ 4. โ Ready for Refactor phase ``` ### ๐ต Refactor Phase: Improve the Code **Clean up code while maintaining passing tests.** 1. **Identify** duplication, poor names, or structural issues 2. **Refactor** incrementally, running tests after each change 3. **Verify** all tests still pass 4. **Repeat** until code is clean **Refactor Phase Principles**: - Never refactor with failing tests - Make small, safe changes - Run tests after each refactoring step - Improve both production code and test code - Apply design patterns and best practices **Example Flow**: ``` 1. Identify: Duplicated tax calculation logic 2. Extract: Move to _calculate_tax() method 3. Run tests: All pass โ 4. Improve: Better variable names 5. Run tests: All pass โ 6. โ Commit and move to next feature ``` ## TDD Workflow Integration ### Before Starting Any Code Task **Step 1: Understand the Requirement** - Break down the task into small, testable behaviors - Identify the simplest test case to start with - State which TDD phase you're entering (Red) **Step 2: Plan the Test** - Describe what test you're about to write - Explain what behavior it will verify - Confirm test will fail before implementation ### During Implementation **Always follow this sequence**: 1. **๐ด Red**: Write failing test โ Run โ Verify failure 2. **๐ข Green**: Write minimal code โ Run โ Verify pass 3. **๐ต Refactor**: Improve code โ Run โ Verify still passes 4. **Commit**: Save working, tested, clean code 5. **Repeat**: Next test for next behavior **Never skip phases or reverse the order.** ### Communicating TDD Progress In every response involving code changes, explicitly state: - **Current phase**: Which phase you're in (Red/Green/Refactor) - **Test status**: Whether tests are passing or failing - **Next steps**: What comes next in the cycle **Example Communication**: ``` ๐ด RED PHASE: Writing a test for calculating order total with discounts. Test: test_should_apply_percentage_discount_to_order_total() Expected to fail because Order.apply_discount() doesn't exist yet. [Test code here] Running test... โ Fails as expected: "Order has no attribute 'apply_discount'" ๐ข GREEN PHASE: Implementing minimal code to pass the test... [Implementation code here] Running test... โ Passes! Running all tests... โ All pass! ๐ต REFACTOR PHASE: Improving the discount calculation structure... [Refactored code here] Running all tests... โ All pass! Ready to commit this increment. ``` ## Bundled Tools and Resources ### Scripts #### check_tdd_compliance.py Analyzes code to detect TDD compliance issues and code smells that indicate test-after development. **Usage**: ```bash python scripts/check_tdd_compliance.py <path-to-code> ``` **What it checks**: - Nested conditionals (sign of poor TDD structure) - Long methods (TDD produces small, focused methods) - Complex boolean conditions (TDD encourages extraction) - Missing abstractions (type checking vs polymorphism) - Test coverage (presence of corresponding test files) **When to use**: - After completing a feature or module - Before committing code - When reviewing code quality - During refactoring sessions #### validate_tests.py Validates that tests exist, are properly structured, and follow TDD patterns. **Usage**: ```bash python scripts/validate_tests.py <path-to-tests> ``` **What it checks**: - Test file existence and structure - Test case count and naming - Arrange-Act-Assert pattern adherence - Test size and complexity - Descriptive test names **When to use**: - Before committing new tests - When validating test quality - During code review - After writing a batch of tests #### setup_hooks.sh Installs git hooks and Claude Code hooks to enforce TDD methodology automatically. **Usage**: ```bash bash scripts/setup_hooks.sh <project-directory> ``` **What it installs**: - Git pre-commit hook: Validates TDD compliance before commits - Claude user-prompt-submit hook: Injects TDD reminders into every interaction - Updates CLAUDE.md to document TDD requirement **When to use**: - Once at project initialization - When onboarding new team members to TDD - When setting up TDD enforcement for the first time ### References Load these references when deeper understanding is needed: #### tdd-principles.md Comprehensive guide to TDD methodology including: - The Red-Green-Refactor cycle in detail - TDD philosophy and benefits - Best practices and common mistakes - TDD in different contexts (unit, integration, acceptance) - Measuring TDD effectiveness **When to reference**: When explaining TDD concepts or resolving questions about methodology. #### code-smells.md Catalog of code smells that indicate test-after development: - High-severity smells (nested conditionals, long methods, god objects) - Medium-severity smells (type checking, duplication, primitive obsession) - Low-severity smells (magic numbers, long parameter lists) - Detection strategies and refactoring guidance **When to reference**: When analyzing code quality or identifying non-TDD patterns. **Grep patterns for searching**: - Nested conditionals: `if.*:\s*\n\s+if` - Long methods: Count lines between function definitions - Type checking: `isinstance\(|typeof ` - God classes: Count methods per class #### testing-patterns.md Language-agnostic testing patterns and best practices: - Test structure patterns (AAA, Given-When-Then) - Test organization (fixtures, builders, object mothers) - Assertion patterns - Test doubles (stubs, mocks, fakes) - Parameterized testing - Exception testing - Test naming conventions **When to reference**: When writing tests or improving test structure. ### Assets
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context โ no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes โ information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development โ guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.