/lstack:test-coveragefrom lstack
Generates unit tests for untested branches and edge cases across JS/TS, Python, Go, and Rust projects. Activates when coverage is low, CI flags gaps, or a release needs hardening.
Ships in lstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Expand unit test coverage by targeting untested branches and edge cases.
Detect the stack from its manifest and use its commands throughout the Workflow:
| Manifest | Stack | Coverage command | Test framework |
|---|---|---|---|
package.json | JavaScript/TypeScript | npx jest --coverage or npx vitest --coverage | Jest, Vitest, Mocha |
pyproject.toml | Python | pytest --cov=<source> --cov-report=term-missing | pytest, unittest |
go.mod | Go | go test -coverprofile=coverage.out ./... | testing, testify |
Cargo.toml | Rust | cargo tarpaulin or cargo llvm-cov | built-in test framework |
Python's <source> is the package or module under test (src, pricing), or bare --cov when coverage config sets source; --cov=. counts test files.
If none of these manifests is found, see Edge Cases — "No test framework detected".
Before creating/updating/deleting files in an existing repository, sync the current branch with remote. First save git status --porcelain --untracked-files=all as the pre-sync list, even when the user says to skip the sync; Step 4 never stages those paths.
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is not clean, stash first, sync, then restore:
git stash push -u -m "pre-sync"
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash pop
If origin is missing, pull is unavailable, or rebase/stash conflicts occur, stop and ask the user before continuing.
git rev-parse --abbrev-ref HEAD as the starting branch. If it is a branch other than main or master that was created for this task, go to item 4.git branch -a and note the prefix most existing branches use (e.g., feat/, feature/, test/).feat/test-coverage. If the run stops BLOCKED, this branch has no commits: git switch <starting branch>, then git branch -d <branch> (never -D). Uncommitted changes move with the switch; list them under Uncertainty:.git rev-parse HEAD as the base. A pre-existing test is any test in a file tracked at the base, except one an earlier run of this skill committed (references/unit-test-quality.md → Integrity check).Run the coverage command for the detected Stack above. Record the total coverage percentage and the pass/fail counts as the baseline. If any test fails, stop here (see Edge Cases).
From the report, identify:
Review the low-coverage code for:
Leave trivial code out of the gap list: getters and setters, plain data classes and DTOs, constants, and one-line calls into a library or framework. Cover such code only through a test of logic that uses it, and list the skipped files under Uncertainty:.
references/unit-test-quality.md.Decision:, unchanged. What may change: references/unit-test-quality.md → Integrity check.Use Step 1's exact commands throughout. For solo runs add only test ids (or a command-line flag naming exactly those tests: -k, -run, a cargo name filter) and Go's -count=1. Judge each test by its own reported result (references/unit-test-quality.md → Reading a test result).
references/unit-test-quality.md → Failing pre-existing tests says: a pre-existing flake goes under Decision:, anything else is PARTIAL. Never rerun the full suite to replace a red result with a green one. If a new test fails, run it on its own twice more, as diagnosis, not a retry: if it passes in either solo run, it is flaky: handle it as in item 2. Only if it fails all three times, read the failure and decide which side is wrong:
Decision: with the test's code and failure output. The run can still be COMPLETE; name the bug in the Result: line. That test becomes the regression test for the fix.-k when they share a file with pre-existing tests (for example pytest tests/test_parser.py, go test ./internal/store -count=1 -run '^TestKey', cargo test key_). If a new test fails in either run, it depends on test order, shared state, or timing. Fix it once from the flakiness table in references/unit-test-quality.md and repeat items 1 and 2. If it still fails, remove it and list it under Uncertainty:.git checkout -- <file> and confirm git diff --name-only no longer lists it. Never plant a bug in a file on the pre-sync list, because the checkout would erase the user's changes; list those tests under Uncertainty: as not break-checked. A test that still passes against the bug gets its assertion strengthened once; repeat the check. If it passes again, remove it and list it under Uncertainty:.Test-Coverage-Run: <before>% -> <after>%. Stage each test file this run wrote by explicit path (git add tests/test_parser.py); never git add -A, git add . or git commit -a, which would sweep in user work Repo Sync restored. Never stage a path on the pre-sync list. Stage a changed manifest or lockfile (Coverage tool not installed) only with its reason in the commit message. Check git diff --cached --name-only before committing, then run the Integrity check from references/unit-test-quality.md against the base. A failed check means commit nothing and report PARTIAL — existing test changed with the line. After committing, run it again on <base>..HEAD. Under Uncertainty:, list each changed file left unstaged, or every new test file when the commit is skipped (failed suite or regression).Result: — COMPLETE, PARTIAL — reason, or BLOCKED — reason — followed by:
Evidence: the commands that ran, with before/after totals, pass/fail counts, the item 2 rerun result, and the item 3 break-check countUncertainty: what was not checked (e.g., excluded paths, CI not run, covered lines without output assertions)Decision: the action that needs approval, or No approval needed, then any remaining user action (e.g., push the branch, open a PR)A successful Python run ends with:
Result: COMPLETE — coverage 61% → 84%, all tests pass
Evidence: pytest --cov=src --cov-report=term-missing (before): 61% (47/77 statements), 47 passed
same command (after): 84% (65/77 statements), 56 passed, 0 failed
9 new tests run on their own, twice: 9 passed both runs
break check: 9/9 new tests failed on a planted bug; sources restored
Integrity check vs base before and after the commit: PASS
Uncertainty: CI not run; src/vendor/ excluded from coverage; src/models.py skipped (getters only)
Decision: No approval needed. Next: push feat/test-coverage and open a PR.
New tests added: 9
Files improved:
- src/parser.py 52% → 91% (+7 tests: null input, empty string, unicode overflow)
- src/auth.py 71% → 88% (+2 tests: expired token, missing header)
A run passes when all of the following are true:
jest --coverage, pytest --cov, go test -cover).sleep(), or a real database other than a test-database fixture the existing unit tests already use.npm test, pytest, go test ./..., etc.), judged per test (references/unit-test-quality.md → Reading a test result), apart from a pre-existing test shown flaky at the base and named under Decision:, and the new tests pass when run on their own, twice.Decision:. No assertion was loosened to match the code.feat/test-coverage), never on main/master.If any item fails, the final report says PARTIAL or BLOCKED and names the reason.
The final report must also be understandable:
COMPLETE, PARTIAL or BLOCKED and the reason.Evidence: (commands run and their observed totals) is separate from Uncertainty: (assumptions and unchecked behavior).Decision: names the approval needed or says No approval needed, and names any remaining user action.These are instruction checks. Without reviewer feedback, human understanding of the report stays unconfirmed; agent inspection cannot confirm it.
pytest-cov, nyc, cargo tarpaulin, etc.) and rerun the command once. If it fails again, stop and report BLOCKED with the error output.BLOCKED with the failing tests' names, and put each one's visible cause under Decision:. Never add a retry to make the baseline pass.COMPLETE with the baseline as evidence and list the skipped files under Uncertainty:.COMPLETE with the baseline as evidence and stop.node_modules/, vendor/, dist/, build/, files with a generated-code header) out of the Step 2 gap list, and list them under Uncertainty:.unittest.IsolatedAsyncioTestCase, pytest-asyncio if installed, or Jest fake timers). Never use a bare sync wrapper, and never sleep() to wait for async work.monkeypatch on the name the module under test imports, jest.spyOn or vi.spyOn, or Jest or Vitest fake timers for time, restored as the Integrity check says. If no such tool reaches it, do not refactor production code to add a seam. Leave that gap untested and list it under Uncertainty:.After each major step, print:
◆ [Step Name] ([step N of M] — [context])
··································································
[Check 1]: √ pass
[Check 2]: √ pass (note if relevant)
[Check 3]: × fail — [reason]
[Check 4]: √ pass
[Criteria]: √ N/M met
____________________________
Result: PASS | FAIL | PARTIAL
Adapt the check names to the step. Use √ for pass, × for fail, and — to add brief context.
Branch Setup phase checks: Feature branch created, Base recorded, Base coverage measured
Analysis phase checks: Coverage report parsed, Gaps identified, Priority ranked
Test Writing phase checks: Tests written, Trivial code skipped, Self-check passed, No network, DB, clock, randomness, or sleep, Property tests seeded, Framework conventions followed
Verification phase checks: Tests pass, New tests pass on their own, Break check passed, Existing tests unchanged, Coverage improved, No regressions
_test.go, a Rust #[cfg(test)] module) or in its unit-test directory. Never add them to an integration or E2E suite.Optional and propose-only. After the run's result is delivered, run this check:
references/ (the directory holding this SKILL.md). Bump the patch number of metadata.version. If the skill is an installed copy or tracked in git, say so. Commit nothing unless the user asks.Off — the user opted out.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
20 skills in this plugin
/agent-configCreate, update, or audit AGENTS.md (default) or CLAUDE.md agent instructions: set up, prune, add a rule, or merge CLAUDE.md or .cursorrules into one file Claude Code, Codex, and Cursor all read. Don't use for READMEs, skills, or subagents./auto-pushGenerate a commit message, stage all changes, and push to remote after scanning for secrets, large files, and protected-branch risks. Skip for opening PRs, code review, or cutting releases/tags./cleanup-projectPrepare a git repo before new work: review uncommitted changes, fix .gitignore, delete merged branches, end on clean main, or inspect one branch before deciding. Don't use for dead code, commit-and-push, releases, LICENSE files, or git how-tos./cli-builderBuild production-quality CLIs with language detection and a five-step approval-gated workflow. Use when wrapping an existing module or app. Don't use for GUI/TUI apps, web APIs, or one-off shell scripts./code-analysis-setupPlan, then install on approval, free static analysis (lint, SAST, secrets, deps) across repos, merged into existing hooks and CI. Use when adding code analysis. Don't use for one-repo security stacks (security-setup) or CI/CD (devops-pipeline)./code-reviewReview or improve code in four modes: bug/security review (default), performance, clean-code audit, slop cleanup (mode:review|perf|clean|cleanup). Don't use for features, tests (test-coverage) or a full comment audit (comment-audit).npx claudepluginhub luongnv89/skills --plugin lstackOther plugins' skills for the same job