claude-everything-workflow 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.md +36 -0
- package/CLAUDE.md +7 -0
- package/LICENSE +22 -0
- package/README.md +369 -0
- package/agents/architect.md +59 -0
- package/agents/code-reviewer.md +57 -0
- package/agents/database-reviewer.md +44 -0
- package/agents/e2e-runner.md +153 -0
- package/agents/harness-optimizer.md +92 -0
- package/agents/planner.md +124 -0
- package/agents/refactor-cleaner.md +54 -0
- package/agents/security-reviewer.md +47 -0
- package/agents/tdd-guide.md +101 -0
- package/bin/claude-everything-workflow.js +91 -0
- package/commands/code-review.md +27 -0
- package/commands/e2e.md +28 -0
- package/commands/evolve.md +42 -0
- package/commands/harness-audit.md +27 -0
- package/commands/instinct-status.md +38 -0
- package/commands/learn-eval.md +91 -0
- package/commands/pr.md +88 -0
- package/commands/projects.md +27 -0
- package/commands/promote.md +29 -0
- package/commands/prune.md +46 -0
- package/commands/tdd.md +27 -0
- package/commands/verify.md +93 -0
- package/homunculus/instincts/personal/always-test-first.md +28 -0
- package/homunculus/instincts/personal/pr-ci-quality-gate.md +30 -0
- package/hooks/check-console-log.js +37 -0
- package/hooks/commit-quality.js +143 -0
- package/hooks/evaluate-session.js +59 -0
- package/hooks/pre-compact.js +92 -0
- package/hooks/runtime/hook-flags.js +40 -0
- package/hooks/runtime/run-with-flags.js +141 -0
- package/hooks/runtime/session-utils.js +45 -0
- package/hooks/session-end.js +62 -0
- package/hooks/session-start.js +60 -0
- package/package.json +48 -0
- package/references/agents/database-reviewer.md +657 -0
- package/references/agents/refactor-cleaner.md +75 -0
- package/references/agents/security-reviewer.md +542 -0
- package/rules/01-base.md +49 -0
- package/rules/02-code-size.md +13 -0
- package/rules/03-architecture.md +64 -0
- package/rules/04-error-handling.md +27 -0
- package/rules/05-git-workflow.md +56 -0
- package/rules/06-comments.md +44 -0
- package/rules/07-forbidden.md +43 -0
- package/rules/08-ecc-integration.md +46 -0
- package/rules/common/agent-orchestration.md +54 -0
- package/rules/common/context-hygiene.md +85 -0
- package/rules/common/harness-engineering.md +46 -0
- package/rules/common/hooks.md +87 -0
- package/rules/common/implementation.md +25 -0
- package/rules/common/performance.md +71 -0
- package/rules/common/pr-automation.md +73 -0
- package/rules/common/security.md +19 -0
- package/rules/common/skills-learning.md +39 -0
- package/rules/common/testing.md +68 -0
- package/scripts/install.ps1 +286 -0
- package/scripts/install.sh +214 -0
- package/scripts/learning/migrate-homunculus.js +93 -0
- package/scripts/learning/project-utils.js +214 -0
- package/scripts/learning/projects.js +60 -0
- package/scripts/learning/promote.js +98 -0
- package/scripts/learning/review-confidence.js +455 -0
- package/scripts/verify-harness.js +868 -0
- package/settings.json +77 -0
- package/skills/brainstorming/SKILL.md +185 -0
- package/skills/brainstorming/agents/openai.yaml +3 -0
- package/skills/brainstorming/scripts/frame-template.html +214 -0
- package/skills/brainstorming/scripts/helper.js +88 -0
- package/skills/brainstorming/scripts/server.cjs +354 -0
- package/skills/brainstorming/scripts/start-server.sh +148 -0
- package/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +287 -0
- package/skills/continuous-learning-v2/SKILL.md +74 -0
- package/skills/continuous-learning-v2/agents/observer.md +129 -0
- package/skills/continuous-learning-v2/agents/start-observer.sh +83 -0
- package/skills/continuous-learning-v2/config.json +58 -0
- package/skills/continuous-learning-v2/hooks/observe-v2.js +144 -0
- package/skills/documentation-lookup/SKILL.md +90 -0
- package/skills/e2e-testing/SKILL.md +326 -0
- package/skills/executing-plans/SKILL.md +66 -0
- package/skills/find-skills/SKILL.md +142 -0
- package/skills/skill-creator/LICENSE.txt +202 -0
- package/skills/skill-creator/SKILL.md +356 -0
- package/skills/skill-creator/references/output-patterns.md +82 -0
- package/skills/skill-creator/references/workflows.md +28 -0
- package/skills/skill-creator/scripts/init_skill.py +303 -0
- package/skills/skill-creator/scripts/package_skill.py +110 -0
- package/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/skills/systematic-debugging/SKILL.md +59 -0
- package/skills/test-driven-development/SKILL.md +71 -0
- package/skills/using-git-worktrees/SKILL.md +64 -0
- package/skills/verification-before-completion/SKILL.md +77 -0
- package/skills/writing-plans/SKILL.md +183 -0
- package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Observe Hook v2
|
|
4
|
+
*
|
|
5
|
+
* 观察工具调用,带详细上下文记录
|
|
6
|
+
* 用于 PreToolUse/PostToolUse hook
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs')
|
|
10
|
+
const path = require('path')
|
|
11
|
+
const os = require('os')
|
|
12
|
+
const {
|
|
13
|
+
ensureDir,
|
|
14
|
+
getDataRoot,
|
|
15
|
+
getProjectContext,
|
|
16
|
+
registerProject
|
|
17
|
+
} = require('../../../scripts/learning/project-utils')
|
|
18
|
+
|
|
19
|
+
function getConfig() {
|
|
20
|
+
const configPath = path.join(os.homedir(), '.claude', 'skills', 'continuous-learning-v2', 'config.json')
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(fs.readFileSync(configPath, 'utf8'))
|
|
23
|
+
} catch {
|
|
24
|
+
return {
|
|
25
|
+
observation: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
store_path: path.join(os.homedir(), '.claude', 'homunculus', 'observations.jsonl'),
|
|
28
|
+
capture_tools: ['Edit', 'Write', 'Bash', 'Read', 'Grep', 'Glob'],
|
|
29
|
+
ignore_tools: ['TodoWrite']
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getObservationsPath(config) {
|
|
36
|
+
const storePath = config.observation?.store_path || '~/.claude/homunculus/observations.jsonl'
|
|
37
|
+
if (storePath.endsWith('.jsonl')) {
|
|
38
|
+
return storePath.replace('~', os.homedir())
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const dataRoot = getDataRoot(config)
|
|
42
|
+
const context = getProjectContext({})
|
|
43
|
+
return path.join(dataRoot, 'projects', context.project_id, 'observations.jsonl')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function compactPayload(value, maxChars) {
|
|
47
|
+
if (value === undefined || value === null) {
|
|
48
|
+
return value
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const serialized = typeof value === 'string'
|
|
52
|
+
? value
|
|
53
|
+
: JSON.stringify(value)
|
|
54
|
+
|
|
55
|
+
if (!serialized || serialized.length <= maxChars) {
|
|
56
|
+
return value
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
truncated: true,
|
|
61
|
+
original_chars: serialized.length,
|
|
62
|
+
preview: serialized.slice(0, maxChars)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function shouldCapture(tool, config) {
|
|
67
|
+
const captureTools = config.observation?.capture_tools || []
|
|
68
|
+
const ignoreTools = config.observation?.ignore_tools || []
|
|
69
|
+
|
|
70
|
+
if (ignoreTools.includes(tool)) return false
|
|
71
|
+
if (captureTools.length === 0) return true
|
|
72
|
+
return captureTools.includes(tool)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function main() {
|
|
76
|
+
const phase = process.argv[2] // 'pre' or 'post'
|
|
77
|
+
const config = getConfig()
|
|
78
|
+
|
|
79
|
+
if (!config.observation?.enabled) {
|
|
80
|
+
process.exit(0)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let data = ''
|
|
84
|
+
process.stdin.on('data', chunk => {
|
|
85
|
+
data += chunk
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
process.stdin.on('end', () => {
|
|
89
|
+
try {
|
|
90
|
+
const input = JSON.parse(data)
|
|
91
|
+
|
|
92
|
+
// 检查是否需要捕获此工具
|
|
93
|
+
if (!shouldCapture(input.tool, config)) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const projectContext = getProjectContext(input)
|
|
98
|
+
const dataRoot = getDataRoot(config)
|
|
99
|
+
const explicitJsonlPath = config.observation?.store_path &&
|
|
100
|
+
config.observation.store_path.endsWith('.jsonl')
|
|
101
|
+
const observationsPath = explicitJsonlPath ||
|
|
102
|
+
config.observation?.project_scoped === false
|
|
103
|
+
? getObservationsPath(config)
|
|
104
|
+
: path.join(dataRoot, 'projects', projectContext.project_id, 'observations.jsonl')
|
|
105
|
+
|
|
106
|
+
if (config.observation?.project_scoped !== false) {
|
|
107
|
+
registerProject(dataRoot, projectContext)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
ensureDir(path.dirname(observationsPath))
|
|
111
|
+
|
|
112
|
+
const observation = {
|
|
113
|
+
timestamp: new Date().toISOString(),
|
|
114
|
+
event: phase === 'pre' ? 'tool_start' : 'tool_complete',
|
|
115
|
+
session_id: input.session_id || process.env.CLAUDE_SESSION_ID,
|
|
116
|
+
...projectContext,
|
|
117
|
+
tool: input.tool,
|
|
118
|
+
tool_input: phase === 'pre'
|
|
119
|
+
? compactPayload(
|
|
120
|
+
input.tool_input,
|
|
121
|
+
config.observation?.max_tool_input_chars || 2000
|
|
122
|
+
)
|
|
123
|
+
: undefined,
|
|
124
|
+
tool_output: phase === 'post'
|
|
125
|
+
? compactPayload(
|
|
126
|
+
input.tool_output || '',
|
|
127
|
+
config.observation?.max_tool_output_chars || 500
|
|
128
|
+
)
|
|
129
|
+
: undefined
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 追加到观察记录
|
|
133
|
+
fs.appendFileSync(
|
|
134
|
+
observationsPath,
|
|
135
|
+
JSON.stringify(observation) + '\n'
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error(`[Hook] observe-v2 failed: ${error.message}`)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
main()
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-lookup
|
|
3
|
+
description: Use up-to-date library and framework docs via Context7 MCP instead of training data. Activates for setup questions, API references, code examples, or when the user names a framework (e.g. React, Next.js, Prisma).
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Documentation Lookup (Context7)
|
|
8
|
+
|
|
9
|
+
When the user asks about libraries, frameworks, or APIs, fetch current documentation via the Context7 MCP (tools `resolve-library-id` and `query-docs`) instead of relying on training data.
|
|
10
|
+
|
|
11
|
+
## Core Concepts
|
|
12
|
+
|
|
13
|
+
- **Context7**: MCP server that exposes live documentation; use it instead of training data for libraries and APIs.
|
|
14
|
+
- **resolve-library-id**: Returns Context7-compatible library IDs (e.g. `/vercel/next.js`) from a library name and query.
|
|
15
|
+
- **query-docs**: Fetches documentation and code snippets for a given library ID and question. Always call resolve-library-id first to get a valid library ID.
|
|
16
|
+
|
|
17
|
+
## When to use
|
|
18
|
+
|
|
19
|
+
Activate when the user:
|
|
20
|
+
|
|
21
|
+
- Asks setup or configuration questions (e.g. "How do I configure Next.js middleware?")
|
|
22
|
+
- Requests code that depends on a library ("Write a Prisma query for...")
|
|
23
|
+
- Needs API or reference information ("What are the Supabase auth methods?")
|
|
24
|
+
- Mentions specific frameworks or libraries (React, Vue, Svelte, Express, Tailwind, Prisma, Supabase, etc.)
|
|
25
|
+
|
|
26
|
+
Use this skill whenever the request depends on accurate, up-to-date behavior of a library, framework, or API. Applies across harnesses that have the Context7 MCP configured (e.g. Claude Code, Cursor, Codex).
|
|
27
|
+
|
|
28
|
+
## How it works
|
|
29
|
+
|
|
30
|
+
### Step 1: Resolve the Library ID
|
|
31
|
+
|
|
32
|
+
Call the **resolve-library-id** MCP tool with:
|
|
33
|
+
|
|
34
|
+
- **libraryName**: The library or product name taken from the user's question (e.g. `Next.js`, `Prisma`, `Supabase`).
|
|
35
|
+
- **query**: The user's full question. This improves relevance ranking of results.
|
|
36
|
+
|
|
37
|
+
You must obtain a Context7-compatible library ID (format `/org/project` or `/org/project/version`) before querying docs. Do not call query-docs without a valid library ID from this step.
|
|
38
|
+
|
|
39
|
+
### Step 2: Select the Best Match
|
|
40
|
+
|
|
41
|
+
From the resolution results, choose one result using:
|
|
42
|
+
|
|
43
|
+
- **Name match**: Prefer exact or closest match to what the user asked for.
|
|
44
|
+
- **Benchmark score**: Higher scores indicate better documentation quality (100 is highest).
|
|
45
|
+
- **Source reputation**: Prefer High or Medium reputation when available.
|
|
46
|
+
- **Version**: If the user specified a version (e.g. "React 19", "Next.js 15"), prefer a version-specific library ID if listed (e.g. `/org/project/v1.2.0`).
|
|
47
|
+
|
|
48
|
+
### Step 3: Fetch the Documentation
|
|
49
|
+
|
|
50
|
+
Call the **query-docs** MCP tool with:
|
|
51
|
+
|
|
52
|
+
- **libraryId**: The selected Context7 library ID from Step 2 (e.g. `/vercel/next.js`).
|
|
53
|
+
- **query**: The user's specific question or task. Be specific to get relevant snippets.
|
|
54
|
+
|
|
55
|
+
Limit: do not call query-docs (or resolve-library-id) more than 3 times per question. If the answer is unclear after 3 calls, state the uncertainty and use the best information you have rather than guessing.
|
|
56
|
+
|
|
57
|
+
### Step 4: Use the Documentation
|
|
58
|
+
|
|
59
|
+
- Answer the user's question using the fetched, current information.
|
|
60
|
+
- Include relevant code examples from the docs when helpful.
|
|
61
|
+
- Cite the library or version when it matters (e.g. "In Next.js 15...").
|
|
62
|
+
|
|
63
|
+
## Examples
|
|
64
|
+
|
|
65
|
+
### Example: Next.js middleware
|
|
66
|
+
|
|
67
|
+
1. Call **resolve-library-id** with `libraryName: "Next.js"`, `query: "How do I set up Next.js middleware?"`.
|
|
68
|
+
2. From results, pick the best match (e.g. `/vercel/next.js`) by name and benchmark score.
|
|
69
|
+
3. Call **query-docs** with `libraryId: "/vercel/next.js"`, `query: "How do I set up Next.js middleware?"`.
|
|
70
|
+
4. Use the returned snippets and text to answer; include a minimal `middleware.ts` example from the docs if relevant.
|
|
71
|
+
|
|
72
|
+
### Example: Prisma query
|
|
73
|
+
|
|
74
|
+
1. Call **resolve-library-id** with `libraryName: "Prisma"`, `query: "How do I query with relations?"`.
|
|
75
|
+
2. Select the official Prisma library ID (e.g. `/prisma/prisma`).
|
|
76
|
+
3. Call **query-docs** with that `libraryId` and the query.
|
|
77
|
+
4. Return the Prisma Client pattern (e.g. `include` or `select`) with a short code snippet from the docs.
|
|
78
|
+
|
|
79
|
+
### Example: Supabase auth methods
|
|
80
|
+
|
|
81
|
+
1. Call **resolve-library-id** with `libraryName: "Supabase"`, `query: "What are the auth methods?"`.
|
|
82
|
+
2. Pick the Supabase docs library ID.
|
|
83
|
+
3. Call **query-docs**; summarize the auth methods and show minimal examples from the fetched docs.
|
|
84
|
+
|
|
85
|
+
## Best Practices
|
|
86
|
+
|
|
87
|
+
- **Be specific**: Use the user's full question as the query where possible for better relevance.
|
|
88
|
+
- **Version awareness**: When users mention versions, use version-specific library IDs from the resolve step when available.
|
|
89
|
+
- **Prefer official sources**: When multiple matches exist, prefer official or primary packages over community forks.
|
|
90
|
+
- **No sensitive data**: Redact API keys, passwords, tokens, and other secrets from any query sent to Context7. Treat the user's question as potentially containing secrets before passing it to resolve-library-id or query-docs.
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: e2e-testing
|
|
3
|
+
description: Playwright E2E testing patterns, Page Object Model, configuration, CI/CD integration, artifact management, and flaky test strategies.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# E2E Testing Patterns
|
|
8
|
+
|
|
9
|
+
Comprehensive Playwright patterns for building stable, fast, and maintainable E2E test suites.
|
|
10
|
+
|
|
11
|
+
## Test File Organization
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
tests/
|
|
15
|
+
├── e2e/
|
|
16
|
+
│ ├── auth/
|
|
17
|
+
│ │ ├── login.spec.ts
|
|
18
|
+
│ │ ├── logout.spec.ts
|
|
19
|
+
│ │ └── register.spec.ts
|
|
20
|
+
│ ├── features/
|
|
21
|
+
│ │ ├── browse.spec.ts
|
|
22
|
+
│ │ ├── search.spec.ts
|
|
23
|
+
│ │ └── create.spec.ts
|
|
24
|
+
│ └── api/
|
|
25
|
+
│ └── endpoints.spec.ts
|
|
26
|
+
├── fixtures/
|
|
27
|
+
│ ├── auth.ts
|
|
28
|
+
│ └── data.ts
|
|
29
|
+
└── playwright.config.ts
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Page Object Model (POM)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { Page, Locator } from '@playwright/test'
|
|
36
|
+
|
|
37
|
+
export class ItemsPage {
|
|
38
|
+
readonly page: Page
|
|
39
|
+
readonly searchInput: Locator
|
|
40
|
+
readonly itemCards: Locator
|
|
41
|
+
readonly createButton: Locator
|
|
42
|
+
|
|
43
|
+
constructor(page: Page) {
|
|
44
|
+
this.page = page
|
|
45
|
+
this.searchInput = page.locator('[data-testid="search-input"]')
|
|
46
|
+
this.itemCards = page.locator('[data-testid="item-card"]')
|
|
47
|
+
this.createButton = page.locator('[data-testid="create-btn"]')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async goto() {
|
|
51
|
+
await this.page.goto('/items')
|
|
52
|
+
await this.page.waitForLoadState('networkidle')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async search(query: string) {
|
|
56
|
+
await this.searchInput.fill(query)
|
|
57
|
+
await this.page.waitForResponse(resp => resp.url().includes('/api/search'))
|
|
58
|
+
await this.page.waitForLoadState('networkidle')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async getItemCount() {
|
|
62
|
+
return await this.itemCards.count()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Test Structure
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { test, expect } from '@playwright/test'
|
|
71
|
+
import { ItemsPage } from '../../pages/ItemsPage'
|
|
72
|
+
|
|
73
|
+
test.describe('Item Search', () => {
|
|
74
|
+
let itemsPage: ItemsPage
|
|
75
|
+
|
|
76
|
+
test.beforeEach(async ({ page }) => {
|
|
77
|
+
itemsPage = new ItemsPage(page)
|
|
78
|
+
await itemsPage.goto()
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
test('should search by keyword', async ({ page }) => {
|
|
82
|
+
await itemsPage.search('test')
|
|
83
|
+
|
|
84
|
+
const count = await itemsPage.getItemCount()
|
|
85
|
+
expect(count).toBeGreaterThan(0)
|
|
86
|
+
|
|
87
|
+
await expect(itemsPage.itemCards.first()).toContainText(/test/i)
|
|
88
|
+
await page.screenshot({ path: 'artifacts/search-results.png' })
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
test('should handle no results', async ({ page }) => {
|
|
92
|
+
await itemsPage.search('xyznonexistent123')
|
|
93
|
+
|
|
94
|
+
await expect(page.locator('[data-testid="no-results"]')).toBeVisible()
|
|
95
|
+
expect(await itemsPage.getItemCount()).toBe(0)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Playwright Configuration
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { defineConfig, devices } from '@playwright/test'
|
|
104
|
+
|
|
105
|
+
export default defineConfig({
|
|
106
|
+
testDir: './tests/e2e',
|
|
107
|
+
fullyParallel: true,
|
|
108
|
+
forbidOnly: !!process.env.CI,
|
|
109
|
+
retries: process.env.CI ? 2 : 0,
|
|
110
|
+
workers: process.env.CI ? 1 : undefined,
|
|
111
|
+
reporter: [
|
|
112
|
+
['html', { outputFolder: 'playwright-report' }],
|
|
113
|
+
['junit', { outputFile: 'playwright-results.xml' }],
|
|
114
|
+
['json', { outputFile: 'playwright-results.json' }]
|
|
115
|
+
],
|
|
116
|
+
use: {
|
|
117
|
+
baseURL: process.env.BASE_URL || 'http://localhost:3000',
|
|
118
|
+
trace: 'on-first-retry',
|
|
119
|
+
screenshot: 'only-on-failure',
|
|
120
|
+
video: 'retain-on-failure',
|
|
121
|
+
actionTimeout: 10000,
|
|
122
|
+
navigationTimeout: 30000,
|
|
123
|
+
},
|
|
124
|
+
projects: [
|
|
125
|
+
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
|
126
|
+
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
|
127
|
+
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
|
|
128
|
+
{ name: 'mobile-chrome', use: { ...devices['Pixel 5'] } },
|
|
129
|
+
],
|
|
130
|
+
webServer: {
|
|
131
|
+
command: 'npm run dev',
|
|
132
|
+
url: 'http://localhost:3000',
|
|
133
|
+
reuseExistingServer: !process.env.CI,
|
|
134
|
+
timeout: 120000,
|
|
135
|
+
},
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Flaky Test Patterns
|
|
140
|
+
|
|
141
|
+
### Quarantine
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
test('flaky: complex search', async ({ page }) => {
|
|
145
|
+
test.fixme(true, 'Flaky - Issue #123')
|
|
146
|
+
// test code...
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
test('conditional skip', async ({ page }) => {
|
|
150
|
+
test.skip(process.env.CI, 'Flaky in CI - Issue #123')
|
|
151
|
+
// test code...
|
|
152
|
+
})
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Identify Flakiness
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npx playwright test tests/search.spec.ts --repeat-each=10
|
|
159
|
+
npx playwright test tests/search.spec.ts --retries=3
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Common Causes & Fixes
|
|
163
|
+
|
|
164
|
+
**Race conditions:**
|
|
165
|
+
```typescript
|
|
166
|
+
// Bad: assumes element is ready
|
|
167
|
+
await page.click('[data-testid="button"]')
|
|
168
|
+
|
|
169
|
+
// Good: auto-wait locator
|
|
170
|
+
await page.locator('[data-testid="button"]').click()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Network timing:**
|
|
174
|
+
```typescript
|
|
175
|
+
// Bad: arbitrary timeout
|
|
176
|
+
await page.waitForTimeout(5000)
|
|
177
|
+
|
|
178
|
+
// Good: wait for specific condition
|
|
179
|
+
await page.waitForResponse(resp => resp.url().includes('/api/data'))
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Animation timing:**
|
|
183
|
+
```typescript
|
|
184
|
+
// Bad: click during animation
|
|
185
|
+
await page.click('[data-testid="menu-item"]')
|
|
186
|
+
|
|
187
|
+
// Good: wait for stability
|
|
188
|
+
await page.locator('[data-testid="menu-item"]').waitFor({ state: 'visible' })
|
|
189
|
+
await page.waitForLoadState('networkidle')
|
|
190
|
+
await page.locator('[data-testid="menu-item"]').click()
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Artifact Management
|
|
194
|
+
|
|
195
|
+
### Screenshots
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
await page.screenshot({ path: 'artifacts/after-login.png' })
|
|
199
|
+
await page.screenshot({ path: 'artifacts/full-page.png', fullPage: true })
|
|
200
|
+
await page.locator('[data-testid="chart"]').screenshot({ path: 'artifacts/chart.png' })
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Traces
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
await browser.startTracing(page, {
|
|
207
|
+
path: 'artifacts/trace.json',
|
|
208
|
+
screenshots: true,
|
|
209
|
+
snapshots: true,
|
|
210
|
+
})
|
|
211
|
+
// ... test actions ...
|
|
212
|
+
await browser.stopTracing()
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Video
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// In playwright.config.ts
|
|
219
|
+
use: {
|
|
220
|
+
video: 'retain-on-failure',
|
|
221
|
+
videosPath: 'artifacts/videos/'
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## CI/CD Integration
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
# .github/workflows/e2e.yml
|
|
229
|
+
name: E2E Tests
|
|
230
|
+
on: [push, pull_request]
|
|
231
|
+
|
|
232
|
+
jobs:
|
|
233
|
+
test:
|
|
234
|
+
runs-on: ubuntu-latest
|
|
235
|
+
steps:
|
|
236
|
+
- uses: actions/checkout@v4
|
|
237
|
+
- uses: actions/setup-node@v4
|
|
238
|
+
with:
|
|
239
|
+
node-version: 20
|
|
240
|
+
- run: npm ci
|
|
241
|
+
- run: npx playwright install --with-deps
|
|
242
|
+
- run: npx playwright test
|
|
243
|
+
env:
|
|
244
|
+
BASE_URL: ${{ vars.STAGING_URL }}
|
|
245
|
+
- uses: actions/upload-artifact@v4
|
|
246
|
+
if: always()
|
|
247
|
+
with:
|
|
248
|
+
name: playwright-report
|
|
249
|
+
path: playwright-report/
|
|
250
|
+
retention-days: 30
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Test Report Template
|
|
254
|
+
|
|
255
|
+
```markdown
|
|
256
|
+
# E2E Test Report
|
|
257
|
+
|
|
258
|
+
**Date:** YYYY-MM-DD HH:MM
|
|
259
|
+
**Duration:** Xm Ys
|
|
260
|
+
**Status:** PASSING / FAILING
|
|
261
|
+
|
|
262
|
+
## Summary
|
|
263
|
+
- Total: X | Passed: Y (Z%) | Failed: A | Flaky: B | Skipped: C
|
|
264
|
+
|
|
265
|
+
## Failed Tests
|
|
266
|
+
|
|
267
|
+
### test-name
|
|
268
|
+
**File:** `tests/e2e/feature.spec.ts:45`
|
|
269
|
+
**Error:** Expected element to be visible
|
|
270
|
+
**Screenshot:** artifacts/failed.png
|
|
271
|
+
**Recommended Fix:** [description]
|
|
272
|
+
|
|
273
|
+
## Artifacts
|
|
274
|
+
- HTML Report: playwright-report/index.html
|
|
275
|
+
- Screenshots: artifacts/*.png
|
|
276
|
+
- Videos: artifacts/videos/*.webm
|
|
277
|
+
- Traces: artifacts/*.zip
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Wallet / Web3 Testing
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
test('wallet connection', async ({ page, context }) => {
|
|
284
|
+
// Mock wallet provider
|
|
285
|
+
await context.addInitScript(() => {
|
|
286
|
+
window.ethereum = {
|
|
287
|
+
isMetaMask: true,
|
|
288
|
+
request: async ({ method }) => {
|
|
289
|
+
if (method === 'eth_requestAccounts')
|
|
290
|
+
return ['0x1234567890123456789012345678901234567890']
|
|
291
|
+
if (method === 'eth_chainId') return '0x1'
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
await page.goto('/')
|
|
297
|
+
await page.locator('[data-testid="connect-wallet"]').click()
|
|
298
|
+
await expect(page.locator('[data-testid="wallet-address"]')).toContainText('0x1234')
|
|
299
|
+
})
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Financial / Critical Flow Testing
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
test('trade execution', async ({ page }) => {
|
|
306
|
+
// Skip on production — real money
|
|
307
|
+
test.skip(process.env.NODE_ENV === 'production', 'Skip on production')
|
|
308
|
+
|
|
309
|
+
await page.goto('/markets/test-market')
|
|
310
|
+
await page.locator('[data-testid="position-yes"]').click()
|
|
311
|
+
await page.locator('[data-testid="trade-amount"]').fill('1.0')
|
|
312
|
+
|
|
313
|
+
// Verify preview
|
|
314
|
+
const preview = page.locator('[data-testid="trade-preview"]')
|
|
315
|
+
await expect(preview).toContainText('1.0')
|
|
316
|
+
|
|
317
|
+
// Confirm and wait for blockchain
|
|
318
|
+
await page.locator('[data-testid="confirm-trade"]').click()
|
|
319
|
+
await page.waitForResponse(
|
|
320
|
+
resp => resp.url().includes('/api/trade') && resp.status() === 200,
|
|
321
|
+
{ timeout: 30000 }
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
await expect(page.locator('[data-testid="trade-success"]')).toBeVisible()
|
|
325
|
+
})
|
|
326
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: executing-plans
|
|
3
|
+
description: Use after an approved implementation plan exists and the user wants execution. Runs the plan task-by-task with checkpoints, optional project-agent loop, tests, reviews, and final verification without expanding scope.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Executing Plans
|
|
7
|
+
|
|
8
|
+
Reference: https://github.com/obra/superpowers
|
|
9
|
+
|
|
10
|
+
Use this skill only after `skills/writing-plans/SKILL.md` has produced an approved plan. The plan is the source of truth; do not add scope unless the user approves a plan update.
|
|
11
|
+
|
|
12
|
+
## Preconditions
|
|
13
|
+
|
|
14
|
+
- An implementation plan exists and has been approved by the user.
|
|
15
|
+
- If work should be isolated, use `skills/using-git-worktrees/SKILL.md` before editing.
|
|
16
|
+
- Read the plan once, extract tasks, files, tests, and acceptance criteria.
|
|
17
|
+
- Confirm whether execution is inline or project-agent loop.
|
|
18
|
+
|
|
19
|
+
## Inline Execution
|
|
20
|
+
|
|
21
|
+
Use inline execution for small, clear, tightly coupled work.
|
|
22
|
+
|
|
23
|
+
For each task:
|
|
24
|
+
|
|
25
|
+
1. Mark exactly one task in progress.
|
|
26
|
+
2. Perform the next unchecked step only.
|
|
27
|
+
3. Run the command specified by the plan.
|
|
28
|
+
4. If a test or command fails unexpectedly, pause and use `skills/systematic-debugging/SKILL.md`.
|
|
29
|
+
5. Do a requirement/spec compliance check for the task.
|
|
30
|
+
6. Do a code quality check for the task.
|
|
31
|
+
7. Mark the task complete only after checks pass.
|
|
32
|
+
|
|
33
|
+
## Project-Agent Loop
|
|
34
|
+
|
|
35
|
+
Use this for substantial plans with independent tasks.
|
|
36
|
+
|
|
37
|
+
For each task:
|
|
38
|
+
|
|
39
|
+
1. Dispatch one fresh implementation agent with only:
|
|
40
|
+
- the approved spec summary
|
|
41
|
+
- the exact task section
|
|
42
|
+
- relevant file paths
|
|
43
|
+
- expected tests and acceptance criteria
|
|
44
|
+
2. Tell the agent it is not alone in the codebase and must not revert others' changes.
|
|
45
|
+
3. After implementation, run requirement/spec compliance review.
|
|
46
|
+
4. Run code quality review with `agents/code-reviewer.md`; add security or database review only when the touched area warrants it.
|
|
47
|
+
5. Send findings back to the same implementer until resolved.
|
|
48
|
+
6. Mark the task complete only after tests and reviews pass.
|
|
49
|
+
|
|
50
|
+
Subagents must return only conclusion, evidence paths, risks, and next steps. Do not accept large raw logs as final output.
|
|
51
|
+
|
|
52
|
+
## Completion Loop
|
|
53
|
+
|
|
54
|
+
After all tasks are complete:
|
|
55
|
+
|
|
56
|
+
1. Apply `skills/verification-before-completion/SKILL.md`: identify the verification evidence required before any completion claim.
|
|
57
|
+
2. Run `/verify` or the plan's equivalent verification commands to produce that fresh evidence.
|
|
58
|
+
3. If verification fails, use `skills/systematic-debugging/SKILL.md` for each failure class before changing code.
|
|
59
|
+
4. Run a final review over the full diff.
|
|
60
|
+
5. Summarize files changed, tests run, skipped checks, remaining risk, and whether the work is ready for `/pr`.
|
|
61
|
+
|
|
62
|
+
## Boundaries
|
|
63
|
+
|
|
64
|
+
- Do not commit, push, create PRs, delete branches, or remove worktrees unless the user asked for that action.
|
|
65
|
+
- Do not skip failed tests because later tasks might fix them; record the failure and debug now unless the plan explicitly says the failure is expected.
|
|
66
|
+
- Do not mark multiple tasks complete at the end; update status incrementally.
|