Analyzes code to identify untested functions, low coverage areas, and missing edge cases. Use when reviewing test coverage or planning test improvements. Generates specific test suggestions with example templates following amplihack's testing pyramid (60% unit, 30% integration, 10% E2E). Can use coverage.py for Python projects.
This skill automatically analyzes codebases to identify untested functions, low coverage areas, and missing edge case tests. It generates actionable test suggestions organized by priority and risk impact, following amplihack's testing pyramid (60% unit, 30% integration, 10% E2E).
Tests should follow this distribution:
This skill helps balance tests across these layers while prioritizing coverage.
The skill identifies gaps in these areas:
The analyzer:
For each function/method:
Classify gaps by:
For each gap, generate:
Organize suggestions by:
.coverage files (Python)Provides ready-to-use test templates for:
User: Analyze test coverage gaps in my src/ directory
Claude:
1. Scans src/ for all Python files
2. Reads .coverage or uses ast analysis
3. Identifies untested functions
4. Generates gap report with suggestions
Output:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Test Gap Analysis Report
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Summary:
- Total functions: 145
- Untested: 23 (16%)
- Low coverage (< 85%): 34 (23%)
CRITICAL GAPS (High Risk):
1. payment_processor.py::process_payment()
- Untested | Handles money | 15 min effort
- Suggested tests:
- Valid payment processing
- Insufficient funds error
- Payment timeout
- Currency conversion
MEDIUM GAPS:
2. user_service.py::validate_email()
- 40% coverage | Missing edge cases
- Suggested tests:
- Unicode characters
- Long email addresses
- Special characters
LOW GAPS:
3. utils.py::format_date()
- 60% coverage
- Suggested tests:
- Timezone handling
- Daylight saving transitions
User: Generate test templates for my untested auth module
Claude:
Creates templates organized by testing pyramid:
Unit Tests (60%):
- test_token_validation_valid()
- test_token_validation_expired()
- test_token_validation_invalid_signature()
Integration Tests (30%):
- test_auth_flow_with_database()
- test_multi_user_concurrent_auth()
E2E Tests (10%):
- test_user_login_to_protected_resource()
- test_session_persistence_across_requests()
User: Help me improve test coverage from 65% to 85%
Claude:
1. Analyzes current coverage
2. Identifies gaps blocking 85% threshold
3. Prioritizes by impact
4. Estimates effort
Output:
To reach 85% coverage:
- 12 quick wins (< 2 hours each)
- 3 medium tasks (2-4 hours each)
- 2 complex tasks (4+ hours each)
Recommended order:
1. Add error case tests (5 tests, 3 hours) -> +8%
2. Cover auth edge cases (8 tests, 4 hours) -> +6%
3. Add integration tests (12 tests, 6 hours) -> +7%
# Test Gap Analysis Report
## Summary
- Total functions: N
- Untested functions: N (X%)
- Functions < 85%: N (X%)
- Average coverage: X%
## Critical Gaps (Must Test)
1. Function name | Type | Priority | Effort
Suggested tests: [list]
## Medium Priority Gaps
[Similar structure]
## Low Priority Gaps
[Similar structure]
## Testing Pyramid Distribution
Current:
- Unit: X% | Target: 60%
- Integration: X% | Target: 30%
- E2E: X% | Target: 10%
## Test Templates
[Ready-to-use test code]
## Effort Estimate
- Quick wins: N hours
- Medium tasks: N hours
- Complex work: N hours
- Total: N hours
def test_function_name_happy_path():
"""Test function with valid inputs."""
# Arrange
input_data = {...}
expected = {...}
# Act
result = function_name(input_data)
# Assert
assert result == expected
def test_function_name_invalid_input():
"""Test function raises ValueError on invalid input."""
with pytest.raises(ValueError, match="Expected error message"):
function_name(invalid_input)
def test_function_name_edge_case():
"""Test function handles edge case correctly."""
# Test boundary conditions
result = function_name(boundary_value)
assert result is not None
def test_user_service_with_database(test_db):
"""Test user service with real database."""
user_service = UserService(test_db)
user = user_service.create_user("test@example.com")
assert user.id is not None
User: Quick test coverage review of api/
Claude:
- Scans directory
- Identifies top 5 gaps
- Provides quick recommendations
- Total time: < 2 minutes
User: Plan test coverage improvement from 60% to 85%
Claude:
- Analyzes gaps
- Creates phased improvement plan
- Prioritizes by risk
- Provides effort estimates
- Generates all test templates
User: Generate complete test plan for new auth module
Claude:
- Analyzes module structure
- Maps public functions
- Creates test suggestions
- Balances testing pyramid
- Provides all templates
After analysis, verify:
Test behavior, not how the code works. Details can change.
Be specific: "Test empty string" not "Test edge cases"
Don't just test functions in isolation. Test how they work together.
Every error condition should have at least one test.
Mock external systems, but test the integration points.
A good test gap analysis:
# Generate coverage report
coverage run -m pytest
coverage json # Creates coverage.json
# Analyze gaps with this skill
Claude: Analyze test gaps in my project using coverage.json
# Generate coverage report
jest --coverage
# Analyze gaps
Claude: Analyze test gaps in my TypeScript project
Project Stats:
- 156 functions
- 52% test coverage
- Unknown untested functions
- Scattered test files
Gap Report:
- 24 untested functions (15%)
- 34 functions < 85% (22%)
- 12 critical gaps (high impact)
- 45 medium gaps (medium impact)
- 40 low gaps (low priority)
Recommendations:
1. Focus on critical gaps (payment, auth, data)
2. Add error case tests (20 tests, 8 hours)
3. Cover edge cases (15 tests, 6 hours)
4. Integration tests (12 tests, 10 hours)
Result after implementing:
- 89% test coverage
- All critical functions tested
- Balanced testing pyramid
- Improved confidence in refactoring
After gap analysis:
Effective test gap analysis results in:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer