@relipa/ai-flow-kit 0.1.0-beta.0 → 0.1.1-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 (236) hide show
  1. package/README.md +497 -497
  2. package/bin/aiflow.js +525 -525
  3. package/bin/ak.js +0 -0
  4. package/custom/mcp-presets/README.md +0 -0
  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/naming.md +0 -0
  22. package/custom/rules/php/code-style.md +0 -0
  23. package/custom/rules/php/naming.md +0 -0
  24. package/custom/rules/project-conventions.md +0 -0
  25. package/custom/rules/review-checklist.md +0 -0
  26. package/custom/skills/figma-to-component/SKILL.md +294 -207
  27. package/custom/skills/generate-spec/SKILL.md +0 -0
  28. package/custom/skills/impact-analysis/SKILL.md +0 -0
  29. package/custom/skills/investigate-bug/SKILL.md +0 -0
  30. package/custom/skills/read-study-requirement/SKILL.md +334 -334
  31. package/custom/skills/report-customer/SKILL.md +0 -0
  32. package/custom/skills/review-plan/SKILL.md +0 -0
  33. package/custom/templates/laravel.md +0 -0
  34. package/custom/templates/nestjs.md +0 -0
  35. package/custom/templates/nextjs.md +0 -0
  36. package/custom/templates/nodejs-express.md +0 -0
  37. package/custom/templates/php-plain.md +0 -0
  38. package/custom/templates/php.md +0 -0
  39. package/custom/templates/python-django.md +0 -0
  40. package/custom/templates/python-fastapi.md +0 -0
  41. package/custom/templates/python.md +0 -0
  42. package/custom/templates/reactjs.md +0 -0
  43. package/custom/templates/shared/gate-workflow.md +91 -91
  44. package/custom/templates/spring-boot.md +0 -0
  45. package/custom/templates/tools/claude.md +0 -0
  46. package/custom/templates/tools/copilot.md +0 -0
  47. package/custom/templates/tools/cursor.md +0 -0
  48. package/custom/templates/tools/gemini.md +0 -0
  49. package/custom/templates/tools/generic.md +0 -0
  50. package/custom/templates/vue-nuxt.md +0 -0
  51. package/docs/common/AIFLOW.md +0 -0
  52. package/docs/common/CHANGELOG.md +334 -334
  53. package/docs/common/QUICK_START.md +537 -537
  54. package/docs/common/ai-integration.md +0 -0
  55. package/docs/common/cli-reference.md +657 -657
  56. package/docs/common/configuration.md +0 -0
  57. package/docs/common/getting-started.md +0 -0
  58. package/docs/common/troubleshooting.md +0 -0
  59. package/docs/common/workflows/bug-fix.md +0 -0
  60. package/docs/common/workflows/feature.md +0 -0
  61. package/docs/common/workflows/figma.md +0 -0
  62. package/docs/common/workflows/impact-analysis.md +0 -0
  63. package/docs/common/workflows/investigation.md +0 -0
  64. package/docs/common/workflows/refactor.md +0 -0
  65. package/docs/project/ARCHITECTURE.md +0 -0
  66. package/index.js +0 -0
  67. package/package.json +68 -67
  68. package/scripts/checkpoint.js +0 -0
  69. package/scripts/config.js +0 -0
  70. package/scripts/context.js +0 -0
  71. package/scripts/create-score-excel.js +0 -0
  72. package/scripts/detect.js +0 -0
  73. package/scripts/doctor.js +26 -0
  74. package/scripts/gitnexus-worker.js +0 -0
  75. package/scripts/guide.js +314 -314
  76. package/scripts/hooks/block-git-write.js +0 -0
  77. package/scripts/hooks/session-start.js +315 -315
  78. package/scripts/hooks/session-stop.js +0 -0
  79. package/scripts/init.js +0 -0
  80. package/scripts/link-resolver.js +0 -0
  81. package/scripts/memory.js +0 -0
  82. package/scripts/prompt.js +95 -9
  83. package/scripts/remove.js +0 -0
  84. package/scripts/score_members.js +320 -0
  85. package/scripts/task.js +0 -0
  86. package/scripts/telemetry/cli.js +0 -0
  87. package/scripts/telemetry/config.js +0 -0
  88. package/scripts/telemetry/crypto.js +0 -0
  89. package/scripts/telemetry/flush.js +0 -0
  90. package/scripts/telemetry/record.js +0 -0
  91. package/scripts/update.js +0 -0
  92. package/scripts/use.js +1162 -1162
  93. package/scripts/validate.js +0 -0
  94. package/upstream/.claude-plugin/marketplace.json +0 -0
  95. package/upstream/.claude-plugin/plugin.json +0 -0
  96. package/upstream/.codex/INSTALL.md +0 -0
  97. package/upstream/.cursor-plugin/plugin.json +0 -0
  98. package/upstream/.gitattributes +0 -0
  99. package/upstream/.github/FUNDING.yml +0 -0
  100. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  101. package/upstream/.github/ISSUE_TEMPLATE/config.yml +0 -0
  102. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  103. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +0 -0
  104. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  105. package/upstream/.opencode/INSTALL.md +0 -0
  106. package/upstream/.opencode/plugins/superpowers.js +0 -0
  107. package/upstream/.version-bump.json +0 -0
  108. package/upstream/AGENTS.md +0 -0
  109. package/upstream/CHANGELOG.md +0 -0
  110. package/upstream/CLAUDE.md +0 -0
  111. package/upstream/CODE_OF_CONDUCT.md +0 -0
  112. package/upstream/GEMINI.md +0 -0
  113. package/upstream/LICENSE +0 -0
  114. package/upstream/README.md +0 -0
  115. package/upstream/RELEASE-NOTES.md +0 -0
  116. package/upstream/agents/code-reviewer.md +0 -0
  117. package/upstream/commands/brainstorm.md +0 -0
  118. package/upstream/commands/execute-plan.md +0 -0
  119. package/upstream/commands/write-plan.md +0 -0
  120. package/upstream/docs/README.codex.md +0 -0
  121. package/upstream/docs/README.opencode.md +0 -0
  122. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +0 -0
  123. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +0 -0
  124. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +0 -0
  125. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +0 -0
  126. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +0 -0
  127. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +0 -0
  128. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +0 -0
  129. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +0 -0
  130. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +0 -0
  131. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +0 -0
  132. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +0 -0
  133. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +0 -0
  134. package/upstream/docs/testing.md +0 -0
  135. package/upstream/docs/windows/polyglot-hooks.md +0 -0
  136. package/upstream/gemini-extension.json +0 -0
  137. package/upstream/hooks/hooks-cursor.json +0 -0
  138. package/upstream/hooks/hooks.json +0 -0
  139. package/upstream/hooks/run-hook.cmd +0 -0
  140. package/upstream/hooks/session-start +0 -0
  141. package/upstream/package.json +0 -0
  142. package/upstream/scripts/bump-version.sh +0 -0
  143. package/upstream/skills/brainstorming/SKILL.md +0 -0
  144. package/upstream/skills/brainstorming/scripts/frame-template.html +0 -0
  145. package/upstream/skills/brainstorming/scripts/helper.js +0 -0
  146. package/upstream/skills/brainstorming/scripts/server.cjs +0 -0
  147. package/upstream/skills/brainstorming/scripts/start-server.sh +0 -0
  148. package/upstream/skills/brainstorming/scripts/stop-server.sh +0 -0
  149. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +0 -0
  150. package/upstream/skills/brainstorming/visual-companion.md +0 -0
  151. package/upstream/skills/dispatching-parallel-agents/SKILL.md +0 -0
  152. package/upstream/skills/executing-plans/SKILL.md +0 -0
  153. package/upstream/skills/finishing-a-development-branch/SKILL.md +0 -0
  154. package/upstream/skills/receiving-code-review/SKILL.md +0 -0
  155. package/upstream/skills/requesting-code-review/SKILL.md +0 -0
  156. package/upstream/skills/requesting-code-review/code-reviewer.md +0 -0
  157. package/upstream/skills/subagent-driven-development/SKILL.md +0 -0
  158. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
  159. package/upstream/skills/subagent-driven-development/implementer-prompt.md +0 -0
  160. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +0 -0
  161. package/upstream/skills/systematic-debugging/CREATION-LOG.md +0 -0
  162. package/upstream/skills/systematic-debugging/SKILL.md +0 -0
  163. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +0 -0
  164. package/upstream/skills/systematic-debugging/condition-based-waiting.md +0 -0
  165. package/upstream/skills/systematic-debugging/defense-in-depth.md +0 -0
  166. package/upstream/skills/systematic-debugging/find-polluter.sh +0 -0
  167. package/upstream/skills/systematic-debugging/root-cause-tracing.md +0 -0
  168. package/upstream/skills/systematic-debugging/test-academic.md +0 -0
  169. package/upstream/skills/systematic-debugging/test-pressure-1.md +0 -0
  170. package/upstream/skills/systematic-debugging/test-pressure-2.md +0 -0
  171. package/upstream/skills/systematic-debugging/test-pressure-3.md +0 -0
  172. package/upstream/skills/tdd-lean/SKILL.md +0 -0
  173. package/upstream/skills/test-driven-development/SKILL.md +0 -0
  174. package/upstream/skills/test-driven-development/testing-anti-patterns.md +0 -0
  175. package/upstream/skills/using-git-worktrees/SKILL.md +0 -0
  176. package/upstream/skills/using-superpowers/SKILL.md +0 -0
  177. package/upstream/skills/using-superpowers/references/codex-tools.md +0 -0
  178. package/upstream/skills/using-superpowers/references/copilot-tools.md +0 -0
  179. package/upstream/skills/using-superpowers/references/gemini-tools.md +0 -0
  180. package/upstream/skills/verification-before-completion/SKILL.md +0 -0
  181. package/upstream/skills/writing-plans/SKILL.md +0 -0
  182. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +0 -0
  183. package/upstream/skills/writing-skills/SKILL.md +0 -0
  184. package/upstream/skills/writing-skills/anthropic-best-practices.md +0 -0
  185. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -0
  186. package/upstream/skills/writing-skills/graphviz-conventions.dot +0 -0
  187. package/upstream/skills/writing-skills/persuasion-principles.md +0 -0
  188. package/upstream/skills/writing-skills/render-graphs.js +0 -0
  189. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +0 -0
  190. package/upstream/tests/brainstorm-server/package-lock.json +0 -0
  191. package/upstream/tests/brainstorm-server/package.json +0 -0
  192. package/upstream/tests/brainstorm-server/server.test.js +0 -0
  193. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +0 -0
  194. package/upstream/tests/brainstorm-server/ws-protocol.test.js +0 -0
  195. package/upstream/tests/claude-code/README.md +0 -0
  196. package/upstream/tests/claude-code/analyze-token-usage.py +0 -0
  197. package/upstream/tests/claude-code/run-skill-tests.sh +0 -0
  198. package/upstream/tests/claude-code/test-document-review-system.sh +0 -0
  199. package/upstream/tests/claude-code/test-helpers.sh +0 -0
  200. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +0 -0
  201. package/upstream/tests/claude-code/test-subagent-driven-development.sh +0 -0
  202. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +0 -0
  203. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +0 -0
  204. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +0 -0
  205. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +0 -0
  206. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +0 -0
  207. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +0 -0
  208. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +0 -0
  209. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +0 -0
  210. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +0 -0
  211. package/upstream/tests/explicit-skill-requests/run-all.sh +0 -0
  212. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +0 -0
  213. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +0 -0
  214. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +0 -0
  215. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +0 -0
  216. package/upstream/tests/explicit-skill-requests/run-test.sh +0 -0
  217. package/upstream/tests/opencode/run-tests.sh +0 -0
  218. package/upstream/tests/opencode/setup.sh +0 -0
  219. package/upstream/tests/opencode/test-plugin-loading.sh +0 -0
  220. package/upstream/tests/opencode/test-priority.sh +0 -0
  221. package/upstream/tests/opencode/test-tools.sh +0 -0
  222. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +0 -0
  223. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +0 -0
  224. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +0 -0
  225. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +0 -0
  226. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +0 -0
  227. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +0 -0
  228. package/upstream/tests/skill-triggering/run-all.sh +0 -0
  229. package/upstream/tests/skill-triggering/run-test.sh +0 -0
  230. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +0 -0
  231. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +0 -0
  232. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +0 -0
  233. package/upstream/tests/subagent-driven-dev/run-test.sh +0 -0
  234. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +0 -0
  235. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +0 -0
  236. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +0 -0
package/bin/ak.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,207 +1,294 @@
1
- ---
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
5
- ---
6
-
7
- # Figma to Component
8
-
9
- ## When to use
10
-
11
- - Received a Figma link from a designer and need to generate a component
12
- - Designer has approved the UI, developer starts implementation
13
- - Need to ensure pixel-perfect matching with the design
14
-
15
- ---
16
-
17
- ## Process
18
-
19
- ### Step 1: Identify input
20
-
21
- Receive one of the following from the user:
22
- - Figma URL frame: `https://www.figma.com/design/<fileKey>/...?node-id=<nodeId>`
23
- - Figma URL file: `https://www.figma.com/design/<fileKey>/...`
24
- - Node description: "UserCard component in file ABC"
25
-
26
- Extract `fileKey` and `nodeId` from the URL.
27
-
28
- ### Step 2: Read design via Figma MCP
29
-
30
- Use Figma MCP tools to fetch design information:
31
-
32
- ```
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)
37
- ```
38
-
39
- Analyze the output to extract:
40
- - **Layout**: flexbox direction, gap, padding, alignment
41
- - **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
47
- - **States**: hover, focus, disabled, active (if variants present)
48
- - **Responsive**: breakpoints if multiple frames present
49
-
50
- ### Step 3: Map Figma tokens → Tailwind / CSS
51
-
52
- **Color mapping:**
53
- ```
54
- Figma hex #3B82F6 → Tailwind blue-500
55
- Figma hex #EF4444Tailwind red-500
56
- Figma rgba(0,0,0,0.5) → Tailwind black/50
57
- No Tailwind matchuse arbitrary value [#hexcode]
58
- ```
59
-
60
- **Spacing mapping (8px grid):**
61
- ```
62
- 4px → p-1 / gap-1
63
- 8px → p-2 / gap-2
64
- 12px → p-3 / gap-3
65
- 16px → p-4 / gap-4
66
- 24px → p-6 / gap-6
67
- 32px p-8 / gap-8
68
- No match → arbitrary value [20px]
69
- ```
70
-
71
- **Typography mapping:**
72
- ```
73
- text-xs: 12px
74
- text-sm: 14px
75
- text-base: 16px
76
- text-lg: 18px
77
- text-xl: 20px
78
- text-2xl: 24px
79
- text-3xl: 30px
80
- font-normal: 400
81
- font-medium: 500
82
- font-semibold: 600
83
- font-bold: 700
84
- ```
85
-
86
- ### Step 4: Generate component
87
-
88
- **Framework detection** — check the project's CLAUDE.md to determine the framework:
89
- - `reactjs` / `nextjs` → generate `.tsx` with React conventions
90
- - `vue-nuxt` → generate `.vue` with Vue 3 Composition API
91
-
92
- #### React/Next.js component template:
93
-
94
- ```tsx
95
- interface [ComponentName]Props {
96
- // Props extracted from Figma variants or dynamic content slots
97
- className?: string;
98
- }
99
-
100
- export const [ComponentName] = ({ className }: [ComponentName]Props) => {
101
- return (
102
- <div className={cn(
103
- // Layout classes
104
- // Sizing classes
105
- // Color classes
106
- // Typography classes (if text node)
107
- className
108
- )}>
109
- {/* Child nodes rendered recursively */}
110
- </div>
111
- );
112
- };
113
- ```
114
-
115
- #### Vue 3 component template:
116
-
117
- ```vue
118
- <script setup lang="ts">
119
- interface Props {
120
- // Props extracted from Figma variants
121
- class?: string;
122
- }
123
-
124
- const props = withDefaults(defineProps<Props>(), {});
125
- </script>
126
-
127
- <template>
128
- <div :class="cn(
129
- // Layout classes
130
- // Sizing classes
131
- // Color classes
132
- props.class
133
- )">
134
- <!-- Child nodes -->
135
- </div>
136
- </template>
137
- ```
138
-
139
- ### Step 5: Handle interactive states
140
-
141
- If Figma has variants (Default, Hover, Disabled, Active):
142
-
143
- ```tsx
144
- // Map variants into props + conditional classes
145
- interface ButtonProps {
146
- variant?: 'primary' | 'secondary' | 'outline';
147
- size?: 'sm' | 'md' | 'lg';
148
- disabled?: boolean;
149
- }
150
-
151
- const variantClasses = {
152
- primary: 'bg-blue-600 text-white hover:bg-blue-700',
153
- secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
154
- outline: 'border border-gray-300 hover:bg-gray-50',
155
- };
156
- ```
157
-
158
- ### Step 6: Verify and output
159
-
160
- After generation, verify:
161
-
162
- - [ ] Layout matches Figma (flex direction, alignment, gap)
163
- - [ ] Colors mapping correct (or use arbitrary values if no Tailwind match)
164
- - [ ] Typography correct (size, weight, line-height)
165
- - [ ] Spacing correct (padding, margin, gap)
166
- - [ ] Component has `className` prop for external overrides
167
- - [ ] Use `cn()` helper for conditional/mergeable classes
168
- - [ ] Responsive if Figma has mobile frames
169
- - [ ] Props typed with TypeScript interface
170
-
171
- ---
172
-
173
- ## Output format
174
-
175
- Always output in order:
176
-
177
- 1. **Design Summary** (brief): layout structure, color palette, typography scale
178
- 2. **Component file** with full code
179
- 3. **Usage example**:
180
- ```tsx
181
- <ComponentName variant="primary" className="mt-4" />
182
- ```
183
- 4. **Notes** if anything cannot be mapped 100% accurately from Figma
184
-
185
- ---
186
-
187
- ## Rules
188
-
189
- - **Do not hardcode** hex colors directly into className if a Tailwind equivalent exists
190
- - **Always use** `cn()` (clsx + twMerge) to merge classes
191
- - **No new CSS imports** — use Tailwind utilities only
192
- - **Responsive** — if Figma only has 1 breakpoint, default to mobile-first design
193
- - **Accessibility** — add `aria-label`, `role`, `alt` for interactive and image elements
194
- - **Image** use `next/image` for Next.js, `<img>` for React, add `alt` from Figma layer name
195
- - **Icon** — if Figma uses SVG icons, extract SVG or map to lucide-react / heroicons
196
-
197
- ---
198
-
199
- ## Trigger Example Commands
200
-
201
- ```
202
- Read Figma and generate component: https://www.figma.com/design/xxxxx/App?node-id=123-456
203
-
204
- Generate UserCard component from Figma frame node-id=123-456
205
-
206
- Implement UI from this Figma link following my project: [URL]
207
- ```
1
+ ---
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
5
+ ---
6
+
7
+ # Figma to Component
8
+
9
+ ## When to use
10
+
11
+ - Received a Figma link from a designer and need to generate a component
12
+ - Designer has approved the UI, developer starts implementation
13
+ - Need to ensure pixel-perfect matching with the design
14
+
15
+ ---
16
+
17
+ ## Process
18
+
19
+ ### Step 1: Identify input
20
+
21
+ Receive one of the following from the user:
22
+ - Figma URL frame: `https://www.figma.com/design/<fileKey>/...?node-id=<nodeId>`
23
+ - Figma URL file: `https://www.figma.com/design/<fileKey>/...`
24
+ - Node description: "UserCard component in file ABC"
25
+
26
+ Extract `fileKey` and `nodeId` from the URL.
27
+
28
+ ### Step 2: Read design via Figma MCP
29
+
30
+ Use Figma MCP tools to fetch design information:
31
+
32
+ ```
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)
37
+ ```
38
+
39
+ Analyze the output to extract:
40
+ - **Layout**: flexbox direction, gap, padding, alignment
41
+ - **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
47
+ - **States**: hover, focus, disabled, active (if variants present)
48
+ - **Responsive**: breakpoints if multiple frames present
49
+
50
+ ### Step 2.5: Image Detection & Export
51
+
52
+ After receiving node data from Step 2, scan the entire node tree to detect image nodes:
53
+
54
+ **Detect image nodes:**
55
+ - Node has a `fills` array containing at least 1 fill with `type === "IMAGE"` this is an image node
56
+ - Node is a frame/group containing many complex layers (icon, illustration, banner) that cannot be recreated with CSS needs image export
57
+ - Node has `type === "VECTOR"` or `type === "BOOLEAN_OPERATION"` always export as SVG/PNG
58
+
59
+ **Export images via MCP:**
60
+
61
+ For each detected image node, call MCP tool `download_figma_images`:
62
+
63
+ ```
64
+ download_figma_images({
65
+ fileKey: "<fileKey>",
66
+ nodes: [
67
+ { nodeId: "<nodeId>", fileName: "<layerName-nodeId>.png" }
68
+ ],
69
+ localPath: "public/assets/figma/"
70
+ })
71
+ ```
72
+
73
+ - `localPath` defaults to `public/assets/figma/` (relative to the project root)
74
+ - `fileName` follows the pattern: `<layer name in lowercase, spaces replaced with ->-<nodeId>.png`
75
+ - 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/`
77
+
78
+ **Record the result:**
79
+
80
+ After export, save the mapping for use in Step 4:
81
+
82
+ ```
83
+ imageMap = {
84
+ "<nodeId>": "public/assets/figma/<fileName>.png"
85
+ }
86
+ ```
87
+
88
+ Example:
89
+ ```
90
+ imageMap = {
91
+ "123-456": "public/assets/figma/banner-top-123-456.png",
92
+ "789-012": "public/assets/figma/icon-star-789-012.png"
93
+ }
94
+ ```
95
+
96
+ ### Step 3: Map Figma tokens Tailwind / CSS
97
+
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
+ ```
105
+
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
+ ```
116
+
117
+ **Typography mapping:**
118
+ ```
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
130
+ ```
131
+
132
+ ### Step 4: Generate component
133
+
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
137
+
138
+ **Image node rendering rule:**
139
+
140
+ Before rendering each node, check `imageMap` from Step 2.5:
141
+ - 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
143
+
144
+ React/Next.js template for image node:
145
+ ```tsx
146
+ {/* Image node exported from Figma */}
147
+ <img
148
+ src="/assets/figma/<fileName>.png"
149
+ alt="<layer name from Figma>"
150
+ width={<width from Figma>}
151
+ height={<height from Figma>}
152
+ className="<sizing classes if needed>"
153
+ />
154
+ ```
155
+
156
+ Next.js with `next/image`:
157
+ ```tsx
158
+ import Image from 'next/image';
159
+ <Image
160
+ src="/assets/figma/<fileName>.png"
161
+ alt="<layer name from Figma>"
162
+ width={<width from Figma>}
163
+ height={<height from Figma>}
164
+ />
165
+ ```
166
+
167
+ Vue 3 template for image node:
168
+ ```vue
169
+ <img
170
+ src="/assets/figma/<fileName>.png"
171
+ :alt="'<layer name from Figma>'"
172
+ :width="<width from Figma>"
173
+ :height="<height from Figma>"
174
+ />
175
+ ```
176
+
177
+ #### React/Next.js component template:
178
+
179
+ ```tsx
180
+ interface [ComponentName]Props {
181
+ // Props extracted from Figma variants or dynamic content slots
182
+ className?: string;
183
+ }
184
+
185
+ export const [ComponentName] = ({ className }: [ComponentName]Props) => {
186
+ return (
187
+ <div className={cn(
188
+ // Layout classes
189
+ // Sizing classes
190
+ // Color classes
191
+ // Typography classes (if text node)
192
+ className
193
+ )}>
194
+ {/* Child nodes rendered recursively */}
195
+ </div>
196
+ );
197
+ };
198
+ ```
199
+
200
+ #### Vue 3 component template:
201
+
202
+ ```vue
203
+ <script setup lang="ts">
204
+ interface Props {
205
+ // Props extracted from Figma variants
206
+ class?: string;
207
+ }
208
+
209
+ const props = withDefaults(defineProps<Props>(), {});
210
+ </script>
211
+
212
+ <template>
213
+ <div :class="cn(
214
+ // Layout classes
215
+ // Sizing classes
216
+ // Color classes
217
+ props.class
218
+ )">
219
+ <!-- Child nodes -->
220
+ </div>
221
+ </template>
222
+ ```
223
+
224
+ ### Step 5: Handle interactive states
225
+
226
+ If Figma has variants (Default, Hover, Disabled, Active):
227
+
228
+ ```tsx
229
+ // Map variants into props + conditional classes
230
+ interface ButtonProps {
231
+ variant?: 'primary' | 'secondary' | 'outline';
232
+ size?: 'sm' | 'md' | 'lg';
233
+ disabled?: boolean;
234
+ }
235
+
236
+ const variantClasses = {
237
+ primary: 'bg-blue-600 text-white hover:bg-blue-700',
238
+ secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200',
239
+ outline: 'border border-gray-300 hover:bg-gray-50',
240
+ };
241
+ ```
242
+
243
+ ### Step 6: Verify and output
244
+
245
+ After generation, verify:
246
+
247
+ - [ ] Layout matches Figma (flex direction, alignment, gap)
248
+ - [ ] Colors mapping correct (or use arbitrary values if no Tailwind match)
249
+ - [ ] Typography correct (size, weight, line-height)
250
+ - [ ] Spacing correct (padding, margin, gap)
251
+ - [ ] Component has `className` prop for external overrides
252
+ - [ ] Use `cn()` helper for conditional/mergeable classes
253
+ - [ ] Responsive if Figma has mobile frames
254
+ - [ ] Props typed with TypeScript interface
255
+ - [ ] Image nodes use `<img>` tag (do not use CSS `background-image`)
256
+ - [ ] Image files exist in `public/assets/figma/` before submitting code
257
+
258
+ ---
259
+
260
+ ## Output format
261
+
262
+ Always output in order:
263
+
264
+ 1. **Design Summary** (brief): layout structure, color palette, typography scale
265
+ 2. **Component file** with full code
266
+ 3. **Usage example**:
267
+ ```tsx
268
+ <ComponentName variant="primary" className="mt-4" />
269
+ ```
270
+ 4. **Notes** if anything cannot be mapped 100% accurately from Figma
271
+
272
+ ---
273
+
274
+ ## Rules
275
+
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
279
+ - **Responsive** — if Figma only has 1 breakpoint, default to mobile-first design
280
+ - **Accessibility** — add `aria-label`, `role`, `alt` for interactive and image elements
281
+ - **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.
282
+ - **Icon** — if Figma uses SVG icons, extract SVG or map to lucide-react / heroicons
283
+
284
+ ---
285
+
286
+ ## Trigger Example Commands
287
+
288
+ ```
289
+ Read Figma and generate component: https://www.figma.com/design/xxxxx/App?node-id=123-456
290
+
291
+ Generate UserCard component from Figma frame node-id=123-456
292
+
293
+ Implement UI from this Figma link following my project: [URL]
294
+ ```
File without changes
File without changes
File without changes