{"slug":"dart-test-coverage","title":"dart-test-coverage","summary":"Understand and improve test coverage in a Dart package. Helps agents run coverage, interpret results, and identify missed lines.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-14T18:30:24.503997Z","repo":{"url":"https://github.com/kevmoo/dash_skills","stars":146,"forks":16,"license":"Apache-2.0","updatedAt":"2026-09-24T00:03:49Z"},"bodyHtml":"<hr>\n<p>name: dart-test-coverage\ndescription: |-\nUnderstand and improve test coverage in a Dart package.\nHelps agents run coverage, interpret results, and identify missed lines.\nkey_features:</p>\n<ul>\n<li>LCOV report collection</li>\n<li>Missed line identification</li>\n<li>Coverage analysis &amp; improvement</li>\n</ul>\n<hr>\n<h1>Dart Test Coverage</h1>\n<p>Guidelines for running and interpreting test coverage in Dart packages.</p>\n<h2>When to use this skill</h2>\n<ul>\n<li>When asked to \"check test coverage\" or \"improve coverage\".</li>\n<li>When you need to identify which parts of a library are untested.</li>\n</ul>\n<h3>When NOT to use (Abstention Guardrails)</h3>\n<p>Do NOT collect or demand test coverage for:</p>\n<ul>\n<li><strong>Generated Code</strong>: Code generated by builders (<code>*.g.dart</code>, <code>*.freezed.dart</code>,\nprotobufs).</li>\n<li><strong>Platform-Specific FFI / OS Entrypoints</strong>: Low-level platform bindings or\nentrypoints that require specific physical hardware or OS services not\navailable in the execution environment.</li>\n<li><strong>Example Applications &amp; Tool Scripts</strong>: Standalone sample code under\n<code>example/</code> or developer maintenance scripts under <code>tool/</code> unless the package\nexplicitly mandates 100% repository-wide coverage.</li>\n<li><strong>Failing Test Suites</strong>: If existing tests are failing under <code>dart test</code>, fix\nthe broken tests first before collecting or reporting coverage.</li>\n</ul>\n<h2>Discovery</h2>\n<p>To find areas lacking test coverage:</p>\n<h3>Run Coverage Analysis</h3>\n<p>Follow the workflow to generate and interpret coverage data:</p>\n<ol>\n<li><strong>Run Tests with Coverage</strong>: <code>dart test --coverage=.dart_tool/coverage</code></li>\n<li><strong>Interpret Results</strong>: Use the script or <code>format_coverage</code> as described in\nthe <strong>Interpreting Results</strong> section to identify specific files and missed\nlines.</li>\n</ol>\n<h2>How to use this skill (The Workflow)</h2>\n<ol>\n<li>Ensure tests pass by running <code>dart test</code>.</li>\n<li>Collect coverage by running <code>dart test --coverage=.dart_tool/coverage</code>.</li>\n<li>Interpret the results using the provided script or standard tools.</li>\n<li>Add tests to cover missed lines.</li>\n</ol>\n<h2>Running Coverage</h2>\n<p>Run the following command to collect coverage in JSON format:</p>\n<pre><code>dart test --coverage=.dart_tool/coverage\n</code></pre>\n<blockquote>\n<p>[!NOTE] We use <code>.dart_tool/coverage</code> as the output directory because\n<code>.dart_tool</code> is typically already ignored in <code>.gitignore</code> files.</p>\n</blockquote>\n<blockquote>\n<p>[!TIP] For projects with complex conditional logic, you can pass the\n<code>--branch-coverage</code> flag to <code>dart test</code> to collect branch-level coverage.</p>\n</blockquote>\n<h2>Interpreting Results</h2>\n<h3>Option 1: Use the custom interpreter script</h3>\n<p>This repository includes a zero-dependency script that parses the raw JSON\noutput and provides a summary of covered percentage and missed lines.</p>\n<p>Run it from the project root (adjust path to script as needed):</p>\n<pre><code>dart run skills/dart-test-coverage/scripts/interpret_coverage.dart .dart_tool/coverage &lt;package_name&gt;\n</code></pre>\n<p>Replace <code>&lt;package_name&gt;</code> with the name from <code>pubspec.yaml</code>.</p>\n<p>Example Output:</p>\n<pre><code>package:my_pkg/src/file.dart: 50.0% (2/4 lines)\n  Missed lines: 3, 4\n</code></pre>\n<h3>Option 2: Use package:coverage</h3>\n<p>If <code>package:test</code> is installed, <code>package:coverage</code> is likely available as a\ntransitive dependency. You can use its <code>format_coverage</code> tool.</p>\n<p>To get a human-readable \"pretty print\" of the coverage:</p>\n<pre><code>dart run coverage:format_coverage --in=.dart_tool/coverage --out=stdout --pretty-print --report-on=lib\n</code></pre>\n<p>This will output the file content with hit counts on the left (e.g., <code>0|</code> for\nmissed lines).</p>\n<h2>Best Practices for Reporting Results</h2>\n<p>When presenting coverage results to the user, follow these guidelines:</p>\n<ol>\n<li><strong>State the high-level percentage first</strong> to give immediate context.</li>\n<li><strong>Identify specific files and missed lines</strong> clearly.</li>\n<li><strong>Translate line numbers to code</strong>: Don't just say \"lines 3-6 are missed\".\nLook at the source file and tell the user which functions or blocks are\nuntested (e.g., \"The <code>divide</code> function is missing coverage\").</li>\n<li><strong>Propose concrete fixes</strong>: Provide example test code that the user can\nimmediately apply to cover the missed lines.</li>\n<li><strong>Use tables for multi-file summaries</strong>: When reporting on multiple files,\nuse a markdown table with columns for File, Coverage %, and Missed Lines to\nmake the summary easy to scan.</li>\n</ol>\n<h2>Constraints</h2>\n<ul>\n<li>ALWAYS verify that tests pass before collecting coverage.</li>\n<li>DO NOT commit the <code>.dart_tool/coverage</code> directory.</li>\n<li>Focus coverage improvements on <code>lib/</code> files, not <code>test/</code> or generated files.</li>\n</ul>\n","files":[{"path":"evals/evals.json","sizeBytes":1826,"isText":true},{"path":"example/lib/src/calculator.dart","sizeBytes":212,"isText":false},{"path":"example/pubspec.yaml","sizeBytes":118,"isText":true},{"path":"example/test/calculator_test.dart","sizeBytes":210,"isText":false},{"path":"scripts/interpret_coverage.dart","sizeBytes":2769,"isText":false},{"path":"scripts/pubspec.yaml","sizeBytes":111,"isText":true},{"path":"scripts/test/interpret_coverage_test.dart","sizeBytes":2752,"isText":false},{"path":"SKILL.md","sizeBytes":4341,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-14T18:30:31.693635Z","sha256":"D95B93D00FA97B9910E261077BC648658FC4DF9FF4CCAA93E7C6CC7A467A4651","sizeBytes":6084},"review":null,"source":{"repositoryUrl":"https://github.com/kevmoo/dash_skills","path":"skills/dart-test-coverage","license":"Apache-2.0","commit":"0b6371c26516df82443ee5491771befa70d60f0f","subtreeSha":"FB274C88C5F40FE4EBAAE2709B111422CB773D9EEF7BFCCB65F0A52908333A8A","lastSyncedAt":"2026-09-26T23:12:20.969684Z"},"reviewedAt":"2026-09-14T18:30:53.104624Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/kevmoo/dash_skills/tree/main/skills/dart-test-coverage"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kevmoo-dash-skills@llmmart"},{"target":"git","command":"git clone https://github.com/kevmoo/dash_skills.git"}]}