improve-test-coverage — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited improve-test-coverage (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Autonomously run tests, identify coverage gaps, write targeted unit tests, and repeat until both line and branch coverage reach 80% or no further improvement is possible.
run-coverageanalyze-coverage-gaps| Input | Required | Description |
|---|---|---|
sourcePath | Yes | Scope target: a .cs file, a folder, or a .csproj project |
testProjectPath | Yes | Full path to the .csproj test project |
filter | Yes | Test filter string — use * or broad filter for batch/folder/project scope |
lineBudget | No | Max total lines per batch (default: 300). Small files get grouped, large files run solo |
workingDir | No | Working directory; defaults to project directory |
includeClass | No | Do NOT pass this in the iterative workflow. It scopes coverage to a single class and would skew batch-level numbers. Only used by run-coverage for single-class reports. |
reportgenerator is installed (dotnet tool list -g); install if missingGetSourceFiles with sourcePath and lineBudget to get:files — all .cs files with lines and methodCount metadatabatches — files grouped by line budget (small files together, large files solo)batchCount — how many cycles to expectExample response:
{
"scope": "folder",
"totalFiles": 18,
"totalLines": 4200,
"lineBudget": 300,
"batchCount": 8,
"batches": [
[{"path": "SmallA.cs", "lines": 80}, {"path": "SmallB.cs", "lines": 120}, {"path": "SmallC.cs", "lines": 90}],
[{"path": "BigService.cs", "lines": 920}]
]
}For each file in the current batch:
scaffold-test-files to create one[SetUp] method; add one if missing using AppendTestCodeCall RunTestsWithCoverage with testProjectPath and a broad filter (use * or namespace-level filter). This runs dotnet test once and collects coverage across all source files.
Leave includeClass unset. It would silently limit collection to a single class and zero out the rest of the batch.
Then for each file in the batch, call GetFileCoverage with coberturaXmlPath and the file name.
allMeetTarget: true → mark file as done, skip itallMeetTarget: false → include in this cycle's workFrom all non-done files in the batch, pick the 3 lowest branch-coverage methods, excluding:
For each target method, call GetUncoveredBranches with coberturaXmlPath and the method name.
Note which branch conditions (branch-N-true, branch-N-false) are uncovered and what they represent.
For each uncovered branch, write a focused unit test using AppendTestCode:
[TestCase] for data variations, separate [Test] methods for different mock setupsinsertAfterAnchor to place tests after the relevant test class or last test methodTest quality rules (strictly enforce):
MethodName_Condition_ExpectedResult patternIf RunTestsWithCoverage returns a build error after writing tests:
using statementRunTestsWithCoverage before continuingDo NOT call `AppendTestCode` to fix errors — use Edit to surgically fix the broken line instead.
Call RunTestsWithCoverage once with the same broad filter. Call GetFileCoverage for each file in the batch to check per-file progress. Call GetCoverageDiff to see method-level deltas.
For each file in the batch:
| Condition | Action |
|---|---|
| All files in batch at ≥ 80% line AND branch | Batch done — move to next batch |
| No improvement for 3 consecutive cycles in a batch | Batch plateau — move to next batch |
| Method fails 3 times with no gain | Mark as blocked, skip in future cycles |
| All batches processed | Session complete — report final state |
GetFileCoverage is instant (XML parse) — call it for every file in the batch freely* or namespace) for batch/folder/project scopeincludeClass — it restricts coverage collection to one class and would zero out the rest of the batchGetSourceFiles returned batches grouped by line budgetRunTestsWithCoverage call per cycle (not per file)GetFileCoverage checked for every file in the batch after each test run| Pitfall | Solution |
|---|---|
| Tests compile but coverage doesn't improve | The test may not be reaching the target branch — verify mock setup matches the condition |
AppendTestCode inserts in wrong location | Use a precise insertAfterAnchor string matching the last test method signature |
| Plateau after 1–2 cycles | Check if remaining uncovered branches require complex setup (async, private methods, static calls) — mark as blocked |
| Over-testing simple properties | Skip auto-properties with no logic; focus on methods with conditionals |
| Broad filter runs too many tests | Narrow filter to namespace level instead of * for faster test runs |
| Batch too large for AI context | Reduce lineBudget (e.g., 200) to get smaller batches |
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.