acc-analyze-test-coverage
Analyzes PHP codebase for test coverage gaps. Detects untested classes, methods, branches, exception paths, and edge cases. Provides actionable recommendations.
Best use case
acc-analyze-test-coverage is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Analyzes PHP codebase for test coverage gaps. Detects untested classes, methods, branches, exception paths, and edge cases. Provides actionable recommendations.
Teams using acc-analyze-test-coverage should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/acc-analyze-test-coverage/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How acc-analyze-test-coverage Compares
| Feature / Agent | acc-analyze-test-coverage | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Analyzes PHP codebase for test coverage gaps. Detects untested classes, methods, branches, exception paths, and edge cases. Provides actionable recommendations.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Test Coverage Analysis
Analyzes PHP codebase to identify untested code and coverage gaps.
## Detection Patterns
### 1. Classes Without Tests
```bash
# Find all PHP classes in src/
Glob: src/**/*.php
# Find all test files
Glob: tests/**/*Test.php
# Compare: class Foo in src/ should have FooTest in tests/
```
**Pattern Matching:**
```
src/Domain/User/User.php → tests/Unit/Domain/User/UserTest.php
src/Application/PlaceOrder/PlaceOrderHandler.php → tests/Unit/Application/PlaceOrder/PlaceOrderHandlerTest.php
```
### 2. Methods Without Tests
```php
// For each public method in class
Grep: "public function [a-z]" --glob "src/**/*.php"
// Check if test method exists
Grep: "test_methodName" --glob "tests/**/*Test.php"
```
**Detection Logic:**
```
Class: Order
├── confirm() → test_confirm_* exists? ✅/❌
├── cancel() → test_cancel_* exists? ✅/❌
├── ship() → test_ship_* exists? ✅/❌
└── addItem() → test_addItem_* / test_add_item_* exists? ✅/❌
```
### 3. Branches Not Covered
**If/Else Branches:**
```php
// Source code
public function process(Order $order): void
{
if ($order->isPending()) { // Branch 1: pending
$this->processPending($order);
} elseif ($order->isConfirmed()) { // Branch 2: confirmed
$this->processConfirmed($order);
} else { // Branch 3: other
throw new InvalidStateException();
}
}
// Required tests:
// - test_process_when_pending_*
// - test_process_when_confirmed_*
// - test_process_when_other_throws_exception
```
**Switch Statements:**
```php
// Source code
match ($status) {
'pending' => $this->handlePending(),
'confirmed' => $this->handleConfirmed(),
'shipped' => $this->handleShipped(),
default => throw new UnexpectedValueException(),
};
// Required tests: one per case + default
```
### 4. Exception Paths
```php
// Detect throw statements
Grep: "throw new" --glob "src/**/*.php"
// Each throw should have corresponding test with expectException
```
**Example:**
```php
// Source
public function withdraw(Money $amount): void
{
if ($amount->greaterThan($this->balance)) {
throw new InsufficientFundsException(); // Line 15
}
}
// Required test
public function test_withdraw_throws_for_insufficient_funds(): void
{
$this->expectException(InsufficientFundsException::class);
// ...
}
```
### 5. Edge Cases
| Type | Values to Test | Detection |
|------|---------------|-----------|
| **Null** | `null` input | Parameters without type hint or nullable |
| **Empty** | `[]`, `''`, `0` | Collection/string/numeric parameters |
| **Boundary** | min, max, min-1, max+1 | Constants, validation limits |
| **Unicode** | `'émoji 🎉'` | String parameters |
| **Concurrent** | Race conditions | Shared state, repositories |
**Detection Patterns:**
```php
// Nullable parameters
Grep: "\?[A-Z]" --glob "src/**/*.php" // ?Type
Grep: "null\|" --glob "src/**/*.php" // Type|null
// Collections
Grep: "array \$" --glob "src/**/*.php"
Grep: "iterable" --glob "src/**/*.php"
// Numeric limits
Grep: "const MAX_" --glob "src/**/*.php"
Grep: "const MIN_" --glob "src/**/*.php"
```
## Analysis Process
### Phase 1: Inventory
1. List all production classes:
```
Glob: src/**/*.php
```
2. List all test classes:
```
Glob: tests/**/*Test.php
```
3. Build mapping:
```
ProductionClass → [TestClass, TestClass]
```
### Phase 2: Class Coverage
For each production class:
1. Check if corresponding test exists
2. Calculate: `covered_classes / total_classes * 100`
### Phase 3: Method Coverage
For each public method:
1. Extract method names from production code
2. Search for `test_{method}` patterns in tests
3. Calculate: `tested_methods / total_methods * 100`
### Phase 4: Branch Coverage
For each conditional:
1. Count branches (if/elseif/else, match cases)
2. Search for tests covering each branch
3. Report uncovered branches
### Phase 5: Edge Cases
1. Identify nullable/optional parameters
2. Identify collections
3. Identify numeric limits
4. Check if edge case tests exist
## Output Format
```markdown
# Test Coverage Analysis Report
## Summary
| Metric | Value | Target |
|--------|-------|--------|
| Class Coverage | 75% | 90% |
| Method Coverage | 60% | 80% |
| Branch Coverage | 45% | 70% |
## Untested Classes
| Class | Location | Priority |
|-------|----------|----------|
| `PaymentProcessor` | src/Domain/Payment/ | High |
| `EmailNotifier` | src/Infrastructure/ | Medium |
## Untested Methods
| Class | Method | Reason |
|-------|--------|--------|
| `Order` | `splitShipment()` | No test found |
| `User` | `resetPassword()` | Only happy path tested |
## Uncovered Branches
| File | Line | Branch | Missing Test |
|------|------|--------|--------------|
| Order.php | 45 | else (cancelled) | test_ship_when_cancelled |
| User.php | 23 | null check | test_with_null_email |
## Missing Edge Cases
| Class | Method | Edge Case |
|-------|--------|-----------|
| `Cart` | `addItem()` | Empty cart, max items |
| `Money` | `add()` | Zero amount, overflow |
## Action Items
### Critical (Must Have)
1. Add `PaymentProcessorTest` — handles money
2. Add `test_order_ship_when_cancelled` — business rule
### High Priority
1. Add null checks for `User::resetPassword()`
2. Add boundary tests for `Cart::addItem()`
### Recommended Skills
| Gap | Skill | Action |
|-----|-------|--------|
| Missing unit test | `acc-create-unit-test` | Generate test class |
| Missing integration test | `acc-create-integration-test` | Generate DB test |
| Need test data | `acc-create-test-builder` | Generate builder |
```
## Severity Levels
| Level | Coverage | Action |
|-------|----------|--------|
| **Critical** | <50% | Immediate attention |
| **Warning** | 50-70% | Prioritize improvement |
| **Good** | 70-90% | Monitor and maintain |
| **Excellent** | >90% | Focus on edge cases |
## Integration with Generator
After analysis, recommend using:
- `acc-create-unit-test` — for missing unit tests
- `acc-create-integration-test` — for missing integration tests
- `acc-create-test-builder` — for complex test data
- `acc-create-mock-repository` — for repository testsRelated Skills
acc-detect-test-smells
Detects test antipatterns and code smells in PHP test suites. Identifies 15 smells (Logic in Test, Mock Overuse, Fragile Tests, Mystery Guest, etc.) with fix recommendations and refactoring patterns for testability.
acc-create-unit-test
Generates PHPUnit unit tests for PHP 8.5. Creates isolated tests with AAA pattern, proper naming, attributes, and one behavior per test. Supports Value Objects, Entities, Services.
acc-create-test-double
Generates test doubles (Mocks, Stubs, Fakes, Spies) for PHP 8.5. Creates appropriate double type based on testing needs with PHPUnit MockBuilder patterns.
ab-testing
Use when designing experiments for subject lines, offers, cadences, or journeys.
ab-testing-statistician
Expert in statistical analysis for blind A/B and ABX audio testing. Validates randomization, calculates statistical significance, and ensures proper experimental design. Use when implementing A/B test features or analyzing test results.
ab-test-setup
Structured guide for setting up A/B tests with mandatory gates for hypothesis, metrics, and execution readiness.
ab-test-calculator
Calculate statistical significance for A/B tests. Sample size estimation, power analysis, and conversion rate comparisons with confidence intervals.
A/B Test Analysis
Design and analyze A/B tests, calculate statistical significance, and determine sample sizes for conversion optimization and experiment validation
60-validate-tests-150
[60] VALIDATE. Ensure new (staged and unstaged) changes are covered by tests at >70% and the full test suite is green. Use when asked to validate coverage for recent changes, add tests for modified code, or verify nothing else broke.
analyze-prd
Analyze existing PRDs to generate actionable implementation plans, risk assessments, and resource estimates
a-b-testing
The science of learning through controlled experimentation. A/B testing isn't about picking winners—it's about building a culture of validated learning and reducing the cost of being wrong. This skill covers experiment design, statistical rigor, feature flagging, analysis, and building experimentation into product development. The best experimenters know that every test, positive or negative, teaches something valuable. Use when "a/b test, experiment, hypothesis, statistical significance, sample size, feature flag, variant, control, treatment, p-value, conversion rate, test winner, split test, experimentation, testing, statistics, feature-flags, hypothesis, growth, optimization, learning, validation" mentioned.
Analyze Regressions
Grade component health based on regression triage metrics for OpenShift releases