test-coverage-improver — Claude Code skill: what it does
test-coverage-improver — a skill that identifies coverage gaps and generates missing tests for critical code paths.
MIT 312 installs ★ 440 updated 2026-10-20
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a claude-codeWhat test-coverage-improver does
The skill runs a coverage report (Jest, Vitest, NYC), pinpoints untested branches and functions, then writes tests to fill the gaps. It includes templates for unit tests, async functions, mocks, React components, and API routes. A branch coverage checklist covers if/else, switch, try/catch, and loops; a target table suggests 80% lines and functions as good, 90% as excellent.
The skill recommends a testing order: critical paths first (auth, payments, data mutations), then complex logic and error handlers, then edge cases and integration points. A Vitest config with thresholds and exclusions is provided.
Without a test runner in the project, the skill cannot run a report or verify results.
What it helps with
- run a coverage report and locate untested code
- write unit tests for uncovered functions
- cover if/else, switch, and try/catch branches with tests
- add tests for React components and API routes
- set coverage thresholds in Vitest config
Example prompts for the agent
- Run a coverage report and show which functions in
src/utils.tslack tests - Write tests for
calculateTotalandformatCurrencyto cover all branches - Add tests for the
Buttoncomponent — click handler, disabled state, and children rendering
How to install test-coverage-improver
1Skills CLI (Vercel)
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a claude-code2Manually: put the files in place
~/.claude/skills/test-coverage-improver/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/test-coverage-improver/
1Skills CLI (Vercel)
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a codex2Manually: put the files in place
.agents/skills/test-coverage-improver/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a cursor2Manually: put the files in place
.cursor/skills/test-coverage-improver/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install OneWave-AI/claude-skills test-coverage-improver2Manually: put the files in place
.github/skills/test-coverage-improver/SKILL.md1Skills CLI (Vercel)
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a gemini-cli2Platform CLI
gemini skills install https://github.com/OneWave-AI/claude-skills --path test-coverage-improverManually: put the files in place
.devin/skills/test-coverage-improver/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about test-coverage-improver
How to install test-coverage-improver in Claude Code?
Run npx skills add OneWave-AI/claude-skills --skill test-coverage-improver -a claude-code; the skill will appear in ~/.claude/skills/test-coverage-improver/SKILL.md.
What does test-coverage-improver do?
The skill analyzes test coverage reports, finds untested functions and branches, generates missing tests, and verifies that coverage has improved.
Which test runners does the skill support?
The skill works with Jest, Vitest, and NYC (Istanbul). It includes test templates for each runner and commands to generate reports.
Source text
SKILL.md · MIT
---
name: test-coverage-improver
description: Analyze test coverage gaps and generate tests to improve coverage. Use when improving test coverage, finding untested code, or writing missing tests.
---
# Test Coverage Improver
## Instructions
When improving test coverage:
1. **Run coverage report** to identify gaps
2. **Prioritize** critical/complex code paths
3. **Write tests** for uncovered code
4. **Verify coverage improved**
## Generate Coverage Report
```bash
# Jest
npx jest --coverage
# Vitest
npx vitest --coverage
# NYC (Istanbul) for any test runner
npx nyc npm test
# View HTML report
open coverage/lcov-report/index.html
```
## Coverage Targets
| Type | Minimum | Good | Excellent |
|------|---------|------|-----------|
| Lines | 70% | 80% | 90%+ |
| Branches | 60% | 75% | 85%+ |
| Functions | 70% | 80% | 90%+ |
| Statements | 70% | 80% | 90%+ |
## Test Templates
### Unit Test (Jest/Vitest)
```typescript
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { calculateTotal, formatCurrency } from './utils';
describe('calculateTotal', () => {
it('should sum all item prices', () => {
const items = [
{ price: 10, quantity: 2 },
{ price: 5, quantity: 1 },
];
expect(calculateTotal(items)).toBe(25);
});
it('should return 0 for empty array', () => {
expect(calculateTotal([])).toBe(0);
});
it('should handle decimal prices', () => {
const items = [{ price: 10.99, quantity: 1 }];
expect(calculateTotal(items)).toBeCloseTo(10.99);
});
});
```
### Testing Async Functions
```typescript
describe('fetchUser', () => {
it('should return user data', async () => {
const user = await fetchUser(1);
expect(user).toEqual({
id: 1,
name: expect.any(String),
email: expect.stringContaining('@'),
});
});
it('should throw for non-existent user', async () => {
await expect(fetchUser(999)).rejects.toThrow('User not found');
});
});
```
### Mocking Dependencies
```typescript
import { vi } from 'vitest';
import { sendEmail } from './email';
import { createUser } from './user';
vi.mock('./email', () => ({
sendEmail: vi.fn().mockResolvedValue({ success: true }),
}));
describe('createUser', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('should send welcome email after creating user', async () => {
await createUser({ name: 'John', email: '[email protected]' });
expect(sendEmail).toHaveBeenCalledWith({
to: '[email protected]',
template: 'welcome',
});
});
});
```
### React Component Testing
```tsx
import { render, screen, fireEvent } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { Button } from './Button';
describe('Button', () => {
it('should render children', () => {
render(<Button>Click me</Button>);
expect(screen.getByText('Click me')).toBeInTheDocument();
});
it('should call onClick when clicked', async () => {
const handleClick = vi.fn();
render(<Button onClick={handleClick}>Click</Button>);
await userEvent.click(screen.getByRole('button'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
it('should be disabled when loading', () => {
render(<Button isLoading>Submit</Button>);
expect(screen.getByRole('button')).toBeDisabled();
});
});
```
### API Route Testing
```typescript
import { createMocks } from 'node-mocks-http';
import handler from './api/users';
describe('GET /api/users', () => {
it('should return users list', async () => {
const { req, res } = createMocks({ method: 'GET' });
await handler(req, res);
expect(res._getStatusCode()).toBe(200);
expect(JSON.parse(res._getData())).toHaveProperty('users');
});
});
```
## Branch Coverage Checklist
Ensure tests cover:
- [ ] If/else branches
- [ ] Ternary operators
- [ ] Switch cases (including default)
- [ ] Try/catch blocks
- [ ] Early returns
- [ ] Nullish coalescing (`??`)
- [ ] Optional chaining results (`?.`)
- [ ] Loop conditions (0, 1, many iterations)
## Coverage Configuration
```javascript
// vitest.config.ts
export default {
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
exclude: [
'node_modules/',
'**/*.d.ts',
'**/*.test.ts',
'**/types/',
],
thresholds: {
lines: 80,
branches: 75,
functions: 80,
statements: 80,
},
},
},
};
```
## Priority Order for Testing
1. **Critical paths**: Auth, payments, data mutations
2. **Complex logic**: Algorithms, state machines, calculations
3. **Error handlers**: Catch blocks, error boundaries
4. **Edge cases**: Empty arrays, null values, boundaries
5. **Integration points**: API calls, database queries
© OneWave-AI · MIT · OneWave-AI/claude-skills