home / skills / proffesor-for-testing / agentic-qe / qe-coverage-analysis

qe-coverage-analysis skill

/v3/assets/skills/qe-coverage-analysis

This skill performs sublinear, risk-weighted QE coverage analysis to identify gaps and prioritize tests based on code criticality.

npx playbooks add skill proffesor-for-testing/agentic-qe --skill qe-coverage-analysis

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.2 KB
---
name: "QE Coverage Analysis"
description: "O(log n) sublinear coverage gap detection with risk-weighted analysis and intelligent test prioritization."
---

# QE Coverage Analysis

## Purpose

Guide the use of v3's advanced coverage analysis capabilities including sublinear gap detection algorithms, risk-weighted coverage scoring, and intelligent test prioritization based on code criticality.

## Activation

- When analyzing test coverage
- When identifying coverage gaps
- When prioritizing testing effort
- When setting coverage targets
- When assessing code risk

## Quick Start

```bash
# Analyze coverage with gap detection
aqe coverage analyze --source src/ --tests tests/

# Find high-risk uncovered code
aqe coverage gaps --risk-weighted --threshold 80

# Generate coverage report
aqe coverage report --format html --output coverage-report/

# Compare coverage between branches
aqe coverage diff --base main --head feature-branch
```

## Agent Workflow

```typescript
// Comprehensive coverage analysis
Task("Analyze coverage gaps", `
  Perform O(log n) coverage analysis on src/:
  - Calculate statement, branch, function coverage
  - Identify uncovered critical paths
  - Risk-weight gaps by code complexity and change frequency
  - Recommend tests to write for maximum coverage impact
`, "qe-coverage-specialist")

// Risk-based prioritization
Task("Prioritize coverage effort", `
  Analyze coverage gaps and prioritize by:
  - Business criticality (payment, auth, data)
  - Code complexity (cyclomatic > 10)
  - Recent bug history
  - Change frequency
  Output prioritized list of files needing tests.
`, "qe-coverage-analyzer")
```

## Analysis Strategies

### 1. Sublinear Gap Detection

```typescript
await coverageAnalyzer.detectGaps({
  algorithm: 'sublinear',  // O(log n) complexity
  source: 'src/**/*.ts',
  metrics: ['statement', 'branch', 'function'],
  sampling: {
    enabled: true,
    confidence: 0.95,
    maxSamples: 1000
  }
});
```

### 2. Risk-Weighted Coverage

```typescript
await coverageAnalyzer.riskWeightedAnalysis({
  coverage: coverageReport,
  riskFactors: {
    complexity: { weight: 0.3, threshold: 10 },
    changeFrequency: { weight: 0.25, window: '90d' },
    bugHistory: { weight: 0.25, window: '180d' },
    criticality: { weight: 0.2, tags: ['payment', 'auth'] }
  },
  output: {
    riskScore: true,
    prioritizedGaps: true
  }
});
```

### 3. Differential Coverage

```typescript
await coverageAnalyzer.diffCoverage({
  base: 'main',
  head: 'feature-branch',
  requirements: {
    newCode: 80,           // New code must have 80% coverage
    modifiedCode: 'maintain',  // Don't decrease existing
    deletedCode: 'ignore'
  }
});
```

## Coverage Thresholds

```yaml
thresholds:
  global:
    statements: 80
    branches: 75
    functions: 85
    lines: 80

  per_file:
    min_statements: 70
    critical_paths: 90

  new_code:
    statements: 85
    branches: 80

  exceptions:
    - path: "src/migrations/**"
      reason: "Database migrations"
    - path: "src/generated/**"
      reason: "Auto-generated code"
```

## Coverage Report

```typescript
interface CoverageAnalysis {
  summary: {
    statements: { covered: number; total: number; percentage: number };
    branches: { covered: number; total: number; percentage: number };
    functions: { covered: number; total: number; percentage: number };
  };
  gaps: {
    file: string;
    uncoveredLines: number[];
    uncoveredBranches: BranchInfo[];
    riskScore: number;
    suggestedTests: string[];
  }[];
  trends: {
    period: string;
    coverageChange: number;
    newGaps: number;
    closedGaps: number;
  };
  recommendations: {
    priority: 'critical' | 'high' | 'medium' | 'low';
    file: string;
    action: string;
    expectedImpact: number;
  }[];
}
```

## Quality Gates

```yaml
quality_gates:
  coverage:
    block_merge:
      - new_code_coverage < 80
      - coverage_regression > 5
      - critical_path_uncovered

    warn:
      - overall_coverage < 75
      - branch_coverage < 70

    metrics:
      - track_trends: true
      - alert_on_decline: 3  # consecutive PRs
```

## Coordination

**Primary Agents**: qe-coverage-specialist, qe-coverage-analyzer, qe-gap-detector
**Coordinator**: qe-coverage-coordinator
**Related Skills**: qe-test-generation, qe-quality-assessment

Overview

This skill provides O(log n) sublinear coverage gap detection with risk-weighted scoring and intelligent test prioritization. It identifies high-impact uncovered code paths, ranks gaps by business and technical risk, and recommends focused tests to maximize coverage improvement. The goal is fast, actionable coverage insights that guide where to invest testing effort.

How this skill works

The skill samples source code and coverage reports using a sublinear detection algorithm to quickly surface likely gaps across large codebases. It computes risk scores by combining complexity, change frequency, bug history, and business criticality, then prioritizes gaps and suggests tests that will yield the largest coverage and risk reduction. It can also diff coverage between branches and enforce differential quality gates for new or modified code.

When to use it

  • When you need fast detection of coverage gaps in very large repositories
  • When prioritizing testing work by business or technical risk
  • When enforcing differential coverage requirements for feature branches
  • When setting or evaluating coverage targets and quality gates
  • When generating prioritized, actionable test recommendations

Best practices

  • Start with well-scoped risk factors: complexity, recent changes, and known hot spots
  • Run sampling-based analysis in CI for quick feedback, then full analysis on demand
  • Set stricter thresholds for new code and critical paths, looser for generated or migration files
  • Integrate differential checks into PR pipelines to block regressions early
  • Use suggested tests as starting points; pair with test-generation agents for automation

Example use cases

  • Quickly find high-risk uncovered files before a release and produce a prioritized test list
  • Block merges when new code coverage drops below a threshold while allowing overall coverage to evolve
  • Compare coverage between main and feature branches to enforce new-code standards
  • Weight uncovered gaps by recent bug history to focus regression-prevention tests
  • Generate a coverage report that includes risk scores and suggested test actions for QA teams

FAQ

How fast is the gap detection on large codebases?

Sublinear (O(log n)) sampling provides quick, probabilistic detection of likely gaps; full analysis is available but runs slower for complete certainty.

Can I customize the risk weights and thresholds?

Yes—risk factors, weights, sampling confidence, and coverage thresholds are configurable to match your product risk model and CI requirements.