---
roadcrew_template_name: "analyze-test-coverage.md"
roadcrew_template_type: "command"
execution_mode: "auto-execute"
roadcrew_template_version: "v1.0"
roadcrew_last_updated: "2025-10-25"
roadcrew_min_version: "1.5.0"
roadcrew_license: "See LICENSE file in .roadcrew folder"
roadcrew_copyright: "Copyright (c) 2025 North Star Holdings, LLC"
spdx_license_identifier: "LicenseRef-RoadcrewLicense-1.0"
---

# analyze-test-coverage

Automatically identify untested code paths and dead code to prioritize test generation efforts.

## Usage

```bash
/analyze-test-coverage [--min-coverage N] [--files pattern]
```

## What This Command Does

Analyzes test coverage reports to identify:
- **Untested Functions** - Functions with 0% coverage
- **Partially Tested** - Branches not covered
- **Dead Code** - Unreachable paths in codebase
- **Coverage Gaps** - Files/modules below minimum threshold
- **Prioritized Gap List** - Ranked by impact and effort

Generates coverage report with prioritized test gaps.

## Output Format

```bash
$ /analyze-test-coverage --min-coverage 80

📊 Test Coverage Analysis: roadcrew-internal

Coverage Report: coverage/lcov.info | Baseline: 62%

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 COVERAGE SUMMARY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Overall Coverage: 62% (Target: 80%)
- ✅ Lines: 1,847 / 2,400 (77%)
- ✅ Branches: 156 / 340 (46%)
- ⚠️ Functions: 89 / 127 (70%)

Files Below Threshold (80%):
- 23 files need more test coverage

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚨 UNTESTED CODE (0% Coverage)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

File 1: scripts/core/github-issue-creator.ts
- Functions: 4 untested
  - createIssuesInBatch() - 145-295 lines
  - validateIssueLinks() - 298-340 lines
  - etc.
- Branches: 12 untested paths

File 2: scripts/utils/issue-parser.ts
- Functions: 2 untested
- Branches: 5 untested paths

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ LOW COVERAGE (<70%)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[List of files with coverage <70%]

📊 Full report: config/reports/coverage-analysis-2025-10-29.md
🔗 Generate tests for gaps?
   Run: /generate-test-cases --coverage-gaps
```

## Flags & Options

```bash
--min-coverage N                # Report files below coverage threshold
--files pattern                 # Analyze specific files only
--show-dead-code                # Identify unreachable code
--generate-stubs                # Generate test stubs for gaps
```
