tdd-refactor-coverage-audit
Installation
SKILL.md
TDD Refactor Coverage Audit
Companion to tdd-process and tdd-refactor-phase. Mechanically audits whether source files added since a reference commit have paired tests, using bundled JSON conventions file. Output is advisory only — warnings reported but never block TDD gate.
Runtime Requirements
Applies No-Runtime Fallback Pattern (see SKILL-DEVELOPMENT-GUIDE.md). Two paths, chosen by preflight:
| Path | Requires | What it does |
|---|---|---|
| Primary (default) | Node 18+ on PATH |
Invokes scripts/test-coverage-audit.js — deterministic, sub-second, exact convention-JSON-driven pairing check. |
| Fallback | None (runs in Claude inline) | Claude reads resources/test-coverage-conventions.json, runs git diff --name-status --diff-filter=A <sha>..HEAD via Bash tool, applies same pairing rules procedurally, emits equivalent advisory warnings. |
Both paths preserve advisory-output contract: warnings emit; audit never halts or fails TDD gate. Fallback's output may have slight prose-formatting differences from script, but structural fields (newSources, pairedSources, missingTests[], coverage) and advisory-only semantics identical. |
Preflight
Caller decides which path to invoke:
- Check Node:
node --versionavailable? - If yes (primary path): invoke script as documented under "Invocation" below. Done.
- If no (fallback path): Surface Pattern 4 diagnostic — "This audit pairs newly added source files with their expected test files using language conventions. The Node script is the primary path; without Node, Claude can perform the same pairing inline by reading the convention JSON + running
git diffvia the Bash tool. The result is structurally equivalent and remains advisory. Or install Node 18+ for the deterministic primary path." Then execute Fallback Procedure below.
Fallback Procedure
When Node unavailable, perform audit inline:
- Read convention JSON from
Skills/tdd-refactor-coverage-audit/resources/test-coverage-conventions.json. Defineslanguages(language →sourceExtensions[],testPatterns[], optionalexcludePatterns,inlineTests),ignoredSourcePatterns[],minTestCoverageRatio(default 0). - Read project override (if present) from
framework-config.json. IftestCoverageAuditblock exists, merge over bundled:additionalLanguagesadded tolanguages;ignoredSourcePatternsunioned;minTestCoverageRatiooverridden. - Enumerate added source files. Run
git diff --name-status --diff-filter=A <since-commit>..HEADvia Bash. LeadingA\tindicates added files; collect paths. - For each added file: skip if matches
ignoredSourcePatterns; detect language by extension againstsourceExtensions(skip if no match); skip if matches language'sexcludePatterns; for eachtestPatternsentry, substitute{stem}(filename without extension) and{dir}(relative directory), check if any expanded path exists on disk; for languages withinlineTests: true(Rust), additionally read source and check for inline#[cfg(test)]block (counts as paired); if no test file found and no inline block, append tomissingTests[]with file path, language, patterns checked.