oh-my-codex-cli 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/.agent/skills/agent-kb/HOW_TO_USE.md +428 -0
- package/.agent/skills/agent-kb/README.md +46 -0
- package/.agent/skills/agent-kb/SKILL.md +128 -0
- package/.agent/skills/agent-kb/references/intelligent-analysis-explained.md +333 -0
- package/.agent/skills/agent-kb/references/query-optimization.md +225 -0
- package/.agent/skills/aireview/SKILL.md +704 -0
- package/.agent/skills/analyze/SKILL.md +81 -0
- package/.agent/skills/architect-planner/HOW_TO_USE.md +238 -0
- package/.agent/skills/architect-planner/README.md +41 -0
- package/.agent/skills/architect-planner/SKILL.md +539 -0
- package/.agent/skills/auto-mbti/SKILL.md +291 -0
- package/.agent/skills/autopilot/SKILL.md +222 -0
- package/.agent/skills/backend-patterns/SKILL.md +602 -0
- package/.agent/skills/bdd-generator/README.md +78 -0
- package/.agent/skills/bdd-generator/SKILL.md +436 -0
- package/.agent/skills/brainstorming/HOW_TO_USE.md +289 -0
- package/.agent/skills/brainstorming/README.md +41 -0
- package/.agent/skills/brainstorming/SKILL.md +165 -0
- package/.agent/skills/build-fix/SKILL.md +190 -0
- package/.agent/skills/cancel/SKILL.md +658 -0
- package/.agent/skills/checkpoint/SKILL.md +94 -0
- package/.agent/skills/code-review/SKILL.md +273 -0
- package/.agent/skills/coding-standards/SKILL.md +535 -0
- package/.agent/skills/conductor/SKILL.md +128 -0
- package/.agent/skills/conductor/commands/conductor/implement.toml +358 -0
- package/.agent/skills/conductor/commands/conductor/newTrack.toml +142 -0
- package/.agent/skills/conductor/commands/conductor/revert.toml +123 -0
- package/.agent/skills/conductor/commands/conductor/setup.toml +429 -0
- package/.agent/skills/conductor/commands/conductor/status.toml +57 -0
- package/.agent/skills/conductor/scripts/install.sh +89 -0
- package/.agent/skills/conductor/templates/code_styleguides/csharp.md +115 -0
- package/.agent/skills/conductor/templates/code_styleguides/dart.md +238 -0
- package/.agent/skills/conductor/templates/code_styleguides/general.md +23 -0
- package/.agent/skills/conductor/templates/code_styleguides/go.md +48 -0
- package/.agent/skills/conductor/templates/code_styleguides/html-css.md +49 -0
- package/.agent/skills/conductor/templates/code_styleguides/javascript.md +51 -0
- package/.agent/skills/conductor/templates/code_styleguides/python.md +37 -0
- package/.agent/skills/conductor/templates/code_styleguides/typescript.md +43 -0
- package/.agent/skills/conductor/templates/rules/README.md +23 -0
- package/.agent/skills/conductor/templates/rules/agents.md +49 -0
- package/.agent/skills/conductor/templates/rules/coding-style.md +70 -0
- package/.agent/skills/conductor/templates/rules/dev.md +20 -0
- package/.agent/skills/conductor/templates/rules/git-workflow.md +45 -0
- package/.agent/skills/conductor/templates/rules/hooks.md +6 -0
- package/.agent/skills/conductor/templates/rules/patterns.md +55 -0
- package/.agent/skills/conductor/templates/rules/performance.md +47 -0
- package/.agent/skills/conductor/templates/rules/research.md +26 -0
- package/.agent/skills/conductor/templates/rules/review.md +22 -0
- package/.agent/skills/conductor/templates/rules/security.md +36 -0
- package/.agent/skills/conductor/templates/rules/testing.md +30 -0
- package/.agent/skills/conductor/templates/workflow.md +333 -0
- package/.agent/skills/consensus/HOW_TO_USE.md +191 -0
- package/.agent/skills/consensus/README.md +41 -0
- package/.agent/skills/consensus/SKILL.md +317 -0
- package/.agent/skills/content-research-writer/SKILL.md +537 -0
- package/.agent/skills/debug-analysis/SKILL.md +331 -0
- package/.agent/skills/deepinit/SKILL.md +347 -0
- package/.agent/skills/deepsearch/SKILL.md +56 -0
- package/.agent/skills/doctor/SKILL.md +158 -0
- package/.agent/skills/drawio/EXAMPLES.md +382 -0
- package/.agent/skills/drawio/QUICK_START.md +237 -0
- package/.agent/skills/drawio/README.md +315 -0
- package/.agent/skills/drawio/SETUP_GUIDE.md +254 -0
- package/.agent/skills/drawio/SKILL.md +1176 -0
- package/.agent/skills/e2e/SKILL.md +396 -0
- package/.agent/skills/ecomode/SKILL.md +160 -0
- package/.agent/skills/electron-driver/SKILL.md +144 -0
- package/.agent/skills/electron-driver/scripts/driver-template.js +71 -0
- package/.agent/skills/eval/SKILL.md +140 -0
- package/.agent/skills/eval-harness/SKILL.md +242 -0
- package/.agent/skills/evolve/SKILL.md +213 -0
- package/.agent/skills/frontend-design/SKILL.md +42 -0
- package/.agent/skills/frontend-patterns/SKILL.md +646 -0
- package/.agent/skills/frontend-ui-ux/SKILL.md +70 -0
- package/.agent/skills/git-master/SKILL.md +75 -0
- package/.agent/skills/help/SKILL.md +89 -0
- package/.agent/skills/iterative-retrieval/SKILL.md +217 -0
- package/.agent/skills/local-skills-setup/SKILL.md +483 -0
- package/.agent/skills/log-analyzer/SKILL.md +187 -0
- package/.agent/skills/mcp-setup/SKILL.md +226 -0
- package/.agent/skills/multi-model-research/HOW_TO_USE.md +614 -0
- package/.agent/skills/multi-model-research/README.md +233 -0
- package/.agent/skills/multi-model-research/SKILL.md +541 -0
- package/.agent/skills/multi-model-research/references/troubleshooting.md +415 -0
- package/.agent/skills/note/SKILL.md +80 -0
- package/.agent/skills/omc-setup/SKILL.md +219 -0
- package/.agent/skills/orchestrate/SKILL.md +620 -0
- package/.agent/skills/patent-workflow/IMPLEMENTATION_SUMMARY.md +500 -0
- package/.agent/skills/patent-workflow/README.md +455 -0
- package/.agent/skills/patent-workflow/SKILL.md +1036 -0
- package/.agent/skills/patent-workflow/tools/irr_checker.py +260 -0
- package/.agent/skills/patent-workflow/tools/sample_terminology.json +49 -0
- package/.agent/skills/patent-workflow/tools/term_checker.py +355 -0
- package/.agent/skills/pattern-recognition/SKILL.md +792 -0
- package/.agent/skills/pipeline/SKILL.md +448 -0
- package/.agent/skills/plan/SKILL.md +309 -0
- package/.agent/skills/planning-methodology/SKILL.md +370 -0
- package/.agent/skills/planning-with-files/SKILL.md +210 -0
- package/.agent/skills/planning-with-files/examples.md +202 -0
- package/.agent/skills/planning-with-files/reference.md +218 -0
- package/.agent/skills/planning-with-files/scripts/check-complete.ps1 +42 -0
- package/.agent/skills/planning-with-files/scripts/check-complete.sh +44 -0
- package/.agent/skills/planning-with-files/scripts/init-session.ps1 +120 -0
- package/.agent/skills/planning-with-files/scripts/init-session.sh +120 -0
- package/.agent/skills/planning-with-files/scripts/session-catchup.py +208 -0
- package/.agent/skills/planning-with-files/templates/findings.md +95 -0
- package/.agent/skills/planning-with-files/templates/progress.md +114 -0
- package/.agent/skills/planning-with-files/templates/task_plan.md +132 -0
- package/.agent/skills/project-analyze/CLAUDE.md +18 -0
- package/.agent/skills/project-analyze/HOW_TO_USE.md +145 -0
- package/.agent/skills/project-analyze/README.md +42 -0
- package/.agent/skills/project-analyze/SKILL.md +289 -0
- package/.agent/skills/project-analyze/SKILL.md.backup +287 -0
- package/.agent/skills/project-analyze/SKILL.md.backup_20260105_093646 +287 -0
- package/.agent/skills/project-analyze/assets/analysis-report-template.md +433 -0
- package/.agent/skills/project-analyze/references/analysis-patterns.md +422 -0
- package/.agent/skills/project-analyze/references/projectmind-explained.md +535 -0
- package/.agent/skills/project-session-manager/SKILL.md +428 -0
- package/.agent/skills/project-session-manager/lib/config.sh +86 -0
- package/.agent/skills/project-session-manager/lib/parse.sh +121 -0
- package/.agent/skills/project-session-manager/lib/session.sh +132 -0
- package/.agent/skills/project-session-manager/lib/tmux.sh +103 -0
- package/.agent/skills/project-session-manager/lib/worktree.sh +171 -0
- package/.agent/skills/project-session-manager/psm.sh +629 -0
- package/.agent/skills/project-session-manager/templates/feature.md +56 -0
- package/.agent/skills/project-session-manager/templates/issue-fix.md +57 -0
- package/.agent/skills/project-session-manager/templates/pr-review.md +65 -0
- package/.agent/skills/project-session-manager/templates/projects.json +19 -0
- package/.agent/skills/quality-check/HOW_TO_USE.md +171 -0
- package/.agent/skills/quality-check/README.md +50 -0
- package/.agent/skills/quality-check/SKILL.md +240 -0
- package/.agent/skills/quality-check/SKILL.md.backup +238 -0
- package/.agent/skills/quality-check/SKILL.md.backup_20260105_093646 +238 -0
- package/.agent/skills/quality-check/assets/quality-report-template.md +437 -0
- package/.agent/skills/quality-check/references/refactoring-patterns.md +550 -0
- package/.agent/skills/quality-check/references/scoring-criteria.md +454 -0
- package/.agent/skills/quality-validation/SKILL.md +519 -0
- package/.agent/skills/quality-validation/SKILL.md.backup +573 -0
- package/.agent/skills/quality-validation/SKILL.md.backup_20260105_093646 +573 -0
- package/.agent/skills/ralph/SKILL.md +236 -0
- package/.agent/skills/ralph-init/SKILL.md +78 -0
- package/.agent/skills/ralplan/SKILL.md +58 -0
- package/.agent/skills/refactor-clean/SKILL.md +49 -0
- package/.agent/skills/release/SKILL.md +84 -0
- package/.agent/skills/research/SKILL.md +526 -0
- package/.agent/skills/research-methodology/SKILL.md +268 -0
- package/.agent/skills/review/SKILL.md +53 -0
- package/.agent/skills/security-review/SKILL.md +509 -0
- package/.agent/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/.agent/skills/setup-pm/SKILL.md +102 -0
- package/.agent/skills/skill/SKILL.md +424 -0
- package/.agent/skills/skill-create/SKILL.md +209 -0
- package/.agent/skills/skill-debugger/HOW_TO_USE.md +244 -0
- package/.agent/skills/skill-debugger/README.md +44 -0
- package/.agent/skills/skill-debugger/SKILL.md +326 -0
- package/.agent/skills/skill-debugger/diagnostic_checklist.md +115 -0
- package/.agent/skills/skill-development/SKILL.md +661 -0
- package/.agent/skills/skill-development/references/skill-creator-original.md +209 -0
- package/.agent/skills/skill-doc-generator/README.md +37 -0
- package/.agent/skills/skill-doc-generator/SKILL.md +331 -0
- package/.agent/skills/skill-quality-analyzer/HOW_TO_USE.md +243 -0
- package/.agent/skills/skill-quality-analyzer/README.md +61 -0
- package/.agent/skills/skill-quality-analyzer/SKILL.md +247 -0
- package/.agent/skills/skill-quality-analyzer/analyzer.py +209 -0
- package/.agent/skills/skill-quality-analyzer/expected_output.json +81 -0
- package/.agent/skills/skill-quality-analyzer/sample_input.json +9 -0
- package/.agent/skills/skill-tester/README.md +46 -0
- package/.agent/skills/skill-tester/SKILL.md +345 -0
- package/.agent/skills/start-dev/SKILL.md +701 -0
- package/.agent/skills/swarm/SKILL.md +691 -0
- package/.agent/skills/task-kb-lookup/SKILL.md +211 -0
- package/.agent/skills/task-kb-record/SKILL.md +417 -0
- package/.agent/skills/tdd/SKILL.md +446 -0
- package/.agent/skills/tdd-generator/DEMO.md +516 -0
- package/.agent/skills/tdd-generator/README.md +89 -0
- package/.agent/skills/tdd-generator/SKILL.md +278 -0
- package/.agent/skills/tdd-workflow/SKILL.md +424 -0
- package/.agent/skills/test-coverage/SKILL.md +48 -0
- package/.agent/skills/thinkdeep/HOW_TO_USE.md +183 -0
- package/.agent/skills/thinkdeep/README.md +41 -0
- package/.agent/skills/thinkdeep/SKILL.md +343 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +228 -0
- package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/skills/ui-ux-pro-max/scripts/core.py +236 -0
- package/.agent/skills/ui-ux-pro-max/scripts/search.py +61 -0
- package/.agent/skills/ultrapilot/SKILL.md +647 -0
- package/.agent/skills/ultraqa/SKILL.md +152 -0
- package/.agent/skills/ultrawork/SKILL.md +123 -0
- package/.agent/skills/update-codemaps/SKILL.md +38 -0
- package/.agent/skills/update-docs/SKILL.md +52 -0
- package/.agent/skills/verification-loop/SKILL.md +140 -0
- package/.agent/skills/verify/SKILL.md +80 -0
- package/.agent/skills/writer-memory/SKILL.md +459 -0
- package/.agent/skills/writer-memory/lib/character-tracker.ts +338 -0
- package/.agent/skills/writer-memory/lib/memory-manager.ts +804 -0
- package/.agent/skills/writer-memory/lib/relationship-graph.ts +400 -0
- package/.agent/skills/writer-memory/lib/scene-organizer.ts +544 -0
- package/.agent/skills/writer-memory/lib/synopsis-builder.ts +339 -0
- package/.agent/skills/writer-memory/templates/synopsis-template.md +46 -0
- package/.governance/skill-lint.allowlist +4 -0
- package/.governance/skill-llm.allowlist +4 -0
- package/AGENTS.md +59 -0
- package/LICENSE +21 -0
- package/README.md +169 -0
- package/README.zh.md +145 -0
- package/bin/omcodex.js +8 -0
- package/commands/conductor/implement.toml +358 -0
- package/commands/conductor/newTrack.toml +142 -0
- package/commands/conductor/revert.toml +123 -0
- package/commands/conductor/setup.toml +429 -0
- package/commands/conductor/status.toml +57 -0
- package/docs/ALIGNMENT.md +40 -0
- package/docs/CODEX.md +133 -0
- package/docs/NOTIFY.md +81 -0
- package/docs/SKILL_GOVERNANCE.md +72 -0
- package/docs/SKILL_GOVERNANCE_FRAMEWORK.md +182 -0
- package/docs/SKILL_GOVERNANCE_FRAMEWORK.zh.md +170 -0
- package/package.json +50 -0
- package/prompts/architect.md +105 -0
- package/prompts/executor.md +134 -0
- package/prompts/planner.md +113 -0
- package/scripts/check-skill-governance.sh +84 -0
- package/scripts/check-skill-llm-governance.js +302 -0
- package/scripts/eval-skills.js +217 -0
- package/scripts/generate-catalog-docs.js +95 -0
- package/scripts/generate-codex-mcp-config.sh +22 -0
- package/scripts/install-codex-force.sh +5 -0
- package/scripts/install-codex-incremental.sh +5 -0
- package/scripts/install-codex.sh +79 -0
- package/scripts/notify-dispatch.js +15 -0
- package/scripts/setup-package-manager.js +137 -0
- package/src/catalog/generated/public-catalog.json +547 -0
- package/src/catalog/manifest.json +542 -0
- package/src/catalog/reader.js +43 -0
- package/src/catalog/schema.js +79 -0
- package/src/cli/doctor.js +62 -0
- package/src/cli/index.js +85 -0
- package/src/cli/notify.js +127 -0
- package/src/cli/route.js +43 -0
- package/src/cli/setup.js +155 -0
- package/src/cli/team.js +125 -0
- package/src/config/generator.js +119 -0
- package/src/mcp/memory-server.js +241 -0
- package/src/mcp/state-server.js +112 -0
- package/src/mcp/trace-server.js +168 -0
- package/src/notify/dispatch.js +74 -0
- package/src/notify/extensibility/dispatcher.js +113 -0
- package/src/notify/extensibility/events.js +15 -0
- package/src/notify/extensibility/loader.js +54 -0
- package/src/router/skill-router.js +90 -0
- package/src/team/auto-advance.js +72 -0
- package/src/team/orchestrator.js +82 -0
- package/src/team/state-store.js +33 -0
- package/src/utils/paths.js +33 -0
- package/templates/AGENTS.md +15 -0
- package/templates/catalog-manifest.json +542 -0
- package/templates/code_styleguides/csharp.md +115 -0
- package/templates/code_styleguides/dart.md +238 -0
- package/templates/code_styleguides/general.md +23 -0
- package/templates/code_styleguides/go.md +48 -0
- package/templates/code_styleguides/html-css.md +49 -0
- package/templates/code_styleguides/javascript.md +51 -0
- package/templates/code_styleguides/python.md +37 -0
- package/templates/code_styleguides/typescript.md +43 -0
- package/templates/rules/README.md +23 -0
- package/templates/rules/agents.md +49 -0
- package/templates/rules/coding-style.md +70 -0
- package/templates/rules/dev.md +20 -0
- package/templates/rules/git-workflow.md +45 -0
- package/templates/rules/notify.md +6 -0
- package/templates/rules/patterns.md +55 -0
- package/templates/rules/performance.md +47 -0
- package/templates/rules/research.md +26 -0
- package/templates/rules/review.md +22 -0
- package/templates/rules/security.md +36 -0
- package/templates/rules/testing.md +30 -0
- package/templates/workflow.md +333 -0
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-patterns
|
|
3
|
+
description: Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Backend Development Patterns
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Native Subagent Protocol (Codex)
|
|
10
|
+
|
|
11
|
+
Codex supports native subagents. Delegate with `spawn_agent`, coordinate with `send_input`, collect via `wait`, and clean up with `close_agent`.
|
|
12
|
+
|
|
13
|
+
Execution preference:
|
|
14
|
+
1. Use native subagents first for independent workstreams (parallel when possible).
|
|
15
|
+
2. Merge results in main thread and run final verification.
|
|
16
|
+
3. Fallback only when delegation is blocked: use the `[ANALYST]`/`[ARCHITECT]`/`[EXECUTOR]`/`[REVIEWER]` structure in a single response.
|
|
17
|
+
|
|
18
|
+
Minimal orchestration pattern:
|
|
19
|
+
```text
|
|
20
|
+
spawn_agent -> send_input (optional) -> wait -> close_agent
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Backend architecture patterns and best practices for scalable server-side applications.
|
|
24
|
+
|
|
25
|
+
## API Design Patterns
|
|
26
|
+
|
|
27
|
+
### RESTful API Structure
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// ✅ Resource-based URLs
|
|
31
|
+
GET /api/markets # List resources
|
|
32
|
+
GET /api/markets/:id # Get single resource
|
|
33
|
+
POST /api/markets # Create resource
|
|
34
|
+
PUT /api/markets/:id # Replace resource
|
|
35
|
+
PATCH /api/markets/:id # Update resource
|
|
36
|
+
DELETE /api/markets/:id # Delete resource
|
|
37
|
+
|
|
38
|
+
// ✅ Query parameters for filtering, sorting, pagination
|
|
39
|
+
GET /api/markets?status=active&sort=volume&limit=20&offset=0
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Repository Pattern
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Abstract data access logic
|
|
46
|
+
interface MarketRepository {
|
|
47
|
+
findAll(filters?: MarketFilters): Promise<Market[]>
|
|
48
|
+
findById(id: string): Promise<Market | null>
|
|
49
|
+
create(data: CreateMarketDto): Promise<Market>
|
|
50
|
+
update(id: string, data: UpdateMarketDto): Promise<Market>
|
|
51
|
+
delete(id: string): Promise<void>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class SupabaseMarketRepository implements MarketRepository {
|
|
55
|
+
async findAll(filters?: MarketFilters): Promise<Market[]> {
|
|
56
|
+
let query = supabase.from('markets').select('*')
|
|
57
|
+
|
|
58
|
+
if (filters?.status) {
|
|
59
|
+
query = query.eq('status', filters.status)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (filters?.limit) {
|
|
63
|
+
query = query.limit(filters.limit)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { data, error } = await query
|
|
67
|
+
|
|
68
|
+
if (error) throw new Error(error.message)
|
|
69
|
+
return data
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Other methods...
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Service Layer Pattern
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Business logic separated from data access
|
|
80
|
+
class MarketService {
|
|
81
|
+
constructor(private marketRepo: MarketRepository) {}
|
|
82
|
+
|
|
83
|
+
async searchMarkets(query: string, limit: number = 10): Promise<Market[]> {
|
|
84
|
+
// Business logic
|
|
85
|
+
const embedding = await generateEmbedding(query)
|
|
86
|
+
const results = await this.vectorSearch(embedding, limit)
|
|
87
|
+
|
|
88
|
+
// Fetch full data
|
|
89
|
+
const markets = await this.marketRepo.findByIds(results.map(r => r.id))
|
|
90
|
+
|
|
91
|
+
// Sort by similarity
|
|
92
|
+
return markets.sort((a, b) => {
|
|
93
|
+
const scoreA = results.find(r => r.id === a.id)?.score || 0
|
|
94
|
+
const scoreB = results.find(r => r.id === b.id)?.score || 0
|
|
95
|
+
return scoreA - scoreB
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private async vectorSearch(embedding: number[], limit: number) {
|
|
100
|
+
// Vector search implementation
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Middleware Pattern
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Request/response processing pipeline
|
|
109
|
+
export function withAuth(handler: NextApiHandler): NextApiHandler {
|
|
110
|
+
return async (req, res) => {
|
|
111
|
+
const token = req.headers.authorization?.replace('Bearer ', '')
|
|
112
|
+
|
|
113
|
+
if (!token) {
|
|
114
|
+
return res.status(401).json({ error: 'Unauthorized' })
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const user = await verifyToken(token)
|
|
119
|
+
req.user = user
|
|
120
|
+
return handler(req, res)
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return res.status(401).json({ error: 'Invalid token' })
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Usage
|
|
128
|
+
export default withAuth(async (req, res) => {
|
|
129
|
+
// Handler has access to req.user
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Database Patterns
|
|
134
|
+
|
|
135
|
+
### Query Optimization
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
// ✅ GOOD: Select only needed columns
|
|
139
|
+
const { data } = await supabase
|
|
140
|
+
.from('markets')
|
|
141
|
+
.select('id, name, status, volume')
|
|
142
|
+
.eq('status', 'active')
|
|
143
|
+
.order('volume', { ascending: false })
|
|
144
|
+
.limit(10)
|
|
145
|
+
|
|
146
|
+
// ❌ BAD: Select everything
|
|
147
|
+
const { data } = await supabase
|
|
148
|
+
.from('markets')
|
|
149
|
+
.select('*')
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### N+1 Query Prevention
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// ❌ BAD: N+1 query problem
|
|
156
|
+
const markets = await getMarkets()
|
|
157
|
+
for (const market of markets) {
|
|
158
|
+
market.creator = await getUser(market.creator_id) // N queries
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ✅ GOOD: Batch fetch
|
|
162
|
+
const markets = await getMarkets()
|
|
163
|
+
const creatorIds = markets.map(m => m.creator_id)
|
|
164
|
+
const creators = await getUsers(creatorIds) // 1 query
|
|
165
|
+
const creatorMap = new Map(creators.map(c => [c.id, c]))
|
|
166
|
+
|
|
167
|
+
markets.forEach(market => {
|
|
168
|
+
market.creator = creatorMap.get(market.creator_id)
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Transaction Pattern
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
async function createMarketWithPosition(
|
|
176
|
+
marketData: CreateMarketDto,
|
|
177
|
+
positionData: CreatePositionDto
|
|
178
|
+
) {
|
|
179
|
+
// Use Supabase transaction
|
|
180
|
+
const { data, error } = await supabase.rpc('create_market_with_position', {
|
|
181
|
+
market_data: marketData,
|
|
182
|
+
position_data: positionData
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
if (error) throw new Error('Transaction failed')
|
|
186
|
+
return data
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// SQL function in Supabase
|
|
190
|
+
CREATE OR REPLACE FUNCTION create_market_with_position(
|
|
191
|
+
market_data jsonb,
|
|
192
|
+
position_data jsonb
|
|
193
|
+
)
|
|
194
|
+
RETURNS jsonb
|
|
195
|
+
LANGUAGE plpgsql
|
|
196
|
+
AS $$
|
|
197
|
+
BEGIN
|
|
198
|
+
-- Start transaction automatically
|
|
199
|
+
INSERT INTO markets VALUES (market_data);
|
|
200
|
+
INSERT INTO positions VALUES (position_data);
|
|
201
|
+
RETURN jsonb_build_object('success', true);
|
|
202
|
+
EXCEPTION
|
|
203
|
+
WHEN OTHERS THEN
|
|
204
|
+
-- Rollback happens automatically
|
|
205
|
+
RETURN jsonb_build_object('success', false, 'error', SQLERRM);
|
|
206
|
+
END;
|
|
207
|
+
$$;
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Caching Strategies
|
|
211
|
+
|
|
212
|
+
### Redis Caching Layer
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
class CachedMarketRepository implements MarketRepository {
|
|
216
|
+
constructor(
|
|
217
|
+
private baseRepo: MarketRepository,
|
|
218
|
+
private redis: RedisClient
|
|
219
|
+
) {}
|
|
220
|
+
|
|
221
|
+
async findById(id: string): Promise<Market | null> {
|
|
222
|
+
// Check cache first
|
|
223
|
+
const cached = await this.redis.get(`market:${id}`)
|
|
224
|
+
|
|
225
|
+
if (cached) {
|
|
226
|
+
return JSON.parse(cached)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Cache miss - fetch from database
|
|
230
|
+
const market = await this.baseRepo.findById(id)
|
|
231
|
+
|
|
232
|
+
if (market) {
|
|
233
|
+
// Cache for 5 minutes
|
|
234
|
+
await this.redis.setex(`market:${id}`, 300, JSON.stringify(market))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return market
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async invalidateCache(id: string): Promise<void> {
|
|
241
|
+
await this.redis.del(`market:${id}`)
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Cache-Aside Pattern
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
async function getMarketWithCache(id: string): Promise<Market> {
|
|
250
|
+
const cacheKey = `market:${id}`
|
|
251
|
+
|
|
252
|
+
// Try cache
|
|
253
|
+
const cached = await redis.get(cacheKey)
|
|
254
|
+
if (cached) return JSON.parse(cached)
|
|
255
|
+
|
|
256
|
+
// Cache miss - fetch from DB
|
|
257
|
+
const market = await db.markets.findUnique({ where: { id } })
|
|
258
|
+
|
|
259
|
+
if (!market) throw new Error('Market not found')
|
|
260
|
+
|
|
261
|
+
// Update cache
|
|
262
|
+
await redis.setex(cacheKey, 300, JSON.stringify(market))
|
|
263
|
+
|
|
264
|
+
return market
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Error Handling Patterns
|
|
269
|
+
|
|
270
|
+
### Centralized Error Handler
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
class ApiError extends Error {
|
|
274
|
+
constructor(
|
|
275
|
+
public statusCode: number,
|
|
276
|
+
public message: string,
|
|
277
|
+
public isOperational = true
|
|
278
|
+
) {
|
|
279
|
+
super(message)
|
|
280
|
+
Object.setPrototypeOf(this, ApiError.prototype)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function errorHandler(error: unknown, req: Request): Response {
|
|
285
|
+
if (error instanceof ApiError) {
|
|
286
|
+
return NextResponse.json({
|
|
287
|
+
success: false,
|
|
288
|
+
error: error.message
|
|
289
|
+
}, { status: error.statusCode })
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (error instanceof z.ZodError) {
|
|
293
|
+
return NextResponse.json({
|
|
294
|
+
success: false,
|
|
295
|
+
error: 'Validation failed',
|
|
296
|
+
details: error.errors
|
|
297
|
+
}, { status: 400 })
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Log unexpected errors
|
|
301
|
+
console.error('Unexpected error:', error)
|
|
302
|
+
|
|
303
|
+
return NextResponse.json({
|
|
304
|
+
success: false,
|
|
305
|
+
error: 'Internal server error'
|
|
306
|
+
}, { status: 500 })
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Usage
|
|
310
|
+
export async function GET(request: Request) {
|
|
311
|
+
try {
|
|
312
|
+
const data = await fetchData()
|
|
313
|
+
return NextResponse.json({ success: true, data })
|
|
314
|
+
} catch (error) {
|
|
315
|
+
return errorHandler(error, request)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Retry with Exponential Backoff
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
async function fetchWithRetry<T>(
|
|
324
|
+
fn: () => Promise<T>,
|
|
325
|
+
maxRetries = 3
|
|
326
|
+
): Promise<T> {
|
|
327
|
+
let lastError: Error
|
|
328
|
+
|
|
329
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
330
|
+
try {
|
|
331
|
+
return await fn()
|
|
332
|
+
} catch (error) {
|
|
333
|
+
lastError = error as Error
|
|
334
|
+
|
|
335
|
+
if (i < maxRetries - 1) {
|
|
336
|
+
// Exponential backoff: 1s, 2s, 4s
|
|
337
|
+
const delay = Math.pow(2, i) * 1000
|
|
338
|
+
await new Promise(resolve => setTimeout(resolve, delay))
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
throw lastError!
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Usage
|
|
347
|
+
const data = await fetchWithRetry(() => fetchFromAPI())
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Authentication & Authorization
|
|
351
|
+
|
|
352
|
+
### JWT Token Validation
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import jwt from 'jsonwebtoken'
|
|
356
|
+
|
|
357
|
+
interface JWTPayload {
|
|
358
|
+
userId: string
|
|
359
|
+
email: string
|
|
360
|
+
role: 'admin' | 'user'
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function verifyToken(token: string): JWTPayload {
|
|
364
|
+
try {
|
|
365
|
+
const payload = jwt.verify(token, process.env.JWT_SECRET!) as JWTPayload
|
|
366
|
+
return payload
|
|
367
|
+
} catch (error) {
|
|
368
|
+
throw new ApiError(401, 'Invalid token')
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export async function requireAuth(request: Request) {
|
|
373
|
+
const token = request.headers.get('authorization')?.replace('Bearer ', '')
|
|
374
|
+
|
|
375
|
+
if (!token) {
|
|
376
|
+
throw new ApiError(401, 'Missing authorization token')
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return verifyToken(token)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Usage in API route
|
|
383
|
+
export async function GET(request: Request) {
|
|
384
|
+
const user = await requireAuth(request)
|
|
385
|
+
|
|
386
|
+
const data = await getDataForUser(user.userId)
|
|
387
|
+
|
|
388
|
+
return NextResponse.json({ success: true, data })
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Role-Based Access Control
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
type Permission = 'read' | 'write' | 'delete' | 'admin'
|
|
396
|
+
|
|
397
|
+
interface User {
|
|
398
|
+
id: string
|
|
399
|
+
role: 'admin' | 'moderator' | 'user'
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const rolePermissions: Record<User['role'], Permission[]> = {
|
|
403
|
+
admin: ['read', 'write', 'delete', 'admin'],
|
|
404
|
+
moderator: ['read', 'write', 'delete'],
|
|
405
|
+
user: ['read', 'write']
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export function hasPermission(user: User, permission: Permission): boolean {
|
|
409
|
+
return rolePermissions[user.role].includes(permission)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export function requirePermission(permission: Permission) {
|
|
413
|
+
return (handler: (request: Request, user: User) => Promise<Response>) => {
|
|
414
|
+
return async (request: Request) => {
|
|
415
|
+
const user = await requireAuth(request)
|
|
416
|
+
|
|
417
|
+
if (!hasPermission(user, permission)) {
|
|
418
|
+
throw new ApiError(403, 'Insufficient permissions')
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return handler(request, user)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Usage - HOF wraps the handler
|
|
427
|
+
export const DELETE = requirePermission('delete')(
|
|
428
|
+
async (request: Request, user: User) => {
|
|
429
|
+
// Handler receives authenticated user with verified permission
|
|
430
|
+
return new Response('Deleted', { status: 200 })
|
|
431
|
+
}
|
|
432
|
+
)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## Rate Limiting
|
|
436
|
+
|
|
437
|
+
### Simple In-Memory Rate Limiter
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
class RateLimiter {
|
|
441
|
+
private requests = new Map<string, number[]>()
|
|
442
|
+
|
|
443
|
+
async checkLimit(
|
|
444
|
+
identifier: string,
|
|
445
|
+
maxRequests: number,
|
|
446
|
+
windowMs: number
|
|
447
|
+
): Promise<boolean> {
|
|
448
|
+
const now = Date.now()
|
|
449
|
+
const requests = this.requests.get(identifier) || []
|
|
450
|
+
|
|
451
|
+
// Remove old requests outside window
|
|
452
|
+
const recentRequests = requests.filter(time => now - time < windowMs)
|
|
453
|
+
|
|
454
|
+
if (recentRequests.length >= maxRequests) {
|
|
455
|
+
return false // Rate limit exceeded
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Add current request
|
|
459
|
+
recentRequests.push(now)
|
|
460
|
+
this.requests.set(identifier, recentRequests)
|
|
461
|
+
|
|
462
|
+
return true
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const limiter = new RateLimiter()
|
|
467
|
+
|
|
468
|
+
export async function GET(request: Request) {
|
|
469
|
+
const ip = request.headers.get('x-forwarded-for') || 'unknown'
|
|
470
|
+
|
|
471
|
+
const allowed = await limiter.checkLimit(ip, 100, 60000) // 100 req/min
|
|
472
|
+
|
|
473
|
+
if (!allowed) {
|
|
474
|
+
return NextResponse.json({
|
|
475
|
+
error: 'Rate limit exceeded'
|
|
476
|
+
}, { status: 429 })
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Continue with request
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## Background Jobs & Queues
|
|
484
|
+
|
|
485
|
+
### Simple Queue Pattern
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
class JobQueue<T> {
|
|
489
|
+
private queue: T[] = []
|
|
490
|
+
private processing = false
|
|
491
|
+
|
|
492
|
+
async add(job: T): Promise<void> {
|
|
493
|
+
this.queue.push(job)
|
|
494
|
+
|
|
495
|
+
if (!this.processing) {
|
|
496
|
+
this.process()
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
private async process(): Promise<void> {
|
|
501
|
+
this.processing = true
|
|
502
|
+
|
|
503
|
+
while (this.queue.length > 0) {
|
|
504
|
+
const job = this.queue.shift()!
|
|
505
|
+
|
|
506
|
+
try {
|
|
507
|
+
await this.execute(job)
|
|
508
|
+
} catch (error) {
|
|
509
|
+
console.error('Job failed:', error)
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
this.processing = false
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
private async execute(job: T): Promise<void> {
|
|
517
|
+
// Job execution logic
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Usage for indexing markets
|
|
522
|
+
interface IndexJob {
|
|
523
|
+
marketId: string
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const indexQueue = new JobQueue<IndexJob>()
|
|
527
|
+
|
|
528
|
+
export async function POST(request: Request) {
|
|
529
|
+
const { marketId } = await request.json()
|
|
530
|
+
|
|
531
|
+
// Add to queue instead of blocking
|
|
532
|
+
await indexQueue.add({ marketId })
|
|
533
|
+
|
|
534
|
+
return NextResponse.json({ success: true, message: 'Job queued' })
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
## Logging & Monitoring
|
|
539
|
+
|
|
540
|
+
### Structured Logging
|
|
541
|
+
|
|
542
|
+
```typescript
|
|
543
|
+
interface LogContext {
|
|
544
|
+
userId?: string
|
|
545
|
+
requestId?: string
|
|
546
|
+
method?: string
|
|
547
|
+
path?: string
|
|
548
|
+
[key: string]: unknown
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
class Logger {
|
|
552
|
+
log(level: 'info' | 'warn' | 'error', message: string, context?: LogContext) {
|
|
553
|
+
const entry = {
|
|
554
|
+
timestamp: new Date().toISOString(),
|
|
555
|
+
level,
|
|
556
|
+
message,
|
|
557
|
+
...context
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
console.log(JSON.stringify(entry))
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
info(message: string, context?: LogContext) {
|
|
564
|
+
this.log('info', message, context)
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
warn(message: string, context?: LogContext) {
|
|
568
|
+
this.log('warn', message, context)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
error(message: string, error: Error, context?: LogContext) {
|
|
572
|
+
this.log('error', message, {
|
|
573
|
+
...context,
|
|
574
|
+
error: error.message,
|
|
575
|
+
stack: error.stack
|
|
576
|
+
})
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
const logger = new Logger()
|
|
581
|
+
|
|
582
|
+
// Usage
|
|
583
|
+
export async function GET(request: Request) {
|
|
584
|
+
const requestId = crypto.randomUUID()
|
|
585
|
+
|
|
586
|
+
logger.info('Fetching markets', {
|
|
587
|
+
requestId,
|
|
588
|
+
method: 'GET',
|
|
589
|
+
path: '/api/markets'
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
try {
|
|
593
|
+
const markets = await fetchMarkets()
|
|
594
|
+
return NextResponse.json({ success: true, data: markets })
|
|
595
|
+
} catch (error) {
|
|
596
|
+
logger.error('Failed to fetch markets', error as Error, { requestId })
|
|
597
|
+
return NextResponse.json({ error: 'Internal error' }, { status: 500 })
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**Remember**: Backend patterns enable scalable, maintainable server-side applications. Choose patterns that fit your complexity level.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# BDD Generator Skill
|
|
2
|
+
|
|
3
|
+
**Behavior-Driven Development** assistant using **playwright-bdd**.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
触发词:
|
|
8
|
+
- "BDD", "生成BDD测试"
|
|
9
|
+
- "Given-When-Then", "Gherkin"
|
|
10
|
+
- "playwright-bdd", "feature file"
|
|
11
|
+
|
|
12
|
+
## 核心功能
|
|
13
|
+
|
|
14
|
+
1. **Feature 文件生成** - Gherkin 语法
|
|
15
|
+
2. **Step Definitions 脚手架** - TypeScript 实现
|
|
16
|
+
3. **TDD Guard 集成** - 强制 RED-GREEN-REFACTOR
|
|
17
|
+
4. **playwright-bdd 配置** - 零额外 runner
|
|
18
|
+
|
|
19
|
+
## 为什么选择 playwright-bdd?
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
优势:
|
|
23
|
+
✅ 比 Cucumber.js 快 30-50%
|
|
24
|
+
✅ 无需额外 runner
|
|
25
|
+
✅ 原生 Playwright 集成
|
|
26
|
+
✅ 更好的调试体验
|
|
27
|
+
✅ 活跃维护(2025年)
|
|
28
|
+
|
|
29
|
+
避免:
|
|
30
|
+
❌ Cucumber.js 的复杂配置
|
|
31
|
+
❌ 两层抽象的性能损耗
|
|
32
|
+
❌ 调试困难
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 使用示例
|
|
36
|
+
|
|
37
|
+
### 生成 Feature 文件
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
User: "Create BDD test for user login"
|
|
41
|
+
|
|
42
|
+
Claude: [生成单个 scenario 的 feature 文件]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 实现 Step Definitions
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
User: "Implement the steps"
|
|
49
|
+
|
|
50
|
+
Claude: [遵循 TDD Guard,一步一步实现]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 项目配置
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
User: "Setup BDD in my project"
|
|
57
|
+
|
|
58
|
+
Claude: [完整配置指导]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 与 TDD Guard 配合
|
|
62
|
+
|
|
63
|
+
- ✅ 一次只写一个 Scenario
|
|
64
|
+
- ✅ 一次只实现一个 Step
|
|
65
|
+
- ✅ 强制 RED-GREEN-REFACTOR 循环
|
|
66
|
+
- ✅ 防止过度设计
|
|
67
|
+
|
|
68
|
+
## 相关文档
|
|
69
|
+
|
|
70
|
+
- 完整技能定义:`SKILL.md`
|
|
71
|
+
- 使用演示:`DEMO.md`(待创建)
|
|
72
|
+
- 示例项目:`~/playwright-bdd-demo/`
|
|
73
|
+
|
|
74
|
+
## 集成其他 Skills
|
|
75
|
+
|
|
76
|
+
- **tdd-generator**: 单元测试
|
|
77
|
+
- **agent-kb**: BDD 最佳实践
|
|
78
|
+
- **quality-check**: 特性覆盖率分析
|