code-review
Comprehensive code review with actionable feedback using extended thinking
Fix bugs using Test-Driven Development approach with regression prevention
> /plugin marketplace add aws-solutions-library-samples/guidance-for-claude-code-with-amazon-bedrockHow it fires
How this command gets triggered: by you, by Claude, or both.
/tdd-bugfixContext preview
What this command does when you run it.
Fix bugs using Test-Driven Development approach with regression prevention
name: tdd-bugfix description: Fix bugs using Test-Driven Development approach with regression prevention version: 1.0.0 argument-hint: "[bug-description-or-issue-number]"
You are a debugging expert who uses TDD principles. ALWAYS write a failing test that reproduces the bug before fixing it.
$ARGUMENTS
If no bug description was provided above, ask the user: "What bug would you like to fix using TDD? Please provide a description or issue number."
Before creating any tests, establish the project's test directory structure:
1. **Scan for existing test structure**:
2. **Create standard structure if needed**:
tests/ ├── unit/ # Unit tests for individual functions/classes ├── integration/ # Tests for component interactions ├── e2e/ # End-to-end system tests ├── fixtures/ # Test data and fixtures └── conftest.py # Shared test configuration
3. **Place bug fix tests appropriately**:
def test_reproduces_reported_bug():
"""
Bug Report: Users can login with expired tokens
This test MUST fail to confirm bug exists
"""
expired_token = create_token(expired=True)
# This should fail but currently passes (bug!)
with pytest.raises(AuthenticationError):
authenticate_with_token(expired_token)# Confirm the bug exists - use proper test path pytest tests/unit/test_auth_module.py::test_reproduces_reported_bug -v # Expected: Test FAILS (confirming bug exists) # FAILED tests/unit/test_auth_module.py::test_reproduces_reported_bug
def test_correct_token_expiry_behavior():
"""Define correct behavior through tests"""
# Valid token should work
valid_token = create_token(expired=False)
assert authenticate_with_token(valid_token) == True
# Expired token should fail
expired_token = create_token(expired=True)
with pytest.raises(AuthenticationError):
authenticate_with_token(expired_token)
# About-to-expire token should work
almost_expired = create_token(expires_in_seconds=60)
assert authenticate_with_token(almost_expired) == True# Minimal fix to pass the test
def authenticate_with_token(token):
"""Fixed implementation"""
if token.is_expired(): # This check was missing!
raise AuthenticationError("Token expired")
return validate_token(token)def test_prevents_token_expiry_regression():
"""Comprehensive tests to prevent regression"""
# Test various expiry scenarios
test_cases = [
(create_token(expired=True), False),
(create_token(expired=False), True),
(create_token(expires_at=yesterday), False),
(create_token(expires_at=tomorrow), True),
(create_token(expires_at=now), False),
]
for token, should_pass in test_cases:
if should_pass:
assert authenticate_with_token(token)
else:
with pytest.raises(AuthenticationError):
authenticate_with_token(token)Before starting bug analysis, agents should:
1. **Detect existing test infrastructure**:
# Check for test directories find . -type d -name "test*" -o -name "*test*" | head -10 # Look for test configuration files ls -la pyproject.toml setup.py pytest.ini tox.ini # Find existing test files to follow naming patterns find . -name "test_*.py" -o -name "*_test.py" | head -5
2. **Analyze current test organization**:
3. **Create missing test structure**:
# Create standard Python test structure if missing
mkdir -p tests/{unit,integration,e2e,fixtures}
touch tests/conftest.pyDeploy concurrent debugging specialists: @code-archaeologist @business-analyst @test-generator @qa-engineer
def test_fixes_calculation_error():
"""Test for calculation bugs"""
# Bug: Total calculated incorrectly
cart = ShoppingCart()
cart.add_item(price=10, quantity=2)
cart.add_item(price=5, quantity=3)
# Should be 35, not 25 (bug!)
assert cart.total() == 35def test_handles_empty_input():
"""Test for edge case bugs"""
# Bug: CThis 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.
Comprehensive code review with actionable feedback using extended thinking
Complete architecture design and documentation workflow using simple-architect and simple-architecture-documenter agents in…
Intelligent refactoring with strategic thinking and parallel analysis
Create comprehensive documentation with intelligent type detection and orchestration
Create in-depth explanations that build conceptual understanding of complex topics
Create practical how-to guides for solving specific problems and accomplishing tasks