Skip to content

Configuration

coverctl uses a YAML configuration file (default: .coverctl.yaml) to define coverage policies.

By default, coverctl looks for .coverctl.yaml in the current directory. If not found, it searches parent directories automatically (useful for monorepos).

Terminal window
# Use custom config path
coverctl check -c config/coverage.yaml
# Auto-detects from current or parent directories
cd packages/mypackage && coverctl check

coverctl searches for these files in order:

  1. .coverctl.yaml
  2. .coverctl.yml
  3. coverctl.yaml
  4. coverctl.yml
version: 1
policy:
default:
min: 75
domains:
- name: core
match: ["./internal/core/..."]
min: 85
exclude:
- "**/generated/**"

Required. Schema version for future compatibility.

version: 1

Inherit configuration from a parent file. Useful for monorepos where packages share common policies.

packages/api/.coverctl.yaml
extends: ../../.coverctl.yaml # Path relative to this config file
policy:
domains:
- name: api
match: ["./..."]
min: 90 # Override parent threshold

Child configs override parent values. See Monorepo Support for details.

Coverage policy configuration. See Policies.

policy:
default:
min: 75
domains:
- name: core
match: ["./internal/core/..."]
min: 85

Glob patterns for files to exclude from coverage. See Domains.

exclude:
- "**/generated/**"
- "**/mocks/**"
- "**/*_test.go"

Per-file coverage rules. See Policies.

files:
- match: ["internal/core/*.go"]
min: 90

Diff-based coverage mode. See Advanced.

diff:
enabled: true
base: origin/main

Integration test coverage. See Advanced.

integration:
enabled: true
packages: ["./internal/integration/..."]
run_args: ["-test.run", "TestIntegration"]

Profile merging. See Advanced.

merge:
profiles:
- ".cover/unit.out"
- ".cover/integration.out"

Code annotation support. See Advanced.

annotations:
enabled: true
version: 1
policy:
default:
min: 75
domains:
- name: core
match: ["./internal/core/..."]
min: 85
- name: api
match: ["./internal/api/..."]
min: 80
- name: infrastructure
match: ["./internal/infrastructure/..."]
min: 70
- name: cli
match: ["./cmd/..."]
min: 75
files:
- match: ["internal/core/critical/*.go"]
min: 95
exclude:
- "**/generated/**"
- "**/mocks/**"
- "**/testdata/**"
diff:
enabled: false
base: origin/main
integration:
enabled: false
packages: ["./internal/integration/..."]
run_args: []
cover_dir: ".cover/integration"
profile: ".cover/integration.out"
merge:
profiles: []
annotations:
enabled: true

A JSON schema is available at schemas/coverctl.schema.json for editor integration:

# yaml-language-server: $schema=./schemas/coverctl.schema.json
version: 1
...