From unit-test-generator
Review code changes and generate comprehensive unit test coverage proposals with test scenarios for positive, negative, edge cases, and defaults
How this skill is triggered — by the user, by Claude, or both
Slash command
/unit-test-generator:unit-test-generatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Analyzes code changes in the current branch and generates detailed unit test coverage proposals, comparing against the default branch to identify coverage gaps.
Analyzes code changes in the current branch and generates detailed unit test coverage proposals, comparing against the default branch to identify coverage gaps.
This skill reviews staged and committed code changes in your current branch, identifies test coverage gaps by comparing against the default branch, and produces a detailed implementation plan for comprehensive unit tests. It analyzes existing test patterns in your repository to maintain consistency.
Search repository for unit test files using patterns:
.(test|spec).(ts|js|tsx|jsx)$ /* TypeScript/JavaScript test files */
^test_.*\.py$ /* Python test files (prefix) */
.*\_test\.(py|go)$ /* Python/Go test files (suffix) */
.*Test\.java$ /* Java test files */
.*_(spec|test)\.rb$ /* Ruby test files */
Extract and document:
Analyze modified code for missing test coverage:
For each coverage gap, propose unit tests covering:
| Scenario | Description | Example |
|---|---|---|
| Positive | Valid inputs produce expected outputs | Call function with valid data, verify correct result |
| Negative | Invalid/error inputs handled properly | Call function with null/undefined, verify error handling |
| Edge Case | Boundary conditions and special values | Zero, empty arrays, max/min values, special characters |
| Default | Default parameters and fallback behavior | Function called without optional params, default values used |
Document:
Files Modified: [list]
Functions/Components Changed: [list]
Lines Added/Modified: [count]
Framework: [e.g., Jest, Pytest, RSpec]
Test Directory: [path]
Naming Convention: [pattern]
Average Tests Per File: [number]
Uncovered Functions: [list with reason]
Uncovered Scenarios: [list by type]
Total Coverage Gaps: [count]
Test Suite: [name]
├── Test 1: [name] (Positive)
│ ├── Input: [description]
│ ├── Expected: [description]
│ └── Assertions: [list]
├── Test 2: [name] (Negative)
│ ├── Input: [description]
│ ├── Expected: [description]
│ └── Assertions: [list]
├── Test 3: [name] (Edge Case)
│ ├── Input: [description]
│ ├── Expected: [description]
│ └── Assertions: [list]
└── Test 4: [name] (Default)
├── Input: [description]
├── Expected: [description]
└── Assertions: [list]
Phase 1 (High Priority):
- Test: [name]
File: [location]
Phase 2 (Medium Priority):
- Test: [name]
File: [location]
Setup Required:
- [list any test fixtures, mocks, or configuration]
// New function in user service
export function calculateMembershipDiscount(
memberLevel: string,
purchaseAmount: number,
): number {
const discountMap: Record<string, number> = {
gold: 0.2,
silver: 0.1,
bronze: 0.05,
};
const discount = discountMap[memberLevel] || 0;
return Math.round(purchaseAmount * discount * 100) / 100;
}
Test Suite: calculateMembershipDiscount
1. Test: should return correct discount for gold member (Positive)
Input: memberLevel = 'gold', purchaseAmount = 100
Expected: 20
Assertions: result === 20
2. Test: should return correct discount for silver member (Positive)
Input: memberLevel = 'silver', purchaseAmount = 200
Expected: 20
Assertions: result === 20
3. Test: should return zero discount for unknown member level (Negative)
Input: memberLevel = 'invalid', purchaseAmount = 100
Expected: 0
Assertions: result === 0
4. Test: should handle zero purchase amount (Edge Case)
Input: memberLevel = 'gold', purchaseAmount = 0
Expected: 0
Assertions: result === 0
5. Test: should return zero discount when no member level provided (Default)
Input: memberLevel = '', purchaseAmount = 100
Expected: 0
Assertions: result === 0
6. Test: should round discount correctly (Edge Case)
Input: memberLevel = 'gold', purchaseAmount = 33
Expected: 6.60
Assertions: result === 6.60
Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub lmaon2466/levar-marketplace --plugin unit-test-generator