@kood/claude-code 0.3.17 → 0.4.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.
@@ -1,400 +0,0 @@
1
- # Design Tokens Extraction and Mapping
2
-
3
- Guide for precisely converting Figma Variables and Styles to Tailwind CSS v4 @theme blocks.
4
-
5
- **Tailwind v4 Characteristics:**
6
- - **No Config File**: Remove tailwind.config.js
7
- - **@theme in CSS**: Define tokens directly in globals.css
8
- - **Auto Class Generation**: `@theme { --color-primary: #xxx; }` → `bg-primary` generated automatically
9
-
10
- ---
11
-
12
- ## Variables Extraction
13
-
14
- ### Color Variables
15
-
16
- **Figma Structure:**
17
- ```
18
- color/
19
- ├─ primary/
20
- │ ├─ 50 → #EFF6FF
21
- │ ├─ 500 → #3182F6
22
- │ └─ 900 → #1E3A8A
23
- ├─ secondary/
24
- │ ├─ 50 → #F8FAFC
25
- │ └─ 500 → #64748B
26
- └─ semantic/
27
- ├─ success → #22C55E
28
- ├─ error → #EF4444
29
- └─ warning → #F59E0B
30
- ```
31
-
32
- **Code Conversion:**
33
-
34
- #### Tailwind v4 (@theme block)
35
-
36
- **Vite** (src/index.css or src/main.css):
37
- ```css
38
- @import "tailwindcss";
39
-
40
- @theme {
41
- /* Primary */
42
- --color-primary-50: #EFF6FF;
43
- --color-primary-500: #3182F6;
44
- --color-primary-900: #1E3A8A;
45
-
46
- /* Secondary */
47
- --color-secondary-50: #F8FAFC;
48
- --color-secondary-500: #64748B;
49
-
50
- /* Semantic */
51
- --color-success: #22C55E;
52
- --color-error: #EF4444;
53
- --color-warning: #F59E0B;
54
- }
55
- ```
56
-
57
- **Next.js** (app/globals.css):
58
- ```css
59
- @import "tailwindcss";
60
-
61
- @theme {
62
- /* Same structure */
63
- }
64
- ```
65
-
66
- **Auto Class Generation:**
67
- ```tsx
68
- // After @theme { --color-primary-500: #3182F6; }
69
- <div className="bg-primary-500"> {/* Background color */}
70
- <div className="text-primary-500"> {/* Text color */}
71
- <div className="border-primary-500"> {/* Border color */}
72
- ```
73
-
74
- **Merge:** Define both existing globals.css tokens and Figma-extracted tokens in @theme block together.
75
-
76
- ### Spacing Variables
77
-
78
- **Figma Structure:**
79
- ```
80
- spacing/
81
- ├─ xs → 4px
82
- ├─ sm → 8px
83
- ├─ md → 16px
84
- ├─ lg → 24px
85
- ├─ xl → 32px
86
- └─ 2xl → 48px
87
- ```
88
-
89
- **Code Conversion (Tailwind v4):**
90
-
91
- ```css
92
- @import "tailwindcss";
93
-
94
- @theme {
95
- --spacing-xs: 4px;
96
- --spacing-sm: 8px;
97
- --spacing-md: 16px;
98
- --spacing-lg: 24px;
99
- --spacing-xl: 32px;
100
- --spacing-2xl: 48px;
101
- }
102
- ```
103
-
104
- **Usage:** `p-md` (16px), `gap-xs` (4px), `m-lg` (24px)
105
-
106
- ### Typography Variables
107
-
108
- **Figma Structure:**
109
- ```
110
- font/
111
- ├─ size/
112
- │ ├─ xs → 12px
113
- │ ├─ sm → 14px
114
- │ ├─ md → 16px
115
- │ └─ lg → 18px
116
- ├─ family/
117
- │ ├─ sans → Pretendard
118
- │ └─ mono → JetBrains Mono
119
- └─ weight/
120
- ├─ regular → 400
121
- ├─ medium → 500
122
- ├─ semibold → 600
123
- └─ bold → 700
124
- ```
125
-
126
- **Code Conversion (Tailwind v4):**
127
-
128
- ```css
129
- @import "tailwindcss";
130
-
131
- @theme {
132
- /* Size */
133
- --font-size-xs: 12px;
134
- --font-size-sm: 14px;
135
- --font-size-md: 16px;
136
- --font-size-lg: 18px;
137
-
138
- /* Family */
139
- --font-sans: Pretendard, -apple-system, sans-serif;
140
- --font-mono: "JetBrains Mono", monospace;
141
-
142
- /* Weight */
143
- --font-weight-regular: 400;
144
- --font-weight-medium: 500;
145
- --font-weight-semibold: 600;
146
- --font-weight-bold: 700;
147
- }
148
- ```
149
-
150
- **Usage:** `text-sm font-regular font-sans` (14px/400/Pretendard), `text-lg font-semibold` (18px/600)
151
-
152
- ---
153
-
154
- ## Styles Extraction
155
-
156
- ### Text Styles
157
-
158
- **Figma Text Style:**
159
- ```json
160
- {
161
- "name": "Heading/H1",
162
- "fontSize": 28,
163
- "fontFamily": "Pretendard",
164
- "fontWeight": 600,
165
- "lineHeight": { "unit": "PIXELS", "value": 36 },
166
- "letterSpacing": { "unit": "PERCENT", "value": -2 },
167
- "textCase": "ORIGINAL",
168
- "textDecoration": "NONE"
169
- }
170
- ```
171
-
172
- **Code Conversion:**
173
-
174
- #### CSS Class
175
-
176
- ```css
177
- .heading-h1 {
178
- font-family: 'Pretendard', sans-serif;
179
- font-size: 28px;
180
- font-weight: 600;
181
- line-height: 36px; /* 128.6% */
182
- letter-spacing: -0.02em; /* -2% → -0.02em */
183
- }
184
- ```
185
-
186
- #### Tailwind
187
-
188
- ```tsx
189
- <h1 className="font-sans text-[28px] font-semibold leading-[36px] tracking-[-0.02em]">
190
- Heading
191
- </h1>
192
- ```
193
-
194
- #### React Component
195
-
196
- ```tsx
197
- const H1 = ({ children }: { children: React.ReactNode }) => (
198
- <h1 className="font-sans text-[28px] font-semibold leading-[36px] tracking-[-0.02em]">
199
- {children}
200
- </h1>
201
- )
202
- ```
203
-
204
- ### Color Styles
205
-
206
- **Figma Color Style:**
207
- ```json
208
- {
209
- "name": "Semantic/Success",
210
- "type": "FILL",
211
- "color": { "r": 0.133, "g": 0.725, "b": 0.478, "a": 1 }
212
- }
213
- ```
214
-
215
- **RGB → HEX Conversion:**
216
- ```
217
- r: 0.133 × 255 = 34 → 22
218
- g: 0.725 × 255 = 185 → B9
219
- b: 0.478 × 255 = 122 → 7A
220
-
221
- Result: #22B97A (more accurately: #22C55E)
222
- ```
223
-
224
- **Code Usage:**
225
- ```css
226
- .text-success {
227
- color: #22C55E;
228
- }
229
-
230
- .bg-success {
231
- background-color: #22C55E;
232
- }
233
- ```
234
-
235
- ### Effect Styles
236
-
237
- **Shadow:**
238
- ```json
239
- {
240
- "name": "Shadow/Medium",
241
- "type": "DROP_SHADOW",
242
- "color": { "r": 0, "g": 0, "b": 0, "a": 0.1 },
243
- "offset": { "x": 0, "y": 4 },
244
- "radius": 8,
245
- "spread": 0
246
- }
247
- ```
248
-
249
- **Code Conversion:**
250
- ```css
251
- .shadow-medium {
252
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
253
- }
254
- ```
255
-
256
- ```css
257
- /* Tailwind v4 @theme */
258
- @theme {
259
- --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.1);
260
- }
261
- ```
262
-
263
- ---
264
-
265
- ## Conversion Rules
266
-
267
- ### Unit Conversion
268
-
269
- | Figma | CSS | Description |
270
- |-------|-----|-------------|
271
- | `16` | `16px` | Pixels as-is |
272
- | `{ unit: "PERCENT", value: 120 }` | `120%` or `1.2` | line-height |
273
- | `{ unit: "PERCENT", value: -2 }` | `-0.02em` | letter-spacing |
274
- | `{ r: 0.5, g: 0.5, b: 0.5, a: 1 }` | `#808080` | RGB → HEX |
275
- | `{ r: 0, g: 0, b: 0, a: 0.5 }` | `rgba(0,0,0,0.5)` | When transparency present |
276
-
277
- ### Naming Rules
278
-
279
- | Figma | CSS Variable | Tailwind |
280
- |-------|--------------|----------|
281
- | `color/primary/500` | `--color-primary-500` | `primary-500` |
282
- | `spacing/md` | `--spacing-md` | `md` (spacing) |
283
- | `font/size/lg` | `--font-size-lg` | `text-lg` |
284
-
285
- ### Case Conversion
286
-
287
- ```
288
- Figma (PascalCase/slash): Heading/H1
289
- CSS (kebab-case): heading-h1
290
- Tailwind (custom): [28px] or heading-h1
291
- ```
292
-
293
- ---
294
-
295
- ## Workflow
296
-
297
- | Step | Tool | Output |
298
- |------|------|--------|
299
- | Extract Variables | get_variables | variables.json |
300
- | Convert CSS | Node script | :root { --color-*: #...; } |
301
- | Extract Styles | get_styles | styles.json |
302
- | Generate @theme | Manual/script | @theme { --shadow-*: ...; } |
303
- | Validate | DevTools | className values match |
304
-
305
- ---
306
-
307
- ## Best Practices
308
-
309
- ### DO
310
-
311
- | Principle | Example |
312
- |-----------|---------|
313
- | **Variables First** | Figma Variables → CSS Variables → Tailwind |
314
- | **Exact Values** | `#3182F6` (hex as-is) |
315
- | **Maintain Hierarchy** | `color/primary/500` → `--color-primary-500` |
316
- | **Use Code Syntax** | Reference Figma codeSyntax attribute |
317
-
318
- ### DON'T
319
-
320
- | Forbidden | Reason |
321
- |-----------|--------|
322
- | **Use Approximations** | `#3182F6` → `bg-blue-500` (different) |
323
- | **Arbitrary Naming** | Ignore Figma naming structure |
324
- | **Hardcode Values** | Use Variables instead of direct values |
325
-
326
- ---
327
-
328
- ## Tools
329
-
330
- ### Color Conversion
331
-
332
- ```js
333
- // RGB (0-1) → HEX
334
- function rgbToHex(r, g, b) {
335
- const toHex = (n) => Math.round(n * 255).toString(16).padStart(2, '0')
336
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase()
337
- }
338
-
339
- // Usage
340
- rgbToHex(0.192, 0.51, 0.965) // "#3182F6"
341
- ```
342
-
343
- ### Letter Spacing Conversion
344
-
345
- ```js
346
- // Figma PERCENT → em
347
- function percentToEm(percent) {
348
- return (percent / 100).toFixed(3) + 'em'
349
- }
350
-
351
- // Usage
352
- percentToEm(-2) // "-0.02em"
353
- ```
354
-
355
- ### Line Height Conversion
356
-
357
- ```js
358
- // Figma pixels → CSS
359
- function lineHeight(fontSize, lineHeightPx) {
360
- const ratio = lineHeightPx / fontSize
361
- return `${lineHeightPx}px /* ${(ratio * 100).toFixed(1)}% */`
362
- }
363
-
364
- // Usage
365
- lineHeight(28, 36) // "36px /* 128.6% */"
366
- ```
367
-
368
- ---
369
-
370
- ## Example
371
-
372
- Figma Variables → @theme block → Auto class generation:
373
-
374
- ```css
375
- @theme { --color-primary-500: #3182F6; }
376
- ```
377
- ```tsx
378
- <button className="bg-primary-500">Button</button>
379
- ```
380
-
381
- ---
382
-
383
- ## Tailwind v4 Migration
384
-
385
- | v3 | v4 |
386
- |-----|-----|
387
- | `tailwind.config.js` | None (moved to CSS) |
388
- | `theme.extend` in JS | `@theme` in CSS |
389
- | `@tailwind base/...` | `@import "tailwindcss"` |
390
-
391
- **globals.css location:** Vite(`src/index.css`), Next.js App(`app/globals.css`), Pages(`styles/globals.css`)
392
-
393
- ---
394
-
395
- ## References
396
-
397
- - [Figma Variables API](https://www.figma.com/developers/api#variables)
398
- - [Design Tokens with Figma](https://blog.prototypr.io/design-tokens-with-figma-aef25c42430f)
399
- - [Tokens Studio Plugin](https://docs.tokens.studio)
400
- - [Tailwind CSS v4 Documentation](https://tailwindcss.com/docs/v4-beta)
@@ -1,285 +0,0 @@
1
- # Figma MCP Tools Usage
2
-
3
- Detailed guide to tools and API endpoints provided by Figma MCP.
4
-
5
- ---
6
-
7
- ## MCP Connection Types
8
-
9
- ### Desktop MCP (Local)
10
-
11
- **Advantages:**
12
- - Selection-based: Process only selected layers
13
- - Fast response
14
- - No internet connection required
15
-
16
- **Setup:**
17
-
18
- ```bash
19
- # Add
20
- claude mcp add --transport http figma-desktop http://127.0.0.1:3845/mcp
21
-
22
- # Verify
23
- claude mcp list
24
-
25
- # Restart
26
- claude mcp restart figma-desktop
27
- ```
28
-
29
- **Enable:** Figma Desktop → Dev Mode (Shift+D) → Inspect → "Enable desktop MCP server" → Verify: `http://127.0.0.1:3845/health`
30
-
31
- ### Remote MCP (Cloud)
32
-
33
- **Advantages:**
34
- - Access via file URL
35
- - No desktop app required
36
- - Better for team collaboration
37
-
38
- **Setup:**
39
-
40
- ```bash
41
- # Add
42
- claude mcp add --transport http figma-remote-mcp https://mcp.figma.com/mcp
43
-
44
- # Authenticate
45
- claude mcp login figma-remote-mcp
46
- ```
47
-
48
- **Usage:**
49
- ```
50
- Provide file URL:
51
- https://www.figma.com/file/ABC123/ProjectName
52
- ```
53
-
54
- ---
55
-
56
- ## Key MCP Tools
57
-
58
- ### 1. get_file_info
59
-
60
- Retrieve file metadata and structure (required before starting work).
61
-
62
- **Response:**
63
- ```json
64
- {
65
- "name": "Design System",
66
- "version": "1.2.3",
67
- "lastModified": "2026-01-20T10:30:00Z",
68
- "document": {
69
- "children": [
70
- { "type": "CANVAS", "name": "Components" },
71
- { "type": "CANVAS", "name": "Tokens" }
72
- ]
73
- }
74
- }
75
- ```
76
-
77
- ### 2. get_variables
78
-
79
- Extract Variables (Color, Number, String, Boolean).
80
-
81
- **Response:**
82
- ```json
83
- {
84
- "variables": [
85
- {
86
- "id": "VariableID:123",
87
- "name": "color/primary/500",
88
- "resolvedType": "COLOR",
89
- "valuesByMode": {
90
- "modeId": { "r": 0.192, "g": 0.51, "b": 0.965, "a": 1 }
91
- },
92
- "codeSyntax": {
93
- "WEB": "--color-primary-500",
94
- "ANDROID": "colorPrimary500",
95
- "iOS": "colorPrimary500"
96
- }
97
- },
98
- {
99
- "id": "VariableID:456",
100
- "name": "spacing/md",
101
- "resolvedType": "FLOAT",
102
- "valuesByMode": { "modeId": 16 },
103
- "codeSyntax": { "WEB": "--spacing-md" }
104
- }
105
- ]
106
- }
107
- ```
108
-
109
- **→ CSS:**
110
- ```css
111
- :root {
112
- --color-primary-500: #3182F6;
113
- --spacing-md: 16px;
114
- }
115
- ```
116
-
117
- ### 3. get_styles
118
-
119
- Extract Text Styles, Color Styles, Effect Styles.
120
-
121
- **Text Styles:**
122
- ```json
123
- {
124
- "id": "S:123",
125
- "name": "Heading/H1",
126
- "type": "TEXT",
127
- "fontSize": 28,
128
- "fontFamily": "Pretendard",
129
- "fontWeight": 600,
130
- "lineHeight": { "unit": "PIXELS", "value": 36 },
131
- "letterSpacing": { "unit": "PERCENT", "value": -2 }
132
- }
133
- ```
134
-
135
- **→ CSS:**
136
- ```css
137
- .heading-h1 {
138
- font-family: 'Pretendard', sans-serif;
139
- font-size: 28px;
140
- font-weight: 600;
141
- line-height: 36px;
142
- letter-spacing: -0.02em;
143
- }
144
- ```
145
-
146
- **Color Styles:**
147
- ```json
148
- {
149
- "id": "S:456",
150
- "name": "Semantic/Success",
151
- "type": "FILL",
152
- "color": { "r": 0.133, "g": 0.725, "b": 0.478, "a": 1 }
153
- }
154
- ```
155
-
156
- ### 4. get_node_properties
157
-
158
- Retrieve layer properties including layout/Auto Layout/styles/text/images (Desktop MCP: requires layer selection).
159
-
160
- **Response:**
161
- ```json
162
- {
163
- "id": "123:456",
164
- "name": "Button/Primary",
165
- "type": "FRAME",
166
- "absoluteBoundingBox": { "x": 100, "y": 200, "width": 120, "height": 44 },
167
- "layoutMode": "HORIZONTAL",
168
- "primaryAxisAlignItems": "CENTER",
169
- "counterAxisAlignItems": "CENTER",
170
- "itemSpacing": 8,
171
- "paddingLeft": 16,
172
- "paddingRight": 16,
173
- "paddingTop": 12,
174
- "paddingBottom": 12,
175
- "fills": [
176
- { "type": "SOLID", "color": { "r": 0.192, "g": 0.51, "b": 0.965, "a": 1 } }
177
- ],
178
- "cornerRadius": 8,
179
- "children": [
180
- {
181
- "type": "TEXT",
182
- "characters": "Button text",
183
- "style": { "fontSize": 14, "fontWeight": 600 }
184
- }
185
- ]
186
- }
187
- ```
188
-
189
- **→ TSX:**
190
- ```tsx
191
- <button className="flex items-center justify-center gap-[8px] px-[16px] py-[12px] bg-[#3182F6] rounded-[8px] w-[120px] h-[44px]">
192
- <span className="text-[14px] font-semibold text-white">Button text</span>
193
- </button>
194
- ```
195
-
196
- ### 5. get_images
197
-
198
- Generate download links for image assets.
199
-
200
- **Usage:**
201
- ```json
202
- // Input: image_refs: ["123:456"]
203
- // Output: { "123:456": "https://s3-alpha.figma.com/..." }
204
- ```
205
-
206
- **Workflow:**
207
- ```bash
208
- curl -o hero.png "https://..." && cwebp hero.png -q 80 -o hero.webp && mv hero.webp public/images/
209
- ```
210
-
211
- ### 6. export_node
212
-
213
- Export layer as SVG/PNG/JPG.
214
-
215
- **Settings:**
216
- ```json
217
- { "node_id": "123:456", "format": "SVG", "scale": 2 }
218
- ```
219
-
220
- **Use Cases:** Icons (SVG), Illustrations (PNG/WebP 2x), Logos (SVG)
221
-
222
- ---
223
-
224
- ## Workflow
225
-
226
- | Step | Tool | Output |
227
- |------|------|--------|
228
- | 1. File structure | get_file_info | Canvas/Frame structure |
229
- | 2. Extract tokens | get_variables | CSS Variables |
230
- | 3. Extract styles | get_styles | Text/Color Styles |
231
- | 4. Layer properties | get_node_properties | Layout/Auto Layout |
232
- | 5. Collect images | get_images | Download URLs |
233
- | 6. Implement code | - | Flexbox/Grid + exact measurements |
234
- | 7. Validate | DevTools | Measurement comparison |
235
-
236
- ---
237
-
238
- ## Important Notes
239
-
240
- ### Desktop MCP
241
-
242
- | Limitation | Solution |
243
- |-----------|----------|
244
- | Layer selection required | Select target layer before work |
245
- | Limited concurrent execution | One file at a time |
246
- | Requires local network | Verify firewall (port 3845) |
247
-
248
- ### Remote MCP
249
-
250
- | Limitation | Solution |
251
- |-----------|----------|
252
- | Authentication required | Run `claude mcp login` |
253
- | Rate limit | Wait if 429 error occurs |
254
- | File permissions | Requires View access or higher |
255
-
256
- ---
257
-
258
- ## Debugging
259
-
260
- ### Verify MCP Connection
261
-
262
- ```bash
263
- # Desktop MCP status
264
- curl http://127.0.0.1:3845/health
265
-
266
- # Remote MCP login status
267
- claude mcp status figma-remote-mcp
268
- ```
269
-
270
- ### Error Troubleshooting
271
-
272
- | Error | Cause | Solution |
273
- |-------|-------|----------|
274
- | `Connection refused` | Desktop MCP not enabled | Enable in Figma Dev Mode |
275
- | `401 Unauthorized` | Remote MCP auth expired | Rerun `claude mcp login` |
276
- | `404 Not Found` | Invalid node_id | Verify ID in Figma |
277
- | `429 Too Many Requests` | Rate limit exceeded | Wait 1 minute and retry |
278
-
279
- ---
280
-
281
- ## References
282
-
283
- - [Figma MCP Server Documentation](https://developers.figma.com/docs/figma-mcp-server/)
284
- - [Figma REST API Reference](https://www.figma.com/developers/api)
285
- - [Claude MCP Integration](https://www.builder.io/blog/figma-mcp-server)