$npx -y skills add Toowiredd/claude-skills-automation --skill testing-builderAutomatically generates comprehensive test suites (unit, integration, E2E) based on code and past testing patterns. Use when user says "write tests", "test this", "add coverage", or after fixing bugs to create regression tests. Eliminates testing friction for ADHD users.
| 1 | # Testing Builder |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Automatic test generation that learns your testing style. Eliminates the ADHD barrier to testing by making it effortless: |
| 6 | 1. Analyzes code to understand what needs testing |
| 7 | 2. Recalls your testing patterns from memory |
| 8 | 3. Generates comprehensive test suite |
| 9 | 4. Ensures all edge cases covered |
| 10 | 5. Saves testing patterns for future |
| 11 | |
| 12 | **For ADHD users**: Zero friction - tests created instantly without manual effort. |
| 13 | **For all users**: Comprehensive coverage without the tedious work. |
| 14 | **Learning system**: Gets better at matching your testing style over time. |
| 15 | |
| 16 | ## Activation Triggers |
| 17 | |
| 18 | - User says: "write tests", "test this", "add tests", "coverage" |
| 19 | - After fixing bug: "create regression test" |
| 20 | - Code review: "needs tests" |
| 21 | - User mentions: "unit test", "integration test", "E2E test" |
| 22 | |
| 23 | ## Core Workflow |
| 24 | |
| 25 | ### 1. Analyze Code |
| 26 | |
| 27 | **Step 1**: Identify what to test |
| 28 | |
| 29 | ```javascript |
| 30 | // Example: Analyzing a function |
| 31 | function calculateDiscount(price, discountPercent, customerType) { |
| 32 | if (customerType === 'premium') { |
| 33 | discountPercent += 10; |
| 34 | } |
| 35 | return price * (1 - discountPercent / 100); |
| 36 | } |
| 37 | |
| 38 | // Identify: |
| 39 | - Function name: calculateDiscount |
| 40 | - Parameters: price, discountPercent, customerType |
| 41 | - Logic branches: premium vs non-premium |
| 42 | - Edge cases: negative values, zero, boundary conditions |
| 43 | - Return type: number |
| 44 | ``` |
| 45 | |
| 46 | **Step 2**: Determine test type needed |
| 47 | |
| 48 | - **Unit test**: Pure functions, utilities, components |
| 49 | - **Integration test**: Multiple components working together, API endpoints |
| 50 | - **E2E test**: Full user workflows, critical paths |
| 51 | - **Regression test**: Specific bug that was fixed |
| 52 | |
| 53 | ### 2. Recall Testing Patterns |
| 54 | |
| 55 | Query context-manager for: |
| 56 | |
| 57 | ``` |
| 58 | search memories: |
| 59 | - Type: PREFERENCE, PROCEDURE |
| 60 | - Tags: testing, test-framework, test-style |
| 61 | - Project: current project |
| 62 | ``` |
| 63 | |
| 64 | **What to recall**: |
| 65 | - Test framework (Jest, Vitest, Pytest, etc.) |
| 66 | - Assertion style (expect, assert, should) |
| 67 | - Test structure (describe/it, test blocks) |
| 68 | - Mocking patterns (jest.mock, vi.mock) |
| 69 | - Coverage requirements |
| 70 | - File naming conventions |
| 71 | |
| 72 | **Example memory**: |
| 73 | ``` |
| 74 | PREFERENCE: Testing style for BOOSTBOX |
| 75 | - Framework: Vitest |
| 76 | - Assertion: expect() |
| 77 | - Structure: describe/it blocks |
| 78 | - Coverage: Minimum 80% |
| 79 | - File naming: {filename}.test.js |
| 80 | ``` |
| 81 | |
| 82 | ### 3. Generate Test Suite |
| 83 | |
| 84 | **Unit Test Template**: |
| 85 | |
| 86 | ```javascript |
| 87 | import { describe, it, expect } from 'vitest'; |
| 88 | import { calculateDiscount } from './discount'; |
| 89 | |
| 90 | describe('calculateDiscount', () => { |
| 91 | describe('basic calculations', () => { |
| 92 | it('should calculate discount correctly for regular customers', () => { |
| 93 | const result = calculateDiscount(100, 10, 'regular'); |
| 94 | expect(result).toBe(90); |
| 95 | }); |
| 96 | |
| 97 | it('should add bonus discount for premium customers', () => { |
| 98 | const result = calculateDiscount(100, 10, 'premium'); |
| 99 | expect(result).toBe(80); // 10% + 10% bonus |
| 100 | }); |
| 101 | }); |
| 102 | |
| 103 | describe('edge cases', () => { |
| 104 | it('should handle zero discount', () => { |
| 105 | const result = calculateDiscount(100, 0, 'regular'); |
| 106 | expect(result).toBe(100); |
| 107 | }); |
| 108 | |
| 109 | it('should handle 100% discount', () => { |
| 110 | const result = calculateDiscount(100, 100, 'regular'); |
| 111 | expect(result).toBe(0); |
| 112 | }); |
| 113 | |
| 114 | it('should handle zero price', () => { |
| 115 | const result = calculateDiscount(0, 10, 'regular'); |
| 116 | expect(result).toBe(0); |
| 117 | }); |
| 118 | }); |
| 119 | |
| 120 | describe('invalid inputs', () => { |
| 121 | it('should handle negative price', () => { |
| 122 | const result = calculateDiscount(-100, 10, 'regular'); |
| 123 | expect(result).toBeLessThan(0); |
| 124 | }); |
| 125 | |
| 126 | it('should handle invalid customer type', () => { |
| 127 | const result = calculateDiscount(100, 10, 'unknown'); |
| 128 | expect(result).toBe(90); // Falls back to regular |
| 129 | }); |
| 130 | }); |
| 131 | }); |
| 132 | ``` |
| 133 | |
| 134 | **Integration Test Template** (API endpoint): |
| 135 | |
| 136 | ```javascript |
| 137 | import { describe, it, expect, beforeAll, afterAll } from 'vitest'; |
| 138 | import request from 'supertest'; |
| 139 | import { app } from './app'; |
| 140 | import { db } from './db'; |
| 141 | |
| 142 | describe('POST /api/users', () => { |
| 143 | beforeAll(async () => { |
| 144 | await db.connect(); |
| 145 | }); |
| 146 | |
| 147 | afterAll(async () => { |
| 148 | await db.disconnect(); |
| 149 | }); |
| 150 | |
| 151 | it('should create a new user', async () => { |
| 152 | const response = await request(app) |
| 153 | .post('/api/users') |
| 154 | .send({ |
| 155 | email: 'test@example.com', |
| 156 | name: 'Test User' |
| 157 | }); |
| 158 | |
| 159 | expect(response.status).toBe(201); |
| 160 | expect(response.body).toHaveProperty('id'); |
| 161 | expect(response.body.email).toBe('test@example.com'); |
| 162 | }); |
| 163 | |
| 164 | it('should reject duplicate email', async () => { |
| 165 | await request(app).post('/api/users').send({ |
| 166 | email: 'duplicate@example.com', |
| 167 | name: 'User 1' |
| 168 | }); |
| 169 | |
| 170 | const response = await request(app) |
| 171 | .post('/api/users') |
| 172 | .send({ |