figma-pixel-kit 0.9.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/.claude/skills/figma-pixel-perfect/SKILL.md +31 -0
- package/.env.example +3 -0
- package/CLAUDE.md +32 -0
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/package.json +56 -0
- package/src/cli.js +3042 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: figma-pixel-perfect
|
|
3
|
+
description: Implements read-only Figma screens from figma-pixel-kit output with visual regression validation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Figma Pixel Perfect Skill
|
|
7
|
+
|
|
8
|
+
Use this skill when a task references a `design-ai/<screen-id>/` folder created by Figma Pixel Kit.
|
|
9
|
+
|
|
10
|
+
## Required behavior
|
|
11
|
+
|
|
12
|
+
1. Read `prompt-for-claude.md` first.
|
|
13
|
+
2. Use `reference.png` as visual truth.
|
|
14
|
+
3. Use `inventory.md` as the complete checklist.
|
|
15
|
+
4. Use `spec.json` for exact bounds, text and style data.
|
|
16
|
+
5. Use `index.html` only as a pixel preview, not production code.
|
|
17
|
+
6. Do not skip visible elements.
|
|
18
|
+
7. Do not redesign.
|
|
19
|
+
8. Reuse existing project components.
|
|
20
|
+
9. Add `data-figma-screen` to the implemented root.
|
|
21
|
+
10. After coding, run visual compare and fix from `visual-report/fix-prompt.md`.
|
|
22
|
+
|
|
23
|
+
## Final response checklist
|
|
24
|
+
|
|
25
|
+
Always report:
|
|
26
|
+
|
|
27
|
+
- Files changed
|
|
28
|
+
- Components reused
|
|
29
|
+
- New components created, if any
|
|
30
|
+
- Visual compare result
|
|
31
|
+
- Missing/approximate elements, if any
|
package/.env.example
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Figma Pixel Kit Project Rules
|
|
2
|
+
|
|
3
|
+
Use these rules when implementing designs from `design-ai/<screen-id>/`.
|
|
4
|
+
|
|
5
|
+
## Source priority
|
|
6
|
+
|
|
7
|
+
1. `reference.png` is the visual truth.
|
|
8
|
+
2. `inventory.md` is the required element checklist.
|
|
9
|
+
3. `spec.json` contains exact bounds, text and style data.
|
|
10
|
+
4. `index.html` is only a pixel-preview reference, not production code.
|
|
11
|
+
|
|
12
|
+
## Implementation rules
|
|
13
|
+
|
|
14
|
+
- Do not implement directly from a raw Figma URL.
|
|
15
|
+
- Do not redesign.
|
|
16
|
+
- Do not simplify the UI.
|
|
17
|
+
- Do not skip visible elements.
|
|
18
|
+
- Reuse existing project components before creating new primitives.
|
|
19
|
+
- Work section by section.
|
|
20
|
+
- Add `data-figma-screen="<node-id>"` to the implemented root element.
|
|
21
|
+
- After implementation, run `figma-pixel-kit compare`.
|
|
22
|
+
- Fix visual differences using `visual-report/fix-prompt.md`.
|
|
23
|
+
|
|
24
|
+
## Final response format
|
|
25
|
+
|
|
26
|
+
Always report:
|
|
27
|
+
|
|
28
|
+
- Files changed
|
|
29
|
+
- Components reused
|
|
30
|
+
- New components created, if any
|
|
31
|
+
- Visual diff result
|
|
32
|
+
- Missing or approximate elements, if any
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ozan Zengin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# figma-pixel-kit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/figma-pixel-kit)
|
|
4
|
+
[](https://github.com/ozanzeng/figma-pixel-kit/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
Figma selected node -> HTML preview + implementation inventory + Claude prompt + Playwright/pixelmatch visual diff.
|
|
9
|
+
|
|
10
|
+
This package is designed for frontend developers who want to give an AI assistant a clean implementation package instead of a raw Figma link.
|
|
11
|
+
|
|
12
|
+
> **Validated on a real 18-screen board — every auto-verifiable screen matched the Figma render at ≤ 2.9 % pixel diff.** See the [real-world example](#real-world-example).
|
|
13
|
+
|
|
14
|
+
## Why this exists
|
|
15
|
+
|
|
16
|
+
Handing a raw Figma link to an AI assistant (or another developer) is a recipe for guesswork. The link alone carries no reliable measurements, so spacing, font sizes and dimensions get approximated; icons that already exist in a library (lucide, font-awesome, …) get hand-redrawn as inline SVG; shared chrome like the sidebar, header and breadcrumb gets re-coded on every screen; and — worst of all — there is no objective way to tell whether the result actually matches the design. The result is screens that look "roughly right" and a slow, subjective back-and-forth review.
|
|
17
|
+
|
|
18
|
+
figma-pixel-kit was built to remove that guesswork. It turns a selected Figma node into a **clean, structured implementation package** — exact bounds and styles, parsed Auto Layout, a reusable-component map, detected library icons, downloaded image assets, and a ready-to-paste AI prompt — and then **closes the loop** with a pixel-level visual diff against the real Figma render, so "does it match?" becomes a number instead of an opinion.
|
|
19
|
+
|
|
20
|
+
## Why use it
|
|
21
|
+
|
|
22
|
+
- **Pixel-accurate inputs, not guesses.** Every element ships with exact bounds, colors, typography and parsed Auto Layout (paste-ready flexbox) — the AI implements real values instead of eyeballing a screenshot.
|
|
23
|
+
- **No redrawn icons.** Library icons (lucide / font-awesome / feather / heroicons / material / phosphor / tabler) are detected and mapped to their package import; real raster assets are downloaded to `assets/`. Nothing is hand-traced as inline SVG.
|
|
24
|
+
- **Build shared components once.** Component instances are grouped across the whole board with a prop-schema (TypeScript interface), so the sidebar/header/breadcrumb are built once and reused — never re-coded per screen.
|
|
25
|
+
- **`reference.png` is the source of truth.** The actual Figma render is exported at 2x; the node→div preview is only a diagnostic. You always have an objective target.
|
|
26
|
+
- **Verification built in.** `compare` runs Playwright + pixelmatch at the same scale as the reference, reports a diff ratio and a hotspot map, and produces a `fix-prompt.md` you can feed straight back to the AI for targeted fixes.
|
|
27
|
+
- **AI- and editor-agnostic.** Works with Claude / Claude Code / Copilot Chat / any assistant, and drops VS Code + Claude skill helpers into your project automatically. No Cursor required.
|
|
28
|
+
- **Zero-setup auth.** A Figma Personal Access Token is all you need to start (OAuth browser sign-in is also supported).
|
|
29
|
+
|
|
30
|
+
## Results
|
|
31
|
+
|
|
32
|
+
In practice this collapses the design-to-code loop from "implement → subjective review → repeat" into "implement from exact specs → measure the diff → fix only the hotspots." The AI starts much closer to pixel-perfect (real spacing, real icons, reused components) and every remaining gap is a measured number, not a debate.
|
|
33
|
+
|
|
34
|
+
Verified end-to-end on a real 5-screen board: **448 component instances reduced to 65 reusable components** with generated prop APIs, **120/241 elements with parsed Auto Layout**, reference PNGs exported at 2x, and pixel diffs that line up 1:1 with the app.
|
|
35
|
+
|
|
36
|
+
## Real-world example
|
|
37
|
+
|
|
38
|
+
A worked example on a real **18-screen board** — a multi-step wizard flow (upload → preview → processing → result) — taken from a single Figma node to a pixel-verified implementation in an existing React + Redux app.
|
|
39
|
+
|
|
40
|
+
**1. Extract the whole board** — one command auto-detects the screens:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
figma-pixel-kit "https://www.figma.com/design/FILE_KEY/App?node-id=2188-2868"
|
|
44
|
+
# → design-ai/<board>/ with implementation-plan.md, component-library.md,
|
|
45
|
+
# and one package per detected screen under screens/
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**2. Implement screen by screen** — hand the assistant each screen's prompt:
|
|
49
|
+
|
|
50
|
+
```txt
|
|
51
|
+
design-ai/<board>/screens/<screen-id>/prompt-for-claude.md
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**3. Verify each screen** against the Figma render:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
figma-pixel-kit compare "<screen-id>" \
|
|
58
|
+
--url "http://localhost:5173" \
|
|
59
|
+
--selector "[data-figma-screen='<node-id>']"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**What it produced.** Of the **8 screens that are directly auto-verifiable**, **all 8 pass** pixel diff at **≤ 2.9 %** — 6 full-text PASS and 2 ignore-text PASS (the residual delta is font rendering + mock data, not layout or color). The other 10 screens were **correctly classified by their app-side blocker** (local tab state, data fixtures, feature flags) rather than any defect in the generated package — and the kit even **flagged one screen the design defines but the codebase never implemented**.
|
|
63
|
+
|
|
64
|
+
| # | Screen (UI pattern) | Result |
|
|
65
|
+
|----|---------------------|--------|
|
|
66
|
+
| 01 | Results grid | ✅ Aligned — **PASS @1.9 %** (ignore-text); cards rebuilt |
|
|
67
|
+
| 02 | Resolution modal — primary tab | ✅ Modal chrome fixed (counter, footer, typography) |
|
|
68
|
+
| 03 | Resolution modal — all-separate state | ✅ "All separate" box → neutral grey |
|
|
69
|
+
| 04 | Resolution modal — mixed selection | ✅ Shared-component variant |
|
|
70
|
+
| 05 | Shared-items panel | ✅ Item card rebuilt (pill, chip, status icons) |
|
|
71
|
+
| 06 | File upload — empty dropzone | ✅ Dropzone 273px; ⚠️ one tab is feature-gated |
|
|
72
|
+
| 07 | List table | ⚠️ Chrome aligned; table is data-fixture-dependent |
|
|
73
|
+
| 08 | Preview — full content | ✅ **PASS @2.8 %** (frame height corrected) |
|
|
74
|
+
| 09 | Upload progress list | ✅ Well-built; depends on local upload state |
|
|
75
|
+
| 10 | AI processing — in progress | ✅ **PASS @2.4 %** |
|
|
76
|
+
| 11 | Processing complete | ✅ **PASS @2.5 %** |
|
|
77
|
+
| 12 | Result — success | ✅ **PASS @2.9 %** |
|
|
78
|
+
| 13 | Result — error | ✅ **PASS @2.3 %** (ignore-text); balance fixture set |
|
|
79
|
+
| 14 | Cancel confirmation modal | ❌ Not in codebase — net-new screen the design defines (kit flagged the gap) |
|
|
80
|
+
| 15 | Cancelled state | ✅ **PASS @2.1 %** |
|
|
81
|
+
| 16 | Loading / progress | ✅ **PASS @2.1 %** |
|
|
82
|
+
| 17 | Templates grid | ✅ Aligned; depends on local tab state |
|
|
83
|
+
| 18 | Blank-start variant | ✅ Content = #06; global chrome not drawn by harness |
|
|
84
|
+
|
|
85
|
+
**Reading the numbers**
|
|
86
|
+
|
|
87
|
+
- **PASS @ X %** — pixelmatch diff ratio against the 2× Figma render; lower is closer. Every passing screen is ≤ 2.9 %.
|
|
88
|
+
- **ignore-text** — text regions masked so browser-vs-Figma font rendering doesn't dominate the ratio; used where the only residual delta is type rendering or mock data.
|
|
89
|
+
- **⚠️ / data-gated** — visually aligned, but the screen's content comes from app state / fixtures / feature flags, so it isn't auto-pixel-compared (a harness limitation, not a package defect).
|
|
90
|
+
- **❌** — the design defines a screen with no code counterpart yet; the kit surfaced the gap.
|
|
91
|
+
|
|
92
|
+
## What it generates
|
|
93
|
+
|
|
94
|
+
For every selected Figma node URL, it creates:
|
|
95
|
+
|
|
96
|
+
```txt
|
|
97
|
+
design-ai/<screen-id>/
|
|
98
|
+
reference.png # Figma render at 2x — the visual truth
|
|
99
|
+
figma-node.json # raw Figma node response
|
|
100
|
+
spec.json # exact bounds/styles + frame.scale + component instance markers
|
|
101
|
+
inventory.md # complete element checklist (instances flagged ↻)
|
|
102
|
+
index.html # pixel-perfect preview (embeds reference.png)
|
|
103
|
+
debug-render.html # diagnostic node-to-div render (backgrounds + image fills)
|
|
104
|
+
styles.css # CSS for debug-render.html
|
|
105
|
+
inspect.md # diagnostic summary of rendered/skipped node types
|
|
106
|
+
prompt-for-claude.md # implementation prompt for the AI assistant
|
|
107
|
+
visual-test.spec.ts # optional Playwright snapshot template
|
|
108
|
+
component-library.md # shared components used here (only if instances exist)
|
|
109
|
+
components.json # structured component data (only if instances exist)
|
|
110
|
+
assets/ # downloaded image fills (only if any)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
After visual comparison it creates:
|
|
114
|
+
|
|
115
|
+
```txt
|
|
116
|
+
design-ai/<screen-id>/visual-report/
|
|
117
|
+
reference.png
|
|
118
|
+
actual.png
|
|
119
|
+
diff.png
|
|
120
|
+
report.json
|
|
121
|
+
fix-prompt.md
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Which file do I give to the AI?
|
|
125
|
+
|
|
126
|
+
This is the whole point of the package — you hand the AI **one file**, not a raw Figma link. That file references everything else in the same folder.
|
|
127
|
+
|
|
128
|
+
**Single screen** → give the assistant:
|
|
129
|
+
|
|
130
|
+
```txt
|
|
131
|
+
design-ai/<screen-id>/prompt-for-claude.md
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`prompt-for-claude.md` is a complete, self-contained implementation prompt. It tells the AI to use `reference.png` as the visual truth, read measurements from `spec.json`, check every element against `inventory.md`, import the icons listed in `assets.md`, reuse the shared components in `component-library.md`, and finish with a `compare` run. All of those files live next to it in the same `<screen-id>/` folder, so the AI can open them directly.
|
|
135
|
+
|
|
136
|
+
> Prompt to paste: *"Implement this screen. Read and follow `design-ai/<screen-id>/prompt-for-claude.md`. `reference.png` is the visual source of truth."*
|
|
137
|
+
|
|
138
|
+
**A whole board (multiple screens)** → start with the plan, then go screen by screen:
|
|
139
|
+
|
|
140
|
+
```txt
|
|
141
|
+
design-ai/<board>/implementation-plan.md # 1) read this FIRST
|
|
142
|
+
design-ai/<board>/component-library.md # 2) build shared components once (Phase 0)
|
|
143
|
+
design-ai/<board>/screens/<screen-id>/prompt-for-claude.md # 3) one screen at a time
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`implementation-plan.md` lists the shared components to build first (so the sidebar/header/breadcrumb are written once) and then the screen order. Do **one screen per task** — don't dump all screens into a single prompt.
|
|
147
|
+
|
|
148
|
+
**Fixing diffs** → after the AI implements a screen and you run `compare`, hand back:
|
|
149
|
+
|
|
150
|
+
```txt
|
|
151
|
+
design-ai/<screen-id>/visual-report/fix-prompt.md # + reference.png, actual.png, diff.png
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`fix-prompt.md` already contains the measured diff ratio and the hotspot regions, so the AI can fix only what's off instead of re-doing the screen.
|
|
155
|
+
|
|
156
|
+
> Works with Claude, Claude Code, GitHub Copilot Chat, or any AI assistant. The files are plain Markdown/JSON/PNG — no special integration needed.
|
|
157
|
+
|
|
158
|
+
## Local development install
|
|
159
|
+
|
|
160
|
+
Until this package is published to npm, install it locally:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
cd figma-pixel-kit
|
|
164
|
+
npm install
|
|
165
|
+
npm run install:browsers # one-time: install the Chromium build used by compare
|
|
166
|
+
npm link
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Then go to your frontend project root and run:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
figma-pixel-kit token "figd_xxxxxxxxxxxxxxxxx"
|
|
173
|
+
figma-pixel-kit doctor # optional: verify the token works against the Figma API
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
After that, normal usage is only:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
figma-pixel-kit "https://www.figma.com/design/FILE_KEY/File-Name?node-id=2188-2879&m=dev"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Real npx usage after npm publish
|
|
183
|
+
|
|
184
|
+
After publishing the package to npm as `figma-pixel-kit`, this will work:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
npx figma-pixel-kit "https://www.figma.com/design/FILE_KEY/File-Name?node-id=2188-2879&m=dev"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## One-time project integration
|
|
191
|
+
|
|
192
|
+
The first export automatically creates safe helper files if they do not exist:
|
|
193
|
+
|
|
194
|
+
```txt
|
|
195
|
+
FIGMA_PIXEL_KIT.md
|
|
196
|
+
.vscode/figma-pixel-kit.instructions.md
|
|
197
|
+
.vscode/tasks.json or .vscode/figma-pixel-kit.tasks.example.json
|
|
198
|
+
.claude/skills/figma-pixel-perfect/SKILL.md
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
You can also run it manually:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
figma-pixel-kit init
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Visual compare
|
|
208
|
+
|
|
209
|
+
After the AI implements the screen in your app, add the generated selector to the root element:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
<section data-figma-screen="2188:2879">
|
|
213
|
+
...
|
|
214
|
+
</section>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Run your frontend app:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npm run dev
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Then compare:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
figma-pixel-kit compare "app-1-2188-2879" \
|
|
227
|
+
--url "http://localhost:3000" \
|
|
228
|
+
--selector "[data-figma-screen='2188:2879']"
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Give `visual-report/fix-prompt.md`, `reference.png`, `actual.png`, and `diff.png` back to the AI assistant for targeted fixes.
|
|
232
|
+
|
|
233
|
+
The app is captured at the same scale `reference.png` was exported with (`spec.json` → `frame.scale`), so pixels line up 1:1. Useful extra flags:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Ignore font/text rendering differences — diff only layout, color and spacing:
|
|
237
|
+
figma-pixel-kit compare "<screen-id>" --url "http://localhost:3000" --ignore-text
|
|
238
|
+
|
|
239
|
+
# Export the reference at 1x for faster CI runs (also affects compare capture scale):
|
|
240
|
+
figma-pixel-kit "<figma-node-url>" --scale 1
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Token storage
|
|
244
|
+
|
|
245
|
+
Token lookup order:
|
|
246
|
+
|
|
247
|
+
1. `FIGMA_TOKEN` environment variable
|
|
248
|
+
2. `.env` file in the current project
|
|
249
|
+
3. `~/.figma-pixel-kit/config.json` created by `figma-pixel-kit token "figd_xxx"`
|
|
250
|
+
|
|
251
|
+
Do not commit your Figma token.
|
|
252
|
+
|
|
253
|
+
## VS Code workflow
|
|
254
|
+
|
|
255
|
+
This package does not require Cursor. It creates VS Code helper instructions under `.vscode/` and Claude skill rules under `.claude/skills/`.
|
|
256
|
+
|
|
257
|
+
Use the generated `prompt-for-claude.md` with Claude/Claude Code/GitHub Copilot Chat/any AI assistant inside VS Code.
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
## v0.4 notes
|
|
261
|
+
|
|
262
|
+
- `inspect` command added.
|
|
263
|
+
- `index.html` is now a pixel-perfect reference preview using `reference.png`.
|
|
264
|
+
- `debug-render.html` contains the experimental node-to-div HTML renderer.
|
|
265
|
+
- `inspect.md` is generated after export and summarizes rendered/skipped node types.
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
## v0.5 notes
|
|
269
|
+
|
|
270
|
+
- `implement` command added.
|
|
271
|
+
- `implement` runs export and prints a clean VS Code/Claude handoff checklist.
|
|
272
|
+
- Use: `figma-pixel-kit implement "<figma-node-url>"`
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
## v0.6 notes
|
|
276
|
+
|
|
277
|
+
- Auto board detection added to the main command.
|
|
278
|
+
- If the selected Figma node contains multiple 1440px-wide frames, the CLI treats it as a board.
|
|
279
|
+
- `analyze` command added.
|
|
280
|
+
- Board exports produce:
|
|
281
|
+
- `board-analysis.json`
|
|
282
|
+
- `screens.md`
|
|
283
|
+
- `implementation-plan.md`
|
|
284
|
+
- `component-library.md` and `components.json`
|
|
285
|
+
- one package per detected screen under `screens/`
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
## v0.7 notes
|
|
289
|
+
|
|
290
|
+
- **Pixel-perfect compare fixed.** `reference.png` is exported at 2x and `compare` now captures the app at the same `deviceScaleFactor`, so pixelmatch compares like-for-like instead of a 2x image against a 1x one. The scale is persisted in `spec.json` (`frame.scale`). Size mismatches are flagged instead of being silently padded, and hotspot coordinates are reported in logical (CSS) px.
|
|
291
|
+
- **Shared component reuse.** Component instances are grouped across screens by their Figma component / variant set. Boards emit `component-library.md` + `components.json`, the implementation plan gets a "Phase 0 — build shared components first" section, and every screen's `inventory.md` / `spec.json` flags instances so the AI reuses one component instead of re-coding it per screen.
|
|
292
|
+
- **Mobile / custom widths.** Board detection is no longer locked to 1440px. Use `--mobile` or `--screen-width / --width-tolerance / --min-height / --max-height` on the main/`export`/`analyze`/`implement` commands.
|
|
293
|
+
- **Better debug render.** `debug-render.html` now draws container/frame background fills, strokes, and image fills (downloaded into `assets/`), and uses the root frame's fill as the page background.
|
|
294
|
+
- **URLs & robustness.** Branch URLs resolve to the branch key; prototype/community URLs and node-ids in the URL fragment are handled; the Figma API retries on 429/5xx with clearer error hints; `compare` validates numeric flags, uses `--wait-until` (default `load`) with a fallback, and prints a friendly message if Chromium is missing. `doctor` is documented. Set `FIGMA_PIXEL_KIT_DEBUG=1` for stack traces.
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
## v0.8 notes (from the critical-suggestions pass)
|
|
298
|
+
|
|
299
|
+
- **`visual-test.spec.ts` is honest now.** A prominent header explains it is a *self-baseline* regression test (catches drift after first run) and does **not** validate against the Figma `reference.png` — use `compare` for that. Viewport + `deviceScaleFactor` match the reference scale.
|
|
300
|
+
- **`compare --ignore-text`.** Masks text element regions (from `spec.json`) identically in both images before diffing, so the browser-vs-Figma font rendering mismatch no longer dominates the ratio. Trade-off: it also hides genuine text bugs, so it is opt-in and reported in `report.json` / `fix-prompt.md`.
|
|
301
|
+
- **`--scale <1-4>`.** Reference export scale is now configurable and persisted; `compare` reads it. Use `--scale 1` for faster CI.
|
|
302
|
+
- **Chunked board rendering.** Board screens are pre-rendered in small chunks (fewer round-trips than one-call-per-screen) while staying under Figma's per-request render-time budget — a single all-screens call returns `Render timeout, try requesting fewer or smaller images` for large 2x desktop screens. If a chunk times out it splits to single ids, and anything still missing is rendered per-screen. (Verified on a real 5-screen 1440×820 board.)
|
|
303
|
+
- **Repeated-pattern detection.** `component-library.md` now lists copy-pasted blocks that repeat 3+ times but are *not* Figma components — strong candidates to turn into one reusable component.
|
|
304
|
+
- **Exact-frame-width rule** added to `prompt-for-claude.md`, plus a note that preview artifacts (`index.html`, `debug-render.html`, `assets/`) must not ship to production.
|
|
305
|
+
|
|
306
|
+
> Note on `/nodes` depth: the tool intentionally fetches the full node tree — component instances, bounds and styles live deep in the tree, so limiting depth would silently drop the data the inventory/component features rely on. The call already avoids heavy vector geometry (no `geometry=paths`), so it is already lean.
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
## v0.9 notes
|
|
310
|
+
|
|
311
|
+
- **Auto Layout parsing.** Figma Auto Layout (`layoutMode`, spacing, padding, alignment, wrap) is parsed into a ready flexbox block on each `spec.json` element (`layout.css` is paste-ready), plus `layoutChild` sizing (FILL/HUG/FIXED). The AI implements exact flex instead of guessing from coordinates. Also surfaced in `inventory.md`.
|
|
312
|
+
- **Variant mapping → prop APIs.** Component variants and properties become a structured prop schema; `component-library.md` now emits a ready TypeScript prop interface per component (enums from variant axes, booleans, text, and `React.ReactNode` slots for instance-swaps).
|
|
313
|
+
- **Constraint metadata.** Each element carries its Figma `constraints` (pin/stretch) for responsive intent.
|
|
314
|
+
- **OAuth login.** Browser sign-in: `oauth-setup <client_id> <client_secret>` once, then `figma-pixel-kit login` opens the browser and captures the token automatically via a loopback callback (`http://localhost:7113/callback`); tokens auto-refresh. `logout` clears them. Requests use `Authorization: Bearer` for OAuth and `X-Figma-Token` for PATs. Personal Access Tokens (`token`) still work unchanged.
|
|
315
|
+
- Requires your own Figma app (the `client_secret` stays in your local `~/.figma-pixel-kit/config.json`). For a publicly distributed npm build you'd front the token exchange with a small hosted service so the secret isn't shipped — PAT remains the zero-setup option.
|
|
316
|
+
|
|
317
|
+
_Verified end-to-end on a real 5-screen board: 448 instances → 65 components with prop APIs, 120/241 elements with parsed Auto Layout, reference PNGs at 2x._
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "figma-pixel-kit",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Figma node to HTML preview, AI implementation package and Playwright visual diff CLI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Ozan Zengin <oznzengin@gmail.com>",
|
|
9
|
+
"homepage": "https://github.com/ozanzeng/figma-pixel-kit#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/ozanzeng/figma-pixel-kit.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/ozanzeng/figma-pixel-kit/issues"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"figma-pixel-kit": "src/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"CLAUDE.md",
|
|
23
|
+
".claude",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
".env.example"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "node src/cli.js",
|
|
30
|
+
"export": "node src/cli.js export",
|
|
31
|
+
"compare": "node src/cli.js compare",
|
|
32
|
+
"init": "node src/cli.js init",
|
|
33
|
+
"help": "node src/cli.js --help",
|
|
34
|
+
"install:browsers": "playwright install chromium",
|
|
35
|
+
"test": "node tests/core-selftest.mjs",
|
|
36
|
+
"test:visual": "playwright test"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@playwright/test": "^1.60.0",
|
|
40
|
+
"pixelmatch": "^7.2.0",
|
|
41
|
+
"playwright": "^1.60.0",
|
|
42
|
+
"pngjs": "^7.0.0"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"figma",
|
|
49
|
+
"playwright",
|
|
50
|
+
"visual-regression",
|
|
51
|
+
"pixel-perfect",
|
|
52
|
+
"html",
|
|
53
|
+
"claude",
|
|
54
|
+
"vscode"
|
|
55
|
+
]
|
|
56
|
+
}
|