codecov-query
A CLI tool to query the Codecov API v2. Designed for both human users and LLM-driven workflows.
Unlike the official codecov-cli (which focuses on uploading coverage reports), codecov-query is a read-only tool for retrieving coverage data — totals, commits, branches, pull requests, comparisons, file reports, flags, and components.
Installation
From crates.io
From source
Pre-built binaries
Download from GitHub Releases.
Authentication
A Codecov API token is required. Provide it via:
--token <TOKEN>flag, orCODECOV_TOKENenvironment variable
Generate a token at codecov.io/account.
Usage
Auto-detection
When run inside a git repository, codecov-query automatically detects the owner and repo from the origin remote. You can override with --owner / --repo.
Output formats
--format json(default) — structured JSON, ideal for piping tojqor feeding to LLMs--format text— human-readable summary
Examples
# Coverage totals (auto-detect repo from git remote)
# Explicit owner/repo
# List repositories
# List commits
# Get a specific commit
# Branches
# Pull requests
# Compare coverage
# File-level coverage
# Flags and components
# Pipe to jq
|
Subcommands
| Subcommand | Description | Key arguments |
|---|---|---|
repos |
List repositories for an owner | --active, --search, --names |
repo |
Get repository details | — |
totals |
Coverage totals | --sha, --branch, --path, --flag, --component-id |
commits |
List commits | --branch |
commit |
Get a specific commit | positional commitid |
branches |
List branches | — |
branch |
Get a specific branch | positional name |
pulls |
List pull requests | --state, --start-date, --ordering |
pull |
Get a specific PR | positional pullid |
compare |
Compare coverage | --base + --head OR --pullid |
file-report |
File-level coverage | positional path, --sha, --branch |
flags |
List flags | — |
components |
List components | — |
All list subcommands support --page and --page-size for pagination.
Global options
| Option | Description | Default |
|---|---|---|
--token |
Codecov API token (or CODECOV_TOKEN env) |
required |
--service |
Git hosting service | github |
--owner / -o |
Repository owner | auto-detected |
--repo / -r |
Repository name | auto-detected |
--format |
Output format (json or text) |
json |
Supported services: github, gitlab, bitbucket, github-enterprise, gitlab-enterprise, bitbucket-server.