home / skills / willsigmon / sigstack / code-coverage-expert

code-coverage-expert skill

/plugins/testing/skills/code-coverage-expert

This skill helps you measure and improve test coverage across TypeScript projects by applying Codecov or Istanbul guidelines and CI thresholds.

npx playbooks add skill willsigmon/sigstack --skill code-coverage-expert

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

Files (1)
SKILL.md
2.7 KB
---
name: Code Coverage Expert
description: Code coverage tools - Codecov, Istanbul, coverage thresholds, CI integration
allowed-tools: Read, Edit, Bash, WebFetch
model: sonnet
---

# Code Coverage Expert

Measure and improve test coverage across your codebase.

## Tools Comparison (2026)

| Tool | Best For | Free Tier | Pricing |
|------|----------|-----------|---------|
| Codecov | Team coverage | Open source | $29/user/mo |
| Coveralls | Simple setup | Open source | $10/repo/mo |
| Istanbul/nyc | JavaScript | Free | Free |
| llvm-cov | Swift/C++ | Free | Free |

## Codecov Setup

### GitHub Actions
```yaml
- uses: codecov/codecov-action@v4
  with:
    token: ${{ secrets.CODECOV_TOKEN }}
    files: ./coverage/lcov.info
    fail_ci_if_error: true
    verbose: true
```

### Coverage Thresholds
```yaml
# codecov.yml
coverage:
  status:
    project:
      default:
        target: 80%
        threshold: 2%
    patch:
      default:
        target: 90%
```

## JavaScript/TypeScript (Istanbul)

### Setup with Jest
```json
{
  "jest": {
    "collectCoverage": true,
    "coverageThreshold": {
      "global": {
        "branches": 80,
        "functions": 80,
        "lines": 80,
        "statements": 80
      }
    }
  }
}
```

### Vitest Coverage
```typescript
// vitest.config.ts
export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      reporter: ['text', 'lcov', 'html'],
      thresholds: {
        lines: 80,
        functions: 80,
        branches: 80,
      }
    }
  }
})
```

## Swift Coverage

### Xcode Coverage
```bash
# Enable coverage in scheme
xcodebuild test \
  -scheme App \
  -enableCodeCoverage YES \
  -resultBundlePath TestResults.xcresult

# Extract report
xcrun xccov view --report TestResults.xcresult
```

### Export to Codecov
```bash
# Convert to lcov format
xcrun llvm-cov export \
  -format=lcov \
  -instr-profile coverage.profdata \
  App.app/App > coverage.lcov
```

## Coverage for Vibe Coders

### Minimum Viable Coverage
```
Core business logic: 80%+
UI code: 40-60% (visual testing preferred)
Generated code: Skip
Third-party wrappers: Skip
```

### Quick Win: Cover Critical Paths
```bash
# Find uncovered critical files
npx nyc report --reporter=text | grep -E "0%|[1-4][0-9]%"
```

## CI Integration Pattern

```yaml
jobs:
  test:
    steps:
      - run: pnpm test --coverage
      - uses: codecov/codecov-action@v4

  coverage-gate:
    needs: test
    steps:
      - run: |
          COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct')
          if (( $(echo "$COVERAGE < 80" | bc -l) )); then
            echo "Coverage below 80%!"
            exit 1
          fi
```

Use when: Setting up coverage, CI thresholds, improving test quality

Overview

This skill helps teams measure, enforce, and improve code coverage across projects using tools like Codecov, Istanbul/nyc, Vitest, and llvm-cov. It provides practical CI integration patterns, coverage-threshold examples, and platform-specific commands for JavaScript/TypeScript and Swift. Use it to catch regressions, prioritize tests for critical paths, and set realistic coverage targets for different code types.

How this skill works

The skill inspects your test output and coverage reports (lcov, coverage-summary.json, xccov) and shows how to upload to hosted services like Codecov. It explains setting global and per-patch thresholds, wiring coverage checks into CI, and converting native reports (llvm-cov/xccov) into lcov. It also recommends where to focus effort (core logic vs UI) and quick shell commands to find low-coverage files.

When to use it

  • When adding coverage reporting to CI pipelines (GitHub Actions, other CI).
  • When enforcing coverage gates for PRs or releases (project and patch thresholds).
  • When converting platform-specific reports (Xcode/llvm-cov) to lcov for upload.
  • When tuning test strategy: identify critical paths versus low-priority code.
  • When choosing between hosted services (Codecov, Coveralls) and local tools (Istanbul, llvm-cov).

Best practices

  • Set realistic targets: 80%+ for core business logic, 40–60% for UI with visual tests preferred.
  • Use patch-level thresholds higher than project defaults to prevent test debt on new code.
  • Upload lcov or native reports to Codecov using official actions and secure tokens.
  • Fail CI fast for obvious regressions but avoid blocking deploys for noncritical autogenerated code.
  • Automate coverage extraction for platform tools (xcrun/llvm-cov) so reports are consistent.

Example use cases

  • Add codecov/codecov-action to GitHub Actions and enforce a project target of 80% with a 2% threshold.
  • Configure Jest or Vitest to collect coverage and fail builds when global thresholds drop below 80%.
  • Use xcodebuild and xcrun xccov to generate Swift coverage, export to lcov, then upload to Codecov.
  • Run a CI coverage-gate job that reads coverage/coverage-summary.json and blocks the merge when lines <80%.
  • Quickly find low-coverage critical files with npx nyc report and a grep of percent values.

FAQ

Should I aim for 100% coverage?

No. Focus on meaningful coverage for core business logic. 80%+ is a practical target; UI and generated code can have lower thresholds or be skipped.

Which tool is best for JavaScript projects?

Istanbul/nyc (used by Jest) and Vitest with V8 coverage are reliable and free; use Codecov for team dashboards and historical views.