Purpose & When-To-Use
Trigger conditions:
- Starting a new project that needs a comprehensive testing approach
- Existing codebase with insufficient or imbalanced test coverage
- Technical debt remediation requiring systematic test improvement
- Architecture changes necessitating test strategy reassessment
- Team onboarding requiring clear testing guidelines
Use this skill when you need to establish or improve testing practices with clear ROI, balanced coverage across the test pyramid, and framework-specific implementation guidance.
Pre-Checks
Before execution, verify:
- Time normalization:
NOW_ET = 2025-10-25T21:30:36-04:00 (NIST/time.gov semantics, America/New_York)
- Input schema validation:
system_description is non-empty string or parseable diagram
tech_stack contains at least one technology identifier
constraints (if provided) includes valid keys: budget, time, team_size
existing_coverage (if provided) has numeric metrics
- Source freshness: All cited sources accessed on
NOW_ET; verify links resolve
- Framework compatibility: Confirm tech_stack technologies have known testing frameworks
Abort conditions:
- System description is too vague to identify testable components
- Tech stack includes only proprietary/undocumented technologies
- Constraints are contradictory (e.g., "zero budget" + "100% coverage")
Procedure
T1: Fast Path (≤2k tokens)
Goal: Analyze system and recommend test type distribution.
Parse system description:
- Identify architecture pattern (monolith, microservices, serverless, mobile, etc.)
- Extract key components (API, database, UI, services, jobs)
- Determine complexity level (simple/moderate/complex)
Apply test pyramid heuristics (based on Martin Fowler's Test Pyramid, accessed 2025-10-25):
- Unit tests (70%): Business logic, utilities, pure functions
- Integration tests (20%): Database, API contracts, external services
- E2E tests (10%): Critical user journeys, smoke tests
- Adjust ratios based on architecture (e.g., API-only systems: 60/30/10)
Output initial recommendation:
{
"test_distribution": {
"unit": 70,
"integration": 20,
"e2e": 10
},
"priority_areas": ["auth", "payment", "data-sync"],
"estimated_effort_hours": 40
}
Token budget: ≤2k tokens
T2: Extended Analysis (≤6k tokens)
Goal: Generate test scaffolding, calculate gaps, and create execution plan.
Map tech stack to testing frameworks:
- JavaScript/Node.js → Jest, Mocha, Supertest, Playwright
- Python → pytest, unittest, Selenium
- Java → JUnit, Mockito, RestAssured
- C# → xUnit, NUnit, SpecFlow
- Consult [Microsoft Testing Patterns](https://learn.microsoft.com/en-us/dotnet/core/testing/, accessed 2025-10-25)
Generate framework-specific scaffolding:
- Unit test template with arrange-act-assert pattern
- Integration test template with setup/teardown
- E2E test template for critical path
- Performance test baseline (if applicable)
- Reference [Google Testing Blog](https://testing.googleblog.com/, accessed 2025-10-25) for best practices
Identify coverage gaps:
- Compare
existing_coverage to targets
- Calculate gap percentage per test type
- Prioritize by risk (auth > payments > admin)
- Output JSON with specific untested modules
Create phased execution plan:
Token budget: ≤6k tokens total (including T1)
T3: Deep Dive (not implemented for this skill)
T3 is not required for this P0 skill; T2 provides sufficient depth for most testing strategies.
Decision Rules
Test distribution adjustments:
- Microservices: Increase integration to 30%, decrease unit to 60%
- Mobile apps: Increase E2E to 20% (UI-critical), decrease integration to 15%
- API-only: Integration to 35%, unit to 55%, E2E to 10%
- ML/Data pipelines: Add performance tests (10%), adjust others proportionally
Effort estimation (per 1000 LOC):
- Unit tests: 4-8 hours
- Integration tests: 8-16 hours
- E2E tests: 16-24 hours
- Performance tests: 20-40 hours
Coverage thresholds (from [Martin Fowler Testing](https://martinfowler.com/testing/, accessed 2025-10-25)):
- Minimum acceptable: 60%
- Target for production: 80%
- Aspirational: 90%+ (diminishing returns above 85%)
Stop conditions:
- If constraints allow <10 hours: recommend T1 fast path only (unit tests for critical paths)
- If no testable components identified: emit TODO and request clarification
- If tech_stack is purely manual/visual testing: redirect to exploratory testing skill
Output Contract
Required fields (all outputs):
interface TestStrategy {
strategy: string; // Markdown document (200-800 words)
test_distribution: {
unit: number; // Percentage (0-100)
integration: number;
e2e: number;
performance?: number;
};
priority_areas: string[]; // Top 3-5 high-risk components
estimated_effort_hours: number;
}
interface TestScaffolding {
framework: string; // e.g., "Jest", "pytest"
unit_template: string; // Code snippet
integration_template: string;
e2e_template: string;
setup_instructions: string; // Installation/config steps
}
interface CoverageGaps {
current_coverage_percent: number;
target_coverage_percent: number;
gap_percent: number;
untested_modules: Array<{
name: string;
risk: "high" | "medium" | "low";
estimated_effort_hours: number;
}>;
}
interface ExecutionPlan {
phases: Array<{
phase_number: number;
duration_weeks: number;
focus_area: string;
deliverables: string[];
success_criteria: string;
}>;
total_duration_weeks: number;
dependencies: string[]; // External blockers
}
Format:
test_strategy: Markdown with headings (## Overview, ## Test Types, ## Rationale)
test_scaffolding: Code blocks with language hints (```javascript)
coverage_gaps: Valid JSON
execution_plan: Markdown with tables or numbered lists
Validation:
- All percentages sum to 100 (±2% rounding tolerance)
- Effort estimates are positive integers
- Phase dependencies are acyclic
Examples
Example 1: REST API System (T2)
INPUT:
system_description: "REST API with Node.js/Express, PostgreSQL, Redis"
tech_stack: ["node.js", "express", "jest", "supertest"]
existing_coverage: {unit: 45, integration: 10, e2e: 0}
OUTPUT:
test_distribution: {unit: 65, integration: 25, e2e: 10}
scaffolding:
# Unit test (Jest)
describe('UserService', () => {
it('hashes password', () => {
expect(hashPassword('secret')).not.toBe('secret');
});
});
# Integration test
describe('POST /users', () => {
it('creates user in DB', async () => {
const res = await request(app).post('/users').send({name: 'Alice'});
expect(res.status).toBe(201);
});
});
coverage_gaps:
- {module: "AuthService", risk: "high", effort_hours: 8}
Quality Gates
Token budgets (mandatory):
- T1 ≤ 2k tokens (recommendation only)
- T2 ≤ 6k tokens (full strategy + scaffolding)
- T3 not implemented
Safety checks:
Auditability:
Determinism:
Validation checklist:
Resources
Primary sources (accessed 2025-10-25):
Google Testing Blog: https://testing.googleblog.com/
Best practices, case studies, and emerging patterns from Google's testing infrastructure team.
Martin Fowler - Testing: https://martinfowler.com/testing/
Canonical testing patterns, pyramid model, and test doubles taxonomy.
Practical Test Pyramid: https://martinfowler.com/articles/practical-test-pyramid.html
Detailed guide on test distribution, anti-patterns, and framework examples.
Microsoft Testing Patterns: https://learn.microsoft.com/en-us/dotnet/core/testing/
Official guidance for unit, integration, and performance testing in .NET ecosystems.
ISTQB Foundation Level: https://www.istqb.org/certifications/certified-tester-foundation-level
International standard for testing terminology, lifecycle, and techniques.
Additional templates:
- See
resources/test-pyramid-template.md for Markdown strategy template
- See
examples/strategy-example.txt for complete workflow example
Related skills (future):
performance-test-designer (for load/stress testing deep dive)
mutation-testing-analyzer (for assessing test effectiveness)
flaky-test-investigator (for debugging unstable tests)
End of SKILL.md
1---2name: testing-strategy-composer3description: Compose comprehensive testing strategies spanning unit, integration, e2e, and performance tests with optimal coverage.4license: MIT5---67## Purpose & When-To-Use89**Trigger conditions:**1011- Starting a new project that needs a comprehensive testing approach12- Existing codebase with insufficient or imbalanced test coverage13- Technical debt remediation requiring systematic test improvement14- Architecture changes necessitating test strategy reassessment15- Team onboarding requiring clear testing guidelines1617**Use this skill when** you need to establish or improve testing practices with clear ROI, balanced coverage across the test pyramid, and framework-specific implementation guidance.1819---2021## Pre-Checks2223**Before execution, verify:**24251. **Time normalization**: `NOW_ET = 2025-10-25T21:30:36-04:00` (NIST/time.gov semantics, America/New_York)262. **Input schema validation**:27 - `system_description` is non-empty string or parseable diagram28 - `tech_stack` contains at least one technology identifier29 - `constraints` (if provided) includes valid keys: `budget`, `time`, `team_size`30 - `existing_coverage` (if provided) has numeric metrics313. **Source freshness**: All cited sources accessed on `NOW_ET`; verify links resolve324. **Framework compatibility**: Confirm tech_stack technologies have known testing frameworks3334**Abort conditions:**3536- System description is too vague to identify testable components37- Tech stack includes only proprietary/undocumented technologies38- Constraints are contradictory (e.g., "zero budget" + "100% coverage")3940---4142## Procedure4344### T1: Fast Path (≤2k tokens)4546**Goal**: Analyze system and recommend test type distribution.47481. **Parse system description**:49 - Identify architecture pattern (monolith, microservices, serverless, mobile, etc.)50 - Extract key components (API, database, UI, services, jobs)51 - Determine complexity level (simple/moderate/complex)52532. **Apply test pyramid heuristics** (based on [Martin Fowler's Test Pyramid](https://martinfowler.com/articles/practical-test-pyramid.html), accessed 2025-10-25):54 - **Unit tests (70%)**: Business logic, utilities, pure functions55 - **Integration tests (20%)**: Database, API contracts, external services56 - **E2E tests (10%)**: Critical user journeys, smoke tests57 - Adjust ratios based on architecture (e.g., API-only systems: 60/30/10)58593. **Output initial recommendation**:60 ```json61 {62 "test_distribution": {63 "unit": 70,64 "integration": 20,65 "e2e": 1066 },67 "priority_areas": ["auth", "payment", "data-sync"],68 "estimated_effort_hours": 4069 }70 ```7172**Token budget**: ≤2k tokens7374---7576### T2: Extended Analysis (≤6k tokens)7778**Goal**: Generate test scaffolding, calculate gaps, and create execution plan.79804. **Map tech stack to testing frameworks**:81 - JavaScript/Node.js → Jest, Mocha, Supertest, Playwright82 - Python → pytest, unittest, Selenium83 - Java → JUnit, Mockito, RestAssured84 - C# → xUnit, NUnit, SpecFlow85 - Consult [Microsoft Testing Patterns](https://learn.microsoft.com/en-us/dotnet/core/testing/, accessed 2025-10-25)86875. **Generate framework-specific scaffolding**:88 - Unit test template with arrange-act-assert pattern89 - Integration test template with setup/teardown90 - E2E test template for critical path91 - Performance test baseline (if applicable)92 - Reference [Google Testing Blog](https://testing.googleblog.com/, accessed 2025-10-25) for best practices93946. **Identify coverage gaps**:95 - Compare `existing_coverage` to targets96 - Calculate gap percentage per test type97 - Prioritize by risk (auth > payments > admin)98 - Output JSON with specific untested modules991007. **Create phased execution plan**:101 - Phase 1 (Week 1): High-risk unit tests102 - Phase 2 (Week 2): Integration tests for data layer103 - Phase 3 (Week 3): E2E critical paths104 - Phase 4 (Week 4): Performance baselines + refactor105 - Apply ISTQB Foundation principles ([ISTQB](https://www.istqb.org/certifications/certified-tester-foundation-level, accessed 2025-10-25))106107**Token budget**: ≤6k tokens total (including T1)108109---110111### T3: Deep Dive (not implemented for this skill)112113**T3 is not required** for this P0 skill; T2 provides sufficient depth for most testing strategies.114115---116117## Decision Rules118119**Test distribution adjustments:**120121- **Microservices**: Increase integration to 30%, decrease unit to 60%122- **Mobile apps**: Increase E2E to 20% (UI-critical), decrease integration to 15%123- **API-only**: Integration to 35%, unit to 55%, E2E to 10%124- **ML/Data pipelines**: Add performance tests (10%), adjust others proportionally125126**Effort estimation** (per 1000 LOC):127128- Unit tests: 4-8 hours129- Integration tests: 8-16 hours130- E2E tests: 16-24 hours131- Performance tests: 20-40 hours132133**Coverage thresholds** (from [Martin Fowler Testing](https://martinfowler.com/testing/, accessed 2025-10-25)):134135- Minimum acceptable: 60%136- Target for production: 80%137- Aspirational: 90%+ (diminishing returns above 85%)138139**Stop conditions:**140141- If constraints allow <10 hours: recommend T1 fast path only (unit tests for critical paths)142- If no testable components identified: emit TODO and request clarification143- If tech_stack is purely manual/visual testing: redirect to exploratory testing skill144145---146147## Output Contract148149**Required fields** (all outputs):150151```typescript152interface TestStrategy {153 strategy: string; // Markdown document (200-800 words)154 test_distribution: {155 unit: number; // Percentage (0-100)156 integration: number;157 e2e: number;158 performance?: number;159 };160 priority_areas: string[]; // Top 3-5 high-risk components161 estimated_effort_hours: number;162}163164interface TestScaffolding {165 framework: string; // e.g., "Jest", "pytest"166 unit_template: string; // Code snippet167 integration_template: string;168 e2e_template: string;169 setup_instructions: string; // Installation/config steps170}171172interface CoverageGaps {173 current_coverage_percent: number;174 target_coverage_percent: number;175 gap_percent: number;176 untested_modules: Array<{177 name: string;178 risk: "high" | "medium" | "low";179 estimated_effort_hours: number;180 }>;181}182183interface ExecutionPlan {184 phases: Array<{185 phase_number: number;186 duration_weeks: number;187 focus_area: string;188 deliverables: string[];189 success_criteria: string;190 }>;191 total_duration_weeks: number;192 dependencies: string[]; // External blockers193}194```195196**Format**:197198- `test_strategy`: Markdown with headings (## Overview, ## Test Types, ## Rationale)199- `test_scaffolding`: Code blocks with language hints (```javascript)200- `coverage_gaps`: Valid JSON201- `execution_plan`: Markdown with tables or numbered lists202203**Validation**:204205- All percentages sum to 100 (±2% rounding tolerance)206- Effort estimates are positive integers207- Phase dependencies are acyclic208209---210211## Examples212213### Example 1: REST API System (T2)214215```yaml216INPUT:217 system_description: "REST API with Node.js/Express, PostgreSQL, Redis"218 tech_stack: ["node.js", "express", "jest", "supertest"]219 existing_coverage: {unit: 45, integration: 10, e2e: 0}220221OUTPUT:222 test_distribution: {unit: 65, integration: 25, e2e: 10}223224 scaffolding:225 # Unit test (Jest)226 describe('UserService', () => {227 it('hashes password', () => {228 expect(hashPassword('secret')).not.toBe('secret');229 });230 });231232 # Integration test233 describe('POST /users', () => {234 it('creates user in DB', async () => {235 const res = await request(app).post('/users').send({name: 'Alice'});236 expect(res.status).toBe(201);237 });238 });239240 coverage_gaps:241 - {module: "AuthService", risk: "high", effort_hours: 8}242```243244---245246## Quality Gates247248**Token budgets** (mandatory):249250- T1 ≤ 2k tokens (recommendation only)251- T2 ≤ 6k tokens (full strategy + scaffolding)252- T3 not implemented253254**Safety checks**:255256- [ ] No hardcoded credentials in test templates257- [ ] No PII in example data258- [ ] Framework versions are recent (within 2 years)259260**Auditability**:261262- [ ] All sources cited with access date = `NOW_ET`263- [ ] Effort estimates include methodology reference264- [ ] Test distribution rationale tied to architecture pattern265266**Determinism**:267268- [ ] Same inputs produce same percentage recommendations (±5%)269- [ ] Scaffolding templates are idempotent270- [ ] Gap calculations are reproducible271272**Validation checklist**:273274- [ ] Output JSON validates against schema275- [ ] Markdown renders without errors276- [ ] Code snippets are syntactically valid277- [ ] Total effort ≤ constraint time budget278279---280281## Resources282283**Primary sources** (accessed 2025-10-25):2842851. **Google Testing Blog**: https://testing.googleblog.com/286 Best practices, case studies, and emerging patterns from Google's testing infrastructure team.2872882. **Martin Fowler - Testing**: https://martinfowler.com/testing/289 Canonical testing patterns, pyramid model, and test doubles taxonomy.2902913. **Practical Test Pyramid**: https://martinfowler.com/articles/practical-test-pyramid.html292 Detailed guide on test distribution, anti-patterns, and framework examples.2932944. **Microsoft Testing Patterns**: https://learn.microsoft.com/en-us/dotnet/core/testing/295 Official guidance for unit, integration, and performance testing in .NET ecosystems.2962975. **ISTQB Foundation Level**: https://www.istqb.org/certifications/certified-tester-foundation-level298 International standard for testing terminology, lifecycle, and techniques.299300**Additional templates**:301302- See `resources/test-pyramid-template.md` for Markdown strategy template303- See `examples/strategy-example.txt` for complete workflow example304305**Related skills** (future):306307- `performance-test-designer` (for load/stress testing deep dive)308- `mutation-testing-analyzer` (for assessing test effectiveness)309- `flaky-test-investigator` (for debugging unstable tests)310311---312313**End of SKILL.md**