Skip to main content
skill CX Codex

dart-test-coverage — Claude Code skill for Dart test coverage

Run Dart test coverage, inspect missed lines, and identify code that needs tests. Useful when checking which parts of a package remain untested.

Apache-2.0 163 installs ★ 149 updated 2026-10-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add kevmoo/dash_skills --skill dart-test-coverage -a claude-code
Open on GitHub

What dart-test-coverage does

The skill starts by checking that dart test passes, then collects data with dart test --coverage=.dart_tool/coverage. It can interpret the results with interpret_coverage.dart or coverage:format_coverage, which displays hit counts beside source lines. For conditional paths, it also describes using --branch-coverage.

The workflow connects missed line numbers to functions or code blocks and suggests concrete tests. Fix failing tests before collecting coverage. Focus on files under lib/; generated files, test files, and maintenance scripts are outside its normal coverage focus. Keep .dart_tool/coverage out of commits.

What it helps with

  • collect coverage data for a Dart package
  • locate files and lines missed by tests
  • interpret coverage output for a package
  • identify functions that need test cases
  • add tests for uncovered branches

Example prompts for the agent

  • Check my Dart tests, collect coverage, and point out missed lines.
  • Analyze .dart_tool/coverage for the package named in pubspec.yaml.
  • Check branch coverage and suggest tests for uncovered functions under lib/.

How to install dart-test-coverage

1Skills CLI (Vercel)

npx skills add kevmoo/dash_skills --skill dart-test-coverage -a claude-code

2Manually: put the files in place

~/.claude/skills/dart-test-coverage/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/dart-test-coverage/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about dart-test-coverage

How do I install dart-test-coverage in Claude Code?

Run npx skills add kevmoo/dash_skills --skill dart-test-coverage -a claude-code. The skill file is at ~/.claude/skills/dart-test-coverage/SKILL.md.

What does dart-test-coverage do?

It guides an agent through collecting Dart test coverage, finding missed lines, and deciding which library code needs tests.

Should I run the tests before collecting coverage?

Yes. Run dart test first and fix any failing tests before collecting coverage data.

Source text

SKILL.md · Apache-2.0
---
name: dart-test-coverage
description: |-
  Understand and improve test coverage in a Dart package.
  Helps agents run coverage, interpret results, and identify missed lines.
key_features:
  - LCOV report collection
  - Missed line identification
  - Coverage analysis & improvement
---

# Dart Test Coverage

Guidelines for running and interpreting test coverage in Dart packages.

## When to use this skill

- When asked to "check test coverage" or "improve coverage".
- When you need to identify which parts of a library are untested.

### When NOT to use (Abstention Guardrails)

Do NOT collect or demand test coverage for:

- **Generated Code**: Code generated by builders (`*.g.dart`, `*.freezed.dart`,
  protobufs).
- **Platform-Specific FFI / OS Entrypoints**: Low-level platform bindings or
  entrypoints that require specific physical hardware or OS services not
  available in the execution environment.
- **Example Applications & Tool Scripts**: Standalone sample code under
  `example/` or developer maintenance scripts under `tool/` unless the package
  explicitly mandates 100% repository-wide coverage.
- **Failing Test Suites**: If existing tests are failing under `dart test`, fix
  the broken tests first before collecting or reporting coverage.

## Discovery

To find areas lacking test coverage:

### Run Coverage Analysis

Follow the workflow to generate and interpret coverage data:

1. **Run Tests with Coverage**: `dart test --coverage=.dart_tool/coverage`
2. **Interpret Results**: Use the script or `format_coverage` as described in
   the **Interpreting Results** section to identify specific files and missed
   lines.

## How to use this skill (The Workflow)

1.  Ensure tests pass by running `dart test`.
2.  Collect coverage by running `dart test --coverage=.dart_tool/coverage`.
3.  Interpret the results using the provided script or standard tools.
4.  Add tests to cover missed lines.

## Running Coverage

Run the following command to collect coverage in JSON format:

```bash
dart test --coverage=.dart_tool/coverage
```

> [!NOTE] We use `.dart_tool/coverage` as the output directory because
> `.dart_tool` is typically already ignored in `.gitignore` files.

> [!TIP] For projects with complex conditional logic, you can pass the
> `--branch-coverage` flag to `dart test` to collect branch-level coverage.

## Interpreting Results

### Option 1: Use the custom interpreter script

This repository includes a zero-dependency script that parses the raw JSON
output and provides a summary of covered percentage and missed lines.

Run it from the project root (adjust path to script as needed):

```bash
dart run skills/dart-test-coverage/scripts/interpret_coverage.dart .dart_tool/coverage <package_name>
```

Replace `<package_name>` with the name from `pubspec.yaml`.

Example Output:

```
package:my_pkg/src/file.dart: 50.0% (2/4 lines)
  Missed lines: 3, 4
```

### Option 2: Use package:coverage

If `package:test` is installed, `package:coverage` is likely available as a
transitive dependency. You can use its `format_coverage` tool.

To get a human-readable "pretty print" of the coverage:

```bash
dart run coverage:format_coverage --in=.dart_tool/coverage --out=stdout --pretty-print --report-on=lib
```

This will output the file content with hit counts on the left (e.g., `0|` for
missed lines).

## Best Practices for Reporting Results

When presenting coverage results to the user, follow these guidelines:

1.  **State the high-level percentage first** to give immediate context.
2.  **Identify specific files and missed lines** clearly.
3.  **Translate line numbers to code**: Don't just say "lines 3-6 are missed".
    Look at the source file and tell the user which functions or blocks are
    untested (e.g., "The `divide` function is missing coverage").
4.  **Propose concrete fixes**: Provide example test code that the user can
    immediately apply to cover the missed lines.
5.  **Use tables for multi-file summaries**: When reporting on multiple files,
    use a markdown table with columns for File, Coverage %, and Missed Lines to
    make the summary easy to scan.

## Constraints

- ALWAYS verify that tests pass before collecting coverage.
- DO NOT commit the `.dart_tool/coverage` directory.
- Focus coverage improvements on `lib/` files, not `test/` or generated files.

© kevmoo · Apache-2.0 · kevmoo/dash_skills

Similar skills

All skills for Testing and QA →
dart-collect-coverage dart-lang dart-collect-coverage collects Dart and Flutter test coverage metrics with the coverage package and generates LCOV reports. Handy for test auditing and CI pipeline preparation. CX Codex +1 20,400installs test-coverage-mcp goldbergyoni test-coverage-mcp feeds your coding agent real coverage numbers from an LCOV file, so it can tell whether its edits helped or hurt the tests. CX Codex +1 ★ 42repo stars Python Unit Test Generator — Comprehensive, Coverage-Mapped & Production-Ready sivasaiyadav8143 Python Unit Test Generator — Comprehensive, Coverage-Mapped & Production-Ready is a prompt that turns a Python snippet into a pytest suite with a coverage map and mocks for external dependencies. GP ChatGPT ★ 178,201repo stars bun-test-coverage secondsky bun-test-coverage — a skill for Claude Code, Codex, Cursor and other platforms that wires up Bun's built-in coverage reporting: thresholds, reporters, and CI upload steps. Generates coverage/lcov.info ready for Codecov via GitHub Actions. CX Codex +1 424installs dart-add-unit-test dart-lang dart-add-unit-test is a skill for Claude Code, Codex, and other agents that writes and structures package:test unit tests. It activates when adding logic or fixing bugs to prevent regressions. CX Codex +1 21,400installs test-coverage NeoLabHQ The test-coverage Claude Code skill assesses what existing tests exercise across code, mutations, requirements, and APIs. It supports analysis after tests have been written. CX Codex +1 683installs

From the same set9

dart-best-practices dart-best-practices enforces idiomatic Dart code style and formatting during generation and review. Focuses on clean multi-line string literals and strict 80-character line wrapping. CX Codex +1 847installs dart-test-fundamentals dart-test-fundamentals — a skill for Claude Code and Codex that enforces best practices for Dart's package:test. It structures test suites, configures dart_test.yaml, and handles teardowns. CX Codex +1 455installs dart-modern-features dart-modern-features guides coding agents on modern Dart 3.0 to 3.10 features. It helps adopt records, extension types, class modifiers, and null-aware elements during refactoring. CX Codex +1 370installs dart-doc-validation The dart-doc-validation skill for Claude Code validates Dart documentation comments with dart doc and the comment_references lint, catching broken links. CX Codex +1 291installs dart-package-maintenance dart-package-maintenance — a skill for maintaining Dart packages per Dart team standards: manage semantic versioning, keep CHANGELOG in sync, and prepare releases. Essential if you publish packages to pub.dev. CX Codex +1 285installs dart-matcher-best-practices dart-matcher-best-practices is a Claude Code skill for writing Dart tests with expect and package:matcher. It steps in when adding assertions, cleaning up manual checks, or investigating confusing test failures. CX Codex +1 269installs dart-long-lines dart-long-lines is a Claude Code skill for keeping Dart lines within 80 columns. It applies while writing code or fixing the lines_longer_than_80_chars lint. CX Codex +1 150installs dart-multiline-strings dart-multiline-strings — a skill for Claude Code, Codex, Cursor and other agents that teaches rewriting consecutive print() calls and string concatenations into triple-quoted literals (''' or """). CX Codex +1 116installs

Project sponsors

Companies that keep this analytics open