@relipa/ai-flow-kit 0.1.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.
- package/README.md +497 -497
- package/bin/aiflow.js +525 -525
- package/custom/skills/figma-to-component/SKILL.md +294 -207
- package/custom/skills/read-study-requirement/SKILL.md +334 -334
- package/custom/templates/shared/gate-workflow.md +91 -91
- package/docs/common/CHANGELOG.md +334 -334
- package/docs/common/QUICK_START.md +537 -537
- package/docs/common/cli-reference.md +657 -657
- package/package.json +68 -67
- package/scripts/doctor.js +26 -0
- package/scripts/guide.js +314 -314
- package/scripts/hooks/session-start.js +315 -315
- package/scripts/prompt.js +95 -9
- package/scripts/score_members.js +320 -0
- package/scripts/use.js +1162 -1162
|
@@ -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
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
If
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
+
```
|