skills/coding/intelligent-test-creation/SKILL.md
Chain-combined skill for creating comprehensive, intelligent tests by combining test-think (what to test), generate-mock (mocking strategy), and setup-test-data (test fixtures). Use when user needs to write tests, wants intelligent test coverage, or when they're unsure what tests to write for a feature. Triggers especially when user says "write tests for this", "how to test this", "test coverage", "what tests do I need", or "generate test cases".
npx skillsauth add ImaginerLabs/skill-manager intelligent-test-creationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Intelligent-test-creation is a chain-combined behavioral specification skill that merges:
test-think — What to test decisionsgenerate-mock — Mocking strategysetup-test-data — Test fixturesThe core judgment it encapsulates: "Given this code change, what tests do I need to write, how should I structure them, and what mocks/fixtures do they require?"
This skill provides a systematic approach to creating test suites that are comprehensive, maintainable, and provide meaningful confidence.
"The goal isn't to test everything — it's to test the things that matter in ways that provide meaningful confidence while remaining maintainable."
┌─────────────────────────────────────────────────────────────┐
│ TEST QUALITY │
│ │
│ CONFIDENCE │
│ ▲ │
│ │ ┌──────────────┐ │
│ │ │ Meaningful │ │
│ │ │ Tests │ │
│ │ └──────────────┘ │
│ │ ┌──────────────┐ │
│ │ │ Fragile │ │
│ │ │ Tests │ │
│ └─────┴──────────────┴──────────────► │
│ Coverage │
│ │
│ HIGH CONFIDENCE + LOW MAINTENANCE = IDEAL │
│ │
└─────────────────────────────────────────────────────────────┘
## Change Classification
| Change Type | Test Priority | Strategy |
|-------------|--------------|----------|
| New feature | High | Positive + negative + edge cases |
| Bug fix | Critical | Regression + fix verification |
| Refactor | Medium | Verify behavior unchanged |
| Config change | Low | Verify config loaded correctly |
| Dependency update | Medium | Verify integration unchanged |
| Performance fix | Medium | Benchmark before/after |
## Risk Assessment Matrix
┌─────────────────────────────────────────────────────────────┐
│ IMPACT × LIKELIHOOD │
│ │
│ Low Impact High Impact │
│ ┌────────────────┬────────────────┬───────────────────┐ │
│ │ High Likelihood│ Quick wins │ Priority tests │ │
│ ├────────────────┼────────────────┼───────────────────┤ │
│ │ Low Likelihood │ Consider skip │ Risk mitigation │ │
│ └────────────────┴────────────────┴───────────────────┘ │
└─────────────────────────────────────────────────────────────┘
// TEMPLATE: Intelligent Test Case
describe('FeatureName', () => {
// GROUP 1: Happy Path (Primary behavior)
describe('when valid input', () => {
it('should [expected behavior]', () => { /* ... */ });
});
// GROUP 2: Negative Cases (Invalid input handling)
describe('when invalid input', () => {
it('should [handle invalid gracefully]', () => { /* ... */ });
it('should [return meaningful error]', () => { /* ... */ });
});
// GROUP 3: Edge Cases (Boundary conditions)
describe('edge cases', () => {
it('should handle [edge case 1]', () => { /* ... */ });
it('should handle [edge case 2]', () => { /* ... */ });
});
// GROUP 4: Integration Points (If applicable)
describe('with external dependencies', () => {
it('should [handle dependency correctly]', () => { /* ... */ });
});
});
// PATTERN: "should [expected behavior] when [condition]"
// Examples:
// Good test names:
should_return_user_when_id_exists()
should_throw_notfound_when_user_does_not_exist()
should_retry_three_times_when_payment_fails()
should_return_empty_list_when_no_results()
// Bad test names (implementation-focused):
test_getUser()
test_handleError()
test_function1()
## Dependency Analysis
Component: processPayment(amount, card)
┌─────────────────────────────────────────────────────────────┐
│ │
│ Dependencies: │
│ ┌─────────────┐ │
│ │ PaymentGateway│ Type: External API │
│ │ [MOCK] │ Why: Can't test with real payments │
│ └─────────────┘ │
│ │
│ ┌─────────────┐ │
│ │ Logger │ Type: Side effect │
│ │ [MOCK] │ Why: Track calls, not assertions │
│ └─────────────┘ │
│ │
│ ┌─────────────┐ │
│ │ UserService │ Type: Internal │
│ │ [REAL/SPIED] │ Why: Test real behavior │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
// Pattern: Descriptive mock factory
function createPaymentGatewayMock(overrides?: {
charge?: () => Promise<PaymentResult>;
refund?: () => Promise<void>;
}) {
return {
charge: vi.fn().mockResolvedValue({ success: true, id: 'tx_123' }),
refund: vi.fn().mockResolvedValue(undefined),
...overrides,
};
}
function createLoggerMock() {
return {
info: vi.fn(),
error: vi.fn(),
warn: vi.fn(),
};
}
// Pattern: Composable test fixtures
const baseUser = {
id: 'user_123',
email: '[email protected]',
name: 'Test User',
createdAt: new Date('2024-01-01'),
};
// For specific test scenarios
function createTestUser(overrides?: Partial<typeof baseUser>) {
return { ...baseUser, ...overrides };
}
describe('getUser', () => {
it('should return user with id', () => {
const user = createTestUser({ id: 'special_123' });
// Use in test
});
});
## Test Data Strategy
┌─────────────────────────────────────────────────────────────┐
│ TEST DATA HIERARCHY │
│ │
│ MINIMAL ─────► TYPICAL ─────► EDGE CASE ─────► ANOMALY │
│ │
│ {id: 1} {id, name, {id: 0, -1, {null, undefined,
│ email, etc} MAX, MIN} empty string}
│ │
│ Fast to Represents Boundary Rare/error │
│ create real usage conditions conditions │
└─────────────────────────────────────────────────────────────┘
## Change Analysis Worksheet
**What changed?**
[Describe the code change]
**What behavior is new/changed?**
[List specific behaviors]
**What's the blast radius?**
[What could this break?]
**What existing tests cover this?**
[List existing tests, if any]
## Coverage Decision
| Behavior | Test Needed | Test Type | Priority |
|----------|-------------|-----------|----------|
| Primary use case | ✅ | Happy path | P0 |
| Invalid input | ✅ | Negative | P0 |
| Edge case: empty | ✅ | Edge | P1 |
| Edge case: max value | ✅ | Edge | P1 |
| Error handling | ✅ | Error | P1 |
| Logging side effects | 🤔 | Verify only | P2 |
**Total: 4-6 tests recommended**
// Structure recommendation:
// - Group by scenario (given/when/then)
// - Name tests descriptively
// - One assertion focus per test
// - Use setup functions for common patterns
describe('UserRegistration', () => {
// SETUP
let mockUserRepo: ReturnType<typeof createUserRepoMock>;
let mockEmailService: ReturnType<typeof createEmailMock>;
beforeEach(() => {
mockUserRepo = createUserRepoMock();
mockEmailService = createEmailMock();
});
// HAPPY PATH
describe('when valid registration', () => {
it('should create user and send welcome email', async () => {
// Arrange
const input = { email: '[email protected]', password: 'Secure123!' };
mockUserRepo.findByEmail.mockResolvedValue(null);
// Act
const result = await registerUser(input, mockUserRepo, mockEmailService);
// Assert
expect(result.user.email).toBe(input.email);
expect(mockEmailService.sendWelcome).toHaveBeenCalledWith(input.email);
});
});
// NEGATIVE CASES
describe('when email already exists', () => {
it('should throw EmailExistsError', async () => {
// Arrange
const existingUser = { email: '[email protected]' };
mockUserRepo.findByEmail.mockResolvedValue(existingUser);
// Act & Assert
await expect(registerUser({ ... }, mockUserRepo, mockEmailService))
.rejects
.toThrow(EmailExistsError);
});
});
// EDGE CASES
describe('edge cases', () => {
it('should handle email with plus addressing', async () => {
// Test that [email protected] is treated as [email protected]
});
});
});
describe('OrderTotalCalculation', () => {
describe('given a cart with items', () => {
const cart = createCartWith([
{ price: 100, quantity: 2 },
{ price: 50, quantity: 1 },
]);
describe('when calculating total', () => {
const total = calculateOrderTotal(cart);
it('then should sum all item totals', () => {
expect(total).toBe(250);
});
it('then should include tax', () => {
expect(total.tax).toBe(25);
});
});
});
});
describe('OrderStateMachine', () => {
it('should transition PENDING -> PAID -> SHIPPED -> DELIVERED', () => {
const order = createPendingOrder();
order.pay();
expect(order.state).toBe('PAID');
order.ship();
expect(order.state).toBe('SHIPPED');
order.deliver();
expect(order.state).toBe('DELIVERED');
});
it('should reject PAID -> SHIPPED if payment failed', () => {
const order = createPaidOrder({ paymentStatus: 'FAILED' });
expect(() => order.ship()).toThrow(InvalidStateTransitionError);
});
});
describe('PaymentProcessing', () => {
it('should throw PaymentDeclined when card is expired', async () => {
const expiredCard = createCard({ expiry: '01/20' }); // Past date
await expect(processPayment(100, expiredCard))
.rejects
.toThrow(PaymentDeclinedError);
});
it('should include decline reason in error', async () => {
const declinedCard = createCard();
mockPaymentGateway.charge.mockRejectedValue(
new DeclinedError('Insufficient funds')
);
try {
await processPayment(100, declinedCard);
} catch (error) {
expect(error.declineReason).toBe('Insufficient funds');
}
});
});
Analysis: New feature - User profile update
**Required tests:**
1. ✅ Happy path: Update name successfully
2. ✅ Negative: Reject invalid email
3. ✅ Negative: Reject empty name
4. ✅ Edge: Handle very long name (truncation?)
5. ✅ Auth: Reject unauthenticated requests
6. ✅ Auth: Reject updating other users
**Optional (if complex):**
- Rate limiting
- Concurrent updates
**Mock strategy:**
- UserRepository: MOCK (database)
- AuthService: REAL (test real auth)
- EmailService: MOCK (don't send real emails)
Bug: NullPointerException when user has no orders
**Regression tests (ensure bug doesn't return):**
1. ✅ should_not_throw_when_user_has_no_orders
2. ✅ should_return_empty_array_when_user_has_no_orders
**Fix verification tests:**
1. ✅ should_handle_null_orders_from_db
2. ✅ should_filter_out_invalid_orders
**Edge cases added:**
1. ✅ should_handle_user_exists_but_orders_table_empty
2. ✅ should_handle_orders_query_returns_null
Wrong approach: Add tests just for coverage %
Right approach: Find real bugs that aren't tested
**Coverage improvement plan:**
1. List last 6 months of production bugs
2. Check if each has a test
3. If not, add a test for that specific bug scenario
4. That's meaningful coverage improvement
**Not worth testing just for coverage:**
- Trivial getters
- One-line wrappers
- Already-covered edge cases
INTELLIGENT TEST CREATION CHECKLIST
====================================
□ 1. Change analyzed - understand what behavior changed
□ 2. Test scope determined - happy path + negative + edge
□ 3. Risk assessed - critical paths covered
□ 4. Dependencies classified - what to mock
□ 5. Test data planned - fixtures designed
□ 6. Test structure organized - grouped by scenario
□ 7. Names are descriptive - what/when/then pattern
□ 8. Assertions are meaningful - test outcomes, not internals
□ 9. Setup is clean - beforeEach for common setup
□ 10. Cleanup is handled - mocks cleared between tests
□ 11. Edge cases included - boundaries + anomalies
□ 12. Error paths tested - what could go wrong
□ 13. Integration verified - if applicable
□ 14. Tests are maintainable - won't break on refactor
Tests should pass when behavior is preserved, even if implementation changes.
Each test should verify one specific behavior. Multiple assertions are OK if they verify one behavior from multiple angles.
Test names serve as executable documentation. Invest in making them clear.
Common setup in beforeEach keeps tests DRY and maintainable.
The happy path probably works. It's the edge cases that bite you.
Mock to isolate, not to avoid testing real behavior.
test-think — Decides what to testgenerate-mock — Provides mock strategysetup-test-data — Creates test fixturesdebug-test — When tests failtest-readability — Clean test structuresafe-refactor — Tests enable safe refactoringread-test-coverage — Understanding coverage metricsdevelopment
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
devops
Create a new implementation plan file for new features, refactoring existing code or upgrading packages, design, architecture or infrastructure.
tools
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
documentation
Generates standardized porting documentation from completed feature changes. Analyzes commit diffs or file contents, extracts change intent, and outputs Markdown documentation for cross-team understanding. Should be used when the user needs to document a change for cross-team or cross-project consumption. Distinguished from cross-branch-fix-porter which actively re-implements fixes, this skill documents changes.