opencode-goopspec 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/LICENSE +21 -0
- package/README.md +650 -0
- package/agents/goop-debugger.md +265 -0
- package/agents/goop-designer.md +244 -0
- package/agents/goop-executor.md +217 -0
- package/agents/goop-explorer.md +252 -0
- package/agents/goop-librarian.md +197 -0
- package/agents/goop-orchestrator.md +224 -0
- package/agents/goop-planner.md +231 -0
- package/agents/goop-researcher.md +246 -0
- package/agents/goop-tester.md +245 -0
- package/agents/goop-verifier.md +266 -0
- package/agents/goop-writer.md +293 -0
- package/agents/memory-distiller.md +226 -0
- package/commands/goop-accept.md +183 -0
- package/commands/goop-amend.md +175 -0
- package/commands/goop-complete.md +206 -0
- package/commands/goop-debug.md +318 -0
- package/commands/goop-discuss.md +138 -0
- package/commands/goop-execute.md +137 -0
- package/commands/goop-help.md +82 -0
- package/commands/goop-map-codebase.md +501 -0
- package/commands/goop-memory.md +66 -0
- package/commands/goop-milestone.md +213 -0
- package/commands/goop-pause.md +61 -0
- package/commands/goop-plan.md +78 -0
- package/commands/goop-quick.md +165 -0
- package/commands/goop-recall.md +48 -0
- package/commands/goop-remember.md +71 -0
- package/commands/goop-research.md +98 -0
- package/commands/goop-resume.md +57 -0
- package/commands/goop-setup.md +208 -0
- package/commands/goop-specify.md +145 -0
- package/commands/goop-status.md +153 -0
- package/dist/index.js +31017 -0
- package/dist/memory/index.js +48752 -0
- package/package.json +73 -0
- package/references/agent-patterns.md +334 -0
- package/references/boundary-system.md +141 -0
- package/references/deviation-rules.md +80 -0
- package/references/dispatch-patterns.md +176 -0
- package/references/model-profiles.md +109 -0
- package/references/orchestrator-philosophy.md +280 -0
- package/references/security-checklist.md +163 -0
- package/references/subagent-protocol.md +393 -0
- package/references/tdd.md +231 -0
- package/references/ui-brand.md +261 -0
- package/references/workflow-accept.md +325 -0
- package/references/workflow-execute.md +315 -0
- package/references/workflow-plan.md +179 -0
- package/references/workflow-research.md +234 -0
- package/references/workflow-specify.md +278 -0
- package/skills/README.md +362 -0
- package/skills/accessibility/skill.md +41 -0
- package/skills/accessibility-testing/skill.md +47 -0
- package/skills/api-docs/skill.md +50 -0
- package/skills/architecture-design/skill.md +168 -0
- package/skills/atomic-commits/skill.md +53 -0
- package/skills/code-review/skill.md +59 -0
- package/skills/codebase-mapping/skill.md +54 -0
- package/skills/convention-detection/skill.md +68 -0
- package/skills/debugging/skill.md +59 -0
- package/skills/deviation-handling/skill.md +187 -0
- package/skills/documentation/skill.md +213 -0
- package/skills/goop-core/skill.md +383 -0
- package/skills/memory-usage/skill.md +208 -0
- package/skills/parallel-planning/skill.md +170 -0
- package/skills/pattern-extraction/skill.md +73 -0
- package/skills/performance-optimization/skill.md +188 -0
- package/skills/playwright/skill.md +69 -0
- package/skills/playwright-testing/skill.md +93 -0
- package/skills/progress-tracking/skill.md +155 -0
- package/skills/readme-generation/skill.md +87 -0
- package/skills/research/skill.md +161 -0
- package/skills/responsive-design/skill.md +76 -0
- package/skills/scientific-method/skill.md +67 -0
- package/skills/security-audit/skill.md +152 -0
- package/skills/task-decomposition/skill.md +153 -0
- package/skills/task-delegation/skill.md +127 -0
- package/skills/technical-writing/skill.md +69 -0
- package/skills/testing/skill.md +202 -0
- package/skills/ui-design/skill.md +73 -0
- package/skills/ux-patterns/skill.md +82 -0
- package/skills/verification/skill.md +178 -0
- package/skills/visual-regression/skill.md +86 -0
- package/templates/blueprint.md +141 -0
- package/templates/chronicle.md +156 -0
- package/templates/milestone.md +131 -0
- package/templates/research.md +117 -0
- package/templates/retrospective.md +188 -0
- package/templates/spec.md +103 -0
- package/templates/summary.md +202 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: parallel-planning
|
|
3
|
+
description: Plan for parallel execution and wave-based scheduling
|
|
4
|
+
category: core
|
|
5
|
+
triggers:
|
|
6
|
+
- parallel
|
|
7
|
+
- wave
|
|
8
|
+
- concurrent
|
|
9
|
+
- batch
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
requires:
|
|
12
|
+
- goop-core
|
|
13
|
+
- task-decomposition
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Parallel Planning Skill
|
|
17
|
+
|
|
18
|
+
## Wave-Based Execution Model
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Wave 1 Wave 2 Wave 3
|
|
22
|
+
[A] [C] [F]
|
|
23
|
+
[B] [D]
|
|
24
|
+
[E]
|
|
25
|
+
|
|
26
|
+
A,B parallel → C,D,E parallel → F sequential
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Identifying Parallelism
|
|
30
|
+
|
|
31
|
+
### Independent Tasks
|
|
32
|
+
Tasks with no shared:
|
|
33
|
+
- Files being modified
|
|
34
|
+
- Database tables being changed
|
|
35
|
+
- External resources being accessed
|
|
36
|
+
- State being mutated
|
|
37
|
+
|
|
38
|
+
### Parallel Candidates
|
|
39
|
+
- Different feature modules
|
|
40
|
+
- Read-only operations
|
|
41
|
+
- Documentation tasks
|
|
42
|
+
- Test suites for different modules
|
|
43
|
+
|
|
44
|
+
### Sequential Requirements
|
|
45
|
+
- Schema migration before data access
|
|
46
|
+
- Build before deploy
|
|
47
|
+
- Tests before commit
|
|
48
|
+
|
|
49
|
+
## Plan Frontmatter
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
---
|
|
53
|
+
phase: 1
|
|
54
|
+
plan: feature-auth
|
|
55
|
+
wave: 2
|
|
56
|
+
depends_on: [setup-db, config-env]
|
|
57
|
+
autonomous: true
|
|
58
|
+
files_modified:
|
|
59
|
+
- src/auth/login.ts
|
|
60
|
+
- src/auth/session.ts
|
|
61
|
+
---
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Wave Assignment Rules
|
|
65
|
+
|
|
66
|
+
### Wave 1: Foundation
|
|
67
|
+
- No external dependencies
|
|
68
|
+
- Setup and configuration
|
|
69
|
+
- Schema definitions
|
|
70
|
+
|
|
71
|
+
### Wave 2: Core Implementation
|
|
72
|
+
- Depends on Wave 1
|
|
73
|
+
- Main feature development
|
|
74
|
+
- Can be parallel within wave
|
|
75
|
+
|
|
76
|
+
### Wave 3: Integration
|
|
77
|
+
- Depends on Wave 2
|
|
78
|
+
- Cross-cutting concerns
|
|
79
|
+
- E2E tests
|
|
80
|
+
|
|
81
|
+
### Wave N: Cleanup
|
|
82
|
+
- Final polish
|
|
83
|
+
- Documentation
|
|
84
|
+
- Performance optimization
|
|
85
|
+
|
|
86
|
+
## Conflict Detection
|
|
87
|
+
|
|
88
|
+
### File Conflicts
|
|
89
|
+
Two plans modifying same file cannot be parallel.
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
# Plan A
|
|
93
|
+
files_modified: [src/user.ts, src/auth.ts]
|
|
94
|
+
|
|
95
|
+
# Plan B
|
|
96
|
+
files_modified: [src/auth.ts, src/session.ts]
|
|
97
|
+
|
|
98
|
+
# Conflict: src/auth.ts - must be sequential
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Resource Conflicts
|
|
102
|
+
Two plans using same external resource.
|
|
103
|
+
|
|
104
|
+
```yaml
|
|
105
|
+
# Plan A: Migrate database
|
|
106
|
+
# Plan B: Seed test data
|
|
107
|
+
|
|
108
|
+
# Conflict: Both modify database - sequential
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Execution Strategies
|
|
112
|
+
|
|
113
|
+
### Conservative (Default)
|
|
114
|
+
- Maximum 2 parallel agents
|
|
115
|
+
- Wait for wave completion
|
|
116
|
+
- Checkpoint between waves
|
|
117
|
+
|
|
118
|
+
### Aggressive
|
|
119
|
+
- Maximum 4 parallel agents
|
|
120
|
+
- Start next wave early when possible
|
|
121
|
+
- Minimal checkpoints
|
|
122
|
+
|
|
123
|
+
### Budget
|
|
124
|
+
- Sequential execution only
|
|
125
|
+
- Minimize resource usage
|
|
126
|
+
- Maximum checkpoints
|
|
127
|
+
|
|
128
|
+
## Using goop_wave_execute
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
goop_wave_execute({
|
|
132
|
+
phase: "1",
|
|
133
|
+
gaps_only: false,
|
|
134
|
+
max_parallel: 3
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Response:
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"waves": [
|
|
142
|
+
{
|
|
143
|
+
"wave": 1,
|
|
144
|
+
"plans": ["setup-PLAN", "config-PLAN"],
|
|
145
|
+
"description": "Foundation setup"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"wave": 2,
|
|
149
|
+
"plans": ["auth-PLAN", "user-PLAN"],
|
|
150
|
+
"description": "Core features"
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Merge Strategy
|
|
157
|
+
|
|
158
|
+
After parallel execution:
|
|
159
|
+
1. Verify no conflicts in modified files
|
|
160
|
+
2. Run all tests to catch integration issues
|
|
161
|
+
3. Resolve any merge conflicts
|
|
162
|
+
4. Create consolidated checkpoint
|
|
163
|
+
|
|
164
|
+
## Best Practices
|
|
165
|
+
|
|
166
|
+
1. **Conservative parallelism** - Start with 2 parallel, increase if stable
|
|
167
|
+
2. **Clear boundaries** - No file overlap between parallel plans
|
|
168
|
+
3. **Fail fast** - Stop wave on first failure
|
|
169
|
+
4. **Checkpoint between waves** - Recovery points
|
|
170
|
+
5. **Monitor resources** - Don't exceed API limits
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pattern-extraction
|
|
3
|
+
description: Identify recurring patterns and abstractions in a codebase for documentation and reuse.
|
|
4
|
+
category: code
|
|
5
|
+
triggers:
|
|
6
|
+
- patterns
|
|
7
|
+
- abstraction
|
|
8
|
+
- reuse
|
|
9
|
+
- refactor
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Pattern Extraction Skill
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
Identify recurring patterns and abstractions in a codebase for documentation and reuse.
|
|
17
|
+
|
|
18
|
+
## Pattern Categories
|
|
19
|
+
|
|
20
|
+
### 1. Structural Patterns
|
|
21
|
+
- Module organization
|
|
22
|
+
- Layer architecture
|
|
23
|
+
- Feature-based structure
|
|
24
|
+
- Shared utilities location
|
|
25
|
+
|
|
26
|
+
### 2. Code Patterns
|
|
27
|
+
- Error handling approach
|
|
28
|
+
- Validation patterns
|
|
29
|
+
- Data transformation patterns
|
|
30
|
+
- API client patterns
|
|
31
|
+
|
|
32
|
+
### 3. Testing Patterns
|
|
33
|
+
- Test file organization
|
|
34
|
+
- Mock/stub conventions
|
|
35
|
+
- Fixture patterns
|
|
36
|
+
- Integration test setup
|
|
37
|
+
|
|
38
|
+
### 4. Component Patterns
|
|
39
|
+
- Component composition
|
|
40
|
+
- Prop patterns
|
|
41
|
+
- State management
|
|
42
|
+
- Event handling
|
|
43
|
+
|
|
44
|
+
## Extraction Process
|
|
45
|
+
|
|
46
|
+
1. **Sample Selection** - Choose representative files
|
|
47
|
+
2. **Pattern Identification** - Note recurring structures
|
|
48
|
+
3. **Validation** - Verify pattern is consistent across codebase
|
|
49
|
+
4. **Documentation** - Write pattern description with examples
|
|
50
|
+
5. **Counter-Examples** - Note exceptions and why they differ
|
|
51
|
+
|
|
52
|
+
## Pattern Documentation Template
|
|
53
|
+
|
|
54
|
+
```markdown
|
|
55
|
+
## Pattern: [Name]
|
|
56
|
+
|
|
57
|
+
### Intent
|
|
58
|
+
What problem does this pattern solve?
|
|
59
|
+
|
|
60
|
+
### Structure
|
|
61
|
+
How is it organized?
|
|
62
|
+
|
|
63
|
+
### Example
|
|
64
|
+
```code
|
|
65
|
+
// Representative example
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### When to Use
|
|
69
|
+
Guidelines for when to apply this pattern.
|
|
70
|
+
|
|
71
|
+
### Variations
|
|
72
|
+
Acceptable variations seen in codebase.
|
|
73
|
+
```
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: performance-optimization
|
|
3
|
+
description: Optimize code and system performance
|
|
4
|
+
category: optimization
|
|
5
|
+
triggers:
|
|
6
|
+
- performance
|
|
7
|
+
- optimize
|
|
8
|
+
- speed
|
|
9
|
+
- memory
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
requires:
|
|
12
|
+
- goop-core
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Performance Optimization Skill
|
|
16
|
+
|
|
17
|
+
## Optimization Principles
|
|
18
|
+
|
|
19
|
+
### 1. Measure First
|
|
20
|
+
Never optimize without profiling data.
|
|
21
|
+
|
|
22
|
+
### 2. Focus on Bottlenecks
|
|
23
|
+
Optimize the slowest 20%, not everything.
|
|
24
|
+
|
|
25
|
+
### 3. Maintain Readability
|
|
26
|
+
Performance gains shouldn't sacrifice clarity.
|
|
27
|
+
|
|
28
|
+
### 4. Test After Changes
|
|
29
|
+
Verify optimizations don't break functionality.
|
|
30
|
+
|
|
31
|
+
## Common Bottlenecks
|
|
32
|
+
|
|
33
|
+
### Database
|
|
34
|
+
- N+1 queries
|
|
35
|
+
- Missing indexes
|
|
36
|
+
- Unoptimized queries
|
|
37
|
+
- Connection pool exhaustion
|
|
38
|
+
|
|
39
|
+
### Network
|
|
40
|
+
- Too many requests
|
|
41
|
+
- Large payloads
|
|
42
|
+
- Missing caching
|
|
43
|
+
- Slow DNS resolution
|
|
44
|
+
|
|
45
|
+
### CPU
|
|
46
|
+
- Inefficient algorithms
|
|
47
|
+
- Unnecessary computation
|
|
48
|
+
- Blocking operations
|
|
49
|
+
- Poor parallelization
|
|
50
|
+
|
|
51
|
+
### Memory
|
|
52
|
+
- Memory leaks
|
|
53
|
+
- Large objects in memory
|
|
54
|
+
- Unnecessary copies
|
|
55
|
+
- Missing garbage collection
|
|
56
|
+
|
|
57
|
+
## Profiling Tools
|
|
58
|
+
|
|
59
|
+
### JavaScript/Node.js
|
|
60
|
+
```bash
|
|
61
|
+
# CPU profiling
|
|
62
|
+
node --prof app.js
|
|
63
|
+
node --prof-process isolate-*.log
|
|
64
|
+
|
|
65
|
+
# Memory profiling
|
|
66
|
+
node --inspect app.js
|
|
67
|
+
# Open chrome://inspect
|
|
68
|
+
|
|
69
|
+
# Benchmark
|
|
70
|
+
npm install -g autocannon
|
|
71
|
+
autocannon -c 100 -d 30 http://localhost:3000
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Database
|
|
75
|
+
```sql
|
|
76
|
+
-- PostgreSQL
|
|
77
|
+
EXPLAIN ANALYZE SELECT * FROM users WHERE email = 'test@example.com';
|
|
78
|
+
|
|
79
|
+
-- Add index
|
|
80
|
+
CREATE INDEX idx_users_email ON users(email);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Optimization Patterns
|
|
84
|
+
|
|
85
|
+
### Caching
|
|
86
|
+
```typescript
|
|
87
|
+
const cache = new Map();
|
|
88
|
+
|
|
89
|
+
async function getData(id: string) {
|
|
90
|
+
if (cache.has(id)) {
|
|
91
|
+
return cache.get(id);
|
|
92
|
+
}
|
|
93
|
+
const data = await fetchData(id);
|
|
94
|
+
cache.set(id, data);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Batching
|
|
100
|
+
```typescript
|
|
101
|
+
// Instead of N individual queries
|
|
102
|
+
const users = await Promise.all(ids.map(id => getUser(id)));
|
|
103
|
+
|
|
104
|
+
// Use batch query
|
|
105
|
+
const users = await getUsersByIds(ids);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Lazy Loading
|
|
109
|
+
```typescript
|
|
110
|
+
// Load only when needed
|
|
111
|
+
const heavyModule = await import('./heavy-module');
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Pagination
|
|
115
|
+
```typescript
|
|
116
|
+
// Instead of loading all
|
|
117
|
+
const users = await db.users.findMany({
|
|
118
|
+
skip: page * pageSize,
|
|
119
|
+
take: pageSize,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Performance Checklist
|
|
124
|
+
|
|
125
|
+
### Frontend
|
|
126
|
+
- [ ] Bundle size optimized
|
|
127
|
+
- [ ] Images optimized
|
|
128
|
+
- [ ] Code splitting implemented
|
|
129
|
+
- [ ] Lazy loading for heavy components
|
|
130
|
+
- [ ] Caching headers set
|
|
131
|
+
|
|
132
|
+
### Backend
|
|
133
|
+
- [ ] Database queries optimized
|
|
134
|
+
- [ ] Proper indexes in place
|
|
135
|
+
- [ ] Caching implemented
|
|
136
|
+
- [ ] Connection pooling configured
|
|
137
|
+
- [ ] Async operations used
|
|
138
|
+
|
|
139
|
+
### Infrastructure
|
|
140
|
+
- [ ] CDN configured
|
|
141
|
+
- [ ] Compression enabled
|
|
142
|
+
- [ ] HTTP/2 enabled
|
|
143
|
+
- [ ] Geographic distribution
|
|
144
|
+
|
|
145
|
+
## Metrics to Track
|
|
146
|
+
|
|
147
|
+
| Metric | Target | Tool |
|
|
148
|
+
|--------|--------|------|
|
|
149
|
+
| Response time (p50) | <100ms | APM |
|
|
150
|
+
| Response time (p99) | <500ms | APM |
|
|
151
|
+
| Throughput | >1000 rps | Load test |
|
|
152
|
+
| Error rate | <0.1% | APM |
|
|
153
|
+
| Memory usage | <80% | Monitoring |
|
|
154
|
+
| CPU usage | <70% | Monitoring |
|
|
155
|
+
|
|
156
|
+
## Performance Report
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
# Performance Analysis
|
|
160
|
+
|
|
161
|
+
**Date:** {YYYY-MM-DD}
|
|
162
|
+
**Scope:** {What was analyzed}
|
|
163
|
+
|
|
164
|
+
## Current Performance
|
|
165
|
+
{Baseline metrics}
|
|
166
|
+
|
|
167
|
+
## Bottlenecks Identified
|
|
168
|
+
1. {Bottleneck 1} - {Impact}
|
|
169
|
+
2. {Bottleneck 2} - {Impact}
|
|
170
|
+
|
|
171
|
+
## Optimizations Applied
|
|
172
|
+
1. {Change 1} - {Improvement}
|
|
173
|
+
2. {Change 2} - {Improvement}
|
|
174
|
+
|
|
175
|
+
## Results
|
|
176
|
+
{Before/after comparison}
|
|
177
|
+
|
|
178
|
+
## Recommendations
|
|
179
|
+
{Future improvements}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Best Practices
|
|
183
|
+
|
|
184
|
+
1. **Profile regularly** - Not just when slow
|
|
185
|
+
2. **Set budgets** - Performance budgets for key metrics
|
|
186
|
+
3. **Monitor production** - Lab != production
|
|
187
|
+
4. **Automate testing** - CI performance tests
|
|
188
|
+
5. **Document baselines** - Track trends over time
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright
|
|
3
|
+
description: Write effective end-to-end tests using Playwright for web applications.
|
|
4
|
+
category: review
|
|
5
|
+
triggers:
|
|
6
|
+
- playwright
|
|
7
|
+
- e2e
|
|
8
|
+
- browser
|
|
9
|
+
- testing
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Playwright Skill
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
Write effective end-to-end tests using Playwright for web applications.
|
|
17
|
+
|
|
18
|
+
## Core Concepts
|
|
19
|
+
|
|
20
|
+
### Page Object Model
|
|
21
|
+
Encapsulate page interactions in reusable classes.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
class LoginPage {
|
|
25
|
+
constructor(private page: Page) {}
|
|
26
|
+
|
|
27
|
+
async login(email: string, password: string) {
|
|
28
|
+
await this.page.fill('[data-testid="email"]', email);
|
|
29
|
+
await this.page.fill('[data-testid="password"]', password);
|
|
30
|
+
await this.page.click('[data-testid="submit"]');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Locator Strategies (Priority Order)
|
|
36
|
+
1. `data-testid` attributes (most stable)
|
|
37
|
+
2. Accessible roles and names
|
|
38
|
+
3. Text content
|
|
39
|
+
4. CSS selectors (least preferred)
|
|
40
|
+
|
|
41
|
+
### Waiting Strategies
|
|
42
|
+
- Auto-wait for elements (built-in)
|
|
43
|
+
- `waitForSelector` for dynamic content
|
|
44
|
+
- `waitForResponse` for API calls
|
|
45
|
+
- `waitForLoadState` for navigation
|
|
46
|
+
|
|
47
|
+
## Best Practices
|
|
48
|
+
|
|
49
|
+
1. **Use Test IDs** - Add `data-testid` for test stability
|
|
50
|
+
2. **Isolate Tests** - Each test should be independent
|
|
51
|
+
3. **Mock Strategically** - Mock external services, not internal logic
|
|
52
|
+
4. **Screenshot on Failure** - Capture state for debugging
|
|
53
|
+
5. **Parallel Execution** - Use workers for speed
|
|
54
|
+
|
|
55
|
+
## Common Patterns
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Wait for API response
|
|
59
|
+
await page.waitForResponse(resp =>
|
|
60
|
+
resp.url().includes('/api/users') && resp.status() === 200
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Screenshot on failure
|
|
64
|
+
test.afterEach(async ({ page }, testInfo) => {
|
|
65
|
+
if (testInfo.status !== testInfo.expectedStatus) {
|
|
66
|
+
await page.screenshot({ path: `failure-${testInfo.title}.png` });
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playwright-testing
|
|
3
|
+
description: Design and execute comprehensive Playwright test suites for web applications.
|
|
4
|
+
category: review
|
|
5
|
+
triggers:
|
|
6
|
+
- playwright
|
|
7
|
+
- testing
|
|
8
|
+
- e2e
|
|
9
|
+
- suites
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Playwright Testing Skill
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
Design and execute comprehensive Playwright test suites for web applications.
|
|
17
|
+
|
|
18
|
+
## Test Organization
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
tests/
|
|
22
|
+
e2e/
|
|
23
|
+
auth/
|
|
24
|
+
login.spec.ts
|
|
25
|
+
signup.spec.ts
|
|
26
|
+
dashboard/
|
|
27
|
+
overview.spec.ts
|
|
28
|
+
fixtures/
|
|
29
|
+
auth.fixture.ts
|
|
30
|
+
pages/
|
|
31
|
+
login.page.ts
|
|
32
|
+
dashboard.page.ts
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Test Structure
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { test, expect } from '@playwright/test';
|
|
39
|
+
|
|
40
|
+
test.describe('Feature: User Login', () => {
|
|
41
|
+
test.beforeEach(async ({ page }) => {
|
|
42
|
+
await page.goto('/login');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('should login with valid credentials', async ({ page }) => {
|
|
46
|
+
await page.fill('[data-testid="email"]', 'user@example.com');
|
|
47
|
+
await page.fill('[data-testid="password"]', 'password');
|
|
48
|
+
await page.click('[data-testid="submit"]');
|
|
49
|
+
await expect(page).toHaveURL('/dashboard');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('should show error for invalid credentials', async ({ page }) => {
|
|
53
|
+
await page.fill('[data-testid="email"]', 'wrong@example.com');
|
|
54
|
+
await page.fill('[data-testid="password"]', 'wrong');
|
|
55
|
+
await page.click('[data-testid="submit"]');
|
|
56
|
+
await expect(page.locator('[data-testid="error"]')).toBeVisible();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Fixtures
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// fixtures/auth.fixture.ts
|
|
65
|
+
import { test as base } from '@playwright/test';
|
|
66
|
+
|
|
67
|
+
export const test = base.extend({
|
|
68
|
+
authenticatedPage: async ({ page }, use) => {
|
|
69
|
+
await page.goto('/login');
|
|
70
|
+
await page.fill('[data-testid="email"]', 'test@example.com');
|
|
71
|
+
await page.fill('[data-testid="password"]', 'password');
|
|
72
|
+
await page.click('[data-testid="submit"]');
|
|
73
|
+
await page.waitForURL('/dashboard');
|
|
74
|
+
await use(page);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Configuration
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// playwright.config.ts
|
|
83
|
+
export default defineConfig({
|
|
84
|
+
testDir: './tests',
|
|
85
|
+
retries: 2,
|
|
86
|
+
workers: 4,
|
|
87
|
+
use: {
|
|
88
|
+
baseURL: 'http://localhost:3000',
|
|
89
|
+
trace: 'on-first-retry',
|
|
90
|
+
screenshot: 'only-on-failure',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|