skills/testing/coverage-enhancer/SKILL.md
Raises test coverage by identifying uncovered code regions, ranking them by risk, and generating targeted tests that hit them — prioritizing branches and conditions over raw line count. Use when coverage is below target, when untested code is blocking a release, or when deciding which tests to write next.
npx skillsauth add santosomar/general-secure-coding-agent-skills coverage-enhancerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Line coverage is a floor, not a goal. 100% lines with 50% branches means half your if conditions never ran the other way. This skill targets the uncovered decisions, not just uncovered lines.
| Metric | What it measures | Gaps it misses |
| ------------------- | --------------------------------------------- | ------------------------------------------------- |
| Line | Each line executed at least once | if a or b: — only one of a/b tested |
| Branch | Each if/else arm taken | if a and b: — never tested a=T, b=F |
| Condition | Each boolean sub-expression both T and F | Masking: short-circuit hides some |
| MC/DC | Each condition independently flips the outcome | Nothing — this is the aviation standard |
| Mutation | Tests kill injected bugs | → mutation-test-suite-optimizer |
Default target: branch coverage. MC/DC for safety-critical. Mutation for "is this suite actually good."
| Ecosystem | Branch coverage command |
| --------- | ------------------------------------------------------------- |
| Python | pytest --cov=src --cov-branch --cov-report=term-missing |
| Java | JaCoCo — mvn jacoco:report, look at "branches missed" |
| JS/TS | jest --coverage (Istanbul) — "% Branch" column |
| Go | go test -cover is line-only; use -covermode=count + gocov for branches |
| C/C++ | gcov -b / llvm-cov |
Output: file → uncovered lines + uncovered branches. The branches are the interesting part.
Not all uncovered code is equal. Rank by risk × effort:
| Factor | Weight | How to measure |
| --------------------------------- | ------ | ------------------------------------------------ |
| Code churn (recently changed) | High | git log --since="3 months ago" --oneline -- <file> | wc -l |
| Complexity (cyclomatic) | High | Radon/SonarQube/etc — complex & untested = risky |
| Error handling path | High | except:, if err != nil — errors hide here |
| Public API surface | Medium | Externally reachable |
| Auto-generated / boilerplate | -High | __repr__, getters — low value |
| Defensive dead code | -High | if x is None: that's never None by construction |
Top of the list: complex error-handling in recently-churned public APIs. Bottom: generated __eq__ methods.
For each targeted gap, reverse-engineer the input:
Uncovered branch: pricing.py:47 — if customer.tier == "enterprise" and region == "eu": [TRUE branch never taken]
Path to this line: called from calculate_price(customer, items) → _apply_discounts(customer, subtotal) → line 47.
What needs to be true: customer.tier == "enterprise" AND region == "eu". Where does region come from? customer.billing_address.country mapped through COUNTRY_TO_REGION.
Test:
def test_enterprise_eu_discount_applied():
customer = Customer(
tier="enterprise",
billing_address=Address(country="DE"), # DE → eu in COUNTRY_TO_REGION
)
price = calculate_price(customer, items=[Item(base=100.0)])
# Branch was dead because no test had an enterprise customer in the EU.
# The discount is 15% per the body of the branch.
assert price == 85.0
The assertion isn't assert True — it checks what the branch does, not just that it ran.
Some gaps shouldn't be closed:
| Pattern | Verdict |
| ---------------------------------------------- | ----------------------------------------------- |
| if sys.platform == "win32": | Covered on Windows CI. # pragma: no cover on other platforms. |
| raise AssertionError("unreachable") | It's unreachable. That's the point. Exclude. |
| except MemoryError: | Can't reliably trigger. Document the manual test. |
| Logging, __repr__, debug helpers | Low value. Configurable exclusion. |
| if TYPE_CHECKING: | Never runs at runtime. Exclude. |
Mark these explicitly (# pragma: no cover + a reason). Don't chase 100%.
call_function(); assert True raises coverage and tests nothing. Every new test asserts the effect of the code it covers.@dataclass __eq__ works. Don't test the language.dead-code-eliminator). Sometimes it's a condition that's always False by construction — that's a bug or a simplification opportunity, not a test gap.## Current coverage
Line: <%> Branch: <%> (<tool + config>)
## Gap ranking
| File:line | Type | Risk | Churn | Complexity | Priority |
| --------- | ---- | ---- | ----- | ---------- | -------- |
## Targeted tests
### Gap: <file:line> — <description>
Path condition: <what must be true to reach this>
Test:
<code>
Expected coverage delta: +<N> branches
## Excluded
| File:line | Why uncoverable | Marked with |
| --------- | --------------- | ----------- |
## Projected
After these tests: Line <%> → <%>, Branch <%> → <%>
development
Extracts human-readable pseudocode from a verified formal artifact (Dafny, Lean, TLA+) while preserving the verified properties as annotations, so the proof-carrying logic can be reimplemented in a production language. Use when porting verified code to an unverified target, when documenting what a formal spec actually does, or when handing a verified algorithm to an implementer.
development
Translates natural-language or pseudocode descriptions of concurrent and distributed systems into TLA+ specifications ready for the TLC model checker. Identifies state variables, actions, type invariants, safety properties, and liveness properties from the description. Use when formalizing a protocol, when the user describes a distributed algorithm to verify, when designing a consensus or locking scheme, or when starting formal verification of a concurrent system.
testing
Reduces a TLA+ model so TLC can actually check it — shrinks constants, adds state constraints, abstracts data, or applies symmetry — when the state space is too large to enumerate. Use when TLC runs out of memory, when checking takes hours, or when a spec works at N=2 and you need confidence at larger scale.
development
TLA+-specific instance of model-guided repair — reads a TLC error trace, identifies the enabling condition that should have been false, strengthens the corresponding action, and maps the fix to source code. Use when TLC reports an invariant violation or deadlock and you have the code-to-TLA+ mapping from extraction.