figma-local 1.0.0 → 1.2.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.
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: figma-local
3
+ description: |
4
+ Use this skill whenever the user wants to work with Figma designs, read design context, get design specs, translate designs to code, generate CSS from Figma, inspect UI components, extract design tokens, or bridge Figma Desktop with code. Triggers on: "read the design", "get the Figma specs", "what's on the canvas", "match the design", "inspect this component", "generate CSS from Figma", "get the colors/fonts/spacing", "design tokens", "Figma to code", "check Figma", "read from Figma", or any reference to reading, inspecting, or extracting from Figma designs. Do NOT trigger for Figma API (REST), Figma plugins development, or Figma file URL fetching — this is for local Figma Desktop control only.
5
+ allowed-tools:
6
+ - Bash(fig *)
7
+ - Bash(fig-start *)
8
+ - Bash(figma-cli *)
9
+ ---
10
+
11
+ # Figma Local
12
+
13
+ Control Figma Desktop directly from Claude Code. Read designs, inspect specs, generate CSS/Tailwind, extract styles — no API key required.
14
+
15
+ ## Prerequisites
16
+
17
+ The `fig` CLI must be installed and connected to Figma Desktop.
18
+
19
+ **Check status:**
20
+ ```bash
21
+ fig daemon status
22
+ ```
23
+
24
+ **If not connected:**
25
+ ```bash
26
+ fig connect --safe
27
+ ```
28
+
29
+ This starts the daemon and waits for the Figma Local plugin to connect. The user must have the plugin running in Figma Desktop (Plugins > Development > Figma Local).
30
+
31
+ **If not installed:**
32
+ ```bash
33
+ npm install -g figma-local
34
+ ```
35
+
36
+ ## Workflow: Design to Code
37
+
38
+ Always follow this staged approach — never dump the full canvas at once.
39
+
40
+ ### Step 1 — Scan the canvas (always do this first)
41
+
42
+ ```bash
43
+ fig read
44
+ ```
45
+
46
+ Returns: page name, frame names, sizes, count. Use this to understand what exists before doing anything else.
47
+
48
+ ### Step 2 — Read a specific frame
49
+
50
+ ```bash
51
+ fig read "Login Screen"
52
+ ```
53
+
54
+ Returns: layout hierarchy, component tree, text content, and only the design tokens that frame uses. This is the primary command for getting design context.
55
+
56
+ ### Step 3 — Get detailed specs for a specific element
57
+
58
+ Select the element in Figma, then:
59
+
60
+ ```bash
61
+ fig inspect
62
+ ```
63
+
64
+ Returns: dimensions (px + rem), padding, gap, colors (hex + rgba), typography (font, size, weight, line-height, letter-spacing), border radius, strokes, shadows, opacity, variable bindings.
65
+
66
+ ### Step 4 — Generate code-ready CSS
67
+
68
+ ```bash
69
+ fig css # CSS in rem
70
+ fig css --px # CSS in px
71
+ fig css --tailwind # Tailwind utility classes
72
+ ```
73
+
74
+ ### Step 5 — Verify your implementation
75
+
76
+ ```bash
77
+ fig verify # Screenshot for visual comparison
78
+ ```
79
+
80
+ ## Command Reference
81
+
82
+ ### Reading designs
83
+
84
+ | Command | What it does |
85
+ |---------|-------------|
86
+ | `fig read` | List all frames on the current page |
87
+ | `fig read "Frame Name"` | Layout tree + components + used tokens for that frame |
88
+ | `fig read "Frame" --tokens` | Only the design tokens that frame uses |
89
+ | `fig read --selection` | Read whatever is selected in Figma |
90
+ | `fig read --link "https://..."` | Read a node from a Figma selection URL |
91
+ | `fig read --json` | Raw JSON output |
92
+
93
+ ### Inspecting specs
94
+
95
+ | Command | What it does |
96
+ |---------|-------------|
97
+ | `fig inspect` | Full specs for current selection (px + rem) |
98
+ | `fig inspect --deep` | Inspect element + all children |
99
+ | `fig inspect --link "https://..."` | Inspect from a Figma link |
100
+ | `fig inspect --node "123:456"` | Inspect a specific node ID |
101
+ | `fig inspect --json` | Raw JSON output |
102
+
103
+ ### Generating CSS
104
+
105
+ | Command | What it does |
106
+ |---------|-------------|
107
+ | `fig css` | CSS for current selection (rem units) |
108
+ | `fig css --px` | CSS in px units |
109
+ | `fig css --tailwind` | Tailwind utility classes |
110
+ | `fig css --link "https://..."` | CSS from a Figma link |
111
+ | `fig css --node "123:456"` | CSS for a specific node |
112
+
113
+ ### Measuring spacing
114
+
115
+ | Command | What it does |
116
+ |---------|-------------|
117
+ | `fig measure` | Select 2 elements in Figma, get spacing between them (px + rem) |
118
+
119
+ ### Extracting styles
120
+
121
+ | Command | What it does |
122
+ |---------|-------------|
123
+ | `fig styles "Frame Name"` | All text styles, colors, spacing, radii in that frame |
124
+ | `fig styles --selection` | Styles from current selection |
125
+ | `fig styles --link "https://..."` | Styles from a Figma link |
126
+
127
+ ### Design tokens
128
+
129
+ | Command | What it does |
130
+ |---------|-------------|
131
+ | `fig tokens preset shadcn` | Apply full shadcn token system (Light/Dark) |
132
+ | `fig tokens tailwind` | Apply Tailwind color palette |
133
+ | `fig var list` | List all variables |
134
+ | `fig var export css` | Export as CSS custom properties |
135
+ | `fig var export tailwind` | Export as Tailwind config |
136
+
137
+ ### Creating in Figma
138
+
139
+ | Command | What it does |
140
+ |---------|-------------|
141
+ | `fig render '<JSX>'` | Render JSX to Figma canvas |
142
+ | `fig shadcn add button card` | Add shadcn/ui components |
143
+ | `fig blocks create dashboard-01` | Pre-built dashboard layout |
144
+ | `fig create icon lucide:home` | Add icons (150k+ via Iconify) |
145
+
146
+ ### Exporting
147
+
148
+ | Command | What it does |
149
+ |---------|-------------|
150
+ | `fig prompt "Frame" --target lovable` | AI prompt for Lovable |
151
+ | `fig prompt "Frame" --target figma-make` | AI prompt for Figma Make |
152
+ | `fig export screenshot -o out.png` | Screenshot |
153
+ | `fig export-jsx "1:234"` | Export as React JSX |
154
+
155
+ ### Verification
156
+
157
+ | Command | What it does |
158
+ |---------|-------------|
159
+ | `fig verify` | Screenshot of current selection |
160
+ | `fig verify --compare "url"` | Compare prototype vs design |
161
+ | `fig lint` | Design lint (accessibility, contrast, etc.) |
162
+
163
+ ## Important Rules
164
+
165
+ 1. **Always `fig read` first** — scan the canvas before doing anything
166
+ 2. **Staged reading** — never request full canvas data; focus on one frame at a time
167
+ 3. **Verify after creating** — always run `fig verify` after rendering or adding components
168
+ 4. **Use `fig inspect` for pixel-perfect code** — it gives exact specs in px + rem
169
+ 5. **Use `fig css` to generate code** — paste directly into your codebase
170
+ 6. **Select in Figma first** — most commands operate on the current Figma selection
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: figma-measure
3
+ description: |
4
+ Use this skill when the user wants to measure spacing, gaps, or distances between elements in Figma. Triggers on: "measure spacing", "distance between", "gap between", "how far apart", "spacing between elements", "measure the gap". Requires exactly 2 elements to be selected in Figma.
5
+ allowed-tools:
6
+ - Bash(fig measure *)
7
+ - Bash(fig measure)
8
+ ---
9
+
10
+ # Figma Measure
11
+
12
+ Measure the exact spacing between two selected elements in Figma. Returns horizontal gap, vertical gap, and center-to-center distance — all in px and rem.
13
+
14
+ ## Prerequisites
15
+
16
+ The `fig` CLI must be connected. Check with `fig daemon status`. If not connected: `fig connect --safe`.
17
+
18
+ ## Usage
19
+
20
+ Select exactly **2 elements** in Figma (hold Shift and click both), then:
21
+
22
+ ```bash
23
+ fig measure
24
+ ```
25
+
26
+ **Output example:**
27
+ ```
28
+ Submit Button (120x44)
29
+ |
30
+ Cancel Button (100x44)
31
+
32
+ Spacing
33
+ Horizontal: 16px (1rem)
34
+ Vertical: 0px (0rem)
35
+ Center-to-center
36
+ X: 126px (7.875rem)
37
+ Y: 0px (0rem)
38
+ ```
39
+
40
+ ### Raw JSON output
41
+
42
+ ```bash
43
+ fig measure --json
44
+ ```
45
+
46
+ ## When to use
47
+
48
+ - Checking the gap between sibling elements (buttons, cards, list items)
49
+ - Verifying margin/spacing values when coding a layout
50
+ - Comparing spacing consistency across a design
51
+ - Measuring distance between a label and its input field
52
+
53
+ ## Tips
54
+
55
+ - Select exactly 2 elements — fewer or more will fail
56
+ - Hold Shift in Figma to multi-select
57
+ - Horizontal spacing of 0 means elements overlap or are aligned vertically
58
+ - Vertical spacing of 0 means elements are on the same horizontal line
59
+ - Center-to-center distance is useful for grid alignment verification
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: figma-styles
3
+ description: |
4
+ Use this skill when the user wants to extract a style guide, design system overview, or all unique styles from a Figma frame or component. Triggers on: "what styles are used", "style guide", "extract colors", "extract typography", "what fonts", "spacing scale", "design system", "all the colors in this frame", "text styles", "border radii used". Also use when setting up a project's CSS variables, Tailwind config, or theme from a Figma design. Requires a frame name or element selected in Figma.
5
+ allowed-tools:
6
+ - Bash(fig styles *)
7
+ - Bash(fig styles)
8
+ - Bash(fig read *)
9
+ - Bash(fig read)
10
+ ---
11
+
12
+ # Figma Styles
13
+
14
+ Extract all unique text styles, colors, spacing values, and border radii from a Figma frame — a complete mini style guide for translating designs to code.
15
+
16
+ ## Prerequisites
17
+
18
+ The `fig` CLI must be connected. Check with `fig daemon status`. If not connected: `fig connect --safe`.
19
+
20
+ ## Usage
21
+
22
+ ### Extract styles from a named frame
23
+
24
+ ```bash
25
+ fig styles "Login Screen"
26
+ ```
27
+
28
+ **Output example:**
29
+ ```
30
+ Typography (4 styles)
31
+ Inter Bold 24px (1.5rem) line-height: 32px x2
32
+ Inter Medium 16px (1rem) line-height: 24px x5
33
+ Inter Regular 14px (0.875rem) line-height: 20px x8
34
+ Inter Regular 12px (0.75rem) line-height: 16px x3
35
+
36
+ Colors (6 unique)
37
+ #18181b used by: Heading, Label x7
38
+ #71717a used by: Description, Helper text x4
39
+ #ffffff used by: Card, Input x3
40
+ #f4f4f5 used by: Background x1
41
+ #3b82f6 used by: Button x2
42
+ #ef4444 used by: Error text x1
43
+
44
+ Spacing scale (5 values)
45
+ 4px 0.25rem x3
46
+ 8px 0.5rem x8
47
+ 12px 0.75rem x4
48
+ 16px 1rem x6
49
+ 24px 1.5rem x2
50
+
51
+ Border radii (3 values)
52
+ 4px 0.25rem x2
53
+ 8px 0.5rem x5
54
+ full full x3
55
+ ```
56
+
57
+ ### Extract from current selection
58
+
59
+ ```bash
60
+ fig styles --selection
61
+ ```
62
+
63
+ ### Extract from a Figma link
64
+
65
+ ```bash
66
+ fig styles --link "https://www.figma.com/design/FILEID/Name?node-id=123-456"
67
+ ```
68
+
69
+ ### Raw JSON output
70
+
71
+ ```bash
72
+ fig styles --json
73
+ ```
74
+
75
+ ## What it extracts
76
+
77
+ | Category | Details |
78
+ |----------|---------|
79
+ | **Typography** | Font family, style, size (px + rem), line-height, usage count |
80
+ | **Colors** | Hex values, which layers use them, usage count (fills + strokes) |
81
+ | **Spacing** | All gap and padding values used (px + rem), usage count |
82
+ | **Border radii** | All corner radius values (px + rem), usage count |
83
+
84
+ ## Workflow: Setting Up a Project Theme
85
+
86
+ 1. **Scan the canvas:** `fig read` to see available frames
87
+ 2. **Extract styles:** `fig styles "Main Screen"` to get the full style inventory
88
+ 3. **Map to your system:**
89
+ - Typography → CSS font classes or Tailwind `text-*` utilities
90
+ - Colors → CSS custom properties or Tailwind `colors` config
91
+ - Spacing → Tailwind `spacing` scale or CSS variables
92
+ - Radii → Tailwind `borderRadius` config
93
+ 4. **Export tokens if available:** `fig var export css` or `fig var export tailwind`
94
+
95
+ ## Combining with other commands
96
+
97
+ ```bash
98
+ # Get the full picture for a frame
99
+ fig read "Dashboard" # Structure + component tree
100
+ fig styles "Dashboard" # All unique styles used
101
+ fig var export css # Design tokens as CSS variables
102
+
103
+ # Then for individual components
104
+ fig inspect # Exact specs for selected element
105
+ fig css # Ready-to-paste CSS
106
+ ```
107
+
108
+ ## Tips
109
+
110
+ - Usage count (`xN`) shows how many times a style appears — higher counts indicate primary/system styles
111
+ - Colors are sorted by frequency — the most-used color appears first
112
+ - Spacing values are sorted by size — helps identify the spacing scale
113
+ - Use `--json` to pipe into scripts that generate Tailwind configs or CSS variable files
114
+ - Run on the top-level page frame to get the complete style inventory for a screen
package/src/daemon.js CHANGED
@@ -72,7 +72,7 @@ async function getFigmaClient() {
72
72
 
73
73
  const PORT = parseInt(process.env.DAEMON_PORT) || 3456;
74
74
  const MODE = process.env.DAEMON_MODE || 'auto'; // 'auto', 'cdp', 'plugin'
75
- const IDLE_TIMEOUT_MS = parseInt(process.env.DAEMON_IDLE_TIMEOUT) || 10 * 60 * 1000; // Default: 10 minutes
75
+ const IDLE_TIMEOUT_MS = parseInt(process.env.DAEMON_IDLE_TIMEOUT) || 60 * 60 * 1000; // Default: 1 hour
76
76
 
77
77
  // ============ SECURITY ============
78
78