characterization-test-generator
Generate characterization tests to capture and verify existing behavior before migration
What this skill does
# Characterization Test Generator Skill
Generates characterization tests (also known as golden master tests or approval tests) to capture existing system behavior before migration, ensuring functional equivalence after changes.
## Purpose
Enable behavior preservation during migration through:
- Golden master test creation
- Approval test generation
- Edge case discovery
- Input/output recording
- Behavior snapshot capture
- Regression baseline establishment
## Capabilities
### 1. Golden Master Test Creation
- Capture current system outputs for given inputs
- Store outputs as reference "golden" files
- Generate comparison test infrastructure
- Support multiple output formats
- Enable baseline versioning
### 2. Approval Test Generation
- Create human-reviewable test outputs
- Generate diff-based comparison tests
- Support approval workflows
- Enable incremental approval
- Track approval history
### 3. Edge Case Discovery
- Analyze code paths for boundary conditions
- Generate boundary value inputs
- Identify error handling scenarios
- Map exception paths
- Create comprehensive test coverage
### 4. Input/Output Recording
- Instrument code for I/O capture
- Record API request/response pairs
- Capture database interactions
- Log external service calls
- Store timing and sequence data
### 5. Behavior Snapshot
- Capture state at key points
- Record side effects
- Document non-deterministic behavior
- Identify environmental dependencies
- Map configuration impacts
### 6. Regression Baseline Establishment
- Create baseline test suites
- Define acceptance thresholds
- Configure tolerance levels
- Set up CI/CD integration
- Generate coverage reports
## Tool Integrations
This skill can leverage the following external tools when available:
| Tool | Purpose | Integration Method |
|------|---------|-------------------|
| ApprovalTests | Approval testing framework | Library |
| Jest snapshots | JavaScript snapshot testing | Framework |
| pytest-snapshot | Python snapshot testing | Plugin |
| TextTest | Golden master testing | CLI |
| Verify | .NET approval testing | Library |
| Scientist | Safe refactoring library | Library |
| AI Testing MCP | AI-powered test generation | MCP Server |
## Usage
### Basic Test Generation
```bash
# Invoke skill for characterization test generation
# The skill will analyze code and generate tests
# Expected inputs:
# - targetPath: Path to code to characterize
# - testFramework: 'jest' | 'pytest' | 'junit' | 'nunit' | 'auto'
# - outputDir: Directory for generated tests
# - captureMode: 'snapshot' | 'approval' | 'recording'
```
### Generation Workflow
1. **Analysis Phase**
- Identify testable units (functions, methods, endpoints)
- Map input parameters and types
- Detect output formats
- Find external dependencies
2. **Input Discovery Phase**
- Extract existing test inputs
- Generate boundary values
- Identify representative cases
- Create combinatorial inputs
3. **Capture Phase**
- Execute code with inputs
- Record outputs and side effects
- Capture state changes
- Log external interactions
4. **Test Generation Phase**
- Generate test code structure
- Create golden master files
- Set up comparison logic
- Configure CI integration
## Output Schema
```json
{
"generationId": "string",
"timestamp": "ISO8601",
"target": {
"path": "string",
"language": "string",
"framework": "string",
"unitsAnalyzed": "number"
},
"testsGenerated": {
"total": "number",
"byType": {
"snapshot": "number",
"approval": "number",
"recording": "number"
},
"coverage": {
"functions": "number",
"branches": "number",
"lines": "number"
}
},
"characterizations": [
{
"unit": "string",
"type": "function|method|endpoint|class",
"inputs": [
{
"name": "string",
"type": "string",
"values": ["any"],
"source": "existing|generated|boundary"
}
],
"outputs": {
"type": "string",
"goldenMasterPath": "string",
"checksum": "string"
},
"testFile": "string",
"baselineApproved": "boolean"
}
],
"edgeCases": [
{
"unit": "string",
"case": "string",
"input": "any",
"expectedBehavior": "string",
"covered": "boolean"
}
],
"dependencies": {
"external": ["string"],
"mocked": ["string"],
"recorded": ["string"]
},
"artifacts": {
"testSuite": "string",
"goldenMasters": "string",
"recordings": "string",
"coverageReport": "string"
}
}
```
## Integration with Migration Processes
This skill integrates with the following Code Migration/Modernization processes:
- **migration-testing-strategy**: Primary tool for test baseline creation
- **code-refactoring**: Ensure behavior preservation during refactoring
- **framework-upgrade**: Verify functionality after upgrade
- **monolith-to-microservices**: Validate service extraction
## Configuration
### Skill Configuration File
Create `.characterization-tests.json` in the project root:
```json
{
"testFramework": "auto",
"outputDir": "./tests/characterization",
"captureMode": "snapshot",
"goldenMasterDir": "./tests/golden-masters",
"inputGeneration": {
"boundary": true,
"combinatorial": true,
"maxCombinations": 100,
"includeNulls": true,
"includeEmpty": true
},
"outputCapture": {
"format": "json",
"normalizeWhitespace": true,
"ignorePaths": ["$.timestamp", "$.requestId"],
"tolerance": {
"numeric": 0.001,
"dateTime": "1s"
}
},
"dependencies": {
"mockExternal": true,
"recordMode": false,
"replayMode": true
},
"approval": {
"requireApproval": true,
"approvalDir": "./tests/approvals",
"reportFormat": "markdown"
},
"ci": {
"failOnNewTests": false,
"updateGoldenOnPass": false,
"generateCoverageReport": true
}
}
```
## MCP Server Integration
When AI Testing MCP Server is available:
```javascript
// Example AI-powered test generation
{
"tool": "ai_testing_generate",
"arguments": {
"target": "./src/services/user.ts",
"framework": "jest",
"style": "characterization"
}
}
```
## Test Patterns
### Snapshot Testing (Jest)
```javascript
// Generated characterization test
describe('UserService', () => {
describe('calculateDiscount', () => {
it('should match snapshot for standard customer', () => {
const result = userService.calculateDiscount({
customerId: 'C001',
purchaseAmount: 100,
loyaltyPoints: 500
});
expect(result).toMatchSnapshot();
});
it('should match snapshot for premium customer', () => {
const result = userService.calculateDiscount({
customerId: 'C002',
purchaseAmount: 100,
loyaltyPoints: 5000,
isPremium: true
});
expect(result).toMatchSnapshot();
});
// Edge cases
it('should match snapshot for zero amount', () => {
const result = userService.calculateDiscount({
customerId: 'C001',
purchaseAmount: 0,
loyaltyPoints: 0
});
expect(result).toMatchSnapshot();
});
});
});
```
### Approval Testing (ApprovalTests)
```java
// Generated approval test
public class UserServiceCharacterizationTest {
@Test
public void calculateDiscount_standardCustomer() {
UserService service = new UserService();
DiscountResult result = service.calculateDiscount(
new DiscountRequest("C001", 100.0, 500)
);
Approvals.verify(result);
}
@Test
public void calculateDiscount_boundaryValues() {
UserService service = new UserService();
// Boundary: minimum values
Approvals.verify(service.calculateDiscount(
new DiscountRequest("C001", 0.01, 0)
), "minimum");
// Boundary: maximum values
Approvals.verify(serRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.