@relipa/ai-flow-kit 0.1.1-beta.0 → 0.1.2-beta.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 (247) hide show
  1. package/README.md +0 -0
  2. package/bin/aiflow.js +55 -2
  3. package/bin/ak.js +0 -0
  4. package/custom/mcp-presets/README.md +204 -204
  5. package/custom/mcp-presets/backlog.json +0 -0
  6. package/custom/mcp-presets/figma-desktop.json +0 -0
  7. package/custom/mcp-presets/figma.json +0 -0
  8. package/custom/mcp-presets/gitnexus.json +0 -0
  9. package/custom/mcp-presets/google-sheets.json +0 -0
  10. package/custom/mcp-presets/jira.json +0 -0
  11. package/custom/prompts/bug-fix.md +0 -0
  12. package/custom/prompts/feature.md +0 -0
  13. package/custom/prompts/investigation.md +0 -0
  14. package/custom/rules/code-style.md +0 -0
  15. package/custom/rules/java/code-style.md +0 -0
  16. package/custom/rules/java/naming.md +0 -0
  17. package/custom/rules/java/review-checklist.md +0 -0
  18. package/custom/rules/java/spring-boot-examples.md +0 -0
  19. package/custom/rules/javascript/code-style.md +0 -0
  20. package/custom/rules/javascript/naming.md +0 -0
  21. package/custom/rules/ml-conventions.md +88 -0
  22. package/custom/rules/ml-review-checklist.md +14 -0
  23. package/custom/rules/naming.md +0 -0
  24. package/custom/rules/php/code-style.md +0 -0
  25. package/custom/rules/php/naming.md +0 -0
  26. package/custom/rules/project-conventions.md +0 -0
  27. package/custom/rules/review-checklist.md +0 -0
  28. package/custom/skills/deploy-model/SKILL.md +90 -0
  29. package/custom/skills/design-experiment/SKILL.md +88 -0
  30. package/custom/skills/evaluate-model/SKILL.md +93 -0
  31. package/custom/skills/explore-data/SKILL.md +87 -0
  32. package/custom/skills/figma-to-component/SKILL.md +164 -59
  33. package/custom/skills/frame-ml-problem/SKILL.md +88 -0
  34. package/custom/skills/generate-spec/SKILL.md +0 -0
  35. package/custom/skills/impact-analysis/SKILL.md +0 -0
  36. package/custom/skills/improve-algorithm/SKILL.md +74 -0
  37. package/custom/skills/investigate-bug/SKILL.md +0 -0
  38. package/custom/skills/read-study-requirement/SKILL.md +0 -0
  39. package/custom/skills/report-customer/SKILL.md +0 -0
  40. package/custom/skills/review-plan/SKILL.md +0 -0
  41. package/custom/skills/train-model/SKILL.md +78 -0
  42. package/custom/templates/laravel.md +0 -0
  43. package/custom/templates/nestjs.md +0 -0
  44. package/custom/templates/nextjs.md +0 -0
  45. package/custom/templates/nodejs-express.md +0 -0
  46. package/custom/templates/php-plain.md +0 -0
  47. package/custom/templates/php.md +0 -0
  48. package/custom/templates/python-django.md +0 -0
  49. package/custom/templates/python-fastapi.md +0 -0
  50. package/custom/templates/python-ml.md +273 -0
  51. package/custom/templates/python.md +0 -0
  52. package/custom/templates/reactjs.md +0 -0
  53. package/custom/templates/shared/gate-workflow.md +0 -0
  54. package/custom/templates/shared/ml-gate-workflow.md +103 -0
  55. package/custom/templates/spring-boot.md +0 -0
  56. package/custom/templates/tools/claude.md +0 -0
  57. package/custom/templates/tools/copilot.md +0 -0
  58. package/custom/templates/tools/cursor.md +0 -0
  59. package/custom/templates/tools/gemini.md +0 -0
  60. package/custom/templates/tools/generic.md +0 -0
  61. package/custom/templates/vue-nuxt.md +0 -0
  62. package/docs/common/AIFLOW.md +512 -512
  63. package/docs/common/CHANGELOG.md +16 -0
  64. package/docs/common/QUICK_START.md +0 -0
  65. package/docs/common/ai-integration.md +0 -0
  66. package/docs/common/cli-reference.md +0 -0
  67. package/docs/common/configuration.md +0 -0
  68. package/docs/common/getting-started.md +0 -0
  69. package/docs/common/troubleshooting.md +0 -0
  70. package/docs/common/workflows/bug-fix.md +0 -0
  71. package/docs/common/workflows/feature.md +0 -0
  72. package/docs/common/workflows/figma.md +0 -0
  73. package/docs/common/workflows/impact-analysis.md +0 -0
  74. package/docs/common/workflows/investigation.md +0 -0
  75. package/docs/common/workflows/refactor.md +0 -0
  76. package/docs/project/ARCHITECTURE.md +0 -0
  77. package/index.js +0 -0
  78. package/package.json +2 -2
  79. package/scripts/checkpoint.js +0 -0
  80. package/scripts/config.js +0 -0
  81. package/scripts/context.js +0 -0
  82. package/scripts/create-score-excel.js +0 -0
  83. package/scripts/detect.js +239 -239
  84. package/scripts/doctor.js +192 -218
  85. package/scripts/gitnexus-worker.js +0 -0
  86. package/scripts/guide.js +0 -0
  87. package/scripts/hooks/block-git-write.js +0 -0
  88. package/scripts/hooks/session-start.js +0 -0
  89. package/scripts/hooks/session-stop.js +0 -0
  90. package/scripts/init.js +1112 -1009
  91. package/scripts/link-resolver.js +0 -0
  92. package/scripts/memory.js +0 -0
  93. package/scripts/prompt.js +538 -538
  94. package/scripts/remove.js +0 -0
  95. package/scripts/task.js +546 -546
  96. package/scripts/telemetry/cli.js +0 -0
  97. package/scripts/telemetry/config.js +0 -0
  98. package/scripts/telemetry/crypto.js +0 -0
  99. package/scripts/telemetry/flush.js +0 -0
  100. package/scripts/telemetry/record.js +0 -0
  101. package/scripts/update.js +10 -7
  102. package/scripts/use.js +33 -12
  103. package/scripts/validate.js +0 -0
  104. package/upstream/.claude-plugin/marketplace.json +0 -0
  105. package/upstream/.claude-plugin/plugin.json +0 -0
  106. package/upstream/.codex/INSTALL.md +0 -0
  107. package/upstream/.cursor-plugin/plugin.json +0 -0
  108. package/upstream/.gitattributes +0 -0
  109. package/upstream/.github/FUNDING.yml +0 -0
  110. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  111. package/upstream/.github/ISSUE_TEMPLATE/config.yml +0 -0
  112. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  113. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +0 -0
  114. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  115. package/upstream/.opencode/INSTALL.md +0 -0
  116. package/upstream/.opencode/plugins/superpowers.js +0 -0
  117. package/upstream/.version-bump.json +0 -0
  118. package/upstream/AGENTS.md +0 -0
  119. package/upstream/CHANGELOG.md +0 -0
  120. package/upstream/CLAUDE.md +0 -0
  121. package/upstream/CODE_OF_CONDUCT.md +0 -0
  122. package/upstream/GEMINI.md +0 -0
  123. package/upstream/LICENSE +0 -0
  124. package/upstream/README.md +0 -0
  125. package/upstream/RELEASE-NOTES.md +0 -0
  126. package/upstream/agents/code-reviewer.md +0 -0
  127. package/upstream/commands/brainstorm.md +0 -0
  128. package/upstream/commands/execute-plan.md +0 -0
  129. package/upstream/commands/write-plan.md +0 -0
  130. package/upstream/docs/README.codex.md +0 -0
  131. package/upstream/docs/README.opencode.md +0 -0
  132. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +0 -0
  133. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +0 -0
  134. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +0 -0
  135. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +0 -0
  136. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +0 -0
  137. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +0 -0
  138. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +0 -0
  139. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +0 -0
  140. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +0 -0
  141. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +0 -0
  142. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +0 -0
  143. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +0 -0
  144. package/upstream/docs/testing.md +0 -0
  145. package/upstream/docs/windows/polyglot-hooks.md +0 -0
  146. package/upstream/gemini-extension.json +0 -0
  147. package/upstream/hooks/hooks-cursor.json +0 -0
  148. package/upstream/hooks/hooks.json +0 -0
  149. package/upstream/hooks/run-hook.cmd +0 -0
  150. package/upstream/hooks/session-start +0 -0
  151. package/upstream/package.json +0 -0
  152. package/upstream/scripts/bump-version.sh +0 -0
  153. package/upstream/skills/brainstorming/SKILL.md +0 -0
  154. package/upstream/skills/brainstorming/scripts/frame-template.html +0 -0
  155. package/upstream/skills/brainstorming/scripts/helper.js +0 -0
  156. package/upstream/skills/brainstorming/scripts/server.cjs +0 -0
  157. package/upstream/skills/brainstorming/scripts/start-server.sh +0 -0
  158. package/upstream/skills/brainstorming/scripts/stop-server.sh +0 -0
  159. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +0 -0
  160. package/upstream/skills/brainstorming/visual-companion.md +0 -0
  161. package/upstream/skills/dispatching-parallel-agents/SKILL.md +0 -0
  162. package/upstream/skills/executing-plans/SKILL.md +0 -0
  163. package/upstream/skills/finishing-a-development-branch/SKILL.md +0 -0
  164. package/upstream/skills/receiving-code-review/SKILL.md +0 -0
  165. package/upstream/skills/requesting-code-review/SKILL.md +0 -0
  166. package/upstream/skills/requesting-code-review/code-reviewer.md +0 -0
  167. package/upstream/skills/subagent-driven-development/SKILL.md +0 -0
  168. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
  169. package/upstream/skills/subagent-driven-development/implementer-prompt.md +0 -0
  170. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +0 -0
  171. package/upstream/skills/systematic-debugging/CREATION-LOG.md +0 -0
  172. package/upstream/skills/systematic-debugging/SKILL.md +0 -0
  173. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +0 -0
  174. package/upstream/skills/systematic-debugging/condition-based-waiting.md +0 -0
  175. package/upstream/skills/systematic-debugging/defense-in-depth.md +0 -0
  176. package/upstream/skills/systematic-debugging/find-polluter.sh +0 -0
  177. package/upstream/skills/systematic-debugging/root-cause-tracing.md +0 -0
  178. package/upstream/skills/systematic-debugging/test-academic.md +0 -0
  179. package/upstream/skills/systematic-debugging/test-pressure-1.md +0 -0
  180. package/upstream/skills/systematic-debugging/test-pressure-2.md +0 -0
  181. package/upstream/skills/systematic-debugging/test-pressure-3.md +0 -0
  182. package/upstream/skills/tdd-lean/SKILL.md +0 -0
  183. package/upstream/skills/test-driven-development/SKILL.md +0 -0
  184. package/upstream/skills/test-driven-development/testing-anti-patterns.md +0 -0
  185. package/upstream/skills/using-git-worktrees/SKILL.md +0 -0
  186. package/upstream/skills/using-superpowers/SKILL.md +0 -0
  187. package/upstream/skills/using-superpowers/references/codex-tools.md +0 -0
  188. package/upstream/skills/using-superpowers/references/copilot-tools.md +0 -0
  189. package/upstream/skills/using-superpowers/references/gemini-tools.md +0 -0
  190. package/upstream/skills/verification-before-completion/SKILL.md +0 -0
  191. package/upstream/skills/writing-plans/SKILL.md +0 -0
  192. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +0 -0
  193. package/upstream/skills/writing-skills/SKILL.md +0 -0
  194. package/upstream/skills/writing-skills/anthropic-best-practices.md +0 -0
  195. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -0
  196. package/upstream/skills/writing-skills/graphviz-conventions.dot +0 -0
  197. package/upstream/skills/writing-skills/persuasion-principles.md +0 -0
  198. package/upstream/skills/writing-skills/render-graphs.js +0 -0
  199. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +0 -0
  200. package/upstream/tests/brainstorm-server/package-lock.json +0 -0
  201. package/upstream/tests/brainstorm-server/package.json +0 -0
  202. package/upstream/tests/brainstorm-server/server.test.js +0 -0
  203. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +0 -0
  204. package/upstream/tests/brainstorm-server/ws-protocol.test.js +0 -0
  205. package/upstream/tests/claude-code/README.md +0 -0
  206. package/upstream/tests/claude-code/analyze-token-usage.py +0 -0
  207. package/upstream/tests/claude-code/run-skill-tests.sh +0 -0
  208. package/upstream/tests/claude-code/test-document-review-system.sh +0 -0
  209. package/upstream/tests/claude-code/test-helpers.sh +0 -0
  210. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +0 -0
  211. package/upstream/tests/claude-code/test-subagent-driven-development.sh +0 -0
  212. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +0 -0
  213. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +0 -0
  214. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +0 -0
  215. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +0 -0
  216. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +0 -0
  217. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +0 -0
  218. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +0 -0
  219. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +0 -0
  220. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +0 -0
  221. package/upstream/tests/explicit-skill-requests/run-all.sh +0 -0
  222. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +0 -0
  223. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +0 -0
  224. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +0 -0
  225. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +0 -0
  226. package/upstream/tests/explicit-skill-requests/run-test.sh +0 -0
  227. package/upstream/tests/opencode/run-tests.sh +0 -0
  228. package/upstream/tests/opencode/setup.sh +0 -0
  229. package/upstream/tests/opencode/test-plugin-loading.sh +0 -0
  230. package/upstream/tests/opencode/test-priority.sh +0 -0
  231. package/upstream/tests/opencode/test-tools.sh +0 -0
  232. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +0 -0
  233. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +0 -0
  234. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +0 -0
  235. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +0 -0
  236. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +0 -0
  237. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +0 -0
  238. package/upstream/tests/skill-triggering/run-all.sh +0 -0
  239. package/upstream/tests/skill-triggering/run-test.sh +0 -0
  240. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +0 -0
  241. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +0 -0
  242. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +0 -0
  243. package/upstream/tests/subagent-driven-dev/run-test.sh +0 -0
  244. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +0 -0
  245. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +0 -0
  246. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +0 -0
  247. package/scripts/score_members.js +0 -320
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: figma-to-component
3
- description: Read designs from Figma and generate React/Next.js/Vue components following project conventions. Supports specific frame URLs and entire pages.
4
- keywords: figma, design, component, ui, generate, react, nextjs, vue, frontend
3
+ description: Read designs from Figma and generate React/Next.js App Router/Vue/Angular components following project conventions. Supports specific frame URLs and entire pages.
4
+ keywords: figma, design, component, ui, generate, react, nextjs, nextjs-app-router, vue, angular, frontend
5
5
  ---
6
6
 
7
7
  # Figma to Component
@@ -14,6 +14,19 @@ keywords: figma, design, component, ui, generate, react, nextjs, vue, frontend
14
14
 
15
15
  ---
16
16
 
17
+ ## Step 0: Verify Figma MCP is available
18
+
19
+ Before doing anything, confirm the Figma MCP server is connected in this session:
20
+
21
+ - The tool `mcp__figma__get_figma_data` (and `mcp__figma__download_figma_images`) must be available.
22
+ - If it is **not** available, STOP and tell the developer:
23
+ > Figma MCP not connected. Run `aiflow init -a figma` (REST API token) or
24
+ > `aiflow init -a figma-desktop` (Figma Desktop), then restart the session.
25
+
26
+ Do not guess design values from the URL — without the MCP server the skill cannot read the design.
27
+
28
+ ---
29
+
17
30
  ## Process
18
31
 
19
32
  ### Step 1: Identify input
@@ -30,20 +43,24 @@ Extract `fileKey` and `nodeId` from the URL.
30
43
  Use Figma MCP tools to fetch design information:
31
44
 
32
45
  ```
33
- 1. Get node info: figma_get_file_nodes(fileKey, nodeIds=[nodeId])
34
- 2. Get styles: figma_get_file_styles(fileKey)
35
- 3. Get components: figma_get_file_components(fileKey) if needed
36
- 4. Export image if visual reference needed: figma_get_image(fileKey, nodeId)
46
+ 1. Get node info, styles, and components in one call:
47
+ get_figma_data(fileKey, nodeId, depth=2)
48
+
49
+ 2. Export image if visual reference needed:
50
+ download_figma_images(fileKey, nodes=[{ nodeId, fileName }], localPath)
37
51
  ```
38
52
 
53
+ Note: `get_figma_data` returns layout, fills, strokes, typography, and component
54
+ definitions in a single response. No separate style or component fetch is needed.
55
+
39
56
  Analyze the output to extract:
40
57
  - **Layout**: flexbox direction, gap, padding, alignment
41
58
  - **Sizing**: width/height (fixed vs fill vs hug)
42
- - **Colors**: fills, strokes → map to Tailwind colors if available
43
- - **Typography**: font-size, font-weight, line-height, letter-spacing → map to Tailwind text classes
44
- - **Spacing**: padding, margin, gap → map to Tailwind spacing scale
45
- - **Border**: radius, width, color → map to Tailwind border classes
46
- - **Shadow**: box-shadow → map to Tailwind shadow classes
59
+ - **Colors**: fills, strokes → map to project CSS tokens / Tailwind colors if available
60
+ - **Typography**: font-size, font-weight, line-height, letter-spacing
61
+ - **Spacing**: padding, margin, gap
62
+ - **Border**: radius, width, color
63
+ - **Shadow**: box-shadow
47
64
  - **States**: hover, focus, disabled, active (if variants present)
48
65
  - **Responsive**: breakpoints if multiple frames present
49
66
 
@@ -73,19 +90,12 @@ download_figma_images({
73
90
  - `localPath` defaults to `public/assets/figma/` (relative to the project root)
74
91
  - `fileName` follows the pattern: `<layer name in lowercase, spaces replaced with ->-<nodeId>.png`
75
92
  - Example: layer "Banner Top" with nodeId "123-456" → `banner-top-123-456.png`
76
- - If MCP does not support `download_figma_images`, use `get_images` to get the URL, then notify DEV to download manually and place in `public/assets/figma/`
93
+ - If MCP does not support `download_figma_images`, get the image URL via `get_figma_data`, then notify DEV to download manually and place in `public/assets/figma/`
77
94
 
78
95
  **Record the result:**
79
96
 
80
97
  After export, save the mapping for use in Step 4:
81
98
 
82
- ```
83
- imageMap = {
84
- "<nodeId>": "public/assets/figma/<fileName>.png"
85
- }
86
- ```
87
-
88
- Example:
89
99
  ```
90
100
  imageMap = {
91
101
  "123-456": "public/assets/figma/banner-top-123-456.png",
@@ -93,53 +103,50 @@ imageMap = {
93
103
  }
94
104
  ```
95
105
 
96
- ### Step 3: Map Figma tokens Tailwind / CSS
106
+ ### Step 3: Detect CSS tooling, then map Figma tokens
97
107
 
98
- **Color mapping:**
99
- ```
100
- Figma hex #3B82F6 → Tailwind blue-500
101
- Figma hex #EF4444 → Tailwind red-500
102
- Figma rgba(0,0,0,0.5) → Tailwind black/50
103
- No Tailwind match → use arbitrary value [#hexcode]
104
- ```
108
+ **Detect the project's styling approach first** (do not assume Tailwind):
105
109
 
106
- **Spacing mapping (8px grid):**
107
- ```
108
- 4px → p-1 / gap-1
109
- 8px p-2 / gap-2
110
- 12px → p-3 / gap-3
111
- 16px p-4 / gap-4
112
- 24px p-6 / gap-6
113
- 32px p-8 / gap-8
114
- No match → arbitrary value [20px]
115
- ```
110
+ 1. `tailwind.config.*` present → **Tailwind** map to utility classes; extend `tailwind.config` with design tokens when a value has no built-in match
111
+ 2. `*.module.css` / `*.module.scss` files present → **CSS Modules** — emit a co-located `.module.css` and reference `styles.x`
112
+ 3. `styled-components` / `@emotion` in `package.json` → **CSS-in-JS** — emit styled components
113
+ 4. None of the above **vanilla CSS** — emit a co-located `.css` file with CSS custom properties
114
+
115
+ **Design tokens:** prefer mapping Figma Styles/Variables to existing project tokens
116
+ (Tailwind theme keys or CSS custom properties) instead of hardcoding hex/px values.
117
+ Only fall back to an arbitrary value when no token matches.
118
+
119
+ **Tailwind reference mappings** (when Tailwind is the detected tooling):
116
120
 
117
- **Typography mapping:**
118
121
  ```
119
- text-xs: 12px
120
- text-sm: 14px
121
- text-base: 16px
122
- text-lg: 18px
123
- text-xl: 20px
124
- text-2xl: 24px
125
- text-3xl: 30px
126
- font-normal: 400
127
- font-medium: 500
128
- font-semibold: 600
129
- font-bold: 700
122
+ Color: #3B82F6 → blue-500 · #EF4444 → red-500 · rgba(0,0,0,0.5) → black/50
123
+ no match → arbitrary value [#hexcode]
124
+ Spacing: 4→p-1/gap-1 · 8→p-2 · 12→p-3 · 16→p-4 · 24→p-6 · 32→p-8 (8px grid)
125
+ no match → arbitrary value [20px]
126
+ Type: 12→text-xs · 14→text-sm · 16→text-base · 18→text-lg · 20→text-xl · 24→text-2xl · 30→text-3xl
127
+ 400→font-normal · 500→font-medium · 600→font-semibold · 700→font-bold
130
128
  ```
131
129
 
132
130
  ### Step 4: Generate component
133
131
 
134
- **Framework detection** — check the project's CLAUDE.md to determine the framework:
135
- - `reactjs` / `nextjs` → generate `.tsx` with React conventions
136
- - `vue-nuxt` generate `.vue` with Vue 3 Composition API
132
+ **Framework detection** — check in this order:
133
+
134
+ 1. Read project's `CLAUDE.md` for framework identifier:
135
+ - `nextjs-app-router` → Next.js App Router (Server/Client Components)
136
+ - `reactjs` / `nextjs` → React / Next.js Pages Router `.tsx`
137
+ - `vue-nuxt` → Vue 3 `.vue` with Composition API
138
+ - `angular` → Angular `@Component` class
139
+ 2. Scan project files if CLAUDE.md is ambiguous:
140
+ - `app/` directory present → `nextjs-app-router`
141
+ - `angular.json` present → `angular`
142
+ - `nuxt.config.*` present → `vue-nuxt`
143
+ 3. Fallback → `nextjs` (React Pages Router)
137
144
 
138
145
  **Image node rendering rule:**
139
146
 
140
147
  Before rendering each node, check `imageMap` from Step 2.5:
141
148
  - If `nodeId` is in `imageMap` → render using `<img>` (React/Vue) or `<Image>` (Next.js), do NOT use CSS `background-image`
142
- - If not in `imageMap` → render normally using div + Tailwind classes
149
+ - If not in `imageMap` → render normally using div + styling classes
143
150
 
144
151
  React/Next.js template for image node:
145
152
  ```tsx
@@ -197,6 +204,57 @@ export const [ComponentName] = ({ className }: [ComponentName]Props) => {
197
204
  };
198
205
  ```
199
206
 
207
+ #### Next.js App Router component template:
208
+
209
+ Default to **Server Component**. Add `'use client'` only when the design has
210
+ interactive states (hover effects, click handlers, form inputs, modals).
211
+
212
+ ```tsx
213
+ // Server Component — no interactivity (default)
214
+ interface [ComponentName]Props {
215
+ className?: string;
216
+ }
217
+
218
+ export default async function [ComponentName]({ className }: [ComponentName]Props) {
219
+ return (
220
+ <div className={cn(
221
+ // Layout classes
222
+ // Sizing classes
223
+ // Color classes
224
+ className
225
+ )}>
226
+ {/* Child nodes */}
227
+ </div>
228
+ );
229
+ }
230
+ ```
231
+
232
+ ```tsx
233
+ // Client Component — has onClick / useState / useEffect
234
+ 'use client'
235
+
236
+ import { useState } from 'react'
237
+
238
+ interface [ComponentName]Props {
239
+ className?: string;
240
+ }
241
+
242
+ export function [ComponentName]({ className }: [ComponentName]Props) {
243
+ return (
244
+ <div className={cn(
245
+ // Layout classes
246
+ // Sizing classes
247
+ // Color classes
248
+ className
249
+ )}>
250
+ {/* Child nodes */}
251
+ </div>
252
+ );
253
+ }
254
+ ```
255
+
256
+ File path: `app/components/[ComponentName].tsx` or `components/[ComponentName].tsx`
257
+
200
258
  #### Vue 3 component template:
201
259
 
202
260
  ```vue
@@ -221,6 +279,40 @@ const props = withDefaults(defineProps<Props>(), {});
221
279
  </template>
222
280
  ```
223
281
 
282
+ #### Angular component template:
283
+
284
+ Use Tailwind classes if `tailwind.config.*` exists in the project root.
285
+ Otherwise use `styles` array with CSS-in-component.
286
+
287
+ ```typescript
288
+ import { Component, Input } from '@angular/core';
289
+ import { CommonModule } from '@angular/common';
290
+
291
+ @Component({
292
+ selector: 'app-[component-name]',
293
+ standalone: true,
294
+ imports: [CommonModule],
295
+ template: `
296
+ <div [class]="hostClasses">
297
+ <!-- Child nodes -->
298
+ </div>
299
+ `,
300
+ styles: []
301
+ })
302
+ export class [ComponentName]Component {
303
+ @Input() className = '';
304
+
305
+ get hostClasses(): string {
306
+ return [
307
+ // Layout classes
308
+ // Sizing classes
309
+ // Color classes
310
+ this.className
311
+ ].filter(Boolean).join(' ');
312
+ }
313
+ }
314
+ ```
315
+
224
316
  ### Step 5: Handle interactive states
225
317
 
226
318
  If Figma has variants (Default, Hover, Disabled, Active):
@@ -245,14 +337,14 @@ const variantClasses = {
245
337
  After generation, verify:
246
338
 
247
339
  - [ ] Layout matches Figma (flex direction, alignment, gap)
248
- - [ ] Colors mapping correct (or use arbitrary values if no Tailwind match)
340
+ - [ ] Colors mapping correct (project tokens, or arbitrary values if no match)
249
341
  - [ ] Typography correct (size, weight, line-height)
250
342
  - [ ] Spacing correct (padding, margin, gap)
251
343
  - [ ] Component has `className` prop for external overrides
252
- - [ ] Use `cn()` helper for conditional/mergeable classes
344
+ - [ ] Conditional/mergeable classes use the project's helper (`cn()` for Tailwind)
253
345
  - [ ] Responsive if Figma has mobile frames
254
346
  - [ ] Props typed with TypeScript interface
255
- - [ ] Image nodes use `<img>` tag (do not use CSS `background-image`)
347
+ - [ ] Image nodes use `<img>` / `<Image>` (do not use CSS `background-image`)
256
348
  - [ ] Image files exist in `public/assets/figma/` before submitting code
257
349
 
258
350
  ---
@@ -273,9 +365,9 @@ Always output in order:
273
365
 
274
366
  ## Rules
275
367
 
276
- - **Do not hardcode** hex colors directly into className if a Tailwind equivalent exists
277
- - **Always use** `cn()` (clsx + twMerge) to merge classes
278
- - **No new CSS imports** use Tailwind utilities only
368
+ - **Detect styling tooling first** do not assume Tailwind; honour CSS Modules / styled-components / vanilla CSS when detected
369
+ - **Prefer design tokens** map Figma Styles/Variables to project tokens; only hardcode a value when no token matches
370
+ - **Always use** the project's class-merge helper (`cn()` = clsx + twMerge for Tailwind)
279
371
  - **Responsive** — if Figma only has 1 breakpoint, default to mobile-first design
280
372
  - **Accessibility** — add `aria-label`, `role`, `alt` for interactive and image elements
281
373
  - **Image** — detect image fills in Figma node data, export via `download_figma_images` MCP, save to `public/assets/figma/`. Use `<Image>` (Next.js) or `<img>` (React/Vue) with `src` pointing to the exported file. Do NOT use CSS `background-image` for image nodes.
@@ -283,6 +375,19 @@ Always output in order:
283
375
 
284
376
  ---
285
377
 
378
+ ## Troubleshooting
379
+
380
+ | Symptom | Cause | Fix |
381
+ |---------|-------|-----|
382
+ | `mcp__figma__get_figma_data` not available | Figma MCP server not connected | Run `aiflow init -a figma` or `-a figma-desktop`, restart session |
383
+ | `403 Forbidden` / token rejected | PAT invalid or wrong header | Re-issue a `figd_...` token; `init` sends `X-Figma-Token` (not `Bearer`) |
384
+ | Tool call hangs / times out | Large node tree (`depth` too high) | Lower `depth` (e.g. `depth=1`), target a specific `nodeId` not the whole file |
385
+ | `404` on node | Wrong `fileKey`/`nodeId` | Re-copy the frame URL; node-id uses `-` in URL but `:` in API |
386
+ | Empty fills / no styles | Node is a component instance | Fetch the main component, or increase `depth` |
387
+ | `download_figma_images` unsupported | Older MCP preset | Get image URL via `get_figma_data`, download manually to `public/assets/figma/` |
388
+
389
+ ---
390
+
286
391
  ## Trigger Example Commands
287
392
 
288
393
  ```
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: frame-ml-problem
3
+ description: Frame an ML problem before any modeling — define the prediction target, the correct evaluation metric, a baseline, and the success threshold.
4
+ keywords: ml, problem framing, metric, baseline, target, success criteria
5
+ ---
6
+
7
+ # Frame ML Problem
8
+
9
+ > This skill **inherits and extends** `superpowers:brainstorming` for collaborative Q&A.
10
+ > First, invoke `superpowers:brainstorming` to explore intent and ambiguities with the developer,
11
+ > then apply the structured framing steps below.
12
+
13
+ ---
14
+
15
+ ## When to use this skill
16
+
17
+ - Gate 1 of the ML workflow — always the first step before any modeling
18
+ - Any new ML ticket where the prediction target or success criterion is not yet explicit
19
+ - Whenever the evaluation metric has not been pinned down or justified against the business goal
20
+
21
+ ---
22
+
23
+ ## Steps
24
+
25
+ ### 1. Read the ticket context
26
+
27
+ Read `.aiflow/context/current.json`:
28
+ - `description` — what the stakeholder wants the model to do
29
+ - `comments` — additional context, constraints, or prior attempts
30
+ - `context.files` — related notebooks, data samples, or prior model artifacts
31
+
32
+ ### 2. State the prediction target precisely
33
+
34
+ Define what is being predicted, at what granularity (row level, user level, session level, etc.), and crucially **when the input features are available** relative to the prediction moment. Guard against accidentally incorporating future information — any feature computed from or derived after the target event is a candidate for leakage.
35
+
36
+ ### 3. Classify the problem type
37
+
38
+ Explicitly label the task:
39
+ - **Classification** (binary or multi-class): predict a category
40
+ - **Regression**: predict a continuous value
41
+ - **Ranking / Recommendation**: order items by relevance
42
+ - **Generation / Seq-to-seq**: produce text, code, or structured output
43
+ - **Clustering / Anomaly detection**: unsupervised grouping or outlier detection
44
+
45
+ State the type before choosing any model family or metric.
46
+
47
+ ### 4. Choose the evaluation metric and justify it
48
+
49
+ Select the primary metric and tie it explicitly to the business goal:
50
+ - Imbalanced classification: prefer F1, PR-AUC, or recall at fixed precision over plain accuracy
51
+ - Regression: choose MAE (robust to outliers) vs RMSE (penalises large errors) deliberately
52
+ - Ranking: use MAP, NDCG, or MRR depending on position sensitivity
53
+ - Note the difference between the **offline proxy metric** (what can be measured from historical data) and the **online KPI** (what the business ultimately cares about); acknowledge any gap
54
+
55
+ **State the metric before any modeling begins. It must not change after training.**
56
+
57
+ ### 5. Define a baseline and success threshold
58
+
59
+ - **Baseline:** the simplest defensible reference — majority-class prediction, median value, current rule-based system, or the model already in production
60
+ - **Success threshold:** the quantitative improvement over baseline that is meaningful to the business (e.g. "+3 pp F1 on the held-out set" or "<10 ms p99 latency with no accuracy regression")
61
+ - A threshold of "as high as possible" is not acceptable — make it concrete
62
+
63
+ ### 6. List constraints
64
+
65
+ Document non-negotiable constraints that shape model choice and architecture:
66
+ - **Latency / throughput:** real-time vs batch; maximum inference time
67
+ - **Memory / hardware:** CPU-only, GPU budget, edge deployment
68
+ - **Interpretability:** regulatory or stakeholder requirements for explanations
69
+ - **Data volume:** row count, feature count, labelling cost
70
+ - **Compliance:** PII handling, data residency, auditability requirements
71
+
72
+ ### 7. Ask one clarifying question at a time when ambiguous
73
+
74
+ If any of the above cannot be answered from the ticket, ask exactly **one question**, wait for a reply, and continue. Do not bundle multiple questions.
75
+
76
+ ---
77
+
78
+ ## Completion Checklist
79
+
80
+ - [ ] Ticket context read (description + comments + related files)
81
+ - [ ] Prediction target defined with the exact availability time of input features
82
+ - [ ] Problem type classified (classification / regression / ranking / generation / clustering)
83
+ - [ ] Evaluation metric chosen and justified against the business goal
84
+ - [ ] Offline proxy metric vs online KPI gap acknowledged
85
+ - [ ] Baseline defined (majority class, heuristic, or current production model)
86
+ - [ ] Success threshold quantified (not "as high as possible")
87
+ - [ ] Constraints listed (latency, memory, interpretability, data volume, compliance)
88
+ - [ ] Findings written to `plan/[ticket-id]/ml-problem.md`
File without changes
File without changes
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: improve-algorithm
3
+ description: Systematically improve an existing model or algorithm — profile, hypothesize, ablate, and measure accuracy/latency/memory. No guessing.
4
+ keywords: optimization, algorithm, performance, latency, accuracy, ablation, profiling
5
+ ---
6
+
7
+ # Improve Algorithm
8
+
9
+ > This skill inherits the discipline of `superpowers:systematic-debugging` — measure before changing, change one thing at a time, measure again. Guessing is not a method; every change must be motivated by evidence from profiling or error analysis.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 3, for tickets specifically about improving an existing model or algorithm (accuracy, latency, or memory targets)
16
+ - Any time a model already exists and the goal is to make it better rather than build from scratch
17
+ - When performance regressions are reported in production
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Establish the current baseline
24
+
25
+ Run the existing system through the eval harness and record the exact number — metric, split, and seed. This is the floor that every proposed change must be measured against. If no eval harness exists yet, invoke `train-model` first to establish one.
26
+
27
+ ### 2. Profile before optimizing
28
+
29
+ Do not form a hypothesis before you know where the bottleneck is.
30
+
31
+ - **Accuracy bottleneck:** run error analysis by slice and by class. Plot learning curves to distinguish bias (underfitting — train error high) from variance (overfitting — large train/val gap). Identify the failure pattern first.
32
+ - **Latency/memory bottleneck:** profile the hot path end-to-end. Tools: `cProfile` / `line_profiler` for Python; `torch.profiler` or `torch.autograd.profiler` for PyTorch; `tf.profiler` for TF. Measure throughput (samples/sec) and peak memory before and after every change.
33
+
34
+ Never skip this step. Optimizing the wrong part wastes time and can introduce regressions.
35
+
36
+ ### 3. Form ONE hypothesis
37
+
38
+ Based on the profiling/error-analysis evidence, form exactly one hypothesis tied to the identified bottleneck. Examples:
39
+
40
+ - "Error analysis shows the model fails on short-text inputs → hypothesis: adding n-gram features reduces error on that slice"
41
+ - "Profiler shows 60% of latency in the preprocessing step → hypothesis: vectorizing the transform halves latency"
42
+ - "Learning curves show high variance → hypothesis: stronger L2 regularization closes the train/val gap"
43
+
44
+ State the hypothesis explicitly before writing any code.
45
+
46
+ ### 4. Run a single ablation
47
+
48
+ Implement only the change implied by the hypothesis. Run the eval harness with the same seed, same split, same data version. Track the run in MLflow/wandb with a descriptive name and note the hypothesis in the run description. Compare to the baseline number directly.
49
+
50
+ ### 5. Decide: keep or revert
51
+
52
+ Keep the change only if it:
53
+
54
+ - Beats the baseline meaningfully (respects the success threshold from Gate 1)
55
+ - Respects all constraints: accuracy/latency/memory trade-off stated explicitly
56
+ - Does not introduce a new regression in a different slice or metric
57
+
58
+ Revert if it does not satisfy the above. Log the failure reason; failed experiments are also information.
59
+
60
+ ### 6. Repeat and document
61
+
62
+ Repeat steps 3–5 for the next bottleneck. Log every attempt — including reversions — so the improvement story is fully reproducible. The final state must be explainable: "we tried X (failed because Y), then tried Z (improved metric by W%)."
63
+
64
+ ---
65
+
66
+ ## Completion Checklist
67
+
68
+ - [ ] Baseline number recorded on the eval harness before any change
69
+ - [ ] Bottleneck identified by profiling (latency/memory) or error analysis (accuracy) — not guessed
70
+ - [ ] Each change is a single isolated ablation motivated by a stated hypothesis
71
+ - [ ] Every attempt (including failures) measured on the same harness and tracked with params/metrics
72
+ - [ ] Trade-offs between accuracy, latency, and memory stated explicitly for kept changes
73
+ - [ ] Kept changes beat the baseline by the success threshold
74
+ - [ ] Full improvement log available (hypothesis → result → decision for each attempt)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: train-model
3
+ description: Reproducible model training — eval-harness-first, fixed seeds, pinned environment, logged configs, checkpointing, experiment tracking.
4
+ keywords: training, reproducibility, seed, checkpoint, mlflow, wandb, fine-tune
5
+ ---
6
+
7
+ # Train Model
8
+
9
+ > **Eval-harness-first is the ML analog of `superpowers:test-driven-development`** — build the metric/eval harness and a reproducible baseline BEFORE writing any model improvement code. If the harness does not run clean, stop and fix it first.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 3 of the ML workflow, after the experiment plan has been APPROVED
16
+ - Any time a new model or training run is initiated
17
+ - Fine-tuning or transfer-learning tasks where reproducibility is critical
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Eval-harness-first
24
+
25
+ Implement the metric function and the validation loop as defined in the approved experiment plan. Run it against the baseline (majority class, heuristic, or current production model). Confirm you get a reproducible number before touching any model code. This number is the target to beat.
26
+
27
+ ### 2. Enforce reproducibility
28
+
29
+ Set all random seeds at the top of every training script:
30
+
31
+ - `random.seed(seed)` and `numpy.random.seed(seed)`
32
+ - Framework seed: `torch.manual_seed(seed)` + `torch.cuda.manual_seed_all(seed)` for PyTorch; `tf.random.set_seed(seed)` for TF/Keras
33
+ - Enable deterministic ops where feasible (`torch.use_deterministic_algorithms(True)`)
34
+
35
+ Pin the environment: `requirements.txt` or a lockfile (`pip freeze > requirements.txt`). No floating version ranges in the pinned file.
36
+
37
+ ### 3. Config over hardcoding
38
+
39
+ Place all hyperparameters (learning rate, batch size, number of layers, regularization strength, etc.) in a YAML, Hydra config, or argparse definition — never as literals in the training script. This ensures any run can be exactly reproduced from its config file alone.
40
+
41
+ ### 4. Experiment tracking
42
+
43
+ Log the following to MLflow or wandb for every run:
44
+
45
+ - All hyperparameters (from config)
46
+ - Metric per epoch / per fold
47
+ - Seed, data version (DVC hash or path), and git commit SHA
48
+ - Run name following the naming convention in `custom/rules/ml-conventions.md`: `[ticket-id]_[approach]_[yyyymmdd-n]`
49
+
50
+ Do not leave runs unnamed or untracked.
51
+
52
+ ### 5. Checkpointing
53
+
54
+ Save the best checkpoint by the primary validation metric (not the final epoch). Store the config file alongside the artifact so the checkpoint is self-contained. Use the model registry (MLflow Model Registry or equivalent) when available.
55
+
56
+ ### 6. Framework-specific considerations
57
+
58
+ - **scikit-learn:** wrap preprocessing + model in a single `Pipeline` so transforms are fitted on training data only — never on the full dataset.
59
+ - **PyTorch:** seed `DataLoader` workers (`worker_init_fn`), toggle `model.train()` before training and `model.eval()` before validation/inference. Use `torch.no_grad()` for inference.
60
+ - **TF/Keras:** use callbacks for `ModelCheckpoint` (save best) and `EarlyStopping`; set `tf.config.experimental.enable_op_determinism()` if needed.
61
+ - **Fine-tuning:** apply a freeze/unfreeze schedule; use LR warmup before unfreezing. Log the freeze schedule as a config parameter.
62
+
63
+ ### 7. Iterate per the ablation plan
64
+
65
+ Follow the ablation plan from the experiment design — change exactly one factor per run, track it, compare to the established baseline on the same harness. Do not run ad-hoc experiments that are not tracked or not comparable.
66
+
67
+ ---
68
+
69
+ ## Completion Checklist
70
+
71
+ - [ ] Eval harness implemented and confirmed running on baseline before any model change
72
+ - [ ] Reproducible baseline number recorded
73
+ - [ ] All random seeds set (language, numpy, framework, CUDA)
74
+ - [ ] Environment pinned (requirements.txt or lockfile committed)
75
+ - [ ] All hyperparameters in a config file — no literals in training code
76
+ - [ ] Every run tracked with params, metrics, seed, data version, and git commit
77
+ - [ ] Best checkpoint saved with its config alongside the artifact
78
+ - [ ] Experiments follow the ablation plan (one change at a time)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes