CC-301h · Module 2

Coverage Analysis

3 min read

Code coverage tells you which lines of code are executed during tests. Claude Code uses coverage reports to identify untested paths and generate targeted tests. The workflow: run your test suite with coverage enabled (vitest --coverage, jest --coverage, nyc), examine the report, and ask Claude to fill the gaps.

The prompt: "Here is the coverage report. These lines in src/auth/validate.ts are not covered: lines 45-52 (the token expiration branch) and lines 78-84 (the invalid signature branch). Write tests that exercise these specific code paths." Claude reads the uncovered code, understands the conditions needed to reach it, and generates tests that exercise exactly those paths. This is surgical coverage improvement — not "add more tests" but "add tests for these specific untested branches."