dart-test-coverage
Skill148 starsChanged 13 days agoApache-2.0View on GitHub
Understand and improve test coverage in a Dart package. Helps agents run coverage, interpret results, and identify missed lines.
In this repository11 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 10 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
When asked to "check test coverage" or "improve coverage".
- Distinctive: line 19
When you need to identify which parts of a library are untested.
- Distinctive: line 23
Do NOT collect or demand test coverage for:
- Very specific: line 33
Failing Test Suites: If existing tests are failing under dart test, fix the broken tests first before collecting or reporting coverage.
- Distinctive: line 42
Follow the workflow to generate and interpret coverage data:
- Very specific: line 45
Interpret Results: Use the script or format_coverage as described in the Interpreting Results section to identify specific files and missed …
- Very specific: line 51
Ensure tests pass by running dart test.
- Distinctive: line 54
Add tests to cover missed lines.
- Distinctive: line 58
Run the following command to collect coverage in JSON format:
- Distinctive: line 77
Run it from the project root (adjust path to script as needed):
- Very specific: line 94
If package:test is installed, package:coverage is likely available as a transitive dependency.
- Distinctive: line 108
When presenting coverage results to the user, follow these guidelines:
- Very specific: line 112
Translate line numbers to code: Don't just say "lines 3-6 are missed".
- Very specific: line 113
Look at the source file and tell the user which functions or blocks are untested (e.g., "The divide function is missing coverage").
- Distinctive: line 117
Use tables for multi-file summaries: When reporting on multiple files, use a markdown table with columns for File, Coverage %, and Missed …
- Distinctive: line 123
ALWAYS verify that tests pass before collecting coverage.
- Very specific: line 124
DO NOT commit the .dart_tool/coverage directory.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 undertool/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:
- Run Tests with Coverage:
dart test --coverage=.dart_tool/coverage - Interpret Results: Use the script or
format_coverageas described in the Interpreting Results section to identify specific files and missed lines.
How to use this skill (The Workflow)
- Ensure tests pass by running
dart test. - Collect coverage by running
dart test --coverage=.dart_tool/coverage. - Interpret the results using the provided script or standard tools.
- Add tests to cover missed lines.
Running Coverage
Run the following command to collect coverage in JSON format:
dart test --coverage=.dart_tool/coverage[!NOTE] We use
.dart_tool/coverageas the output directory because.dart_toolis typically already ignored in.gitignorefiles.
[!TIP] For projects with complex conditional logic, you can pass the
--branch-coverageflag todart testto 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):
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, 4Option 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:
dart run coverage:format_coverage --in=.dart_tool/coverage --out=stdout --pretty-print --report-on=libThis 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:
- State the high-level percentage first to give immediate context.
- Identify specific files and missed lines clearly.
- 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
dividefunction is missing coverage"). - Propose concrete fixes: Provide example test code that the user can immediately apply to cover the missed lines.
- 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/coveragedirectory. - Focus coverage improvements on
lib/files, nottest/or generated files.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

