Analyze test coverage, identify gaps, and recommend test improvements.
Analyzes test coverage reports to identify gaps and recommend improvements. Triggers on phrases like "analyze test coverage" or "find untested code" to parse coverage data, map to requirements, and generate prioritized test recommendations.
/plugin marketplace add jmagly/ai-writing-guide/plugin install sdlc@aiwgThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Analyze test coverage, identify gaps, and recommend test improvements.
This skill provides comprehensive test coverage analysis by:
When triggered, this skill:
Locates coverage data:
Analyzes coverage metrics:
Identifies critical gaps:
Maps to requirements:
Generates recommendations:
Tracks trends:
line_coverage:
description: Percentage of code lines executed by tests
calculation: (lines_executed / total_lines) * 100
targets:
excellent: ">= 90%"
good: ">= 80%"
acceptable: ">= 70%"
poor: "< 70%"
branch_coverage:
description: Percentage of decision branches executed
calculation: (branches_taken / total_branches) * 100
targets:
excellent: ">= 85%"
good: ">= 75%"
acceptable: ">= 65%"
poor: "< 65%"
importance: Critical for logic paths
function_coverage:
description: Percentage of functions called by tests
calculation: (functions_called / total_functions) * 100
targets:
excellent: ">= 95%"
good: ">= 90%"
acceptable: ">= 80%"
poor: "< 80%"
statement_coverage:
description: Percentage of statements executed
calculation: (statements_executed / total_statements) * 100
note: Similar to line coverage but counts multi-statement lines
# Test Coverage Analysis Report
**Date**: 2025-12-08
**Project**: User Service
**Analyzer**: test-coverage skill
## Executive Summary
| Metric | Current | Target | Status |
|--------|---------|--------|--------|
| Line Coverage | 78.5% | 80% | ⚠️ Below Target |
| Branch Coverage | 72.3% | 75% | ⚠️ Below Target |
| Function Coverage | 91.2% | 90% | ✅ Meets Target |
| Files with 0% | 3 | 0 | ❌ Action Required |
**Overall Assessment**: Coverage below targets in 2 of 4 metrics. Focus on branch coverage and untested files.
## Coverage by Component
| Component | Lines | Branches | Functions | Trend |
|-----------|-------|----------|-----------|-------|
| src/auth/ | 92% | 88% | 100% | ↑ +2% |
| src/user/ | 85% | 78% | 95% | → 0% |
| src/api/ | 76% | 68% | 88% | ↓ -3% |
| src/utils/ | 65% | 55% | 82% | → 0% |
| src/db/ | 58% | 45% | 75% | ↓ -5% |
## Critical Gaps
### Priority 1: Untested Files
Files with 0% coverage that require immediate attention:
| File | Lines | Risk | Action |
|------|-------|------|--------|
| src/db/migrations.ts | 145 | High | Add migration tests |
| src/api/webhooks.ts | 89 | High | Add webhook handler tests |
| src/utils/retry.ts | 42 | Medium | Add retry logic tests |
### Priority 2: Low-Coverage Critical Paths
Business-critical code with insufficient coverage:
| File | Current | Target | Gap | Critical Path |
|------|---------|--------|-----|---------------|
| src/auth/oauth.ts | 55% | 90% | 35% | User authentication |
| src/api/payments.ts | 62% | 90% | 28% | Payment processing |
| src/user/permissions.ts | 68% | 85% | 17% | Authorization |
### Priority 3: Branch Coverage Gaps
Files with low branch coverage (complex logic undertested):
| File | Branch % | Uncovered Branches | Example |
|------|----------|-------------------|---------|
| src/api/router.ts | 45% | 12 | Error handling paths |
| src/utils/validator.ts | 52% | 8 | Edge case validations |
| src/db/query-builder.ts | 48% | 15 | Query variations |
## Uncovered Code Analysis
### src/auth/oauth.ts (55% line coverage)
Lines not covered:
Recommended tests:
### src/api/payments.ts (62% line coverage)
Lines not covered:
Recommended tests:
## Requirements Coverage
Cross-reference with traceability data:
| Requirement | Test Coverage | Status |
|-------------|---------------|--------|
| UC-001: User Login | 95% | ✅ Covered |
| UC-002: User Registration | 88% | ✅ Covered |
| UC-003: Password Reset | 45% | ⚠️ Partial |
| UC-004: OAuth Login | 55% | ⚠️ Partial |
| REQ-001: Input Validation | 78% | ⚠️ Partial |
| NFR-001: Performance | 30% | ❌ Insufficient |
## Test Recommendations
### High Priority (This Sprint)
| # | Test to Add | File | Est. Effort | Coverage Gain |
|---|-------------|------|-------------|---------------|
| 1 | OAuth token refresh tests | oauth.test.ts | 2h | +15% |
| 2 | Payment retry scenarios | payments.test.ts | 3h | +12% |
| 3 | Migration execution tests | migrations.test.ts | 4h | +100% (new) |
| 4 | Webhook handler tests | webhooks.test.ts | 2h | +100% (new) |
### Medium Priority (Next Sprint)
| # | Test to Add | File | Est. Effort | Coverage Gain |
|---|-------------|------|-------------|---------------|
| 5 | Permission edge cases | permissions.test.ts | 2h | +8% |
| 6 | Router error paths | router.test.ts | 3h | +20% branch |
| 7 | Validation edge cases | validator.test.ts | 2h | +15% branch |
### Projected Impact
If all high-priority tests added:
- Line coverage: 78.5% → 85.2% (+6.7%)
- Branch coverage: 72.3% → 79.1% (+6.8%)
- Untested files: 3 → 1
## Coverage Trends
### Last 30 Days
Week 1: 82.1% ────────────────────────── Week 2: 80.5% ──────────────────────── Week 3: 79.2% ────────────────────── Week 4: 78.5% ───────────────────── ↓ Declining trend
### By Sprint
| Sprint | Coverage | Change | Notes |
|--------|----------|--------|-------|
| Sprint 10 | 82.1% | - | Baseline |
| Sprint 11 | 80.5% | -1.6% | New auth module |
| Sprint 12 | 79.2% | -1.3% | Payment integration |
| Sprint 13 | 78.5% | -0.7% | API expansion |
**Trend Analysis**: Coverage declining due to new feature velocity without proportional test additions. Recommend test-first approach for new features.
## Action Plan
### Immediate (This Week)
- [ ] Add OAuth token refresh tests
- [ ] Add payment retry tests
- [ ] Set up coverage gates in CI (minimum 80%)
### Short-term (This Sprint)
- [ ] Create migration test suite
- [ ] Create webhook test suite
- [ ] Address UC-003 and UC-004 coverage gaps
### Ongoing
- [ ] Require tests with new feature PRs
- [ ] Weekly coverage review in standup
- [ ] Quarterly coverage target adjustment
## Configuration
Coverage thresholds for CI gates:
```yaml
coverage_gates:
global:
lines: 80
branches: 75
functions: 90
statements: 80
per_file:
lines: 70
branches: 65
new_code:
lines: 90
branches: 85
## Usage Examples
### Full Coverage Analysis
User: "Analyze test coverage"
Skill executes:
Output: "Test Coverage Analysis Complete
Overall: 78.5% line, 72.3% branch
Status: ⚠️ Below targets
Critical Findings:
Top Recommendations:
Report: .aiwg/testing/coverage-analysis.md"
### Find Untested Code
User: "What's not tested in auth module?"
Skill analyzes:
Output: "Auth Module Coverage: 92% lines, 88% branches
Untested Code:
oauth.ts (lines 45-67)
oauth.ts (lines 89-112)
session.ts (lines 134-145)
Recommended Test Additions:
### Coverage Trend
User: "Coverage report over time"
Skill returns: "Coverage Trend (Last 4 Sprints):
Sprint 10: 82.1% ██████████████████████ Sprint 11: 80.5% █████████████████████ Sprint 12: 79.2% ████████████████████ Sprint 13: 78.5% ███████████████████ ↓ Declining (-3.6%)
Cause: New feature velocity outpacing test additions
Recommendation:
## Integration
This skill uses:
- `traceability-check`: Map coverage to requirements
- `project-awareness`: Identify test conventions
- `artifact-metadata`: Track coverage reports
## Agent Orchestration
```yaml
agents:
analysis:
agent: test-architect
focus: Coverage analysis and strategy
implementation:
agent: test-engineer
focus: Test recommendations and implementation
review:
agent: code-reviewer
focus: Coverage quality assessment
coverage_tools:
javascript:
- istanbul/nyc: coverage/lcov.info
- jest: coverage/coverage-final.json
- c8: coverage/lcov.info
python:
- coverage.py: .coverage, coverage.xml
- pytest-cov: coverage.xml
java:
- jacoco: target/site/jacoco/jacoco.xml
- cobertura: target/site/cobertura/coverage.xml
go:
- go test: coverage.out
priority_factors:
critical_path:
weight: 3
paths: [auth, payments, permissions]
recent_changes:
weight: 2
lookback: 30 days
complexity:
weight: 1.5
metric: cyclomatic_complexity
bug_history:
weight: 2
source: issue_tracker
.aiwg/testing/coverage/.aiwg/testing/coverage-analysis.md.aiwg/testing/coverage-trends.json.aiwg/testing/coverage-recommendations.mdThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.