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.
Files changed (292) hide show
  1. package/.agent/skills/agent-kb/HOW_TO_USE.md +428 -0
  2. package/.agent/skills/agent-kb/README.md +46 -0
  3. package/.agent/skills/agent-kb/SKILL.md +128 -0
  4. package/.agent/skills/agent-kb/references/intelligent-analysis-explained.md +333 -0
  5. package/.agent/skills/agent-kb/references/query-optimization.md +225 -0
  6. package/.agent/skills/aireview/SKILL.md +704 -0
  7. package/.agent/skills/analyze/SKILL.md +81 -0
  8. package/.agent/skills/architect-planner/HOW_TO_USE.md +238 -0
  9. package/.agent/skills/architect-planner/README.md +41 -0
  10. package/.agent/skills/architect-planner/SKILL.md +539 -0
  11. package/.agent/skills/auto-mbti/SKILL.md +291 -0
  12. package/.agent/skills/autopilot/SKILL.md +222 -0
  13. package/.agent/skills/backend-patterns/SKILL.md +602 -0
  14. package/.agent/skills/bdd-generator/README.md +78 -0
  15. package/.agent/skills/bdd-generator/SKILL.md +436 -0
  16. package/.agent/skills/brainstorming/HOW_TO_USE.md +289 -0
  17. package/.agent/skills/brainstorming/README.md +41 -0
  18. package/.agent/skills/brainstorming/SKILL.md +165 -0
  19. package/.agent/skills/build-fix/SKILL.md +190 -0
  20. package/.agent/skills/cancel/SKILL.md +658 -0
  21. package/.agent/skills/checkpoint/SKILL.md +94 -0
  22. package/.agent/skills/code-review/SKILL.md +273 -0
  23. package/.agent/skills/coding-standards/SKILL.md +535 -0
  24. package/.agent/skills/conductor/SKILL.md +128 -0
  25. package/.agent/skills/conductor/commands/conductor/implement.toml +358 -0
  26. package/.agent/skills/conductor/commands/conductor/newTrack.toml +142 -0
  27. package/.agent/skills/conductor/commands/conductor/revert.toml +123 -0
  28. package/.agent/skills/conductor/commands/conductor/setup.toml +429 -0
  29. package/.agent/skills/conductor/commands/conductor/status.toml +57 -0
  30. package/.agent/skills/conductor/scripts/install.sh +89 -0
  31. package/.agent/skills/conductor/templates/code_styleguides/csharp.md +115 -0
  32. package/.agent/skills/conductor/templates/code_styleguides/dart.md +238 -0
  33. package/.agent/skills/conductor/templates/code_styleguides/general.md +23 -0
  34. package/.agent/skills/conductor/templates/code_styleguides/go.md +48 -0
  35. package/.agent/skills/conductor/templates/code_styleguides/html-css.md +49 -0
  36. package/.agent/skills/conductor/templates/code_styleguides/javascript.md +51 -0
  37. package/.agent/skills/conductor/templates/code_styleguides/python.md +37 -0
  38. package/.agent/skills/conductor/templates/code_styleguides/typescript.md +43 -0
  39. package/.agent/skills/conductor/templates/rules/README.md +23 -0
  40. package/.agent/skills/conductor/templates/rules/agents.md +49 -0
  41. package/.agent/skills/conductor/templates/rules/coding-style.md +70 -0
  42. package/.agent/skills/conductor/templates/rules/dev.md +20 -0
  43. package/.agent/skills/conductor/templates/rules/git-workflow.md +45 -0
  44. package/.agent/skills/conductor/templates/rules/hooks.md +6 -0
  45. package/.agent/skills/conductor/templates/rules/patterns.md +55 -0
  46. package/.agent/skills/conductor/templates/rules/performance.md +47 -0
  47. package/.agent/skills/conductor/templates/rules/research.md +26 -0
  48. package/.agent/skills/conductor/templates/rules/review.md +22 -0
  49. package/.agent/skills/conductor/templates/rules/security.md +36 -0
  50. package/.agent/skills/conductor/templates/rules/testing.md +30 -0
  51. package/.agent/skills/conductor/templates/workflow.md +333 -0
  52. package/.agent/skills/consensus/HOW_TO_USE.md +191 -0
  53. package/.agent/skills/consensus/README.md +41 -0
  54. package/.agent/skills/consensus/SKILL.md +317 -0
  55. package/.agent/skills/content-research-writer/SKILL.md +537 -0
  56. package/.agent/skills/debug-analysis/SKILL.md +331 -0
  57. package/.agent/skills/deepinit/SKILL.md +347 -0
  58. package/.agent/skills/deepsearch/SKILL.md +56 -0
  59. package/.agent/skills/doctor/SKILL.md +158 -0
  60. package/.agent/skills/drawio/EXAMPLES.md +382 -0
  61. package/.agent/skills/drawio/QUICK_START.md +237 -0
  62. package/.agent/skills/drawio/README.md +315 -0
  63. package/.agent/skills/drawio/SETUP_GUIDE.md +254 -0
  64. package/.agent/skills/drawio/SKILL.md +1176 -0
  65. package/.agent/skills/e2e/SKILL.md +396 -0
  66. package/.agent/skills/ecomode/SKILL.md +160 -0
  67. package/.agent/skills/electron-driver/SKILL.md +144 -0
  68. package/.agent/skills/electron-driver/scripts/driver-template.js +71 -0
  69. package/.agent/skills/eval/SKILL.md +140 -0
  70. package/.agent/skills/eval-harness/SKILL.md +242 -0
  71. package/.agent/skills/evolve/SKILL.md +213 -0
  72. package/.agent/skills/frontend-design/SKILL.md +42 -0
  73. package/.agent/skills/frontend-patterns/SKILL.md +646 -0
  74. package/.agent/skills/frontend-ui-ux/SKILL.md +70 -0
  75. package/.agent/skills/git-master/SKILL.md +75 -0
  76. package/.agent/skills/help/SKILL.md +89 -0
  77. package/.agent/skills/iterative-retrieval/SKILL.md +217 -0
  78. package/.agent/skills/local-skills-setup/SKILL.md +483 -0
  79. package/.agent/skills/log-analyzer/SKILL.md +187 -0
  80. package/.agent/skills/mcp-setup/SKILL.md +226 -0
  81. package/.agent/skills/multi-model-research/HOW_TO_USE.md +614 -0
  82. package/.agent/skills/multi-model-research/README.md +233 -0
  83. package/.agent/skills/multi-model-research/SKILL.md +541 -0
  84. package/.agent/skills/multi-model-research/references/troubleshooting.md +415 -0
  85. package/.agent/skills/note/SKILL.md +80 -0
  86. package/.agent/skills/omc-setup/SKILL.md +219 -0
  87. package/.agent/skills/orchestrate/SKILL.md +620 -0
  88. package/.agent/skills/patent-workflow/IMPLEMENTATION_SUMMARY.md +500 -0
  89. package/.agent/skills/patent-workflow/README.md +455 -0
  90. package/.agent/skills/patent-workflow/SKILL.md +1036 -0
  91. package/.agent/skills/patent-workflow/tools/irr_checker.py +260 -0
  92. package/.agent/skills/patent-workflow/tools/sample_terminology.json +49 -0
  93. package/.agent/skills/patent-workflow/tools/term_checker.py +355 -0
  94. package/.agent/skills/pattern-recognition/SKILL.md +792 -0
  95. package/.agent/skills/pipeline/SKILL.md +448 -0
  96. package/.agent/skills/plan/SKILL.md +309 -0
  97. package/.agent/skills/planning-methodology/SKILL.md +370 -0
  98. package/.agent/skills/planning-with-files/SKILL.md +210 -0
  99. package/.agent/skills/planning-with-files/examples.md +202 -0
  100. package/.agent/skills/planning-with-files/reference.md +218 -0
  101. package/.agent/skills/planning-with-files/scripts/check-complete.ps1 +42 -0
  102. package/.agent/skills/planning-with-files/scripts/check-complete.sh +44 -0
  103. package/.agent/skills/planning-with-files/scripts/init-session.ps1 +120 -0
  104. package/.agent/skills/planning-with-files/scripts/init-session.sh +120 -0
  105. package/.agent/skills/planning-with-files/scripts/session-catchup.py +208 -0
  106. package/.agent/skills/planning-with-files/templates/findings.md +95 -0
  107. package/.agent/skills/planning-with-files/templates/progress.md +114 -0
  108. package/.agent/skills/planning-with-files/templates/task_plan.md +132 -0
  109. package/.agent/skills/project-analyze/CLAUDE.md +18 -0
  110. package/.agent/skills/project-analyze/HOW_TO_USE.md +145 -0
  111. package/.agent/skills/project-analyze/README.md +42 -0
  112. package/.agent/skills/project-analyze/SKILL.md +289 -0
  113. package/.agent/skills/project-analyze/SKILL.md.backup +287 -0
  114. package/.agent/skills/project-analyze/SKILL.md.backup_20260105_093646 +287 -0
  115. package/.agent/skills/project-analyze/assets/analysis-report-template.md +433 -0
  116. package/.agent/skills/project-analyze/references/analysis-patterns.md +422 -0
  117. package/.agent/skills/project-analyze/references/projectmind-explained.md +535 -0
  118. package/.agent/skills/project-session-manager/SKILL.md +428 -0
  119. package/.agent/skills/project-session-manager/lib/config.sh +86 -0
  120. package/.agent/skills/project-session-manager/lib/parse.sh +121 -0
  121. package/.agent/skills/project-session-manager/lib/session.sh +132 -0
  122. package/.agent/skills/project-session-manager/lib/tmux.sh +103 -0
  123. package/.agent/skills/project-session-manager/lib/worktree.sh +171 -0
  124. package/.agent/skills/project-session-manager/psm.sh +629 -0
  125. package/.agent/skills/project-session-manager/templates/feature.md +56 -0
  126. package/.agent/skills/project-session-manager/templates/issue-fix.md +57 -0
  127. package/.agent/skills/project-session-manager/templates/pr-review.md +65 -0
  128. package/.agent/skills/project-session-manager/templates/projects.json +19 -0
  129. package/.agent/skills/quality-check/HOW_TO_USE.md +171 -0
  130. package/.agent/skills/quality-check/README.md +50 -0
  131. package/.agent/skills/quality-check/SKILL.md +240 -0
  132. package/.agent/skills/quality-check/SKILL.md.backup +238 -0
  133. package/.agent/skills/quality-check/SKILL.md.backup_20260105_093646 +238 -0
  134. package/.agent/skills/quality-check/assets/quality-report-template.md +437 -0
  135. package/.agent/skills/quality-check/references/refactoring-patterns.md +550 -0
  136. package/.agent/skills/quality-check/references/scoring-criteria.md +454 -0
  137. package/.agent/skills/quality-validation/SKILL.md +519 -0
  138. package/.agent/skills/quality-validation/SKILL.md.backup +573 -0
  139. package/.agent/skills/quality-validation/SKILL.md.backup_20260105_093646 +573 -0
  140. package/.agent/skills/ralph/SKILL.md +236 -0
  141. package/.agent/skills/ralph-init/SKILL.md +78 -0
  142. package/.agent/skills/ralplan/SKILL.md +58 -0
  143. package/.agent/skills/refactor-clean/SKILL.md +49 -0
  144. package/.agent/skills/release/SKILL.md +84 -0
  145. package/.agent/skills/research/SKILL.md +526 -0
  146. package/.agent/skills/research-methodology/SKILL.md +268 -0
  147. package/.agent/skills/review/SKILL.md +53 -0
  148. package/.agent/skills/security-review/SKILL.md +509 -0
  149. package/.agent/skills/security-review/cloud-infrastructure-security.md +361 -0
  150. package/.agent/skills/setup-pm/SKILL.md +102 -0
  151. package/.agent/skills/skill/SKILL.md +424 -0
  152. package/.agent/skills/skill-create/SKILL.md +209 -0
  153. package/.agent/skills/skill-debugger/HOW_TO_USE.md +244 -0
  154. package/.agent/skills/skill-debugger/README.md +44 -0
  155. package/.agent/skills/skill-debugger/SKILL.md +326 -0
  156. package/.agent/skills/skill-debugger/diagnostic_checklist.md +115 -0
  157. package/.agent/skills/skill-development/SKILL.md +661 -0
  158. package/.agent/skills/skill-development/references/skill-creator-original.md +209 -0
  159. package/.agent/skills/skill-doc-generator/README.md +37 -0
  160. package/.agent/skills/skill-doc-generator/SKILL.md +331 -0
  161. package/.agent/skills/skill-quality-analyzer/HOW_TO_USE.md +243 -0
  162. package/.agent/skills/skill-quality-analyzer/README.md +61 -0
  163. package/.agent/skills/skill-quality-analyzer/SKILL.md +247 -0
  164. package/.agent/skills/skill-quality-analyzer/analyzer.py +209 -0
  165. package/.agent/skills/skill-quality-analyzer/expected_output.json +81 -0
  166. package/.agent/skills/skill-quality-analyzer/sample_input.json +9 -0
  167. package/.agent/skills/skill-tester/README.md +46 -0
  168. package/.agent/skills/skill-tester/SKILL.md +345 -0
  169. package/.agent/skills/start-dev/SKILL.md +701 -0
  170. package/.agent/skills/swarm/SKILL.md +691 -0
  171. package/.agent/skills/task-kb-lookup/SKILL.md +211 -0
  172. package/.agent/skills/task-kb-record/SKILL.md +417 -0
  173. package/.agent/skills/tdd/SKILL.md +446 -0
  174. package/.agent/skills/tdd-generator/DEMO.md +516 -0
  175. package/.agent/skills/tdd-generator/README.md +89 -0
  176. package/.agent/skills/tdd-generator/SKILL.md +278 -0
  177. package/.agent/skills/tdd-workflow/SKILL.md +424 -0
  178. package/.agent/skills/test-coverage/SKILL.md +48 -0
  179. package/.agent/skills/thinkdeep/HOW_TO_USE.md +183 -0
  180. package/.agent/skills/thinkdeep/README.md +41 -0
  181. package/.agent/skills/thinkdeep/SKILL.md +343 -0
  182. package/.agent/skills/ui-ux-pro-max/SKILL.md +228 -0
  183. package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
  184. package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
  185. package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
  186. package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
  187. package/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
  188. package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  189. package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  190. package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  191. package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  192. package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  193. package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  194. package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  195. package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  196. package/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
  197. package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
  198. package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  199. package/.agent/skills/ui-ux-pro-max/scripts/core.py +236 -0
  200. package/.agent/skills/ui-ux-pro-max/scripts/search.py +61 -0
  201. package/.agent/skills/ultrapilot/SKILL.md +647 -0
  202. package/.agent/skills/ultraqa/SKILL.md +152 -0
  203. package/.agent/skills/ultrawork/SKILL.md +123 -0
  204. package/.agent/skills/update-codemaps/SKILL.md +38 -0
  205. package/.agent/skills/update-docs/SKILL.md +52 -0
  206. package/.agent/skills/verification-loop/SKILL.md +140 -0
  207. package/.agent/skills/verify/SKILL.md +80 -0
  208. package/.agent/skills/writer-memory/SKILL.md +459 -0
  209. package/.agent/skills/writer-memory/lib/character-tracker.ts +338 -0
  210. package/.agent/skills/writer-memory/lib/memory-manager.ts +804 -0
  211. package/.agent/skills/writer-memory/lib/relationship-graph.ts +400 -0
  212. package/.agent/skills/writer-memory/lib/scene-organizer.ts +544 -0
  213. package/.agent/skills/writer-memory/lib/synopsis-builder.ts +339 -0
  214. package/.agent/skills/writer-memory/templates/synopsis-template.md +46 -0
  215. package/.governance/skill-lint.allowlist +4 -0
  216. package/.governance/skill-llm.allowlist +4 -0
  217. package/AGENTS.md +59 -0
  218. package/LICENSE +21 -0
  219. package/README.md +169 -0
  220. package/README.zh.md +145 -0
  221. package/bin/omcodex.js +8 -0
  222. package/commands/conductor/implement.toml +358 -0
  223. package/commands/conductor/newTrack.toml +142 -0
  224. package/commands/conductor/revert.toml +123 -0
  225. package/commands/conductor/setup.toml +429 -0
  226. package/commands/conductor/status.toml +57 -0
  227. package/docs/ALIGNMENT.md +40 -0
  228. package/docs/CODEX.md +133 -0
  229. package/docs/NOTIFY.md +81 -0
  230. package/docs/SKILL_GOVERNANCE.md +72 -0
  231. package/docs/SKILL_GOVERNANCE_FRAMEWORK.md +182 -0
  232. package/docs/SKILL_GOVERNANCE_FRAMEWORK.zh.md +170 -0
  233. package/package.json +50 -0
  234. package/prompts/architect.md +105 -0
  235. package/prompts/executor.md +134 -0
  236. package/prompts/planner.md +113 -0
  237. package/scripts/check-skill-governance.sh +84 -0
  238. package/scripts/check-skill-llm-governance.js +302 -0
  239. package/scripts/eval-skills.js +217 -0
  240. package/scripts/generate-catalog-docs.js +95 -0
  241. package/scripts/generate-codex-mcp-config.sh +22 -0
  242. package/scripts/install-codex-force.sh +5 -0
  243. package/scripts/install-codex-incremental.sh +5 -0
  244. package/scripts/install-codex.sh +79 -0
  245. package/scripts/notify-dispatch.js +15 -0
  246. package/scripts/setup-package-manager.js +137 -0
  247. package/src/catalog/generated/public-catalog.json +547 -0
  248. package/src/catalog/manifest.json +542 -0
  249. package/src/catalog/reader.js +43 -0
  250. package/src/catalog/schema.js +79 -0
  251. package/src/cli/doctor.js +62 -0
  252. package/src/cli/index.js +85 -0
  253. package/src/cli/notify.js +127 -0
  254. package/src/cli/route.js +43 -0
  255. package/src/cli/setup.js +155 -0
  256. package/src/cli/team.js +125 -0
  257. package/src/config/generator.js +119 -0
  258. package/src/mcp/memory-server.js +241 -0
  259. package/src/mcp/state-server.js +112 -0
  260. package/src/mcp/trace-server.js +168 -0
  261. package/src/notify/dispatch.js +74 -0
  262. package/src/notify/extensibility/dispatcher.js +113 -0
  263. package/src/notify/extensibility/events.js +15 -0
  264. package/src/notify/extensibility/loader.js +54 -0
  265. package/src/router/skill-router.js +90 -0
  266. package/src/team/auto-advance.js +72 -0
  267. package/src/team/orchestrator.js +82 -0
  268. package/src/team/state-store.js +33 -0
  269. package/src/utils/paths.js +33 -0
  270. package/templates/AGENTS.md +15 -0
  271. package/templates/catalog-manifest.json +542 -0
  272. package/templates/code_styleguides/csharp.md +115 -0
  273. package/templates/code_styleguides/dart.md +238 -0
  274. package/templates/code_styleguides/general.md +23 -0
  275. package/templates/code_styleguides/go.md +48 -0
  276. package/templates/code_styleguides/html-css.md +49 -0
  277. package/templates/code_styleguides/javascript.md +51 -0
  278. package/templates/code_styleguides/python.md +37 -0
  279. package/templates/code_styleguides/typescript.md +43 -0
  280. package/templates/rules/README.md +23 -0
  281. package/templates/rules/agents.md +49 -0
  282. package/templates/rules/coding-style.md +70 -0
  283. package/templates/rules/dev.md +20 -0
  284. package/templates/rules/git-workflow.md +45 -0
  285. package/templates/rules/notify.md +6 -0
  286. package/templates/rules/patterns.md +55 -0
  287. package/templates/rules/performance.md +47 -0
  288. package/templates/rules/research.md +26 -0
  289. package/templates/rules/review.md +22 -0
  290. package/templates/rules/security.md +36 -0
  291. package/templates/rules/testing.md +30 -0
  292. package/templates/workflow.md +333 -0
@@ -0,0 +1,278 @@
1
+ ---
2
+ name: TDD Test Generator
3
+ description: AI-powered test-driven development assistant. Generates unit tests (Vitest), component tests (React Testing Library), and E2E tests with Playwright Test Agents integration.
4
+ ---
5
+
6
+ # TDD Test Generator Skill
7
+
8
+ ## When to Use This Skill
9
+
10
+ Automatically invoke when user mentions:
11
+ - "生成测试", "写测试用例", "TDD"
12
+ - "如何测试这个组件/函数"
13
+ - "Playwright Test Agents", "自动化测试"
14
+ - Keywords: test, 测试, TDD, vitest, playwright
15
+
16
+
17
+ ## What This Skill Does
18
+
19
+ **TDD Test Generator** provides:
20
+ 1. **Smart Test Generation**: Auto-generate Vitest unit tests from code
21
+ 2. **Component Testing**: Generate React Testing Library tests
22
+ 3. **E2E Integration**: Deep integration with Playwright Test Agents
23
+ 4. **TDD Workflow**: Support complete Red-Green-Refactor cycle
24
+ 5. **Auto-Healing**: Leverage Playwright Healer Agent to auto-fix broken tests
25
+
26
+ ## Core Features
27
+
28
+ ### Level 1: Unit Tests (Vitest)
29
+
30
+ For: utility functions, pure logic, business rules
31
+
32
+ **Template**:
33
+ ```typescript
34
+ import { describe, it, expect } from 'vitest';
35
+
36
+ describe('functionName', () => {
37
+ it('should handle normal case', () => {
38
+ expect(functionName(input)).toBe(expected);
39
+ });
40
+
41
+ it('should handle edge cases', () => {
42
+ expect(functionName('')).toBe(defaultValue);
43
+ });
44
+ });
45
+ ```
46
+
47
+ ### Level 2: Component Tests (React Testing Library)
48
+
49
+ For: UI components, user interactions, state management
50
+
51
+ **Template**:
52
+ ```typescript
53
+ import { render, screen } from '@testing-library/react';
54
+ import userEvent from '@testing-library/user-event';
55
+
56
+ describe('ComponentName', () => {
57
+ it('renders and handles interaction', async () => {
58
+ const user = userEvent.setup();
59
+ render(<Component />);
60
+ await user.click(screen.getByRole('button'));
61
+ expect(mockFn).toHaveBeenCalled();
62
+ });
63
+ });
64
+ ```
65
+
66
+ ### Level 3: E2E Tests + Playwright Test Agents
67
+
68
+ **Three AI Agents Working Together**:
69
+
70
+ 1. **Planner Agent** - Explores app, generates test plans (Markdown)
71
+ 2. **Generator Agent** - Converts plans to Playwright code
72
+ 3. **Healer Agent** - Auto-fixes broken tests, updates selectors
73
+
74
+ **Setup Commands**:
75
+ ```bash
76
+ # Initialize Playwright Test Agents
77
+ npx playwright test --init-agents
78
+
79
+ # Start agent loop
80
+ npx playwright test --agent=planner
81
+ npx playwright test --agent=generator
82
+ npx playwright test --agent=healer --repeat
83
+ ```
84
+
85
+ **Project Structure**:
86
+ ```
87
+ .github/workflows/agents.yml # Agent definitions
88
+ specs/ # Test plans (Markdown)
89
+ tests/ # Generated tests
90
+ seed.spec.ts # Seed test
91
+ playwright.config.ts
92
+ ```
93
+
94
+ ## Instructions
95
+
96
+ ### Scenario 1: Generate Unit Test
97
+
98
+ **User**: "Generate test for this function"
99
+
100
+ **Your Actions**:
101
+ 1. Analyze code (function/component/flow)
102
+ 2. Identify test points (I/O, edge cases, errors)
103
+ 3. Generate complete Vitest test suite
104
+ 4. Provide run commands
105
+
106
+ **Output Format**:
107
+ ```markdown
108
+ ## 🧪 Generated Unit Test
109
+
110
+ ### Test File: `functionName.test.ts`
111
+ [Generated test code]
112
+
113
+ ### Covered Scenarios:
114
+ - ✅ Normal input/output
115
+ - ✅ Edge cases
116
+ - ✅ Error handling
117
+
118
+ ### Run Test:
119
+ \`pnpm test functionName.test.ts\`
120
+ ```
121
+
122
+ ### Scenario 2: Generate Component Test
123
+
124
+ **User**: "How to test ChatInput component?"
125
+
126
+ **Your Actions**:
127
+ 1. Analyze component props and events
128
+ 2. Identify user interaction flow
129
+ 3. Generate React Testing Library tests
130
+ 4. Include mocks and async handling
131
+
132
+ ### Scenario 3: E2E with Playwright Agents
133
+
134
+ **User**: "Use Playwright Test Agents for E2E"
135
+
136
+ **Your Actions**:
137
+
138
+ **Step 1: Project Setup**
139
+ ```bash
140
+ npm install -D @playwright/test
141
+ npx playwright install
142
+ npx playwright test --init-agents
143
+ ```
144
+
145
+ **Step 2: Create Seed Test**
146
+ ```typescript
147
+ // tests/seed.spec.ts
148
+ import { test, expect } from '@playwright/test';
149
+
150
+ test('seed - setup app state', async ({ page }) => {
151
+ await page.goto('http://localhost:3000');
152
+ // Setup initial state
153
+ await expect(page).toHaveURL('/dashboard');
154
+ });
155
+ ```
156
+
157
+ **Step 3: Start AI Agent Loop**
158
+ ```bash
159
+ # Planner explores and generates plans
160
+ npx playwright test --agent=planner
161
+
162
+ # Generator creates tests from plans
163
+ npx playwright test --agent=generator
164
+
165
+ # Healer monitors and fixes failures
166
+ npx playwright test --agent=healer --repeat
167
+ ```
168
+
169
+ **Output Status**:
170
+ ```markdown
171
+ ## 🤖 Playwright Test Agents Running
172
+
173
+ ### Current Status:
174
+ - ✅ Planner: Generated 3 test plans
175
+ - ✅ Generator: Created 3 test files
176
+ - 🔄 Healer: Monitoring...
177
+
178
+ ### Generated Tests:
179
+ 1. tests/user-login.spec.ts
180
+ 2. tests/create-post.spec.ts
181
+ 3. tests/search-functionality.spec.ts
182
+
183
+ ### View Plans: \`cat specs/*.md\`
184
+ ### Run Tests: \`npx playwright test\`
185
+ ```
186
+
187
+ ## TDD Workflow Support
188
+
189
+ ### Red-Green-Refactor Cycle
190
+
191
+ **User wants TDD workflow**
192
+
193
+ **Your Guidance**:
194
+ ```markdown
195
+ ## 🔴 Phase 1: Red (Write Failing Test)
196
+ [Generate test with expected behavior]
197
+ Run: \`pnpm test --watch\`
198
+ Expected: ❌ All tests fail
199
+
200
+ ## 🟢 Phase 2: Green (Minimal Implementation)
201
+ Implement feature to pass tests
202
+ Expected: ✅ All tests pass
203
+
204
+ ## 🔵 Phase 3: Refactor (Optimize)
205
+ Safely refactor with test protection
206
+ Expected: ✅ Tests still pass
207
+ ```
208
+
209
+ ## Best Practices
210
+
211
+ When generating tests, ensure:
212
+ 1. **Semantic queries** - Use getByRole, getByLabelText
213
+ 2. **Test behavior** - Not implementation details
214
+ 3. **Async handling** - Proper waitFor, findBy*
215
+ 4. **Mock externals** - Only APIs and services
216
+ 5. **One test, one thing** - Keep tests focused
217
+ 6. **Descriptive names** - Clear test descriptions
218
+
219
+ ## Project Integration Checklist
220
+
221
+ Before generating tests, check:
222
+ - [ ] Vitest installed
223
+ - [ ] React Testing Library configured
224
+ - [ ] @testing-library/user-event installed
225
+ - [ ] Playwright installed (for E2E)
226
+ - [ ] test scripts in package.json
227
+ - [ ] vitest.config.ts configured
228
+
229
+ **Auto-install if missing**:
230
+ ```bash
231
+ pnpm add -D vitest @testing-library/react @testing-library/user-event jsdom
232
+ pnpm add -D @playwright/test
233
+ ```
234
+
235
+ ## Troubleshooting
236
+
237
+ ### Issue 1: Vitest "Cannot find module"
238
+ **Fix**: Check vitest.config.ts path aliases
239
+
240
+ ### Issue 2: RTL "Unable to find role"
241
+ **Fix**: Use screen.debug(), check element rendered
242
+
243
+ ### Issue 3: Playwright Agents won't start
244
+ **Fix**:
245
+ ```bash
246
+ npm install -D @playwright/test@latest
247
+ npx playwright install
248
+ npx playwright test --init-agents
249
+ ```
250
+
251
+ ## Examples
252
+
253
+ ### Example 1: Quick Unit Test
254
+ **User**: "Test formatMessage function"
255
+ **Output**: Complete test suite with edge cases
256
+
257
+ ### Example 2: TDD Workflow
258
+ **User**: "TDD ChatInput component"
259
+ **Output**: Red-Green-Refactor guidance
260
+
261
+ ### Example 3: E2E Automation
262
+ **User**: "Playwright Agents for login"
263
+ **Output**: Full agent setup and monitoring
264
+
265
+ ## Integration with Other Skills
266
+
267
+ - **Agent-KB**: Query testing best practices
268
+ - **Quality-Check**: Analyze test coverage
269
+ - **Project-Analyze**: Identify critical modules to test
270
+
271
+ ## Important Notes
272
+
273
+ - **Test-first mindset**: Guide users to understand TDD value
274
+ - **Pragmatism**: Focus on core business, not 100% coverage
275
+ - **Automation**: Maximize Playwright Agents to reduce manual work
276
+ - **Maintainability**: Generate easy-to-maintain tests
277
+ - **Education**: Explain principles, not just generate code
278
+
@@ -0,0 +1,424 @@
1
+ ---
2
+ name: tdd-workflow
3
+ description: Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.
4
+ ---
5
+
6
+ # Test-Driven Development Workflow
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
+ This skill ensures all code development follows TDD principles with comprehensive test coverage.
24
+
25
+ ## When to Activate
26
+
27
+ - Writing new features or functionality
28
+ - Fixing bugs or issues
29
+ - Refactoring existing code
30
+ - Adding API endpoints
31
+ - Creating new components
32
+
33
+ ## Core Principles
34
+
35
+ ### 1. Tests BEFORE Code
36
+ ALWAYS write tests first, then implement code to make tests pass.
37
+
38
+ ### 2. Coverage Requirements
39
+ - Minimum 80% coverage (unit + integration + E2E)
40
+ - All edge cases covered
41
+ - Error scenarios tested
42
+ - Boundary conditions verified
43
+
44
+ ### 3. Test Types
45
+
46
+ #### Unit Tests
47
+ - Individual functions and utilities
48
+ - Component logic
49
+ - Pure functions
50
+ - Helpers and utilities
51
+
52
+ #### Integration Tests
53
+ - API endpoints
54
+ - Database operations
55
+ - Service interactions
56
+ - External API calls
57
+
58
+ #### E2E Tests (Playwright)
59
+ - Critical user flows
60
+ - Complete workflows
61
+ - Browser automation
62
+ - UI interactions
63
+
64
+ ## TDD Workflow Steps
65
+
66
+ ### Step 1: Write User Journeys
67
+ ```
68
+ As a [role], I want to [action], so that [benefit]
69
+
70
+ Example:
71
+ As a user, I want to search for markets semantically,
72
+ so that I can find relevant markets even without exact keywords.
73
+ ```
74
+
75
+ ### Step 2: Generate Test Cases
76
+ For each user journey, create comprehensive test cases:
77
+
78
+ ```typescript
79
+ describe('Semantic Search', () => {
80
+ it('returns relevant markets for query', async () => {
81
+ // Test implementation
82
+ })
83
+
84
+ it('handles empty query gracefully', async () => {
85
+ // Test edge case
86
+ })
87
+
88
+ it('falls back to substring search when Redis unavailable', async () => {
89
+ // Test fallback behavior
90
+ })
91
+
92
+ it('sorts results by similarity score', async () => {
93
+ // Test sorting logic
94
+ })
95
+ })
96
+ ```
97
+
98
+ ### Step 3: Run Tests (They Should Fail)
99
+ ```bash
100
+ npm test
101
+ # Tests should fail - we haven't implemented yet
102
+ ```
103
+
104
+ ### Step 4: Implement Code
105
+ Write minimal code to make tests pass:
106
+
107
+ ```typescript
108
+ // Implementation guided by tests
109
+ export async function searchMarkets(query: string) {
110
+ // Implementation here
111
+ }
112
+ ```
113
+
114
+ ### Step 5: Run Tests Again
115
+ ```bash
116
+ npm test
117
+ # Tests should now pass
118
+ ```
119
+
120
+ ### Step 6: Refactor
121
+ Improve code quality while keeping tests green:
122
+ - Remove duplication
123
+ - Improve naming
124
+ - Optimize performance
125
+ - Enhance readability
126
+
127
+ ### Step 7: Verify Coverage
128
+ ```bash
129
+ npm run test:coverage
130
+ # Verify 80%+ coverage achieved
131
+ ```
132
+
133
+ ## Testing Patterns
134
+
135
+ ### Unit Test Pattern (Jest/Vitest)
136
+ ```typescript
137
+ import { render, screen, fireEvent } from '@testing-library/react'
138
+ import { Button } from './Button'
139
+
140
+ describe('Button Component', () => {
141
+ it('renders with correct text', () => {
142
+ render(<Button>Click me</Button>)
143
+ expect(screen.getByText('Click me')).toBeInTheDocument()
144
+ })
145
+
146
+ it('calls onClick when clicked', () => {
147
+ const handleClick = jest.fn()
148
+ render(<Button onClick={handleClick}>Click</Button>)
149
+
150
+ fireEvent.click(screen.getByRole('button'))
151
+
152
+ expect(handleClick).toHaveBeenCalledTimes(1)
153
+ })
154
+
155
+ it('is disabled when disabled prop is true', () => {
156
+ render(<Button disabled>Click</Button>)
157
+ expect(screen.getByRole('button')).toBeDisabled()
158
+ })
159
+ })
160
+ ```
161
+
162
+ ### API Integration Test Pattern
163
+ ```typescript
164
+ import { NextRequest } from 'next/server'
165
+ import { GET } from './route'
166
+
167
+ describe('GET /api/markets', () => {
168
+ it('returns markets successfully', async () => {
169
+ const request = new NextRequest('http://localhost/api/markets')
170
+ const response = await GET(request)
171
+ const data = await response.json()
172
+
173
+ expect(response.status).toBe(200)
174
+ expect(data.success).toBe(true)
175
+ expect(Array.isArray(data.data)).toBe(true)
176
+ })
177
+
178
+ it('validates query parameters', async () => {
179
+ const request = new NextRequest('http://localhost/api/markets?limit=invalid')
180
+ const response = await GET(request)
181
+
182
+ expect(response.status).toBe(400)
183
+ })
184
+
185
+ it('handles database errors gracefully', async () => {
186
+ // Mock database failure
187
+ const request = new NextRequest('http://localhost/api/markets')
188
+ // Test error handling
189
+ })
190
+ })
191
+ ```
192
+
193
+ ### E2E Test Pattern (Playwright)
194
+ ```typescript
195
+ import { test, expect } from '@playwright/test'
196
+
197
+ test('user can search and filter markets', async ({ page }) => {
198
+ // Navigate to markets page
199
+ await page.goto('/')
200
+ await page.click('a[href="/markets"]')
201
+
202
+ // Verify page loaded
203
+ await expect(page.locator('h1')).toContainText('Markets')
204
+
205
+ // Search for markets
206
+ await page.fill('input[placeholder="Search markets"]', 'election')
207
+
208
+ // Wait for debounce and results
209
+ await page.waitForTimeout(600)
210
+
211
+ // Verify search results displayed
212
+ const results = page.locator('[data-testid="market-card"]')
213
+ await expect(results).toHaveCount(5, { timeout: 5000 })
214
+
215
+ // Verify results contain search term
216
+ const firstResult = results.first()
217
+ await expect(firstResult).toContainText('election', { ignoreCase: true })
218
+
219
+ // Filter by status
220
+ await page.click('button:has-text("Active")')
221
+
222
+ // Verify filtered results
223
+ await expect(results).toHaveCount(3)
224
+ })
225
+
226
+ test('user can create a new market', async ({ page }) => {
227
+ // Login first
228
+ await page.goto('/creator-dashboard')
229
+
230
+ // Fill market creation form
231
+ await page.fill('input[name="name"]', 'Test Market')
232
+ await page.fill('textarea[name="description"]', 'Test description')
233
+ await page.fill('input[name="endDate"]', '2025-12-31')
234
+
235
+ // Submit form
236
+ await page.click('button[type="submit"]')
237
+
238
+ // Verify success message
239
+ await expect(page.locator('text=Market created successfully')).toBeVisible()
240
+
241
+ // Verify redirect to market page
242
+ await expect(page).toHaveURL(/\/markets\/test-market/)
243
+ })
244
+ ```
245
+
246
+ ## Test File Organization
247
+
248
+ ```
249
+ src/
250
+ ├── components/
251
+ │ ├── Button/
252
+ │ │ ├── Button.tsx
253
+ │ │ ├── Button.test.tsx # Unit tests
254
+ │ │ └── Button.stories.tsx # Storybook
255
+ │ └── MarketCard/
256
+ │ ├── MarketCard.tsx
257
+ │ └── MarketCard.test.tsx
258
+ ├── app/
259
+ │ └── api/
260
+ │ └── markets/
261
+ │ ├── route.ts
262
+ │ └── route.test.ts # Integration tests
263
+ └── e2e/
264
+ ├── markets.spec.ts # E2E tests
265
+ ├── trading.spec.ts
266
+ └── auth.spec.ts
267
+ ```
268
+
269
+ ## Mocking External Services
270
+
271
+ ### Supabase Mock
272
+ ```typescript
273
+ jest.mock('@/lib/supabase', () => ({
274
+ supabase: {
275
+ from: jest.fn(() => ({
276
+ select: jest.fn(() => ({
277
+ eq: jest.fn(() => Promise.resolve({
278
+ data: [{ id: 1, name: 'Test Market' }],
279
+ error: null
280
+ }))
281
+ }))
282
+ }))
283
+ }
284
+ }))
285
+ ```
286
+
287
+ ### Redis Mock
288
+ ```typescript
289
+ jest.mock('@/lib/redis', () => ({
290
+ searchMarketsByVector: jest.fn(() => Promise.resolve([
291
+ { slug: 'test-market', similarity_score: 0.95 }
292
+ ])),
293
+ checkRedisHealth: jest.fn(() => Promise.resolve({ connected: true }))
294
+ }))
295
+ ```
296
+
297
+ ### OpenAI Mock
298
+ ```typescript
299
+ jest.mock('@/lib/openai', () => ({
300
+ generateEmbedding: jest.fn(() => Promise.resolve(
301
+ new Array(1536).fill(0.1) // Mock 1536-dim embedding
302
+ ))
303
+ }))
304
+ ```
305
+
306
+ ## Test Coverage Verification
307
+
308
+ ### Run Coverage Report
309
+ ```bash
310
+ npm run test:coverage
311
+ ```
312
+
313
+ ### Coverage Thresholds
314
+ ```json
315
+ {
316
+ "jest": {
317
+ "coverageThresholds": {
318
+ "global": {
319
+ "branches": 80,
320
+ "functions": 80,
321
+ "lines": 80,
322
+ "statements": 80
323
+ }
324
+ }
325
+ }
326
+ }
327
+ ```
328
+
329
+ ## Common Testing Mistakes to Avoid
330
+
331
+ ### ❌ WRONG: Testing Implementation Details
332
+ ```typescript
333
+ // Don't test internal state
334
+ expect(component.state.count).toBe(5)
335
+ ```
336
+
337
+ ### ✅ CORRECT: Test User-Visible Behavior
338
+ ```typescript
339
+ // Test what users see
340
+ expect(screen.getByText('Count: 5')).toBeInTheDocument()
341
+ ```
342
+
343
+ ### ❌ WRONG: Brittle Selectors
344
+ ```typescript
345
+ // Breaks easily
346
+ await page.click('.css-class-xyz')
347
+ ```
348
+
349
+ ### ✅ CORRECT: Semantic Selectors
350
+ ```typescript
351
+ // Resilient to changes
352
+ await page.click('button:has-text("Submit")')
353
+ await page.click('[data-testid="submit-button"]')
354
+ ```
355
+
356
+ ### ❌ WRONG: No Test Isolation
357
+ ```typescript
358
+ // Tests depend on each other
359
+ test('creates user', () => { /* ... */ })
360
+ test('updates same user', () => { /* depends on previous test */ })
361
+ ```
362
+
363
+ ### ✅ CORRECT: Independent Tests
364
+ ```typescript
365
+ // Each test sets up its own data
366
+ test('creates user', () => {
367
+ const user = createTestUser()
368
+ // Test logic
369
+ })
370
+
371
+ test('updates user', () => {
372
+ const user = createTestUser()
373
+ // Update logic
374
+ })
375
+ ```
376
+
377
+ ## Continuous Testing
378
+
379
+ ### Watch Mode During Development
380
+ ```bash
381
+ npm test -- --watch
382
+ # Tests run automatically on file changes
383
+ ```
384
+
385
+ ### Pre-Commit Hook
386
+ ```bash
387
+ # Runs before every commit
388
+ npm test && npm run lint
389
+ ```
390
+
391
+ ### CI/CD Integration
392
+ ```yaml
393
+ # GitHub Actions
394
+ - name: Run Tests
395
+ run: npm test -- --coverage
396
+ - name: Upload Coverage
397
+ uses: codecov/codecov-action@v3
398
+ ```
399
+
400
+ ## Best Practices
401
+
402
+ 1. **Write Tests First** - Always TDD
403
+ 2. **One Assert Per Test** - Focus on single behavior
404
+ 3. **Descriptive Test Names** - Explain what's tested
405
+ 4. **Arrange-Act-Assert** - Clear test structure
406
+ 5. **Mock External Dependencies** - Isolate unit tests
407
+ 6. **Test Edge Cases** - Null, undefined, empty, large
408
+ 7. **Test Error Paths** - Not just happy paths
409
+ 8. **Keep Tests Fast** - Unit tests < 50ms each
410
+ 9. **Clean Up After Tests** - No side effects
411
+ 10. **Review Coverage Reports** - Identify gaps
412
+
413
+ ## Success Metrics
414
+
415
+ - 80%+ code coverage achieved
416
+ - All tests passing (green)
417
+ - No skipped or disabled tests
418
+ - Fast test execution (< 30s for unit tests)
419
+ - E2E tests cover critical user flows
420
+ - Tests catch bugs before production
421
+
422
+ ---
423
+
424
+ **Remember**: Tests are not optional. They are the safety net that enables confident refactoring, rapid development, and production reliability.