Skip to content

Commit 9620f50

Browse files
gold-ak47claude
andcommitted
fix: add layer composition analysis to plan→build pipeline
The planner now detects stacked Figma layers (image + gradient overlay + decorative shapes) and describes how they collapse into minimal CSS constructs. Section-level implementationNotes use a LAYERS: prefix when composition is involved. Both dev agents (shadcn + basecoat-wp) now read section composition notes and follow the collapse strategy instead of creating a <div> per Figma layer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 246f4ec commit 9620f50

3 files changed

Lines changed: 41 additions & 7 deletions

File tree

.claude-plugin/ui/commands/plan.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,35 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
128128
- Match to shadcn/ui if applicable (Button, Input, Card, Badge, etc.) with confidence 0.0-1.0
129129
- For `image-extract` components: reference the `image-map.json` entry — include `imageRef` and `localPath`
130130

131-
6. Write DETAILED implementation notes for this section AND each component in it. Describe:
131+
6. **Layer composition analysis** — CRITICAL. Before writing implementation notes, examine the Figma
132+
tree for this section and identify stacked/overlapping layers that must COLLAPSE into fewer HTML
133+
elements. Designers compose visuals by layering — the builder must NOT create a separate `<div>`
134+
for every Figma layer.
135+
136+
**Common patterns to detect:**
137+
| Figma structure | What it looks like | CSS translation |
138+
|---|---|---|
139+
| RECT(image) + RECT(gradient, opacity) stacked | Image with darkening overlay | `relative` container with `bg-[url(...)] bg-cover`, one `absolute inset-0` overlay div |
140+
| Single node with multiple fills | Stacked color/gradient fills | Single `background:` shorthand with multiple layers |
141+
| RECT(blur) + RECT(white, 10% opacity) | Frosted glass / glassmorphism | `backdrop-blur-md bg-white/10` on one element |
142+
| Decorative shapes behind content | Circles, blobs, abstract graphics | CSS pseudo-elements or absolute decorative divs, NOT separate components |
143+
| GROUP with shaped bottom child | Clipping mask | `overflow-hidden rounded-*` or `clip-path` |
144+
| Layer with blend mode (multiply/screen) | Color tinting or light effects | Approximate with opacity; `mix-blend-mode` is fragile — note if skippable |
145+
146+
**How to write it:** Start the section's `implementationNotes` with a `LAYERS:` prefix when
147+
composition is involved. Example:
148+
```
149+
"implementationNotes": "LAYERS: 3 stacked fills (photo RECT + linear-gradient RECT at 0.6 opacity
150+
+ radial-gradient RECT with screen blend) → collapse to: relative container with bg-[url(...)]
151+
bg-cover bg-center, one absolute inset-0 div for gradient overlay (bg-gradient-to-b from-transparent
152+
to-black/60), skip radial bloom (screen blend unreliable in CSS). Content children get relative z-10.
153+
| Section padding: py-24. Heading: text-5xl font-bold text-white, clamp(2.5rem, 3vw, 3.5rem)..."
154+
```
155+
156+
If the section has NO layer composition (e.g. a simple white-bg text section), skip the LAYERS
157+
prefix and write normal implementation notes.
158+
159+
7. Write DETAILED implementation notes for each **component** in this section. Describe:
132160
- Layout technique (flex, grid, absolute)
133161
- Background treatment (solid, gradient, image+overlay)
134162
- Typography (font, size, weight, color, spacing)
@@ -138,7 +166,7 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
138166
- Icon handling (which icon library, size)
139167
- Image handling (aspect ratio, object-fit, overlay)
140168

141-
7. **Logo and SVG detection** — CRITICAL:
169+
8. **Logo and SVG detection** — CRITICAL:
142170
- If a node is a VECTOR, or a FRAME/GROUP containing mostly VECTOR children, or its name
143171
contains "logo", "brand", "wordmark", "icon" — it is likely an SVG asset, NOT reproducible as text.
144172
- Look at the screenshot. If you see a stylized wordmark, symbol, or graphic that is clearly NOT
@@ -149,7 +177,7 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
149177
`"implementationNotes": "REQUIRES SVG EXTRACTION from Figma node [ID]. Placeholder only."`
150178
- If the node has VECTOR children, the Figma API can export it as SVG — note this for the builder.
151179

152-
8. **Font analysis** — for EVERY font family found in this section:
180+
9. **Font analysis** — for EVERY font family found in this section:
153181
- Record the exact font name from Figma (e.g. "Some Font TRIAL", "Brand Sans Pro")
154182
- Note if it appears to be commercial/licensed (keywords: "Pro", "TRIAL", "Display", unfamiliar names)
155183
- Identify metric-compatible fallback: what system/Google font is closest? (e.g. "Inter" for geometric sans, "Georgia" for serif)
@@ -165,7 +193,7 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
165193
}
166194
```
167195

168-
9. Check `image-map.json` for extracted source images in this frame:
196+
10. Check `image-map.json` for extracted source images in this frame:
169197
```bash
170198
cat .treble/figma/{frameSlug}/image-map.json 2>/dev/null
171199
```
@@ -174,7 +202,7 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
174202
`extractedImages: [{imageRef, localPath}]`. Read the actual image file if needed to understand
175203
what the photo depicts.
176204

177-
10. Return your analysis as a JSON object with this structure:
205+
11. Return your analysis as a JSON object with this structure:
178206
```json
179207
{
180208
"sectionName": "NavBar",
@@ -204,7 +232,7 @@ You are analyzing ONE section of a Figma design for Treble's design planner.
204232
"fullWidth": true,
205233
"containedAtoms": ["Logo", "NavLink", "Button"],
206234
"referenceImages": ["path/to/section.png"],
207-
"implementationNotes": "DETAILED section layout notes..."
235+
"implementationNotes": "LAYERS: [if stacked layers exist, describe Figma layers → CSS collapse strategy] | Section layout, spacing, background details..."
208236
},
209237
"designTokens": {
210238
"colors": [{"hex": "#2A3B5C", "usage": "primary background"}],
@@ -362,7 +390,7 @@ Write the analysis to `.treble/analysis.json`:
362390
"fullWidth": true,
363391
"containedAtoms": ["Logo", "NavLink", "Button"],
364392
"referenceImages": [".treble/figma/contact/snapshots/navbar.png"],
365-
"implementationNotes": "Sticky top nav, white bg, subtle bottom border (1px #E5E7EB).",
393+
"implementationNotes": "LAYERS: single bg fill, no composition needed. | Sticky top nav, white bg, subtle bottom border (1px #E5E7EB).",
366394
"responsive": {
367395
"container": "full-bleed",
368396
"innerMaxWidth": "max-w-7xl",

.claude-plugin/ui/skills/dev-basecoat-wp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Read the component's analysis entry from `analysis.json` (TEXT — fine in main
220220
- `implementationNotes` — the detailed visual reproduction notes (THIS is your primary input)
221221
- `referenceImages` — paths to screenshots (read these in a subagent, not here)
222222

223+
**For organisms/sections:** Also read the **section entry** from `pages.{page}.sections[]` in `analysis.json`. The section's `implementationNotes` contains layer composition strategy (prefixed with `LAYERS:`) that tells you how stacked Figma layers collapse into CSS. This is critical — multiple Figma layers often become a single HTML element with combined CSS. Do NOT create a separate `<div>` for every Figma layer. Follow the collapse strategy described in the notes.
224+
223225
**Use a subagent to examine reference images.** Spawn an Agent that reads the referenceImages PNGs and returns a text description of what it sees. This keeps images out of the main context.
224226

225227
Read node properties for exact measurements (TEXT — fine in main context):
@@ -250,6 +252,7 @@ Write the component as PHP partials / templates with Basecoat classes and Tailwi
250252
- Layout matching the Figma structure (flexbox, grid via Tailwind)
251253
- Content can be hardcoded — these are layout containers
252254
- File at `partials/{name}.php`
255+
- **Layer composition** — if the section's `implementationNotes` starts with `LAYERS:`, follow the collapse strategy exactly. Multiple Figma layers (image fill + gradient overlay + decorative shapes) become minimal HTML: typically a `relative` container, one or two `absolute inset-0` overlay divs, and content at `relative z-10`. Do NOT create a `<div>` per Figma layer.
253256

254257
**Pages:**
255258
- WordPress page template with template header comment

.claude-plugin/ui/skills/dev-shadcn.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ Read the component's analysis entry from `analysis.json` (TEXT — this is fine
220220
- `implementationNotes` — the detailed visual reproduction notes (THIS is your primary input)
221221
- `referenceImages` — paths to screenshots (read these in a subagent, not here)
222222

223+
**For organisms/sections:** Also read the **section entry** from `pages.{page}.sections[]` in `analysis.json`. The section's `implementationNotes` contains layer composition strategy (prefixed with `LAYERS:`) that tells you how stacked Figma layers collapse into CSS. This is critical — multiple Figma layers often become a single HTML element with combined CSS. Do NOT create a separate `<div>` for every Figma layer. Follow the collapse strategy described in the notes.
224+
223225
**Use a subagent to examine reference images.** Spawn an Agent that reads the referenceImages PNGs and returns a text description of what it sees — colors, layout, spacing, typography. This keeps images out of the main context.
224226

225227
Read node properties for exact measurements (TEXT — fine in main context):
@@ -248,6 +250,7 @@ Write the component following these rules. **File placement follows the feature-
248250
- Use `SectionContainer` from `@/components/layout/SectionContainer` for full-bleed wrappers
249251
- File at `src/features/{feature}/components/{ComponentName}.tsx`
250252
- Sections are ALMOST NEVER reusable — they belong in their feature
253+
- **Layer composition** — if the section's `implementationNotes` starts with `LAYERS:`, follow the collapse strategy exactly. Multiple Figma layers (image fill + gradient overlay + decorative shapes) become minimal HTML: typically a `relative` container, one or two `absolute inset-0` overlay divs, and content at `relative z-10`. Do NOT create a `<div>` per Figma layer.
251254

252255
**Layout components:**
253256
- Header, Footer, PageLayout, SectionContainer

0 commit comments

Comments
 (0)