codex-workflows 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/ai-development-guide/SKILL.md +283 -0
- package/.agents/skills/ai-development-guide/agents/openai.yaml +7 -0
- package/.agents/skills/ai-development-guide/references/frontend.md +135 -0
- package/.agents/skills/coding-rules/SKILL.md +98 -0
- package/.agents/skills/coding-rules/agents/openai.yaml +7 -0
- package/.agents/skills/coding-rules/references/typescript.md +220 -0
- package/.agents/skills/documentation-criteria/SKILL.md +127 -0
- package/.agents/skills/documentation-criteria/agents/openai.yaml +7 -0
- package/.agents/skills/documentation-criteria/references/adr-template.md +64 -0
- package/.agents/skills/documentation-criteria/references/design-template.md +327 -0
- package/.agents/skills/documentation-criteria/references/plan-template.md +131 -0
- package/.agents/skills/documentation-criteria/references/prd-template.md +119 -0
- package/.agents/skills/documentation-criteria/references/task-template.md +38 -0
- package/.agents/skills/documentation-criteria/references/ui-spec-template.md +145 -0
- package/.agents/skills/implementation-approach/SKILL.md +145 -0
- package/.agents/skills/implementation-approach/agents/openai.yaml +7 -0
- package/.agents/skills/integration-e2e-testing/SKILL.md +125 -0
- package/.agents/skills/integration-e2e-testing/agents/openai.yaml +7 -0
- package/.agents/skills/integration-e2e-testing/references/e2e-design.md +86 -0
- package/.agents/skills/recipe-add-integration-tests/SKILL.md +128 -0
- package/.agents/skills/recipe-add-integration-tests/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-build/SKILL.md +119 -0
- package/.agents/skills/recipe-build/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-design/SKILL.md +90 -0
- package/.agents/skills/recipe-design/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-diagnose/SKILL.md +187 -0
- package/.agents/skills/recipe-diagnose/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-front-build/SKILL.md +127 -0
- package/.agents/skills/recipe-front-build/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-front-design/SKILL.md +90 -0
- package/.agents/skills/recipe-front-design/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-front-plan/SKILL.md +68 -0
- package/.agents/skills/recipe-front-plan/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-front-review/SKILL.md +101 -0
- package/.agents/skills/recipe-front-review/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-fullstack-build/SKILL.md +139 -0
- package/.agents/skills/recipe-fullstack-build/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-fullstack-implement/SKILL.md +151 -0
- package/.agents/skills/recipe-fullstack-implement/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-implement/SKILL.md +125 -0
- package/.agents/skills/recipe-implement/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-plan/SKILL.md +73 -0
- package/.agents/skills/recipe-plan/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-reverse-engineer/SKILL.md +212 -0
- package/.agents/skills/recipe-reverse-engineer/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-review/SKILL.md +115 -0
- package/.agents/skills/recipe-review/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-task/SKILL.md +74 -0
- package/.agents/skills/recipe-task/agents/openai.yaml +7 -0
- package/.agents/skills/recipe-update-doc/SKILL.md +156 -0
- package/.agents/skills/recipe-update-doc/agents/openai.yaml +7 -0
- package/.agents/skills/subagents-orchestration-guide/SKILL.md +354 -0
- package/.agents/skills/subagents-orchestration-guide/agents/openai.yaml +7 -0
- package/.agents/skills/subagents-orchestration-guide/references/monorepo-flow.md +124 -0
- package/.agents/skills/task-analyzer/SKILL.md +142 -0
- package/.agents/skills/task-analyzer/agents/openai.yaml +7 -0
- package/.agents/skills/task-analyzer/references/skills-index.yaml +162 -0
- package/.agents/skills/testing/SKILL.md +324 -0
- package/.agents/skills/testing/agents/openai.yaml +7 -0
- package/.agents/skills/testing/references/typescript.md +224 -0
- package/.codex/agents/acceptance-test-generator.toml +310 -0
- package/.codex/agents/code-reviewer.toml +228 -0
- package/.codex/agents/code-verifier.toml +231 -0
- package/.codex/agents/design-sync.toml +265 -0
- package/.codex/agents/document-reviewer.toml +367 -0
- package/.codex/agents/integration-test-reviewer.toml +178 -0
- package/.codex/agents/investigator.toml +197 -0
- package/.codex/agents/prd-creator.toml +250 -0
- package/.codex/agents/quality-fixer-frontend.toml +356 -0
- package/.codex/agents/quality-fixer.toml +249 -0
- package/.codex/agents/requirement-analyzer.toml +172 -0
- package/.codex/agents/rule-advisor.toml +186 -0
- package/.codex/agents/scope-discoverer.toml +248 -0
- package/.codex/agents/solver.toml +212 -0
- package/.codex/agents/task-decomposer.toml +262 -0
- package/.codex/agents/task-executor-frontend.toml +312 -0
- package/.codex/agents/task-executor.toml +314 -0
- package/.codex/agents/technical-designer-frontend.toml +492 -0
- package/.codex/agents/technical-designer.toml +474 -0
- package/.codex/agents/ui-spec-designer.toml +150 -0
- package/.codex/agents/verifier.toml +228 -0
- package/.codex/agents/work-planner.toml +251 -0
- package/README.md +365 -0
- package/bin/cli.js +249 -0
- package/package.json +35 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Skills Metadata Index
|
|
2
|
+
# Used to select appropriate skills based on task analysis
|
|
3
|
+
|
|
4
|
+
skills:
|
|
5
|
+
coding-rules:
|
|
6
|
+
skill: "coding-rules"
|
|
7
|
+
tags: [implementation, code-quality, refactoring, clean-code, maintainability, function-design, error-handling, parameterized-dependencies, performance, security]
|
|
8
|
+
typical-use: "Language-agnostic code creation, modification, and refactoring principles applicable to all programming languages"
|
|
9
|
+
size: medium
|
|
10
|
+
key-references:
|
|
11
|
+
- "YAGNI Principle - Kent Beck"
|
|
12
|
+
- "Clean Code - Robert C. Martin"
|
|
13
|
+
- "DRY Principle - The Pragmatic Programmer"
|
|
14
|
+
- "Refactoring - Martin Fowler"
|
|
15
|
+
- "Single Responsibility Principle - SOLID"
|
|
16
|
+
sections:
|
|
17
|
+
- "Core Philosophy [MANDATORY]"
|
|
18
|
+
- "Code Quality [MANDATORY]"
|
|
19
|
+
- "Function Design [MANDATORY]"
|
|
20
|
+
- "Error Handling [MANDATORY]"
|
|
21
|
+
- "Dependency Management"
|
|
22
|
+
- "Performance"
|
|
23
|
+
- "Code Organization"
|
|
24
|
+
- "Commenting Principles"
|
|
25
|
+
- "Refactoring [SAFE CHANGE PROTOCOL]"
|
|
26
|
+
- "Security"
|
|
27
|
+
- "Version Control [MANDATORY]"
|
|
28
|
+
references:
|
|
29
|
+
- "references/typescript.md"
|
|
30
|
+
|
|
31
|
+
testing:
|
|
32
|
+
skill: "testing"
|
|
33
|
+
tags: [testing, tdd, quality, unit-testing, integration-testing, e2e-testing, test-design, coverage, mocking, test-independence, ci-cd, test-quality-criteria]
|
|
34
|
+
typical-use: "Universal testing principles, TDD practice, test quality criteria, test creation and quality assurance for all programming languages"
|
|
35
|
+
size: large
|
|
36
|
+
key-references:
|
|
37
|
+
- "Test-Driven Development - Kent Beck"
|
|
38
|
+
- "Red-Green-Refactor Cycle - Kent Beck"
|
|
39
|
+
- "AAA Pattern - Arrange-Act-Assert"
|
|
40
|
+
- "Test Pyramid - Mike Cohn"
|
|
41
|
+
sections:
|
|
42
|
+
- "Core Testing Philosophy"
|
|
43
|
+
- "TDD Process [MANDATORY for all code changes]"
|
|
44
|
+
- "Quality Requirements [MANDATORY]"
|
|
45
|
+
- "Test Types"
|
|
46
|
+
- "Test Design Principles"
|
|
47
|
+
- "Test Independence"
|
|
48
|
+
- "Mocking and Test Doubles"
|
|
49
|
+
- "Test Quality Practices [MANDATORY]"
|
|
50
|
+
- "What to Test"
|
|
51
|
+
- "Test Quality Criteria [MANDATORY]"
|
|
52
|
+
- "Verification Requirements [MANDATORY for VERIFY phase]"
|
|
53
|
+
- "Test Organization"
|
|
54
|
+
- "Performance Considerations"
|
|
55
|
+
- "Common Anti-Patterns"
|
|
56
|
+
- "Regression Testing"
|
|
57
|
+
references:
|
|
58
|
+
- "references/typescript.md"
|
|
59
|
+
|
|
60
|
+
ai-development-guide:
|
|
61
|
+
skill: "ai-development-guide"
|
|
62
|
+
tags: [anti-patterns, technical-judgment, debugging, quality-commands, rule-of-three, implementation, refactoring, code-reading, best-practices, fail-fast, error-handling, impact-analysis]
|
|
63
|
+
typical-use: "Technical decision criteria, anti-pattern detection, debugging techniques, quality check workflows, impact analysis procedures"
|
|
64
|
+
size: large
|
|
65
|
+
key-references:
|
|
66
|
+
- "Rule of Three - Martin Fowler"
|
|
67
|
+
- "5 Whys - Toyota Production System"
|
|
68
|
+
- "DRY Principle - The Pragmatic Programmer"
|
|
69
|
+
- "YAGNI Principle - Extreme Programming"
|
|
70
|
+
sections:
|
|
71
|
+
- "Technical Anti-patterns (Red Flag Patterns) [MANDATORY]"
|
|
72
|
+
- "Fail-Fast Fallback Design Principles"
|
|
73
|
+
- "Rule of Three - Criteria for Code Duplication"
|
|
74
|
+
- "Common Failure Patterns and Avoidance Methods"
|
|
75
|
+
- "Debugging Techniques"
|
|
76
|
+
- "Quality Check Workflow [MANDATORY]"
|
|
77
|
+
- "Situations Requiring Technical Decisions"
|
|
78
|
+
- "Implementation Completeness Assurance"
|
|
79
|
+
- "Impact Analysis"
|
|
80
|
+
|
|
81
|
+
documentation-criteria:
|
|
82
|
+
skill: "documentation-criteria"
|
|
83
|
+
tags: [documentation, decision-making, adr, prd, design-doc, planning, process, scale-assessment]
|
|
84
|
+
typical-use: "Scale assessment at implementation start, document creation criteria, ADR/PRD/Design Doc/Work Plan creation standards"
|
|
85
|
+
size: medium
|
|
86
|
+
key-references:
|
|
87
|
+
- "ADR Method - Michael Nygard"
|
|
88
|
+
- "Design Doc Culture - Google Engineering Practices"
|
|
89
|
+
- "Single Source of Truth"
|
|
90
|
+
sections:
|
|
91
|
+
- "Templates"
|
|
92
|
+
- "Creation Decision Matrix [MANDATORY]"
|
|
93
|
+
- "ADR Creation Conditions [MANDATORY if Any Apply]"
|
|
94
|
+
- "Detailed Document Definitions"
|
|
95
|
+
- "Creation Process [MANDATORY]"
|
|
96
|
+
- "Storage Locations"
|
|
97
|
+
- "ADR Status"
|
|
98
|
+
- "AI Automation Rules [MANDATORY]"
|
|
99
|
+
- "Diagram Requirements"
|
|
100
|
+
- "Common ADR Relationships"
|
|
101
|
+
|
|
102
|
+
implementation-approach:
|
|
103
|
+
skill: "implementation-approach"
|
|
104
|
+
tags: [architecture, implementation, task-decomposition, strategy-patterns, strangler-pattern, facade-pattern, design, planning, verification-levels]
|
|
105
|
+
typical-use: "Implementation strategy selection, task decomposition, design decisions, large-scale change planning"
|
|
106
|
+
size: medium
|
|
107
|
+
key-references:
|
|
108
|
+
- "Strangler Fig Pattern - Martin Fowler"
|
|
109
|
+
- "Feature Slicing - Martin Fowler"
|
|
110
|
+
- "Walking Skeleton - Alistair Cockburn"
|
|
111
|
+
sections:
|
|
112
|
+
- "Meta-cognitive Strategy Selection Process [MANDATORY]"
|
|
113
|
+
- "Verification Level Definitions"
|
|
114
|
+
- "Integration Point Definitions"
|
|
115
|
+
- "Anti-patterns [MANDATORY to detect]"
|
|
116
|
+
- "Guidelines for Meta-cognitive Execution"
|
|
117
|
+
|
|
118
|
+
integration-e2e-testing:
|
|
119
|
+
skill: "integration-e2e-testing"
|
|
120
|
+
tags: [testing, integration-testing, e2e-testing, test-design, behavior-first, roi, test-skeleton, ears-format]
|
|
121
|
+
typical-use: "Integration and E2E test design principles, ROI-based test selection, behavior-first approach, test skeleton specification"
|
|
122
|
+
size: medium
|
|
123
|
+
key-references:
|
|
124
|
+
- "Test Pyramid - Mike Cohn"
|
|
125
|
+
- "Behavior-Driven Development"
|
|
126
|
+
sections:
|
|
127
|
+
- "References"
|
|
128
|
+
- "Test Type Definition and Limits [MANDATORY]"
|
|
129
|
+
- "Behavior-First Principle [MANDATORY]"
|
|
130
|
+
- "ROI Calculation"
|
|
131
|
+
- "Test Skeleton Specification [MANDATORY]"
|
|
132
|
+
- "EARS Format Mapping"
|
|
133
|
+
- "Test File Naming Convention"
|
|
134
|
+
- "Review Criteria"
|
|
135
|
+
- "Quality Standards [MANDATORY]"
|
|
136
|
+
|
|
137
|
+
subagents-orchestration-guide:
|
|
138
|
+
skill: "subagents-orchestration-guide"
|
|
139
|
+
tags: [orchestration, workflow, subagents, autonomous-execution, planning, design-flow, implementation-flow]
|
|
140
|
+
typical-use: "Orchestrating subagents through implementation workflows, scale determination, stop points, autonomous execution mode"
|
|
141
|
+
size: large
|
|
142
|
+
key-references:
|
|
143
|
+
- "Orchestrator Pattern"
|
|
144
|
+
- "Conductor Pattern"
|
|
145
|
+
sections:
|
|
146
|
+
- "Role: The Orchestrator"
|
|
147
|
+
- "Decision Flow When Receiving Tasks"
|
|
148
|
+
- "Available Subagents"
|
|
149
|
+
- "Orchestration Principles"
|
|
150
|
+
- "Constraints Between Subagents [MANDATORY]"
|
|
151
|
+
- "How to Spawn Agents"
|
|
152
|
+
- "Explicit Stop Points [MANDATORY]"
|
|
153
|
+
- "Scale Determination and Document Requirements"
|
|
154
|
+
- "Structured Response Specification"
|
|
155
|
+
- "Handling Requirement Changes"
|
|
156
|
+
- "Basic Flow for Work Planning"
|
|
157
|
+
- "Autonomous Execution Mode"
|
|
158
|
+
- "Main Orchestrator Roles"
|
|
159
|
+
- "Important Constraints [MANDATORY]"
|
|
160
|
+
- "Required Dialogue Points with Humans [MANDATORY]"
|
|
161
|
+
- "Action Checklist"
|
|
162
|
+
- "References"
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: testing
|
|
3
|
+
description: "Testing principles including TDD, test quality, coverage standards, and test design. Use when: writing tests, designing test strategies, reviewing test quality, or following Red-Green-Refactor cycle."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing Principles
|
|
7
|
+
|
|
8
|
+
## Language-Specific References
|
|
9
|
+
|
|
10
|
+
For language-specific testing patterns, also read:
|
|
11
|
+
- **TypeScript (Vitest/RTL/Playwright)**: [references/typescript.md](references/typescript.md)
|
|
12
|
+
|
|
13
|
+
## Core Testing Philosophy
|
|
14
|
+
|
|
15
|
+
1. **Tests are First-Class Code**: Maintain test quality equal to production code
|
|
16
|
+
2. **Fast Feedback**: Tests should run quickly and provide immediate feedback
|
|
17
|
+
3. **Reliability**: Tests should be deterministic and reproducible
|
|
18
|
+
4. **Independence**: Each test should run in isolation
|
|
19
|
+
|
|
20
|
+
## TDD Process [MANDATORY for all code changes]
|
|
21
|
+
|
|
22
|
+
**Execute this process for every code change:**
|
|
23
|
+
|
|
24
|
+
### RED Phase
|
|
25
|
+
**STEP 1**: Write test that defines expected behavior
|
|
26
|
+
**STEP 2**: Run test
|
|
27
|
+
**STEP 3**: Confirm test FAILS (if it passes, the test is wrong)
|
|
28
|
+
|
|
29
|
+
### GREEN Phase
|
|
30
|
+
**STEP 1**: Write MINIMAL code to make test pass
|
|
31
|
+
**STEP 2**: Run test
|
|
32
|
+
**STEP 3**: Confirm test PASSES
|
|
33
|
+
|
|
34
|
+
### REFACTOR Phase
|
|
35
|
+
**STEP 1**: Improve code quality (eliminate duplication, improve naming)
|
|
36
|
+
**STEP 2**: Run test
|
|
37
|
+
**STEP 3**: Confirm test STILL PASSES
|
|
38
|
+
|
|
39
|
+
### VERIFY Phase [MANDATORY - 0 ERRORS REQUIRED]
|
|
40
|
+
**STEP 1**: Execute ALL quality check commands for your language/project
|
|
41
|
+
**STEP 2**: Fix any errors until ALL commands pass with 0 errors
|
|
42
|
+
**STEP 3**: Confirm no regressions
|
|
43
|
+
|
|
44
|
+
**ENFORCEMENT**: Cannot proceed to next phase with ANY quality check failures
|
|
45
|
+
|
|
46
|
+
### TDD Exceptions (no TDD required)
|
|
47
|
+
- Pure configuration files
|
|
48
|
+
- Documentation only
|
|
49
|
+
- Emergency fixes (but add tests immediately after)
|
|
50
|
+
- Exploratory spikes (discard or rewrite with tests before merging)
|
|
51
|
+
- Build/deployment scripts (unless they contain business logic)
|
|
52
|
+
|
|
53
|
+
## Quality Requirements [MANDATORY]
|
|
54
|
+
|
|
55
|
+
### Coverage Standards
|
|
56
|
+
|
|
57
|
+
- **Minimum 80% code coverage** for production code
|
|
58
|
+
- Prioritize critical paths and business logic
|
|
59
|
+
- Use coverage as a guide, not a goal
|
|
60
|
+
|
|
61
|
+
### Test Characteristics
|
|
62
|
+
|
|
63
|
+
All tests MUST be:
|
|
64
|
+
|
|
65
|
+
- **Independent**: No dependencies between tests
|
|
66
|
+
- **Reproducible**: Same input always produces same output
|
|
67
|
+
- **Fast**: Complete test suite runs in reasonable time
|
|
68
|
+
- **Self-checking**: Clear pass/fail without manual verification
|
|
69
|
+
- **Timely**: Written close to the code they test
|
|
70
|
+
|
|
71
|
+
**ENFORCEMENT**: Tests failing ANY characteristic MUST be fixed immediately
|
|
72
|
+
|
|
73
|
+
## Test Types
|
|
74
|
+
|
|
75
|
+
### Unit Tests
|
|
76
|
+
|
|
77
|
+
**Purpose**: Test individual components in isolation
|
|
78
|
+
|
|
79
|
+
**Characteristics**:
|
|
80
|
+
- Test single function, method, or class
|
|
81
|
+
- Fast execution (milliseconds)
|
|
82
|
+
- No external dependencies
|
|
83
|
+
- Mock external services
|
|
84
|
+
- Majority of your test suite
|
|
85
|
+
|
|
86
|
+
### Integration Tests
|
|
87
|
+
|
|
88
|
+
**Purpose**: Test interactions between components
|
|
89
|
+
|
|
90
|
+
**Characteristics**:
|
|
91
|
+
- Test multiple components together
|
|
92
|
+
- May include database, file system, or APIs
|
|
93
|
+
- Slower than unit tests
|
|
94
|
+
- Verify contracts between modules
|
|
95
|
+
- Smaller portion of test suite
|
|
96
|
+
|
|
97
|
+
### End-to-End (E2E) Tests
|
|
98
|
+
|
|
99
|
+
**Purpose**: Test complete workflows from user perspective
|
|
100
|
+
|
|
101
|
+
**Characteristics**:
|
|
102
|
+
- Test entire application stack
|
|
103
|
+
- Simulate real user interactions
|
|
104
|
+
- Slowest test type
|
|
105
|
+
- Fewest in number
|
|
106
|
+
- Highest confidence level
|
|
107
|
+
|
|
108
|
+
### Test Pyramid
|
|
109
|
+
|
|
110
|
+
Follow the test pyramid structure:
|
|
111
|
+
```
|
|
112
|
+
/\ <- Few E2E Tests (High confidence, slow)
|
|
113
|
+
/ \
|
|
114
|
+
/ \ <- Some Integration Tests (Medium confidence, medium speed)
|
|
115
|
+
/ \
|
|
116
|
+
/________\ <- Many Unit Tests (Fast, foundational)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Test Design Principles
|
|
120
|
+
|
|
121
|
+
### AAA Pattern (Arrange-Act-Assert)
|
|
122
|
+
|
|
123
|
+
Structure every test in three clear phases:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
// Arrange: Setup test data and conditions
|
|
127
|
+
user = createTestUser()
|
|
128
|
+
validator = createValidator()
|
|
129
|
+
|
|
130
|
+
// Act: Execute the code under test
|
|
131
|
+
result = validator.validate(user)
|
|
132
|
+
|
|
133
|
+
// Assert: Verify expected outcome
|
|
134
|
+
assert(result.isValid == true)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### One Assertion Per Concept
|
|
138
|
+
|
|
139
|
+
- Test one behavior per test case
|
|
140
|
+
- Multiple assertions OK if testing single concept
|
|
141
|
+
- Split unrelated assertions into separate tests — one test MUST verify one behavior
|
|
142
|
+
|
|
143
|
+
### Descriptive Test Names
|
|
144
|
+
|
|
145
|
+
Test names should clearly describe:
|
|
146
|
+
- What is being tested
|
|
147
|
+
- Under what conditions
|
|
148
|
+
- What the expected outcome is
|
|
149
|
+
|
|
150
|
+
**Recommended format**: `"should [expected behavior] when [condition]"`
|
|
151
|
+
|
|
152
|
+
## Test Independence
|
|
153
|
+
|
|
154
|
+
### Isolation Requirements
|
|
155
|
+
|
|
156
|
+
- Each test creates its own test data
|
|
157
|
+
- No dependencies on execution order
|
|
158
|
+
- Clean up own state
|
|
159
|
+
- Pass when run in isolation
|
|
160
|
+
|
|
161
|
+
### Setup and Teardown
|
|
162
|
+
|
|
163
|
+
- Use setup hooks to prepare test environment
|
|
164
|
+
- Use teardown hooks to clean up resources
|
|
165
|
+
- Keep setup minimal and focused
|
|
166
|
+
- Ensure teardown runs even if test fails
|
|
167
|
+
|
|
168
|
+
## Mocking and Test Doubles
|
|
169
|
+
|
|
170
|
+
### When to Use Mocks
|
|
171
|
+
|
|
172
|
+
- **Mock external dependencies**: APIs, databases, file systems
|
|
173
|
+
- **Mock slow operations**: Network calls, heavy computations
|
|
174
|
+
- **Mock unpredictable behavior**: Random values, current time
|
|
175
|
+
- **Mock unavailable services**: Third-party services
|
|
176
|
+
|
|
177
|
+
### Mocking Principles [MANDATORY]
|
|
178
|
+
|
|
179
|
+
- Mock at boundaries, not internally — use real implementations for internal utilities
|
|
180
|
+
- Keep mocks simple and focused
|
|
181
|
+
- Verify mock expectations when relevant
|
|
182
|
+
- Use adapters for external libraries/frameworks you do not control
|
|
183
|
+
|
|
184
|
+
### Types of Test Doubles
|
|
185
|
+
|
|
186
|
+
- **Stub**: Returns predetermined values
|
|
187
|
+
- **Mock**: Verifies it was called correctly
|
|
188
|
+
- **Spy**: Records information about calls
|
|
189
|
+
- **Fake**: Simplified working implementation
|
|
190
|
+
- **Dummy**: Passed but never used
|
|
191
|
+
|
|
192
|
+
## Test Quality Practices [MANDATORY]
|
|
193
|
+
|
|
194
|
+
### Keep Tests Active
|
|
195
|
+
|
|
196
|
+
- **Fix or delete failing tests**: Resolve failures immediately
|
|
197
|
+
- **Remove commented-out tests**: Fix them or delete entirely
|
|
198
|
+
- **Keep tests running**: Broken tests lose value quickly
|
|
199
|
+
- **Maintain test suite**: Refactor tests as needed
|
|
200
|
+
|
|
201
|
+
### Test Code Quality
|
|
202
|
+
|
|
203
|
+
- Apply same standards as production code
|
|
204
|
+
- Use descriptive variable names
|
|
205
|
+
- Extract test helpers to reduce duplication
|
|
206
|
+
- Keep tests readable and maintainable
|
|
207
|
+
|
|
208
|
+
### Test Helpers and Utilities
|
|
209
|
+
|
|
210
|
+
- Create reusable test data builders
|
|
211
|
+
- Extract common setup into helper functions
|
|
212
|
+
- Build test utilities for complex scenarios
|
|
213
|
+
- Share helpers across test files appropriately
|
|
214
|
+
|
|
215
|
+
## What to Test
|
|
216
|
+
|
|
217
|
+
### Focus on Behavior
|
|
218
|
+
|
|
219
|
+
**Test observable behavior, not implementation**:
|
|
220
|
+
|
|
221
|
+
- Good: Test that function returns expected output
|
|
222
|
+
- Good: Test that correct API endpoint is called
|
|
223
|
+
- Bad: Test that internal variable was set
|
|
224
|
+
- Bad: Test order of private method calls
|
|
225
|
+
|
|
226
|
+
### Test Edge Cases
|
|
227
|
+
|
|
228
|
+
Always test:
|
|
229
|
+
- **Boundary conditions**: Min/max values, empty collections
|
|
230
|
+
- **Error cases**: Invalid input, null values, missing data
|
|
231
|
+
- **Edge cases**: Special characters, extreme values
|
|
232
|
+
- **Happy path**: Normal, expected usage
|
|
233
|
+
|
|
234
|
+
## Test Quality Criteria [MANDATORY]
|
|
235
|
+
|
|
236
|
+
1. **Literal expectations**: Use hardcoded literal values in assertions — expected value ≠ mock return value (implementation processes data)
|
|
237
|
+
2. **Result verification**: Assert return values and state, not call order
|
|
238
|
+
3. **Meaningful assertions**: Every test MUST have at least one assertion — a test without assertions provides zero value
|
|
239
|
+
4. **Mock external I/O only**: Mock DB/API/filesystem, use real internal utilities
|
|
240
|
+
5. **Boundary coverage**: Include empty/zero/max/error cases with happy paths
|
|
241
|
+
|
|
242
|
+
**ENFORCEMENT**: Tests violating ANY criterion MUST be rewritten
|
|
243
|
+
|
|
244
|
+
## Verification Requirements [MANDATORY for VERIFY phase]
|
|
245
|
+
|
|
246
|
+
### Before Commit Checklist
|
|
247
|
+
|
|
248
|
+
☐ All tests pass
|
|
249
|
+
☐ No tests skipped or commented
|
|
250
|
+
☐ No debug code left in tests
|
|
251
|
+
☐ Test coverage meets standards (≥ 80%)
|
|
252
|
+
☐ Tests run in reasonable time
|
|
253
|
+
|
|
254
|
+
### Zero Tolerance Policy
|
|
255
|
+
|
|
256
|
+
- **Zero failing tests**: Fix immediately
|
|
257
|
+
- **Zero skipped tests**: Delete or fix
|
|
258
|
+
- **Zero flaky tests**: Make deterministic
|
|
259
|
+
- **Zero slow tests**: Optimize or split
|
|
260
|
+
|
|
261
|
+
**ENFORCEMENT**: Cannot proceed with task completion if ANY quality check fails
|
|
262
|
+
|
|
263
|
+
## Test Organization
|
|
264
|
+
|
|
265
|
+
### File Structure
|
|
266
|
+
|
|
267
|
+
- **Mirror production structure**: Tests follow code organization
|
|
268
|
+
- **Clear naming conventions**: Follow project's test file patterns
|
|
269
|
+
- **Logical grouping**: Group related tests together
|
|
270
|
+
- **Separate test types**: Unit, integration, e2e in separate directories
|
|
271
|
+
|
|
272
|
+
### Test Suite Organization
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
tests/
|
|
276
|
+
├── unit/ # Fast, isolated unit tests
|
|
277
|
+
├── integration/ # Integration tests
|
|
278
|
+
├── e2e/ # End-to-end tests
|
|
279
|
+
├── fixtures/ # Test data and fixtures
|
|
280
|
+
└── helpers/ # Shared test utilities
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Performance Considerations
|
|
284
|
+
|
|
285
|
+
### Test Speed
|
|
286
|
+
|
|
287
|
+
- **Unit tests**: < 100ms each
|
|
288
|
+
- **Integration tests**: < 1s each
|
|
289
|
+
- **Full suite**: Should run frequently (< 10 minutes)
|
|
290
|
+
|
|
291
|
+
## Common Anti-Patterns
|
|
292
|
+
|
|
293
|
+
Detect and eliminate these patterns immediately:
|
|
294
|
+
|
|
295
|
+
- Tests that test nothing (always pass)
|
|
296
|
+
- Tests that depend on execution order
|
|
297
|
+
- Tests that depend on external state
|
|
298
|
+
- Tests with complex logic (tests that need their own tests)
|
|
299
|
+
- Testing implementation details instead of observable behavior
|
|
300
|
+
- Excessive mocking (mock boundaries only, use real internals)
|
|
301
|
+
- Test code duplication
|
|
302
|
+
|
|
303
|
+
### Flaky Tests
|
|
304
|
+
|
|
305
|
+
Eliminate tests that fail intermittently:
|
|
306
|
+
- Remove timing dependencies
|
|
307
|
+
- Use deterministic data instead of random values
|
|
308
|
+
- Ensure proper cleanup
|
|
309
|
+
- Fix race conditions
|
|
310
|
+
- Make all tests deterministic
|
|
311
|
+
|
|
312
|
+
## Regression Testing
|
|
313
|
+
|
|
314
|
+
- Add test for every bug fix
|
|
315
|
+
- Maintain comprehensive test suite
|
|
316
|
+
- Run full suite regularly
|
|
317
|
+
- Don't delete tests without good reason
|
|
318
|
+
|
|
319
|
+
### Legacy Code
|
|
320
|
+
|
|
321
|
+
- Add characterization tests before refactoring
|
|
322
|
+
- Test existing behavior first
|
|
323
|
+
- Gradually improve coverage
|
|
324
|
+
- Refactor with confidence
|