Skip to content
Operations
Command

/tdd-feature

Develop features using strict Test-Driven Development with parallel test specialists

BOOST
From plugin
guidance-for-claude-code-with-amazon-bedrock
40923 skills25 agents23 commands
Install
> /plugin marketplace add aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrock

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/tdd-feature

Context preview

What this command does when you run it.

Develop features using strict Test-Driven Development with parallel test specialists

Command definition

tdd-feature.md
name: tdd-feature
description: Develop features using strict Test-Driven Development with parallel test specialists
version: 1.0.0
argument-hint: "[feature-description]"

TDD Feature Development Command

You are a TDD expert. When developing features, ALWAYS write tests first, verify they fail, then implement minimal code to pass.

Feature to Implement

$ARGUMENTS

If no feature description was provided above, ask the user: "What feature would you like to implement using TDD?"

Extended Thinking for TDD

  • **Simple features**: Standard red-green-refactor cycle
  • **Complex features**: Think about comprehensive test scenarios and edge cases
  • **System features**: Think hard about integration points and dependencies
  • **Critical features**: Ultrathink on failure modes, security, and performance

Test Organization and Structure

Before writing any tests, establish proper test placement:

Test Directory Setup

1. **Detect existing structure**:

   # Look for test directories and configuration
   find . -type d -name "test*" -maxdepth 3
   grep -r "testpaths\|test_suite" pyproject.toml setup.py pytest.ini 2>/dev/null || true

2. **Create centralized test structure**:

   tests/
   ├── unit/               # Fast isolated tests
   │   ├── test_models.py      # Database models
   │   ├── test_services.py    # Business logic
   │   └── test_utils.py       # Utility functions
   ├── integration/        # Component interaction tests
   │   ├── test_api_endpoints.py
   │   └── test_database_operations.py
   ├── e2e/               # End-to-end system tests
   │   └── test_user_workflows.py
   ├── fixtures/          # Test data and fixtures
   │   ├── sample_data.json
   │   └── mock_responses.py
   └── conftest.py        # Shared test configuration

3. **Feature test placement guidelines**:

  • **New functions/classes**: `tests/unit/test_[module_name].py`
  • **API endpoints**: `tests/integration/test_[feature_name]_api.py`
  • **User workflows**: `tests/e2e/test_[feature_name]_workflow.py`
  • **Performance tests**: `tests/performance/test_[feature_name]_perf.py`

Parallel TDD Subagents

Deploy concurrent test specialists: @test-generator @qa-engineer @performance-profiler @security-reviewer

All subagents work in parallel to create comprehensive test coverage BEFORE implementation:

  • @test-generator: Design isolated unit tests, component interaction tests, and integration test suites with proper file placement in centralized test structure
  • @qa-engineer: Identify boundary conditions, edge cases, and quality validation scenarios, ensuring tests are placed in appropriate test directories
  • @performance-profiler: Create performance benchmarks and validation tests in dedicated performance test directories
  • @security-reviewer: Design security test cases and vulnerability checks, placing them in appropriate test categories

Strict TDD Process

Phase 1: RED (Write Failing Tests)

# ALWAYS start with tests that fail
def test_feature_core_functionality():
    """Test the main happy path"""
    # This MUST fail initially
    result = new_feature(valid_input)
    assert result == expected_output

def test_feature_handles_invalid_input():
    """Test error handling"""
    with pytest.raises(ValueError):
        new_feature(invalid_input)

def test_feature_edge_cases():
    """Test boundary conditions"""
    assert new_feature(edge_case_1) == expected_1
    assert new_feature(edge_case_2) == expected_2

Phase 2: Verify Failure

# Run tests to confirm they fail - use proper test path
pytest tests/unit/test_new_feature.py -v

# Expected output:
# tests/unit/test_new_feature.py::test_feature_core_functionality FAILED
# tests/unit/test_new_feature.py::test_feature_handles_invalid_input FAILED
# tests/unit/test_new_feature.py::test_feature_edge_cases FAILED

Phase 3: GREEN (Minimal Implementation)

# Write ONLY enough code to pass tests
def new_feature(input_data):
    """Minimal implementation to pass tests"""
    if not is_valid(input_data):
        raise ValueError("Invalid input")
    
    # Just enough logic to pass
    return process(input_data)

Phase 4: REFACTOR (Improve Design)

# After tests pass, improve code quality
class FeatureHandler:
    """Refactored with better design"""
    def __init__(self):
        self.validator = InputValidator()
        self.processor = DataProcessor()
    
    def execute(self, input_data):
        """Clean, maintainable implementation"""
        self.validator.validate(input_data)
        return self.processor.process(input_data)

Test Categories to Always Include

1. Functional Tests

def test_feature_produces_correct_output():
    """Core functionality works correctly"""
    pass

def test_feature_handles_various_inputs():
    """Works with different input types"""
    pass

2. Error Handling Tests

def test_feature_handles_null_input():
    """Gracefully handles None"""
    pass

def test_feature_handles_malformed_data():
    """Handles bad data gracefully"""
    pass

3. Edge Case Tests

def test_feature_with_empty_input():
    """Handles empty collections"""
    pass

def test_feature_with_maximum_values():
    """Handles boundary conditions"""
    pass

4. Performance Tests

def test_feature_performance():
    """Completes within acceptable time"""
    import time
    start = time.time()
    new_feature(large_dataset)
    assert time.time() - start < 1.0  # Under 1 second

5. Integration Tests

def test_feature_integrates_with_system():
    """Works with rest of system"""
    pass

Command Execution Flow

1. **Analyze Project Structure**

   # Detect existing test organization
   find . -name "conftest.py" -o -name "pytest.ini" -o -name "pyproject.toml"
   ls -la tests/ test/ src/tests/ 2>/dev/null || echo "No existing test dirs found"
Read more
Ships withguidance-for-claude-code-with-amazon-bedrock

This guidance enables enterprise deployment of Claude Code and Claude Cowork on Amazon Bedrock across command-line (CLI) and desktop surfaces — with secure single sign-on (SSO), usage monitoring, and cost controls.

Get the whole plugin