canicode 0.9.1 → 0.10.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 CHANGED
@@ -10,7 +10,7 @@
10
10
  <a href="https://github.com/let-sunny/canicode/actions/workflows/release.yml"><img src="https://github.com/let-sunny/canicode/actions/workflows/release.yml/badge.svg" alt="Release"></a>
11
11
  </p>
12
12
 
13
- <p align="center"><strong>Stop explaining your designs. Get scored by AI-calibrated rules.</strong></p>
13
+ <p align="center"><strong>Make your Figma file information-complete so AI generates code that actually works.</strong></p>
14
14
 
15
15
  <p align="center">
16
16
  <strong><a href="https://let-sunny.github.io/canicode/">Try it in your browser</a></strong> — no install needed.
@@ -22,28 +22,30 @@
22
22
 
23
23
  ---
24
24
 
25
- ## Why CanICode
25
+ ## How it works
26
26
 
27
- AI can turn Figma designs into code — but the quality depends heavily on **how the design is structured**. Missing Auto Layout drops pixel accuracy from 95% to 63% at different viewports. Raw JSON input wastes more tokens for 15%p worse results.
27
+ AI can turn Figma designs into code — but the quality depends heavily on **how the design is structured**. CanICode runs a **roundtrip** over your Figma file: analyze the design, surface the gotchas it can't answer on its own, apply fixes back to Figma, re-analyze until the design is clean, then hand off to Figma's `figma-implement-design` skill for code generation. canicode does the design augmentation; code generation lives downstream (see [ADR-013](.claude/docs/ADR.md) for the scope boundary).
28
28
 
29
- CanICode solves this:
30
-
31
- 1. **Analyzes** your Figma design for patterns that hurt AI implementation quality
32
- 2. **Generates a design-tree** — a curated, CSS-ready representation that AI implements more accurately and efficiently than raw Figma data
33
- 3. **Scores** responsive readiness, so you fix the design before generating code
29
+ ### How the analyzer knows what to fix
34
30
 
35
31
  - **16 rules** across 6 categories: Pixel Critical, Responsive Critical, Code Quality, Token Management, Interaction, Semantic
36
32
  - **Deterministic** — no AI tokens consumed per analysis, runs in milliseconds
37
- - **Validated** — [ablation experiments](https://github.com/let-sunny/canicode/wiki) confirmed design-tree achieves 94% pixel accuracy with 5× fewer tokens than raw JSON
33
+ - **Ablation-validated** — [experiments](https://github.com/let-sunny/canicode/wiki) confirmed the curated design-tree achieves 94% pixel accuracy with 5× fewer tokens than raw JSON
38
34
 
39
- ### Scores You Can Trust
35
+ Rule scores aren't guesswork. The calibration pipeline converts real Figma designs to HTML, measures pixel-level similarity (via `visual-compare`), and adjusts scores based on actual implementation difficulty — hard-to-implement patterns get a higher penalty, easy ones get demoted. The pipeline runs on community fixtures, not on every analysis. See the [Calibration wiki](https://github.com/let-sunny/canicode/wiki/Calibration).
40
36
 
41
- Rule scores aren't guesswork. The calibration pipeline converts real Figma designs to HTML, measures pixel-level similarity (via `visual-compare`), and adjusts scores based on actual implementation difficulty.
37
+ ---
42
38
 
43
- - Design that's hard to implement accurately → rule score goes **up**
44
- - Design that's easy despite the flag → rule score goes **down**
39
+ ## The Roundtrip Workflow
45
40
 
46
- The pipeline runs on community fixtures, not on every analysis. Strip ablation uses six `DESIGN_TREE_INFO_TYPES` passes (including `size-constraints` for responsive sizing rules see [`CLAUDE.md`](CLAUDE.md)). See the [Calibration wiki](https://github.com/let-sunny/canicode/wiki/Calibration).
41
+ 1. **Analyze** run the 16 rules against the Figma design and grade it.
42
+ 2. **Surface gotchas** — the analyzer emits questions for design information it can't infer (missing states, unclear variants, responsive intent).
43
+ 3. **Apply fixes to Figma** — the `/canicode-roundtrip` skill writes answers back via `use_figma`. Each write shows up in the summary with one of three outcome markers:
44
+ - ✅ **scene write succeeded** — the property was written directly to the scene node or instance override.
45
+ - 📝 **annotated the scene node** — the skill left a structured annotation instead of writing the property. This is the [ADR-012](.claude/docs/ADR.md) default for instance-child layout writes, because propagating a property to the component definition (and therefore every instance of it) is almost never what the user wants. **A summary full of 📝 markers is correct behavior, not failure.**
46
+ - 🌐 **definition write propagated** — the property was written to the component definition and every instance inherited it. Only happens when the user opted in up front with `allowDefinitionWrite`.
47
+ 4. **Re-analyze** — verify the grade improved. Repeat step 2 if new gotchas surface.
48
+ 5. **Hand off** to `figma-implement-design` — canicode's scope ends here ([ADR-013](.claude/docs/ADR.md)). Figma's official code-generation skill takes the now-clean design and produces code.
47
49
 
48
50
  ---
49
51
 
@@ -51,7 +53,19 @@ The pipeline runs on community fixtures, not on every analysis. Strip ablation u
51
53
 
52
54
  **Quickest way:** **[Open the web app](https://let-sunny.github.io/canicode/)** — paste a Figma URL, get a report.
53
55
 
54
- **For your workflow:**
56
+ **Design-to-code in Claude Code (recommended):**
57
+
58
+ ```bash
59
+ # 1. Save your Figma token AND install the /canicode-roundtrip skill
60
+ canicode init --token figd_xxxxxxxxxxxxx
61
+
62
+ # 2. Run the roundtrip on a Figma URL
63
+ /canicode-roundtrip https://www.figma.com/design/ABC123/MyDesign?node-id=1-234
64
+ ```
65
+
66
+ > **Prerequisite:** the roundtrip skill calls the Figma MCP server to read and write the design. Install it once with `claude mcp add -s project -t http figma https://mcp.figma.com/mcp` — see the **MCP Server** install section below.
67
+
68
+ **If you only want analysis (no writes back to Figma):**
55
69
 
56
70
  ```bash
57
71
  # CLI — one command
@@ -69,9 +83,9 @@ claude mcp add canicode -- npx -y -p canicode canicode-mcp
69
83
  | **[Web App](https://let-sunny.github.io/canicode/)** | Quick check, no install |
70
84
  | **[Figma Plugin](https://www.figma.com/community/plugin/1617144221046795292/canicode)** | Analyze inside Figma (under review) |
71
85
  | **MCP Server** | Claude Code / Cursor / Claude Desktop integration |
72
- | **Claude Code Skill** | Lightweight, no MCP install |
86
+ | **`/canicode-roundtrip` Skill** | Full design-to-code roundtrip via Claude Code (analyze fix re-analyze handoff) |
87
+ | **`/canicode` Skill** | Lightweight analyze-only skill, no MCP install |
73
88
  | **CLI** | Full control, CI/CD, offline analysis |
74
- | **`canicode implement`** | Generate code-ready package (analysis + assets + prompt) |
75
89
  | **[GitHub Action](https://github.com/marketplace/actions/canicode-action)** | PR gate with score threshold |
76
90
 
77
91
  </details>
@@ -102,7 +116,7 @@ Each issue is classified: **Blocking** > **Risk** > **Missing Info** > **Suggest
102
116
  npx canicode analyze "https://www.figma.com/design/ABC123/MyDesign?node-id=1-234"
103
117
  ```
104
118
 
105
- Setup: `canicode init --token figd_xxxxxxxxxxxxx`
119
+ Setup: `canicode init --token figd_xxxxxxxxxxxxx` — saves the token AND installs the Claude Code skills (see below).
106
120
 
107
121
  > **Get your token:** Figma → Settings → Security → Personal access tokens → Generate new token
108
122
 
@@ -113,7 +127,7 @@ Setup: `canicode init --token figd_xxxxxxxxxxxxx`
113
127
  | View, Collab | 6 req/month | 6 req/month |
114
128
  | Dev, Full | 6 req/month | 10–20 req/min |
115
129
 
116
- Hitting 429 errors? Make sure the file is in a paid workspace. Or `save-fixture` once and analyze locally. [Full details](https://developers.figma.com/docs/rest-api/rate-limits/)
130
+ Hitting 429 errors? Make sure the file is in a paid workspace. Or save a fixture once and analyze locally. [Full details](https://developers.figma.com/docs/rest-api/rate-limits/)
117
131
 
118
132
  </details>
119
133
 
@@ -140,38 +154,19 @@ For Cursor / Claude Desktop config, see [`docs/CUSTOMIZATION.md`](docs/CUSTOMIZA
140
154
 
141
155
 
142
156
  <details>
143
- <summary><strong>Design to Code</strong> (prepare implementation package)</summary>
157
+ <summary><strong>Claude Code Skills</strong> (lightweight, no MCP install)</summary>
144
158
 
145
159
  ```bash
146
- canicode implement ./fixtures/my-design
147
- canicode implement "https://www.figma.com/design/ABC/File?node-id=1-234" --prompt ./my-react-prompt.md --image-scale 3
160
+ canicode init --token figd_xxxxxxxxxxxxx
148
161
  ```
149
162
 
150
- Outputs a ready-to-use package for AI code generation:
151
- - `analysis.json` — issues + scores
152
- - `design-tree.txt` — DOM-like tree with CSS styles + token estimate
153
- - `images/` — PNG assets with human-readable names (`hero-banner@2x.png`)
154
- - `vectors/` — SVG assets
155
- - `PROMPT.md` — code generation prompt (default: HTML+CSS, or your custom prompt)
163
+ Saves your Figma token AND installs three skills into `./.claude/skills/`:
156
164
 
157
- | Option | Default | Description |
158
- |--------|---------|-------------|
159
- | `--prompt` | built-in HTML+CSS | Path to your custom prompt file for any stack |
160
- | `--image-scale` | `2` | Image export scale: `2` for PC, `3` for mobile |
161
- | `--output` | `./canicode-implement/` | Output directory |
162
-
163
- Feed `design-tree.txt` + `PROMPT.md` to your AI assistant (Claude, Cursor, etc.) to generate code.
164
-
165
- </details>
166
-
167
- <details>
168
- <summary><strong>Claude Code Skill</strong> (lightweight, no MCP install)</summary>
169
-
170
- ```bash
171
- cp -r .claude/skills/canicode /your-project/.claude/skills/
172
- ```
165
+ - **canicode** lightweight CLI wrapper (use `/canicode <figma-url>`)
166
+ - **canicode-gotchas** — standalone gotcha survey (use `/canicode-gotchas <figma-url>`)
167
+ - **canicode-roundtrip** full analyze gotcha apply roundtrip (use `/canicode-roundtrip <figma-url>`)
173
168
 
174
- Requires FIGMA_TOKEN. Then use `/canicode` with a Figma URL.
169
+ Flags: `--global` installs into `~/.claude/skills/` instead. `--no-skills` skips skill install (token only). `--force` overwrites existing skill files without prompting. Run `canicode docs setup` for the full setup guide.
175
170
 
176
171
  </details>
177
172