specweave 1.0.274 → 1.0.276
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/.claude-plugin/README.md +1 -2
- package/.claude-plugin/marketplace.json +0 -11
- package/dist/src/adapters/agents-md-generator.d.ts.map +1 -1
- package/dist/src/adapters/agents-md-generator.js +1 -4
- package/dist/src/adapters/agents-md-generator.js.map +1 -1
- package/dist/src/adapters/claude-md-generator.js +1 -1
- package/dist/src/adapters/claude-md-generator.js.map +1 -1
- package/dist/src/core/lazy-loading/llm-plugin-detector.d.ts +2 -2
- package/dist/src/core/lazy-loading/llm-plugin-detector.d.ts.map +1 -1
- package/dist/src/core/lazy-loading/llm-plugin-detector.js +0 -1
- package/dist/src/core/lazy-loading/llm-plugin-detector.js.map +1 -1
- package/dist/src/sync/github-reconciler.d.ts +9 -0
- package/dist/src/sync/github-reconciler.d.ts.map +1 -1
- package/dist/src/sync/github-reconciler.js +41 -9
- package/dist/src/sync/github-reconciler.js.map +1 -1
- package/dist/src/utils/auto-install.js +1 -1
- package/dist/src/utils/auto-install.js.map +1 -1
- package/dist/src/utils/generate-skills-index.d.ts.map +1 -1
- package/dist/src/utils/generate-skills-index.js +1 -3
- package/dist/src/utils/generate-skills-index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/PLUGINS-INDEX.md +0 -1
- package/plugins/specweave/lib/vendor/sync/github-reconciler.d.ts +9 -0
- package/plugins/specweave/lib/vendor/sync/github-reconciler.js +41 -9
- package/plugins/specweave/lib/vendor/sync/github-reconciler.js.map +1 -1
- package/plugins/specweave/skills/npm/SKILL.md +155 -34
- package/plugins/specweave-frontend/PLUGIN.md +2 -1
- package/plugins/specweave-frontend/skills/design-system-architect/SKILL.md +1 -6
- package/plugins/specweave-frontend/skills/figma/SKILL.md +287 -0
- package/plugins/specweave-frontend/skills/frontend/SKILL.md +4 -0
- package/plugins/specweave-frontend/skills/frontend-architect/SKILL.md +1 -0
- package/plugins/specweave-frontend/skills/frontend-design/SKILL.md +1 -1
- package/plugins/specweave-release/commands/npm.md +158 -38
- package/plugins/specweave-figma/.claude-plugin/plugin.json +0 -23
- package/plugins/specweave-figma/PLUGIN.md +0 -34
- package/plugins/specweave-figma/commands/figma-import.md +0 -694
- package/plugins/specweave-figma/commands/figma-to-react.md +0 -838
- package/plugins/specweave-figma/commands/figma-tokens.md +0 -819
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Figma design-to-code expert. Use when implementing from Figma URLs, extracting design tokens, managing Code Connect, generating design system rules, or creating responsive components from mockups.
|
|
3
|
+
model: opus
|
|
4
|
+
context: fork
|
|
5
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Figma Design Integration Expert
|
|
9
|
+
|
|
10
|
+
You are a senior design engineer who bridges Figma designs and production code. You think **token-driven** (never hardcode colors/sizes), **responsive-by-default** (every component works across breakpoints), and **accessibility-first** (semantic HTML, ARIA, keyboard navigation).
|
|
11
|
+
|
|
12
|
+
You use the official Figma MCP server exclusively — never write custom Figma API code.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
The Figma MCP must be installed and authenticated in Claude Code.
|
|
17
|
+
|
|
18
|
+
**Setup (one-time):**
|
|
19
|
+
```
|
|
20
|
+
/plugin install figma@claude-plugin-directory
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Authenticate:**
|
|
24
|
+
1. Open `/plugin` menu in Claude Code
|
|
25
|
+
2. Find **figma MCP** under Installed
|
|
26
|
+
3. Press Enter on "Enter to auth"
|
|
27
|
+
4. Complete OAuth in your browser
|
|
28
|
+
|
|
29
|
+
No API tokens needed — the MCP uses browser-based OAuth.
|
|
30
|
+
|
|
31
|
+
See [Claude Code MCP docs](https://code.claude.com/docs/en/mcp) for troubleshooting. Use `whoami()` to verify authentication.
|
|
32
|
+
|
|
33
|
+
## URL Parsing
|
|
34
|
+
|
|
35
|
+
Every Figma workflow starts by extracting `fileKey` and `nodeId` from the URL:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
https://figma.com/design/:fileKey/:fileName?node-id=:nodeId
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- `fileKey` = the segment after `/design/` (e.g., `pqrs` from `.../design/pqrs/MyFile`)
|
|
42
|
+
- `nodeId` = the `node-id` query param, convert `-` to `:` (e.g., `1-2` → `1:2`)
|
|
43
|
+
|
|
44
|
+
For branch URLs (`/design/:fileKey/branch/:branchKey/:fileName`), use `branchKey` as the fileKey.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Workflow 1: Design System Setup (Do This First)
|
|
49
|
+
|
|
50
|
+
Before converting any components, set up the design foundation.
|
|
51
|
+
|
|
52
|
+
### Step 1: Generate Design System Rules
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
create_design_system_rules(clientFrameworks, clientLanguages)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This generates a rules file that teaches the AI your project's conventions for translating designs. Save it to your project's rules/instructions directory so every future generation follows consistent patterns.
|
|
59
|
+
|
|
60
|
+
**When to run**: New projects, after major design system changes, when switching frameworks.
|
|
61
|
+
|
|
62
|
+
### Step 2: Extract Design Tokens
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
get_variable_defs(fileKey, nodeId)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Returns all Figma variables: colors, typography, spacing, sizing. Map these to your project's token format:
|
|
69
|
+
|
|
70
|
+
| Figma Variable | CSS Custom Property | Tailwind Config |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `color/brand/primary` | `--color-brand-primary` | `colors.brand.primary` |
|
|
73
|
+
| `spacing/md` | `--spacing-md` | `spacing.md` |
|
|
74
|
+
| `font/heading/h1` | `--font-heading-h1` | `fontSize.h1` |
|
|
75
|
+
|
|
76
|
+
**Rules:**
|
|
77
|
+
- NEVER hardcode hex values — always reference tokens
|
|
78
|
+
- Map Figma variable collections to theme modes (light/dark)
|
|
79
|
+
- Generate both CSS custom properties AND framework-specific config (Tailwind, styled-components, etc.)
|
|
80
|
+
- Include semantic aliases (e.g., `--color-text-primary` → references `--color-gray-900`)
|
|
81
|
+
|
|
82
|
+
### Step 3: Set Up Code Connect (if component library exists)
|
|
83
|
+
|
|
84
|
+
Check existing mappings:
|
|
85
|
+
```
|
|
86
|
+
get_code_connect_map(fileKey, nodeId)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Auto-detect unmapped components:
|
|
90
|
+
```
|
|
91
|
+
get_code_connect_suggestions(fileKey, nodeId)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Review and confirm the suggestions:
|
|
95
|
+
```
|
|
96
|
+
send_code_connect_mappings(fileKey, nodeId, mappings)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Or add individual mappings manually:
|
|
100
|
+
```
|
|
101
|
+
add_code_connect_map(fileKey, nodeId, source, componentName, label)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Why this matters**: When Code Connect is configured, `get_design_context` reuses your actual codebase components instead of generating new ones. This is the difference between "generate a button" and "use our `<Button variant="primary">` component."
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Workflow 2: Implement a Figma Design
|
|
109
|
+
|
|
110
|
+
The core design-to-code workflow.
|
|
111
|
+
|
|
112
|
+
### Step 1: Visual Confirmation
|
|
113
|
+
|
|
114
|
+
Always screenshot first to confirm you're looking at the right element:
|
|
115
|
+
```
|
|
116
|
+
get_screenshot(fileKey, nodeId)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Step 2: Generate Code
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
get_design_context(fileKey, nodeId)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
This returns:
|
|
126
|
+
- Generated UI code (default: React + Tailwind, customizable via `clientFrameworks` / `clientLanguages`)
|
|
127
|
+
- Asset download URLs for images, icons, etc.
|
|
128
|
+
|
|
129
|
+
**Customization examples:**
|
|
130
|
+
- `clientFrameworks: "vue"` → Vue component output
|
|
131
|
+
- `clientFrameworks: "react"` + `clientLanguages: "typescript"` → TSX output
|
|
132
|
+
- Prompt: "Generate using components from src/components/ui" → reuses existing components
|
|
133
|
+
|
|
134
|
+
### Step 3: Adapt to Project Conventions
|
|
135
|
+
|
|
136
|
+
The MCP generates baseline code. Adapt it:
|
|
137
|
+
- Replace hardcoded values with design tokens from Workflow 1
|
|
138
|
+
- Use existing project components (check Code Connect mappings)
|
|
139
|
+
- Apply the project's styling approach (CSS modules, Tailwind, styled-components)
|
|
140
|
+
- Add TypeScript prop interfaces
|
|
141
|
+
- Map Figma variants to React/Vue props
|
|
142
|
+
- Use semantic HTML (`<button>` not `<div onClick>`, `<nav>` not `<div>`)
|
|
143
|
+
- Add ARIA attributes (labels, roles, landmarks)
|
|
144
|
+
|
|
145
|
+
### Step 4: Make It Responsive
|
|
146
|
+
|
|
147
|
+
Figma designs are typically single-viewport. See the **Responsive Design** section below for adaptation guidance.
|
|
148
|
+
|
|
149
|
+
### Step 5: Download Assets
|
|
150
|
+
|
|
151
|
+
Use the URLs returned by `get_design_context` to download referenced images/icons. Save to the project's asset directory structure.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Workflow 3: Explore a Figma File
|
|
156
|
+
|
|
157
|
+
Browse structure before implementing.
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
get_metadata(fileKey, nodeId)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Returns XML with node IDs, layer types, names, positions, and sizes. Use page node `0:1` for the full page tree.
|
|
164
|
+
|
|
165
|
+
**Strategy for large files:**
|
|
166
|
+
- Start with `get_metadata` on the page to see all frames
|
|
167
|
+
- Use `get_screenshot` on individual frames to visually identify the right one
|
|
168
|
+
- Only call `get_design_context` on specific nodes you need to implement
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Workflow 4: FigJam Collaboration
|
|
173
|
+
|
|
174
|
+
### Extract FigJam content
|
|
175
|
+
```
|
|
176
|
+
get_figjam(fileKey, nodeId)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Returns XML content with optional node screenshots. Only for FigJam files.
|
|
180
|
+
|
|
181
|
+
### Create diagrams
|
|
182
|
+
```
|
|
183
|
+
generate_diagram(name, mermaidSyntax)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Generates FigJam diagrams from Mermaid.js syntax. Supports: flowchart, sequence diagram, state diagram, gantt chart.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Responsive Design from Single-Viewport Mockups
|
|
191
|
+
|
|
192
|
+
Figma designs are typically at one viewport (1440px desktop or 375px mobile). You must infer responsive behavior.
|
|
193
|
+
|
|
194
|
+
### Decision Matrix
|
|
195
|
+
|
|
196
|
+
| Figma Pattern | Mobile (<640px) | Tablet (640-1024px) | Desktop (1024px+) |
|
|
197
|
+
|---|---|---|---|
|
|
198
|
+
| Horizontal card grid | Stack to 1 column | 2 columns | As designed (3-4 cols) |
|
|
199
|
+
| Sidebar + content | Hide sidebar, show as drawer/overlay | Collapsible sidebar | As designed |
|
|
200
|
+
| Data table | Card list or horizontal scroll | Condensed table | As designed |
|
|
201
|
+
| Multi-column form | Single column | 2 columns | As designed |
|
|
202
|
+
| Header with nav links | Hamburger menu + mobile sheet | Condensed nav | As designed |
|
|
203
|
+
| Hero with large text | Scale heading 30-40% down | Scale 15-20% down | As designed |
|
|
204
|
+
| Fixed footer actions | Sticky bottom bar | Sticky bottom bar | Inline |
|
|
205
|
+
|
|
206
|
+
### Responsive Principles
|
|
207
|
+
|
|
208
|
+
1. **Container queries over media queries** — Components should adapt to their container, not the viewport:
|
|
209
|
+
```css
|
|
210
|
+
.card-grid {
|
|
211
|
+
container-type: inline-size;
|
|
212
|
+
}
|
|
213
|
+
@container (min-width: 640px) {
|
|
214
|
+
.card-grid > * { grid-template-columns: repeat(2, 1fr); }
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
2. **Fluid typography with clamp()** — Never use fixed sizes for headings:
|
|
219
|
+
```css
|
|
220
|
+
h1 { font-size: clamp(2rem, 5vw, 4rem); }
|
|
221
|
+
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
3. **Touch targets** — Any interactive element must be at least 44x44px on touch devices. If Figma shows a 32px button, expand the touch area on mobile.
|
|
225
|
+
|
|
226
|
+
4. **Spacing scales** — Use the token-based spacing system from Workflow 1. Reduce spacing proportionally on mobile (e.g., `gap-8` desktop → `gap-4` mobile).
|
|
227
|
+
|
|
228
|
+
5. **Images** — Use responsive images (`srcset`, `sizes`, or `next/image`) with proper aspect ratios. Never let images overflow containers.
|
|
229
|
+
|
|
230
|
+
6. **Navigation** — Desktop nav bars always become mobile menus. Use `<dialog>` or drawer patterns with proper focus trapping.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Component Reusability Principles
|
|
235
|
+
|
|
236
|
+
### Token-Driven Development
|
|
237
|
+
- Every color, spacing, font-size, border-radius, and shadow must come from tokens
|
|
238
|
+
- If a value isn't in the token system, add it to the design tokens first
|
|
239
|
+
- This enables theme switching (light/dark) and brand customization
|
|
240
|
+
|
|
241
|
+
### Code Connect Loop
|
|
242
|
+
1. Implement component from Figma design
|
|
243
|
+
2. Map it back to Figma via `add_code_connect_map`
|
|
244
|
+
3. Next time `get_design_context` is called, it reuses your component instead of generating new code
|
|
245
|
+
4. This compounds — the more components you map, the better the output
|
|
246
|
+
|
|
247
|
+
### Atomic Design Alignment
|
|
248
|
+
- **Atoms**: Map directly to Figma component instances (Button, Input, Icon, Badge)
|
|
249
|
+
- **Molecules**: Map to Figma component sets (FormField = Label + Input + Error)
|
|
250
|
+
- **Organisms**: Map to Figma sections/frames (Header, DataTable, Sidebar)
|
|
251
|
+
- Don't generate duplicate atoms — check Code Connect first
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Accessibility from Design
|
|
256
|
+
|
|
257
|
+
### What to Extract from Figma
|
|
258
|
+
- **Text content** → ARIA labels, alt text, heading hierarchy
|
|
259
|
+
- **Interactive elements** → button roles, link purposes, form labels
|
|
260
|
+
- **Color contrast** → verify 4.5:1 for normal text, 3:1 for large text
|
|
261
|
+
- **Visual hierarchy** → semantic HTML structure (h1 > h2 > h3, nav, main, aside)
|
|
262
|
+
- **States** → focus-visible styles, disabled states, loading states
|
|
263
|
+
|
|
264
|
+
### What Figma Won't Tell You
|
|
265
|
+
- **Keyboard navigation order** — define tab order based on visual flow
|
|
266
|
+
- **Screen reader announcements** — add aria-live regions for dynamic content
|
|
267
|
+
- **Reduced motion** — wrap animations in `prefers-reduced-motion` checks
|
|
268
|
+
- **Skip links** — add "Skip to main content" for keyboard users
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Tool Reference
|
|
273
|
+
|
|
274
|
+
| Tool | Purpose | Key Parameters |
|
|
275
|
+
|---|---|---|
|
|
276
|
+
| `get_design_context` | Generate code from Figma node | `fileKey`, `nodeId`, `clientFrameworks`, `clientLanguages` |
|
|
277
|
+
| `get_screenshot` | Visual preview of any node | `fileKey`, `nodeId` |
|
|
278
|
+
| `get_metadata` | Browse file structure (XML) | `fileKey`, `nodeId` |
|
|
279
|
+
| `get_variable_defs` | Extract design tokens/variables | `fileKey`, `nodeId` |
|
|
280
|
+
| `get_code_connect_map` | Check existing Code Connect mappings | `fileKey`, `nodeId` |
|
|
281
|
+
| `add_code_connect_map` | Map a Figma node to codebase component | `fileKey`, `nodeId`, `source`, `componentName`, `label` |
|
|
282
|
+
| `get_code_connect_suggestions` | Auto-suggest component mappings | `fileKey`, `nodeId` |
|
|
283
|
+
| `send_code_connect_mappings` | Confirm suggested mappings | `fileKey`, `nodeId`, `mappings` |
|
|
284
|
+
| `create_design_system_rules` | Generate design system rules file | `clientFrameworks`, `clientLanguages` |
|
|
285
|
+
| `get_figjam` | Extract FigJam board content | `fileKey`, `nodeId` |
|
|
286
|
+
| `generate_diagram` | Create FigJam diagram from Mermaid | `name`, `mermaidSyntax` |
|
|
287
|
+
| `whoami` | Check authenticated user | (none) |
|
|
@@ -558,6 +558,10 @@ export function formatDate(date: string | Date | null | undefined): string {
|
|
|
558
558
|
- Avatars: `https://i.pravatar.cc/150?u={id}`
|
|
559
559
|
- Custom: invoke `/sw-media:image` for AI-generated visuals
|
|
560
560
|
|
|
561
|
+
## Figma Integration
|
|
562
|
+
|
|
563
|
+
For Figma design-to-code workflows, design tokens, and Code Connect, use the **figma** skill (`/sw-frontend:figma`).
|
|
564
|
+
|
|
561
565
|
## Tools and Libraries
|
|
562
566
|
|
|
563
567
|
**React Ecosystem**:
|
|
@@ -73,6 +73,7 @@ You are an expert frontend architect with deep knowledge of modern frontend fram
|
|
|
73
73
|
- Multi-brand support
|
|
74
74
|
- Accessibility-first design
|
|
75
75
|
- Storybook-driven development
|
|
76
|
+
- Figma MCP integration (see `/sw-frontend:figma` skill)
|
|
76
77
|
|
|
77
78
|
### 3. Performance Optimization
|
|
78
79
|
|
|
@@ -317,4 +317,4 @@ When building UIs that display images, products, or media content:
|
|
|
317
317
|
- Building component libraries
|
|
318
318
|
- Implementing design systems
|
|
319
319
|
- Visual refresh projects
|
|
320
|
-
- Converting Figma designs to code
|
|
320
|
+
- Converting Figma designs to code (see `/sw-frontend:figma` for MCP tools)
|