A Claude Code slash command for generating comprehensive tests for any code.
# Clone to your preferred location
git clone git@github.com:claude-commands/command-test-gen.git <clone-path>/command-test-gen
# Symlink (use full path to cloned repo)
ln -s <clone-path>/command-test-gen/test-gen.md ~/.claude/commands/test-gen.md/test-gen src/auth/login.ts # Generate tests for a file
/test-gen handleAuthentication # Generate tests for a function
- Detects your project's testing framework and conventions
- Analyzes the target code structure and logic paths
- Generates comprehensive test cases including edge cases
- Creates test file following project patterns
- Self-reviews for coverage gaps
// src/__tests__/auth.test.ts
describe('authenticate', () => {
describe('happy path', () => {
it('should return user for valid credentials', async () => {
const result = await authenticate('user@example.com', 'pass')
expect(result.email).toBe('user@example.com')
})
})
describe('edge cases', () => {
it('should handle empty email', async () => {
await expect(authenticate('', 'pass'))
.rejects.toThrow('Email is required')
})
})
describe('error handling', () => {
it('should throw for invalid credentials', async () => {
await expect(authenticate('user@example.com', 'wrong'))
.rejects.toThrow('Invalid credentials')
})
})
})| Category | What's Tested |
|---|---|
| Happy Path | Normal inputs, expected outputs |
| Edge Cases | Empty inputs, boundaries, special chars |
| Error Handling | Invalid inputs, exceptions, failures |
| Concurrency | Race conditions, parallel execution |
| Language | Frameworks |
|---|---|
| Go | testing, testify, gomock |
| TypeScript/JS | Jest, Vitest, Mocha |
| Python | pytest, unittest |
- Auto-detection: Finds your testing framework automatically
- Pattern matching: Follows your existing test conventions
- Edge case discovery: Identifies cases humans often miss
- Mock generation: Creates appropriate mocks for dependencies
- Self-review: Checks for coverage gaps before output
- Git repository with source code
- Existing tests (for pattern detection) - optional but recommended
- Claude Code with Opus 4.5 model access
cd <clone-path>/command-test-gen && git pull