@su-record/vibe 2.8.11 → 2.8.13

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.
@@ -5,1853 +5,98 @@ argument-hint: ""
5
5
 
6
6
  # /vibe.figma
7
7
 
8
- Figma 디자인 + 스토리보드 → 프로덕션 코드. 인터랙티브 방식으로 URL을 입력받아 처리.
8
+ Figma 디자인 + 스토리보드 → 프로덕션 코드. **프레임별 점진적 빌드** 방식.
9
9
 
10
10
  ## Usage
11
11
 
12
12
  ```
13
- /vibe.figma # 인터랙티브 모드 (URL 입력 프롬프트)
13
+ /vibe.figma # 인터랙티브 모드 (단계별 URL 입력)
14
14
  /vibe.figma --new # 새 피처 모드 (기존 디자인 시스템 무시)
15
15
  /vibe.figma --refine # 보완 모드 (기존 코드 + Figma 재비교 → 수정)
16
16
  ```
17
17
 
18
- 커맨드 실행 아래 순서로 사용자에게 질문:
18
+ ## Incremental Build Flow
19
19
 
20
20
  ```
21
- 1. 📋 스토리보드 URL 있나요? (선택)
22
- 브레이크포인트, 인터랙션, 애니메이션 스펙 추출
23
- 없으면 Enter (디폴트 브레이크포인트 사용)
24
-
25
- 2. 🎨 디자인 URL을 입력해주세요. (필수, 복수 가능)
26
- 1개: 단일 디자인
27
- 2개 이상: 반응형 (프레임 width로 mobile/desktop 자동 감지)
28
- URL 줄바꿈 또는 공백으로 구분
21
+ Step A: 스토리보드 URL 입력 (선택)
22
+ 기능 정의, 인터랙션, 브레이크포인트 추출
23
+ 실제 동작하는 레이아웃 코드 + 기능 주석 생성
24
+ → 스타일 없이 클릭/팝업/상태 전환 동작하는 수준
25
+
26
+ Step B: 디자인 URL 입력 프레임별 추출 → 코드 반영 → 검증
27
+ 🔄 검증 루프 (P1=0까지)
28
+ "추가 디자인 URL 있나요?"
29
+ ↓ (있으면 반복)
30
+ Step B: 추가 디자인 URL → 반응형 레이어 추가 → 검증
31
+ → 🔄 검증 루프 (양쪽 뷰포트 P1=0까지)
32
+ → "추가 디자인 URL이 있나요?"
33
+ ↓ (없으면)
34
+ Step C: 최종 공통화 리팩토링
35
+ → 토큰 통합, 중복 제거, variant 통합
36
+ → 🔄 최종 검증 루프
29
37
  ```
30
38
 
31
- ### 입력 예시
32
-
33
- ```
34
- 📋 스토리보드 URL (선택, 없으면 Enter):
35
- > https://www.figma.com/design/ABC/Storyboard?node-id=1-109
39
+ ### URL 입력 규칙
36
40
 
37
- 🎨 디자인 URL (필수, 복수 시 줄바꿈):
38
- > https://www.figma.com/design/ABC/Design?node-id=10-200
39
- > https://www.figma.com/design/ABC/Design?node-id=10-500
40
41
  ```
42
+ ⚠️ AskUserQuestion 사용 시 절대 선택지(options) 제공 금지. 자유 텍스트만.
43
+ ⚠️ 각 질문의 응답을 받은 후에만 다음으로 진행.
41
44
 
42
- ### Generation Mode
43
-
44
- | Mode | 조건 | 동작 |
45
- |------|------|------|
46
- | **Project integration** | 기본값 | 기존 디자인 시스템/토큰 활용, 프로젝트 컨벤션 준수 |
47
- | **--new** | 플래그 지정 시 | 자체 완결 토큰 + 컴포넌트, 기존 디자인 시스템 무관 |
48
- | **--refine** | 플래그 지정 시 | 기존 생성 코드를 Figma 원본과 재비교하여 부족한 부분만 수정 |
49
- | **Responsive** | 디자인 URL 2개 이상 | 자동 감지, fluid clamp() + @media 생성 |
45
+ Step A: "📋 스토리보드 Figma URL을 입력해주세요. (없으면 '없음')"
46
+ → ⏸️ 응답 대기
50
47
 
51
- ### 스토리보드에서 추출하는 정보
52
-
53
- | 항목 | 활용 Phase |
54
- |------|-----------|
55
- | 브레이크포인트 / 해상도 가이드 | Phase 3 (breakpoints 오버라이드) |
56
- | 인터랙션 스펙 (호버, 클릭, 스크롤) | Phase 6 (이벤트 핸들러 + CSS states) |
57
- | 애니메이션 스펙 (타이밍, 이징) | Phase 6 (transition/animation) |
58
- | 상태별 UI (로딩, 에러, 성공, 빈 상태) | Phase 6 (조건부 렌더링) |
59
- | 반응형 동작 설명 | Phase 6-3 (responsive 코드) |
60
- | 컬러/타이포 가이드 | Phase 4 (토큰 생성) |
61
- | 컴포넌트 명세 | Phase 5 (마크업 구조) |
62
-
63
- ### File Reading Policy
64
-
65
- **스토리보드 있을 때:**
66
- 1. 스토리보드 `get_metadata` → 전체 프레임 목록 파악
67
- 2. 관련 섹션별 `get_design_context` → 스펙 정보 추출
68
- 3. 디자인 URL별 `get_design_context` + `get_screenshot` → 비주얼 + 코드
48
+ Step B (반복):
49
+ "🎨 디자인 Figma URL을 입력해주세요."
50
+ ⏸️ 응답 대기 프레임별 추출 + 코드 반영 + 검증
51
+ → 검증 완료 후:
52
+ "🎨 추가 디자인 URL이 있나요? (없으면 '없음')"
53
+ ⏸️ 응답 대기
54
+ URL 입력: 반응형 레이어 추가 검증 다시 "추가?" 질문
55
+ "없음": Step C로 진행
56
+ ```
69
57
 
70
- **스토리보드 없을 때:**
71
- 1. 디자인 URL별 `get_design_context` + `get_screenshot` → 비주얼 + 코드
72
- 2. 디폴트 브레이크포인트 적용
58
+ ### Mode
73
59
 
74
- **항상:**
75
- - `.claude/vibe/config.json` → 프로젝트 스택
76
- - `.claude/vibe/design-context.json` 브랜드, 토큰, 테마
77
- - 기존 코드 스캔 컴포넌트 패턴, 디자인 시스템
60
+ | Mode | 동작 |
61
+ |------|------|
62
+ | **기본** | 기존 디자인 시스템/토큰 활용 |
63
+ | **--new** | 자체 완결 토큰, 기존 시스템 무관 |
64
+ | **--refine** | 기존 코드를 Figma 재비교 → 수정만 |
78
65
 
79
66
  ## Context Reset
80
67
 
81
68
  **이 커맨드 실행 시 이전 대화 무시.**
82
- - Figma 데이터 + 프로젝트 스택 기반으로 판단
83
- - 스토리보드 스펙이 디자인과 충돌 시 → 스토리보드 우선
69
+ 스토리보드 스펙 > 디자인 데이터 > 프로젝트 컨벤션 순으로 우선.
84
70
 
85
71
  ---
86
72
 
87
73
  > **⏱️ Timer**: Call `getCurrentTime` tool at the START. Record the result as `{start_time}`.
88
74
 
89
- ## Model Routing
90
-
91
- | Phase | Claude | GPT (Codex) | 이유 |
92
- |-------|--------|-------------|------|
93
- | Phase 0 (추출) | **Haiku** | — | MCP 호출 + 데이터 수집 |
94
- | Phase 1-2 (분석) | **Sonnet** | — | 이미지 비교 + 구조 파악 |
95
- | Phase 3 (감지) | **Haiku** | — | 파일 읽기 + 패턴 매칭 |
96
- | Phase 4-5 (토큰/마크업) | **Sonnet** | — | 토큰 매핑 + 시맨틱 판단 |
97
- | Phase 6 (코드 생성) | **Sonnet** | **gpt-5.3-codex-spark** (병렬) | 섹션별 컴포넌트 병렬 생성 |
98
- | Phase 7-8 (매핑/리포트) | **Sonnet** | — | 토큰 매핑 + 보고서 |
99
- | Phase 9 (검증 루프) | **Sonnet** | — | 이미지 비교 + diff 판단 + auto-fix |
100
- | Post (코드 리뷰) | — | **gpt-5.3-codex** | 생성 코드 품질 검증 |
101
-
102
- ### GPT 모델 선택 기준
103
-
104
- | 모델 | config key | 용도 |
105
- |------|-----------|------|
106
- | `gpt-5.4` | `models.gpt` | 아키텍처 판단, 복잡한 추론 |
107
- | `gpt-5.3-codex` | `models.gptCodex` | 코드 리뷰, 분석 (정확도 우선) |
108
- | `gpt-5.3-codex-spark` | `models.gptCodexSpark` | 코드 생성 (속도 우선) |
109
-
110
- `~/.vibe/config.json`의 `models` 에서 오버라이드 가능.
111
-
112
- ### Codex 병렬 활용 (codex-plugin-cc 설치 시)
113
-
114
- ```
115
- Phase 6 — 컴포넌트 생성:
116
- 섹션 3개 이상 → /codex:rescue --background (gpt-5.3-codex-spark)
117
- 각 섹션 컴포넌트를 Codex에 병렬 위임, Claude는 루트 페이지 + 토큰 담당
118
-
119
- Post — 코드 리뷰:
120
- /codex:review (gpt-5.3-codex)
121
- 생성된 코드의 design fidelity + 코드 품질 크로스 검증
122
-
123
- Codex 미설치 시 자동 스킵 — Claude만으로 순차 생성.
124
- ```
125
-
126
- ## Phase 0: URL 입력 + Figma Data Extraction
127
-
128
- ### 0-0. 사용자 입력 수집
129
-
130
- AskUserQuestion으로 하나씩 순서대로 **자유 텍스트 입력**을 받는다.
131
- **선택지(options)를 제공하지 않는다. 반드시 자유 입력(freeform text)만 받는다.**
132
- 각 질문 후 반드시 사용자 응답을 받은 다음에만 다음 Step으로 진행.
133
-
134
- ```
135
- Step 1: 스토리보드 URL (선택)
136
- → AskUserQuestion 호출 (options 파라미터 사용 금지):
137
- question: "📋 스토리보드 Figma URL을 입력해주세요. (없으면 '없음')"
138
- → ⏸️ 사용자 응답 대기
139
- → figma.com URL 포함: storyboardUrl 저장
140
- → "없음" 또는 URL 미포함: storyboardUrl = null
141
-
142
- Step 2: 디자인 URL (필수)
143
- → AskUserQuestion 호출 (options 파라미터 사용 금지):
144
- question: "🎨 디자인 Figma URL을 입력해주세요."
145
- → ⏸️ 사용자 응답 대기
146
- → URL 저장: designUrls = [url]
147
-
148
- Step 3: 추가 디자인 URL (반응형)
149
- → AskUserQuestion 호출 (options 파라미터 사용 금지):
150
- question: "🎨 추가 디자인 URL이 있으면 입력해주세요. (없으면 '없음')"
151
- → ⏸️ 사용자 응답 대기
152
- → figma.com URL 포함: designUrls에 추가 → responsive mode
153
- → "없음" 또는 URL 미포함: single mode
154
-
155
- Step 4 (--new 미지정 시):
156
- 프로젝트에 기존 디자인 시스템이 있는지 자동 감지
157
- → 있으면: default mode (기존 토큰 활용)
158
- → 없으면: 자동으로 --new mode
159
-
160
- ⚠️ 절대 Step 1~3을 한 번에 호출하지 않는다.
161
- ⚠️ 절대 선택지(options/choices)를 제공하지 않는다. 순수 텍스트 입력만.
162
- Step 1 응답 → Step 2 호출 → Step 2 응답 → Step 3 호출 순서 엄수.
163
- ```
164
-
165
- ### 0-1. 스토리보드 추출 (storyboardUrl이 있을 때)
166
-
167
- 스토리보드에서 **구현 스펙**을 먼저 추출. 이후 Phase에서 참조.
168
-
169
- ```
170
- URL에서 fileKey, nodeId 추출:
171
- https://www.figma.com/design/:fileKey/:fileName?node-id=:nodeId
172
- → nodeId: 하이픈을 콜론으로 ("1-109" → "1:109")
173
-
174
- 1. get_metadata(fileKey, nodeId) → 전체 프레임 목록 (섹션 파악)
175
- 2. 관련 섹션별 get_design_context:
176
- - "해상도 대응" / "Media Query" → 브레이크포인트
177
- - "인터랙션" / "Interaction" → 호버/클릭/스크롤 스펙
178
- - "애니메이션" / "Animation" / "Motion" → 트랜지션 스펙
179
- - "상태" / "State" → 로딩/에러/성공 UI
180
- - "컬러" / "Color" / "타이포" / "Typography" → 디자인 가이드
181
-
182
- 결과 → storyboardSpec 객체에 저장:
183
- {
184
- breakpoints: { ... }, // 브레이크포인트 오버라이드
185
- interactions: [ ... ], // 인터랙션 목록
186
- animations: [ ... ], // 애니메이션 스펙
187
- states: [ ... ], // UI 상태 목록
188
- colorGuide: { ... }, // 컬러 가이드
189
- typographyGuide: { ... } // 타이포 가이드
190
- }
191
- ```
192
-
193
- ### 0-2. 디자인 추출 (MCP)
194
-
195
- 각 디자인 URL에 대해 MCP로 추출:
196
-
197
- ```
198
- URL에서 fileKey, nodeId 추출 (동일 방식)
199
-
200
- 각 URL에 대해:
201
- 1. get_design_context(fileKey, nodeId) → 코드 + 스크린샷 + 메타데이터 + 에셋 URL
202
- 2. get_metadata(fileKey, nodeId) → 레이어 구조 (XML)
203
- 3. get_screenshot(fileKey, nodeId) → 프레임 이미지
204
-
205
- 디자인 URL이 2개 이상이면:
206
- → 프레임 width로 viewport 자동 감지 (mobile/tablet/desktop)
207
- → responsive mode 진입
208
- ```
209
-
210
- ### 0-3. Image Asset Download (BLOCKING — 코드 생성 전 반드시 완료)
211
-
212
- > **⛔ 이 단계를 건너뛰면 안 됨.** 이미지 다운로드가 완료되지 않으면 Phase 6 코드 생성으로 진행하지 않는다.
213
-
214
- `get_design_context` 응답에 포함된 이미지 에셋 URL은 **7일 후 만료**되는 임시 URL.
215
- **즉시 다운로드**하여 프로젝트에 저장해야 함.
216
-
217
- **Step 1: 에셋 URL 수집**
218
-
219
- `get_design_context` 응답에서 모든 이미지 URL 추출:
220
- ```
221
- 패턴: https://www.figma.com/api/mcp/asset/...
222
- 코드에 const xxxImage = 'https://...' 형태로 포함됨
223
- ```
224
-
225
- **Step 2: 다운로드 + 저장**
226
-
227
- ```
228
- 각 URL에 대해:
229
- 1. WebFetch로 다운로드
230
- 2. 프로젝트 에셋 디렉토리에 저장:
231
- - Nuxt: static/images/{feature}/ 또는 public/images/{feature}/
232
- - Next.js: public/images/{feature}/
233
- - React: public/images/{feature}/
234
- 3. 파일명은 레이어 이름 기반 (kebab-case):
235
- - "Hero Background" → hero-background.webp
236
- - "Product Photo 1" → product-photo-1.webp
237
- ```
238
-
239
- **Step 3: URL → 로컬 경로 매핑 테이블 생성**
240
-
241
- ```
242
- 다운로드 완료 후, 매핑 테이블을 메모리에 보관:
243
-
244
- | Figma 임시 URL | 로컬 경로 | 레이어 이름 |
245
- |---------------|----------|-----------|
246
- | https://figma.com/api/mcp/asset/abc... | /images/winter-pcbang/hero-bg.webp | Hero Background |
247
- | https://figma.com/api/mcp/asset/def... | /images/winter-pcbang/hero-title.webp | Hero Title |
248
-
249
- → Phase 6 코드 생성 시 이 매핑 테이블로 임시 URL을 로컬 경로로 교체
250
- ```
251
-
252
- **Step 4: SVG 처리**
253
-
254
- ```
255
- - 벡터 에셋 (아이콘, 로고) → SVG로 다운로드
256
- - 작은 아이콘 (< 1KB) → 인라인 SVG 컴포넌트
257
- - 큰 SVG → 파일로 저장
258
- ```
259
-
260
- ### 0-4. Extraction Gate (코드 생성 진행 조건)
261
-
262
- > **다음 조건을 모두 만족해야 Phase 1로 진행:**
263
-
264
- ```
265
- ✅ 디자인 URL 최소 1개의 get_design_context 성공
266
- ✅ 디자인 스크린샷 최소 1개 획득
267
- ✅ 이미지 에셋 전부 다운로드 완료 (0개 남은 미다운로드)
268
- ✅ URL→로컬경로 매핑 테이블 생성 완료
269
- ✅ (responsive) 최소 2개 뷰포트의 스크린샷 획득
270
-
271
- ❌ 하나라도 실패 시:
272
- → 실패 항목 보고 + 재시도
273
- → 이미지 다운로드 실패 시: 해당 URL 재시도 (최대 3회)
274
- → 재시도 후에도 실패: 사용자에게 수동 다운로드 요청 후 계속
275
- ```
276
-
277
- ---
278
-
279
- ## Phase 1: Design Analysis (Image-First)
280
-
281
- ### Single mode
282
-
283
- Read `figma-output/frame.png` and analyze:
284
-
285
- | Aspect | What to Extract |
286
- |--------|-----------------|
287
- | Layout | Flex/Grid direction, alignment, wrapping |
288
- | Components | Visual boundaries (cards, buttons, inputs, modals) |
289
- | Spacing | Padding, margins, gaps between elements |
290
- | Typography | Font sizes, weights, line heights, hierarchy |
291
- | Colors | Background, text, border, accent colors |
292
- | States | Hover/active/disabled indicators if visible |
293
- | Responsive hints | Breakpoint indicators, fluid vs fixed widths |
294
-
295
- ### Responsive mode
296
-
297
- Read **ALL** frame images and analyze **side-by-side**:
298
-
299
- | Aspect | What to Compare |
300
- |--------|-----------------|
301
- | Layout shift | Which elements reflow? (e.g., horizontal → vertical stack) |
302
- | Visibility | Which elements hide/show per viewport? |
303
- | Typography scale | Font size ratio between viewports |
304
- | Spacing scale | Padding/gap ratio between viewports |
305
- | Component shape | Does the component change form? (e.g., drawer → sidebar) |
306
- | Navigation | Does nav change? (e.g., hamburger ↔ full nav bar) |
307
-
308
- Build a **viewport diff table**:
309
-
310
- ```
311
- | Element | Mobile (375px) | Desktop (1440px) | Strategy |
312
- |---------------|------------------------|------------------------|-------------------|
313
- | Nav | hamburger + drawer | horizontal bar | component swap |
314
- | Hero title | 24px | 48px | fluid: clamp() |
315
- | Card grid | 1 column | 3 columns | grid auto-fit |
316
- | Sidebar | hidden | visible | display toggle |
317
- | Body text | 14px | 16px | fluid: clamp() |
318
- | Padding | 16px | 48px | fluid: clamp() |
319
- ```
320
-
321
- ## Phase 2: Layer Data Extraction
322
-
323
- ### Single mode
324
-
325
- Read `figma-output/layers.json` and extract:
326
-
327
- 1. **Component hierarchy** — Map nested layers to component tree
328
- 2. **Design tokens** — Colors (fill, stroke), font properties, spacing values, border radius, shadows
329
- 3. **Auto-layout** — Direction, gap, padding (maps directly to flex/grid)
330
- 4. **Constraints** — Fixed vs fluid sizing
331
- 5. **Component instances** — Identify reusable patterns
332
- 6. **Image fills** — Identify layers with `type: "IMAGE"` fills (see Phase 2-A)
333
-
334
- ### Responsive mode
335
-
336
- Read **ALL** `layers.{N}.json` files and extract **per-viewport**:
337
-
338
- 1. **Per-viewport tokens** — Record exact values for each viewport:
339
- ```
340
- { "mobile": { "h1": 24, "body": 14, "padding": 16 },
341
- "desktop": { "h1": 48, "body": 16, "padding": 48 } }
342
- ```
343
- 2. **Layout differences** — Auto-layout direction changes (e.g., HORIZONTAL → VERTICAL)
344
- 3. **Visibility map** — Which layers exist in one viewport but not the other
345
- 4. **Shared tokens** — Values identical across all viewports (colors, border-radius, shadows are usually shared)
346
-
347
- ### Phase 2-A: Image Fill Classification
348
-
349
- Figma에서 이미지는 레이어의 `fills` 배열에 `type: "IMAGE"`로 들어옴. 이를 **용도별로 분류**해야 코드에서 올바른 패턴을 생성할 수 있음.
350
-
351
- #### 감지 방법
352
-
353
- `layers.json`에서 아래 패턴을 탐색:
354
-
355
- ```
356
- fills: [{ type: "IMAGE", scaleMode: "FILL" | "FIT" | "CROP" | "TILE", imageRef: "..." }]
357
- ```
358
-
359
- #### 분류 기준
360
-
361
- | 판별 조건 | 분류 | 코드 패턴 |
362
- |----------|------|----------|
363
- | 레이어가 프레임/섹션의 **직계 배경**이고, 위에 텍스트/UI 요소가 겹침 | **Background Image** | `background-image` + `background-size` |
364
- | 레이어가 독립적이고, 위에 겹치는 요소 없음 | **Content Image** | `<img>` 또는 `<picture>` |
365
- | 레이어 이름에 `icon`, `logo`, `avatar` 포함 | **Inline Asset** | `<img>` (작은 크기) |
366
- | 레이어가 반복 패턴(`scaleMode: "TILE"`) | **Pattern/Texture** | `background-image` + `background-repeat` |
367
- | 레이어가 전체 프레임을 덮고 opacity < 1 또는 blendMode 적용 | **Overlay Image** | `background-image` + overlay `::before`/`::after` |
368
-
369
- #### 이미지-텍스트 겹침 판별 (Background vs Content)
370
-
371
- ```
372
- frame의 fills에 IMAGE가 있고, children에 TEXT 레이어가 있으면:
373
- → Background Image (텍스트 아래 깔리는 배경)
374
-
375
- 독립 레이어의 fills에 IMAGE가 있고, 형제 레이어와 겹치지 않으면:
376
- → Content Image
377
- ```
378
-
379
- #### 이미지 소스 추출
380
-
381
- - `imageRef` 값으로 Figma API의 이미지 렌더링 사용 (`/images/{fileKey}`)
382
- - 추출된 이미지는 `figma-output/assets/` 디렉토리에 저장
383
- - 파일명은 레이어 이름 기반: `hero-bg.png`, `product-photo.jpg`
384
-
385
- ### Responsive Scaling Calculation
386
-
387
- Per-viewport 토큰 쌍에서 clamp() 값을 계산. 공식은 **Phase 4-3** 참조.
388
-
389
- 핵심: Figma 디자인이 2x 스케일(2560px/720px)이므로, 반드시 타겟 해상도(1920px/480px)로 환산 후 clamp를 계산해야 함.
390
-
391
- **Correction rule**: When image and JSON disagree, **image wins**. The image shows designer intent; JSON may have structural artifacts.
392
-
393
- ## Phase 3: Project Stack Detection + Mode Resolution
394
-
395
- ### 3-1. Detect Stack
396
-
397
- 1. Read `.claude/vibe/config.json` → check `stacks` field
398
- 2. If no config, detect from project files:
399
- - `package.json` → React, Vue, Svelte, Angular, etc.
400
- - `tailwind.config.*` → Tailwind CSS
401
- - `next.config.*` → Next.js
402
- - `nuxt.config.*` → Nuxt
403
- - `*.module.css` → CSS Modules pattern
404
- - `*.scss` / `sass` in deps → SCSS
405
- - `styled-components` / `@emotion` in deps → CSS-in-JS
406
-
407
- ### 3-2. Load Design Context (Design Skill Integration)
408
-
409
- Read these files **in order** — later sources override earlier ones:
410
-
411
- 1. **`.claude/vibe/design-context.json`** — brand personality, aesthetic direction, constraints
412
- - `aesthetic.style` → guides visual weight (minimal vs bold)
413
- - `aesthetic.colorMood` → warm/cool/vibrant tone for token selection
414
- - `brand.personality` → preserve brand-expressive elements
415
- - `constraints.accessibility` → AA or AAA level (affects contrast, focus, ARIA depth)
416
- - `constraints.devices` → responsive breakpoints priority
417
- 2. **`.claude/vibe/design-system/{project}/MASTER.md`** — authoritative token definitions
418
- - If MASTER.md exists: **map Figma tokens to MASTER.md tokens first**, only create new tokens for values with no match
419
- - If no MASTER.md: generate `figma-tokens.css` as standalone token source
420
-
421
- **Decision rule**: When Figma token ≈ existing MASTER.md token (within 10% color distance or ±2px spacing), **use the existing token** — do not duplicate.
422
-
423
- ### 3-3. Load Breakpoints
424
-
425
- Breakpoints are loaded from multiple sources in priority order:
426
-
427
- #### Source Priority
428
-
429
- | Priority | Source | How |
430
- |----------|--------|-----|
431
- | 1 | **Storyboard** | Phase 0-1에서 추출한 `storyboardSpec.breakpoints` |
432
- | 2 | **`~/.vibe/config.json`** | `figma.breakpoints` — user-customized via `vibe figma breakpoints --set` |
433
- | 3 | **Project CSS/Tailwind** | Grep `tailwind.config.*` → `theme.screens`, or `@media.*min-width` patterns in codebase |
434
- | 4 | **Defaults** | Built-in values (breakpoint: 1024px, etc.) |
435
-
436
- #### Default Breakpoints (built-in)
437
-
438
- Based on game industry responsive storyboard standards:
439
-
440
- ```
441
- breakpoint: 1024px ← PC↔Mobile boundary (@media min-width)
442
- pcTarget: 1920px ← PC main target resolution
443
- mobilePortrait: 480px ← Mobile portrait max width
444
- mobileMinimum: 360px ← Mobile minimum supported width
445
- designPc: 2560px ← Figma PC artboard width (design is 2x scale)
446
- designMobile: 720px ← Figma Mobile artboard width (design is 2x scale)
447
- ```
448
-
449
- #### How to use in code generation
75
+ ## Step A: 스토리보드 + Base 구조
450
76
 
451
- ```
452
- @media breakpoint:
453
- - Single breakpoint model: @media (min-width: {breakpoint}px)
454
- - Mobile-first: styles below breakpoint = mobile, above = PC
455
-
456
- clamp() range:
457
- - minVw = mobileMinimum (360px) — smallest supported viewport
458
- - maxVw = pcTarget (1920px) — largest target viewport
459
- - Values scale linearly between these bounds
460
-
461
- Design scale factor:
462
- - PC design at {designPc}px targets {pcTarget}px → scale = pcTarget/designPc
463
- - Mobile design at {designMobile}px targets {mobilePortrait}px → scale = mobilePortrait/designMobile
464
- - Apply scale to convert Figma pixel values to target pixel values
465
- ```
466
-
467
- #### User customization
468
-
469
- Users can override any value via CLI:
470
-
471
- ```bash
472
- vibe figma breakpoints # Show current values
473
- vibe figma breakpoints --set breakpoint=768 # Change PC↔Mobile boundary
474
- vibe figma breakpoints --set mobileMinimum=320 # Change mobile minimum
475
- ```
476
-
477
- Stored in `~/.vibe/config.json` → `figma.breakpoints`. Partial overrides merge with defaults.
478
-
479
- ### 3-4. Resolve Generation Mode
480
-
481
- **Both modes use the project's existing directory structure.** Never create `figma-output/generated/`.
482
-
483
- ```
484
- if --new flag:
485
- → detect project's page/component/style directories (same as default)
486
- → generate self-contained token file (no MASTER.md dependency)
487
- → components are self-contained (own tokens, no external design system imports)
488
- → placed in project's standard directories with feature-named subfolder
489
-
490
- default (no flag):
491
- → scan existing component directories, theme files, token definitions
492
- → map output to project's conventions (file location, naming, imports)
493
- → add only NEW tokens that don't exist yet
494
- ```
495
-
496
- ---
497
-
498
- ## Phase 4: Style Architecture
499
-
500
- ### 4-1. Global Styles File
501
-
502
- **Token resolution priority** (default mode):
503
-
504
- 1. **MASTER.md tokens** — if `.claude/vibe/design-system/{project}/MASTER.md` exists, map Figma values to these tokens
505
- 2. **design-context.json tokens** — if `detectedStack.fonts`, `aesthetic.colorMood` exist, align with these
506
- 3. **New figma-tokens** — only for values that have no existing match
507
-
508
- **--new mode**: Generate self-contained token file (no MASTER.md dependency), in project's standard directories.
509
-
510
- #### Output Structure (both modes — project structure 준수)
511
-
512
- 프로젝트의 기존 디렉토리 구조를 감지하여 올바른 위치에 파일 생성.
513
-
514
- **Step 1: 디렉토리 감지**
515
-
516
- ```
517
- 페이지 디렉토리:
518
- Next.js → pages/ or app/
519
- Nuxt → pages/
520
- React → src/pages/ or src/views/
521
- Vue → src/views/
522
-
523
- 컴포넌트 디렉토리:
524
- Next.js → components/ or src/components/
525
- Nuxt → components/
526
- React → src/components/
527
- Vue → src/components/
528
-
529
- 스타일 디렉토리:
530
- SCSS → assets/scss/ or src/scss/ or src/styles/
531
- CSS → src/styles/ or styles/
532
- Tailwind → tailwind.config.* (extend)
533
- ```
534
-
535
- **Step 2: 피처명 기반 폴더 생성**
536
-
537
- Figma 파일명에서 피처명 자동 추출 → kebab-case 변환.
538
-
539
- ```
540
- 예: Figma 파일명 "PUBG 9주년 이벤트" → pubg-anniversary
541
-
542
- Nuxt 프로젝트:
543
- pages/pubg-anniversary.vue ← 루트 페이지
544
- components/pubg-anniversary/
545
- HeroSection.vue ← 섹션 컴포넌트
546
- EventSection.vue
547
- RewardSection.vue
548
- ...
549
- assets/scss/_pubg-anniversary-tokens.scss ← 피처별 토큰
550
-
551
- React + Next.js 프로젝트:
552
- app/pubg-anniversary/page.tsx ← 루트 페이지
553
- components/pubg-anniversary/
554
- HeroSection.tsx
555
- HeroSection.module.css (or .module.scss)
556
- EventSection.tsx
557
- ...
558
- styles/pubg-anniversary-tokens.css ← 피처별 토큰
559
-
560
- Default mode 차이점:
561
- → 토큰 파일에서 기존 MASTER.md / 프로젝트 토큰 참조
562
- → 새 토큰만 추가
563
-
564
- --new mode 차이점:
565
- → 토큰 파일이 자체 완결 (외부 의존 없음)
566
- → 다른 프로젝트에 폴더째 복사 가능
567
- ```
568
-
569
- ### 4-2. Token File Format
570
-
571
- **CSS Custom Properties (default):**
572
-
573
- ```css
574
- /* figma-tokens.css — Auto-generated from Figma. Do not edit manually. */
575
- /* Source: https://www.figma.com/design/{fileKey} */
576
-
577
- :root {
578
- /* Colors */
579
- --figma-primary: #3B82F6;
580
- --figma-primary-hover: #2563EB;
581
- --figma-surface: #FFFFFF;
582
- --figma-surface-secondary: #F9FAFB;
583
- --figma-text-primary: #111827;
584
- --figma-text-secondary: #6B7280;
585
- --figma-border: #E5E7EB;
586
-
587
- /* Typography */
588
- --figma-font-family: 'Inter', system-ui, sans-serif;
589
- --figma-text-xs: 0.75rem; /* 12px */
590
- --figma-text-sm: 0.875rem; /* 14px */
591
- --figma-text-base: 1rem; /* 16px */
592
- --figma-text-lg: 1.125rem; /* 18px */
593
- --figma-text-xl: 1.25rem; /* 20px */
594
- --figma-leading-tight: 1.25;
595
- --figma-leading-normal: 1.5;
596
-
597
- /* Spacing */
598
- --figma-space-1: 0.25rem; /* 4px */
599
- --figma-space-2: 0.5rem; /* 8px */
600
- --figma-space-3: 0.75rem; /* 12px */
601
- --figma-space-4: 1rem; /* 16px */
602
- --figma-space-6: 1.5rem; /* 24px */
603
- --figma-space-8: 2rem; /* 32px */
604
-
605
- /* Shadows */
606
- --figma-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
607
- --figma-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
608
-
609
- /* Border Radius */
610
- --figma-radius-sm: 0.25rem; /* 4px */
611
- --figma-radius-md: 0.5rem; /* 8px */
612
- --figma-radius-lg: 0.75rem; /* 12px */
613
- --figma-radius-full: 9999px;
614
- }
615
- ```
616
-
617
- **Tailwind extend (if Tailwind detected):**
618
-
619
- ```js
620
- // figma.config.ts — merge into tailwind.config.ts theme.extend
621
- export const figmaTokens = {
622
- colors: {
623
- figma: {
624
- primary: '#3B82F6',
625
- 'primary-hover': '#2563EB',
626
- // ...
627
- },
628
- },
629
- spacing: { /* ... */ },
630
- borderRadius: { /* ... */ },
631
- };
632
- ```
633
-
634
- **SCSS (if `*.scss` or `sass` detected):**
635
-
636
- ```scss
637
- // _figma-tokens.scss — Auto-generated from Figma. Do not edit manually.
638
-
639
- // ── Variables ──
640
- $figma-primary: #3B82F6;
641
- $figma-primary-hover: #2563EB;
642
- $figma-surface: #FFFFFF;
643
- $figma-text-primary: #111827;
644
- $figma-text-secondary: #6B7280;
645
- $figma-border: #E5E7EB;
646
-
647
- $figma-font-family: 'Inter', system-ui, sans-serif;
648
- $figma-text-xs: 0.75rem;
649
- $figma-text-sm: 0.875rem;
650
- $figma-text-base: 1rem;
651
- $figma-text-lg: 1.125rem;
652
- $figma-text-xl: 1.25rem;
653
-
654
- $figma-space-1: 0.25rem;
655
- $figma-space-2: 0.5rem;
656
- $figma-space-4: 1rem;
657
- $figma-space-6: 1.5rem;
658
- $figma-space-8: 2rem;
659
-
660
- $figma-radius-sm: 0.25rem;
661
- $figma-radius-md: 0.5rem;
662
- $figma-radius-lg: 0.75rem;
663
-
664
- $figma-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
665
- $figma-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
666
-
667
- // ── Breakpoints ──
668
- $figma-bp: 1024px;
669
- $figma-bp-mobile-min: 360px;
670
- $figma-bp-pc-target: 1920px;
671
-
672
- // ── Mixins ──
673
- @mixin figma-pc {
674
- @media (min-width: $figma-bp) { @content; }
675
- }
676
-
677
- @mixin figma-mobile-only {
678
- @media (max-width: $figma-bp - 1px) { @content; }
679
- }
680
-
681
- // ── Functions ──
682
- @function figma-fluid($mobile, $desktop, $min-vw: $figma-bp-mobile-min, $max-vw: $figma-bp-pc-target) {
683
- $slope: ($desktop - $mobile) / ($max-vw - $min-vw);
684
- $intercept: $mobile - $slope * $min-vw;
685
- @return clamp(#{$mobile}, #{$intercept} + #{$slope * 100}vw, #{$desktop});
686
- }
687
-
688
- // Usage: font-size: figma-fluid(1rem, 2rem);
689
- ```
690
-
691
- **SCSS 사용 시 추가 규칙:**
692
- - CSS custom properties 대신 `$변수` 사용 (프로젝트 컨벤션에 따라 둘 다 가능)
693
- - `@mixin figma-pc` 로 breakpoint 일관성 유지 — `@media` 직접 사용 금지
694
- - `figma-fluid()` 함수로 clamp() 계산 자동화 — 수동 계산 금지
695
- - 파일명: `_figma-tokens.scss` (partial, `_` prefix)
696
- - `@use 'figma-tokens' as figma;` 로 네임스페이스 import
697
-
698
- ### 4-3. Responsive Token Format (responsive mode only)
699
-
700
- When `responsive.json` exists, tokens that **differ across viewports** use `clamp()` for fluid scaling.
701
- Tokens that are **identical** across viewports remain static.
702
-
703
- **clamp() range uses breakpoints from Phase 3-3:**
704
-
705
- ```
706
- minVw = mobileMinimum (default: 360px)
707
- maxVw = pcTarget (default: 1920px)
708
- breakpoint = breakpoint (default: 1024px) ← used for @media
709
-
710
- Design values must be scaled before clamp:
711
- PC Figma value × (pcTarget / designPc) = target PC value
712
- Mobile Figma value × (mobilePortrait / designMobile) = target mobile value
713
- ```
714
-
715
- **CSS Custom Properties (responsive):**
716
-
717
- ```css
718
- /* figma-tokens.css — Responsive tokens from Figma */
719
- /* clamp range: {mobileMinimum}px → {pcTarget}px */
720
- /* Breakpoint: {breakpoint}px (PC↔Mobile) */
721
- /* Design scale: PC {designPc}→{pcTarget}, Mobile {designMobile}→{mobilePortrait} */
722
-
723
- :root {
724
- /* === Shared (same across all viewports) === */
725
- --figma-primary: #3B82F6;
726
- --figma-font-family: 'Inter', system-ui, sans-serif;
727
- --figma-radius-md: 0.5rem;
728
- --figma-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
729
-
730
- /* === Fluid Typography (scales with viewport) === */
731
- /* Figma PC 96px → target 36px, Figma Mobile 48px → target 32px */
732
- --figma-text-h1: clamp(2rem, {intercept}rem + {slope}vw, 2.25rem);
733
- --figma-text-body: clamp(0.875rem, {intercept}rem + {slope}vw, 1rem);
734
-
735
- /* === Fluid Spacing (scales with viewport) === */
736
- --figma-space-section: clamp(1rem, {intercept}rem + {slope}vw, 3rem);
737
- --figma-space-content: clamp(0.75rem, {intercept}rem + {slope}vw, 1.5rem);
738
-
739
- /* === Breakpoint (from config, user-customizable) === */
740
- --figma-bp: 1024px;
741
- }
742
- ```
743
-
744
- **clamp() calculation formula:**
745
-
746
- ```
747
- Step 1: Scale Figma values to target viewport
748
- targetMobile = figmaMobileValue × (mobilePortrait / designMobile)
749
- targetPc = figmaPcValue × (pcTarget / designPc)
750
-
751
- Example (defaults): Figma PC h1=96px, Figma Mobile h1=48px
752
- targetPc = 96 × (1920 / 2560) = 72px
753
- targetMobile = 48 × (480 / 720) = 32px
754
-
755
- Step 2: Calculate clamp()
756
- minVw = mobileMinimum (360)
757
- maxVw = pcTarget (1920)
758
- min = targetMobile, max = targetPc
759
-
760
- slope = (max - min) / (maxVw - minVw)
761
- intercept = min - slope * minVw
762
- → clamp({min/16}rem, {intercept/16}rem + {slope*100}vw, {max/16}rem)
763
-
764
- Example:
765
- slope = (72 - 32) / (1920 - 360) = 0.02564
766
- intercept = 32 - 0.02564 × 360 = 22.77
767
- → clamp(2rem, 1.423rem + 2.564vw, 4.5rem)
768
- ```
769
-
770
- **Tailwind (responsive — if Tailwind detected):**
771
-
772
- Use Tailwind's responsive prefixes instead of clamp() for layout, clamp() for typography/spacing:
773
-
774
- ```js
775
- export const figmaTokens = {
776
- fontSize: {
777
- 'figma-h1': ['clamp(1.5rem, 1.076rem + 1.878vw, 3rem)', { lineHeight: '1.2' }],
778
- 'figma-body': ['clamp(0.875rem, 0.828rem + 0.188vw, 1rem)', { lineHeight: '1.5' }],
779
- },
780
- spacing: {
781
- 'figma-section': 'clamp(1rem, 0.248rem + 3.286vw, 3rem)',
782
- },
783
- };
784
- ```
785
-
786
- **SCSS (responsive):**
787
-
788
- ```scss
789
- // _figma-tokens.scss — figma-fluid() 함수로 자동 계산
790
- @use 'sass:math';
791
-
792
- $figma-bp: 1024px;
793
- $figma-bp-mobile-min: 360px;
794
- $figma-bp-pc-target: 1920px;
795
-
796
- @function figma-fluid($mobile, $desktop, $min-vw: $figma-bp-mobile-min, $max-vw: $figma-bp-pc-target) {
797
- $slope: math.div($desktop - $mobile, $max-vw - $min-vw);
798
- $intercept: $mobile - $slope * $min-vw;
799
- @return clamp(#{$mobile}, #{$intercept} + #{$slope * 100}vw, #{$desktop});
800
- }
801
-
802
- @mixin figma-pc { @media (min-width: $figma-bp) { @content; } }
803
-
804
- // Token 사용
805
- $figma-text-h1: figma-fluid(2rem, 4.5rem);
806
- $figma-text-body: figma-fluid(0.875rem, 1rem);
807
- $figma-space-section: figma-fluid(1rem, 3rem);
808
- ```
809
-
810
- ```scss
811
- // Component.module.scss — 사용 예시
812
- @use 'figma-tokens' as figma;
813
-
814
- .heroSection {
815
- padding: figma.$figma-space-section;
816
- }
817
-
818
- .heroTitle {
819
- font-size: figma.$figma-text-h1;
820
- }
821
-
822
- .cardGrid {
823
- display: grid;
824
- grid-template-columns: 1fr;
825
-
826
- @include figma.figma-pc {
827
- grid-template-columns: repeat(3, 1fr);
828
- }
829
- }
830
- ```
831
-
832
- ### 4-4. Class Naming Rules
833
-
834
- 클래스 이름은 **역할(role)**을 드러내야 하며, 구조나 스타일 속성을 이름에 넣지 않는다.
835
-
836
- #### 네이밍 원칙
837
-
838
- | 원칙 | 좋은 예 | 나쁜 예 |
839
- |------|--------|--------|
840
- | **역할 기반** | `.heroSection`, `.productCard`, `.navPrimary` | `.section1`, `.card`, `.nav` |
841
- | **용도 명시** | `.heroBg`, `.cardThumbnail`, `.avatarImg` | `.bg`, `.img`, `.image1` |
842
- | **상태 포함** | `.buttonPrimary`, `.inputError` | `.blueButton`, `.redBorder` |
843
- | **관계 표현** | `.heroTitle`, `.heroDescription` | `.title`, `.text` |
844
- | **축약 금지** | `.navigationMenu`, `.backgroundImage` | `.navMnu`, `.bgImg` |
845
-
846
- #### 구체적 규칙
847
-
848
- ```
849
- 1. 컴포넌트 루트: 섹션/컴포넌트 이름 그대로
850
- .loginForm, .heroSection, .productGrid
851
-
852
- 2. 자식 요소: 부모이름 + 역할
853
- .heroTitle, .heroDescription, .heroCta
854
- .loginFormInput, .loginFormSubmit
855
-
856
- 3. 이미지 클래스: 반드시 용도를 명시
857
- .heroBg ← 히어로 배경 이미지
858
- .heroBgOverlay ← 배경 위 오버레이
859
- .productPhoto ← 상품 사진
860
- .brandLogo ← 브랜드 로고
861
-
862
- 4. 상태 변형: variant/state 접미사
863
- .buttonPrimary, .buttonDisabled
864
- .cardHighlight, .cardCompact
865
- ```
866
-
867
- #### Anti-Patterns
868
-
869
- ```css
870
- /* WRONG: 의미 없는 이름 */
871
- .wrapper { }
872
- .inner { }
873
- .box { }
874
- .item { }
875
- .text1 { }
876
-
877
- /* CORRECT: 역할이 드러나는 이름 */
878
- .eventSection { }
879
- .eventContent { }
880
- .rewardCard { }
881
- .rewardItem { }
882
- .eventDescription { }
883
- ```
884
-
885
- **Component style file MUST reference global tokens:**
886
-
887
- ```css
888
- /* LoginForm.module.css */
889
- .loginForm {
890
- padding: var(--figma-space-6);
891
- background: var(--figma-surface);
892
- border-radius: var(--figma-radius-lg);
893
- box-shadow: var(--figma-shadow-md);
894
- }
895
-
896
- .loginFormTitle {
897
- font-size: var(--figma-text-xl);
898
- font-weight: 600;
899
- color: var(--figma-text-primary);
900
- line-height: var(--figma-leading-tight);
901
- }
902
-
903
- .loginFormSubmit {
904
- background: var(--figma-primary);
905
- color: var(--figma-surface);
906
- border-radius: var(--figma-radius-md);
907
- padding: var(--figma-space-2) var(--figma-space-4);
908
- transition: background 150ms ease;
909
- }
910
-
911
- .loginFormSubmit:hover {
912
- background: var(--figma-primary-hover);
913
- }
914
- ```
915
-
916
- ---
77
+ 1. Load skill `vibe-figma` — 스토리보드 URL 입력 + MCP 추출
78
+ 2. Load skill `vibe-figma-analyze` — 세밀 분석 → 동작하는 레이아웃 코드 + 기능 주석
917
79
 
918
- ## Phase 5: Markup Quality Standards
80
+ ## Step B: 디자인 반영 (반복)
919
81
 
920
- ### 5-1. Semantic HTML (Mandatory)
82
+ Load skill `vibe-figma-frame` 디자인 URL → 프레임별 추출 → 코드 반영 → 검증 루프
921
83
 
922
- Every element MUST use the most specific semantic tag available. `<div>` is a last resort.
84
+ - 번째 URL: base 스타일 적용
85
+ - 추가 URL: 반응형 레이어 추가 (clamp + @media)
86
+ - URL이 더 없을 때까지 반복
923
87
 
924
- | Visual Element | Correct Tag | Wrong |
925
- |---------------|------------|-------|
926
- | Page section | `<section>`, `<article>`, `<aside>` | `<div>` |
927
- | Navigation | `<nav>` | `<div class="nav">` |
928
- | Page header | `<header>` | `<div class="header">` |
929
- | Page footer | `<footer>` | `<div class="footer">` |
930
- | Heading hierarchy | `<h1>`→`<h6>` (sequential, no skips) | `<div class="title">` |
931
- | Paragraph text | `<p>` | `<div>` or `<span>` |
932
- | List of items | `<ul>`/`<ol>` + `<li>` | `<div>` repeated |
933
- | Clickable action | `<button>` | `<div onClick>` |
934
- | Navigation link | `<a href>` | `<span onClick>` |
935
- | Form field | `<input>` + `<label>` | `<div contenteditable>` |
936
- | Image | `<img alt="descriptive">` or `<figure>` + `<figcaption>` | `<div style="background-image">` for content images |
937
- | Tabular data | `<table>` + `<thead>` + `<tbody>` | `<div>` grid |
938
- | Time/Date | `<time datetime>` | `<span>` |
939
- | Emphasized text | `<strong>`, `<em>` | `<span class="bold">` |
940
- | Grouped fields | `<fieldset>` + `<legend>` | `<div>` |
88
+ ## Step C: 최종 공통화
941
89
 
942
- ### 5-2. Accessibility Checklist
90
+ Load skill `vibe-figma-consolidate` 토큰 통합 + 중복 제거 + 최종 검증
943
91
 
944
- Every generated component MUST pass:
92
+ ## 코드 생성 규칙 (각 Step에서 필요 시 참조)
945
93
 
946
- - [ ] All interactive elements keyboard-reachable (tab order)
947
- - [ ] `<button>` for actions, `<a>` for navigation — never reversed
948
- - [ ] `<img>` has descriptive `alt` (not "image", not filename)
949
- - [ ] Form `<input>` linked to `<label>` (via `htmlFor` / `id`)
950
- - [ ] Color contrast >= 4.5:1 (text), >= 3:1 (large text, UI controls)
951
- - [ ] Focus indicator visible on all interactive elements
952
- - [ ] `aria-label` on icon-only buttons
953
- - [ ] `role` attribute on custom interactive widgets
954
- - [ ] Heading hierarchy is sequential (no h1 → h3 skip)
955
- - [ ] `<ul>`/`<ol>` for any visually listed items
94
+ | Skill | 내용 | 참조 시점 |
95
+ |-------|------|----------|
96
+ | `vibe-figma-rules` | 분석/감지 (Model Routing, Phase 1-3) | Step A, B |
97
+ | `vibe-figma-style` | 스타일 (토큰, SCSS, 클래스 네이밍) | Step B, C |
98
+ | `vibe-figma-codegen` | 코드 생성 (마크업, 이미지, 반응형, 검증) | Step B, C |
956
99
 
957
- ### 5-3. Wrapper Elimination (Fragment / template)
100
+ ## Design Quality Pipeline
958
101
 
959
- **불필요한 래핑 태그를 제거**하고 프레임워크가 제공하는 투명 래퍼를 사용:
960
-
961
- | Stack | 투명 래퍼 | 사용 시점 |
962
- |-------|----------|----------|
963
- | React / Next.js | `<>...</>` 또는 `<React.Fragment>` | 형제 요소를 그룹핑할 때 (DOM에 노드 추가 안 함) |
964
- | Vue / Nuxt | `<template>` (컴포넌트 루트 이외) | `v-if`, `v-for` 로 여러 요소를 조건부 렌더링할 때 |
965
- | Svelte | `{#if}`, `{#each}` 블록 | 자체적으로 래핑 불필요 |
966
-
967
- ```tsx
968
- // WRONG: 불필요한 div 래핑
969
- <div>
970
- <Header />
971
- <Main />
972
- <Footer />
973
- </div>
974
-
975
- // CORRECT: React Fragment
976
- <>
977
- <Header />
978
- <Main />
979
- <Footer />
980
- </>
981
- ```
982
-
983
- ```vue
984
- <!-- WRONG: 불필요한 div 래핑 -->
985
- <div v-if="showGroup">
986
- <ItemA />
987
- <ItemB />
988
- </div>
989
-
990
- <!-- CORRECT: Vue template (DOM에 렌더링 안 됨) -->
991
- <template v-if="showGroup">
992
- <ItemA />
993
- <ItemB />
994
- </template>
995
- ```
996
-
997
- **규칙**: 래핑 요소에 스타일이나 이벤트가 없으면 → Fragment/template 사용. 스타일이 있으면 → semantic 태그 사용.
998
-
999
- ### 5-4. Similar UI Consolidation (80% Rule)
1000
-
1001
- 디자인에서 **유사도 80% 이상**인 UI 패턴이 발견되면, 별도 컴포넌트로 분리하지 말고 **하나의 컴포넌트 + variant props/slots**으로 통합:
1002
-
1003
- ```
1004
- 유사도 판단 기준:
1005
- - 레이아웃 구조 동일
1006
- - 색상/크기/텍스트만 다름
1007
- → 하나의 컴포넌트 + props로 변형
1008
-
1009
- - 구조 자체가 다름 (요소 추가/제거, 레이아웃 방향 변경)
1010
- → 별도 컴포넌트
1011
- ```
1012
-
1013
- | Stack | 변형 방법 |
1014
- |-------|----------|
1015
- | React | `variant` prop + 조건부 className / style |
1016
- | Vue | `variant` prop + `<slot>` for 커스텀 영역 |
1017
- | Svelte | `variant` prop + `<slot>` |
1018
- | React Native | `variant` prop + StyleSheet 조건 선택 |
1019
-
1020
- ```tsx
1021
- // React — 하나의 Card 컴포넌트가 3가지 변형 처리
1022
- interface CardProps {
1023
- variant: 'default' | 'highlight' | 'compact';
1024
- title: string;
1025
- children: React.ReactNode;
1026
- }
1027
-
1028
- export function Card({ variant, title, children }: CardProps): JSX.Element {
1029
- return (
1030
- <article className={styles[variant]}>
1031
- <h3 className={styles.title}>{title}</h3>
1032
- {children}
1033
- </article>
1034
- );
1035
- }
1036
- ```
1037
-
1038
- ```vue
1039
- <!-- Vue — slot으로 커스텀 영역 제공 -->
1040
- <template>
1041
- <article :class="$style[variant]">
1042
- <h3 :class="$style.title">{{ title }}</h3>
1043
- <slot />
1044
- </article>
1045
- </template>
1046
-
1047
- <script setup lang="ts">
1048
- defineProps<{ variant: 'default' | 'highlight' | 'compact'; title: string }>();
1049
- </script>
1050
- ```
1051
-
1052
- ### 5-5. Component Structure Rules
1053
-
1054
- ```
1055
- Max nesting depth: 3 levels (container > group > element)
1056
- Max component length: 50 lines
1057
- Max props: 5 per component
1058
- ```
1059
-
1060
- **Split triggers:**
1061
-
1062
- | Signal | Action |
1063
- |--------|--------|
1064
- | Component > 50 lines | Split into sub-components |
1065
- | Repeated visual pattern (2+ times) | Extract shared component |
1066
- | **Similar pattern (80%+ match)** | **Single component + variant prop** |
1067
- | Distinct visual boundary (card, modal, form) | Own component + own style file |
1068
- | 3+ related props | Group into object prop or extract sub-component |
1069
-
1070
- ### 5-6. Markup Anti-Patterns (NEVER Generate)
1071
-
1072
- ```tsx
1073
- // WRONG: div soup
1074
- <div className="card">
1075
- <div className="card-header">
1076
- <div className="title">Login</div>
1077
- </div>
1078
- <div className="card-body">
1079
- <div className="input-group">
1080
- <div className="label">Email</div>
1081
- <div className="input"><input /></div>
1082
- </div>
1083
- </div>
1084
- </div>
1085
-
1086
- // CORRECT: semantic markup
1087
- <article className={styles.card}>
1088
- <header className={styles.header}>
1089
- <h2 className={styles.title}>Login</h2>
1090
- </header>
1091
- <form className={styles.body}>
1092
- <fieldset className={styles.fieldGroup}>
1093
- <label htmlFor="email" className={styles.label}>Email</label>
1094
- <input id="email" type="email" className={styles.input} />
1095
- </fieldset>
1096
- </form>
1097
- </article>
1098
- ```
1099
-
1100
- ```tsx
1101
- // WRONG: 불필요한 래핑
1102
- <div>
1103
- <ComponentA />
1104
- <ComponentB />
1105
- </div>
1106
-
1107
- // CORRECT: Fragment
1108
- <>
1109
- <ComponentA />
1110
- <ComponentB />
1111
- </>
1112
- ```
1113
-
1114
- ```tsx
1115
- // WRONG: 유사한 UI를 별도 컴포넌트로
1116
- <DefaultCard /> // 구조 동일, 색상만 다름
1117
- <HighlightCard /> // 구조 동일, 색상만 다름
1118
-
1119
- // CORRECT: 단일 컴포넌트 + variant
1120
- <Card variant="default" />
1121
- <Card variant="highlight" />
1122
- ```
1123
-
1124
- ---
1125
-
1126
- ## Phase 6: Code Generation
1127
-
1128
- ### 6-0. Apply Storyboard Spec + Design Context
1129
-
1130
- **스토리보드 스펙 (Phase 0-1)이 있으면 우선 적용:**
1131
-
1132
- | storyboardSpec | Effect on Code Generation |
1133
- |----------------|--------------------------|
1134
- | `interactions` | 호버/클릭/스크롤 이벤트 → CSS `:hover`/`:active`/`:focus` + JS 핸들러 |
1135
- | `animations` | 트랜지션/애니메이션 → `transition`, `@keyframes`, timing/easing 스펙대로 |
1136
- | `states` | 로딩/에러/성공/빈 상태 → 조건부 렌더링 + 상태별 UI 컴포넌트 |
1137
- | `breakpoints` | Phase 3-3에서 이미 적용됨 |
1138
- | `colorGuide` | 스토리보드 컬러 가이드 → 토큰 검증 |
1139
- | `typographyGuide` | 스토리보드 타이포 가이드 → 토큰 검증 |
1140
-
1141
- **design-context.json이 있으면 추가 적용:**
1142
-
1143
- | Context Field | Effect on Code Generation |
1144
- |---------------|--------------------------|
1145
- | `constraints.accessibility = "AAA"` | Use `aria-describedby` on all form fields, `prefers-reduced-motion` media query, `prefers-contrast` support |
1146
- | `constraints.devices = ["mobile"]` | Mobile-only layout, no desktop breakpoints, touch target ≥ 44px |
1147
- | `constraints.devices = ["mobile","desktop"]` | Mobile-first with `md:` breakpoint |
1148
- | `aesthetic.style = "minimal"` | Reduce visual weight — fewer shadows, thinner borders, more whitespace |
1149
- | `aesthetic.style = "bold"` | Stronger shadows, thicker borders, larger typography scale |
1150
- | `brand.personality` | Preserve brand-unique visual patterns (do NOT distill these away) |
1151
- | `detectedStack.fonts` | Use project's existing font stack instead of Figma's font family |
1152
-
1153
- ### 6-1. Stack-Specific Rules
1154
-
1155
- Generate code following these rules per stack:
1156
-
1157
- #### React / Next.js + TypeScript
1158
-
1159
- ```
1160
- - Functional components with explicit return types
1161
- - Props interface defined above component
1162
- - Named exports (not default)
1163
- - <></> Fragment for sibling grouping (no unnecessary wrapper div)
1164
- - CSS Modules: import styles from './Component.module.css'
1165
- - Tailwind: classes in JSX, extract repeated patterns to @apply
1166
- - Responsive: mobile-first breakpoints
1167
- - Variant pattern: discriminated union props for similar UI
1168
- - useMemo/useCallback only when measurably needed (not by default)
1169
- - Next.js: use 'use client' only when client interactivity needed
1170
- - Next.js: Image component for images, Link for navigation
1171
- ```
1172
-
1173
- #### Vue 3 / Nuxt
1174
-
1175
- ```
1176
- - <script setup lang="ts"> composition API
1177
- - defineProps with TypeScript interface (with defaults via withDefaults)
1178
- - <template> for invisible grouping (v-if, v-for on multiple elements)
1179
- - <style scoped> (or <style module>) with CSS custom property references
1180
- - v-bind in <style> for dynamic values: color: v-bind(themeColor)
1181
- - <slot> + named slots for composable variant patterns
1182
- - <Teleport> for modals/overlays
1183
- - Or Tailwind classes in template
1184
- - Nuxt: <NuxtLink> for navigation, <NuxtImg> for images
1185
- - Nuxt: definePageMeta for page-level config
1186
- - computed() for derived state (not methods for template expressions)
1187
- ```
1188
-
1189
- #### Svelte
1190
-
1191
- ```
1192
- - TypeScript in <script lang="ts">
1193
- - Export let for props with types
1194
- - {#if}/{#each}/{#await} blocks — inherently wrapper-free
1195
- - <slot> for composable patterns
1196
- - <style> block with CSS custom property references
1197
- - Or Tailwind classes in markup
1198
- - Reactive declarations ($:) for derived values
1199
- - transition: directive for animations
1200
- ```
1201
-
1202
- #### SCSS (any framework with SCSS)
1203
-
1204
- ```
1205
- - @use 'figma-tokens' as figma — namespaced import (not @import)
1206
- - $변수 for tokens: figma.$figma-primary, figma.$figma-space-4
1207
- - @include figma.figma-pc { } for breakpoint — @media 직접 사용 금지
1208
- - figma-fluid($mobile, $desktop) for responsive values — 수동 clamp() 금지
1209
- - Nesting max 3 levels: .section { .title { .icon { } } } ← 한계
1210
- - & for BEM-like modifiers: &--active, &__title
1211
- - @each for variant generation from map
1212
- - Partials: _figma-tokens.scss, _figma-mixins.scss
1213
- - Vue: <style lang="scss" scoped> with @use
1214
- ```
1215
-
1216
- ```scss
1217
- // Component usage example
1218
- @use 'figma-tokens' as figma;
1219
-
1220
- .heroSection {
1221
- position: relative;
1222
- padding: figma.figma-fluid(1rem, 3rem);
1223
-
1224
- &Title {
1225
- font-size: figma.figma-fluid(1.5rem, 3rem);
1226
- color: figma.$figma-text-primary;
1227
- }
1228
-
1229
- &Cta {
1230
- background: figma.$figma-primary;
1231
- border-radius: figma.$figma-radius-md;
1232
-
1233
- &:hover { background: figma.$figma-primary-hover; }
1234
- }
1235
- }
1236
-
1237
- .cardGrid {
1238
- display: grid;
1239
- grid-template-columns: 1fr;
1240
-
1241
- @include figma.figma-pc {
1242
- grid-template-columns: repeat(3, 1fr);
1243
- }
1244
- }
1245
- ```
1246
-
1247
- #### React Native
1248
-
1249
- ```
1250
- - StyleSheet.create at bottom of file
1251
- - <></> Fragment for sibling grouping
1252
- - Dimensions-aware responsive layout
1253
- - Platform.select / Platform.OS for platform-specific styles
1254
- - Extract shared style constants to styles/tokens.ts
1255
- ```
1256
-
1257
- #### Flutter (Dart)
1258
-
1259
- ```
1260
- - StatelessWidget or StatefulWidget as appropriate
1261
- - Theme.of(context) for design tokens
1262
- - Extract shared values to lib/theme/figma_tokens.dart
1263
- - Proper widget composition
1264
- ```
1265
-
1266
- ### 6-2. Image Code Patterns (from Phase 2-A classification)
1267
-
1268
- Phase 2-A에서 분류된 이미지 유형별 코드 생성 규칙:
1269
-
1270
- #### Background Image Class Separation (핵심 원칙)
1271
-
1272
- 배경 이미지 관련 요소는 **용도별로 별도 클래스**로 분리한다. 레이아웃과 이미지를 합치지 않는다.
1273
-
1274
- ##### 별도 클래스로 분리해야 하는 유형
1275
-
1276
- | 유형 | 클래스 예시 | 분리 이유 |
1277
- |------|-----------|----------|
1278
- | **섹션 전면 배경** | `.heroBg`, `.eventBg`, `.rewardsBg` | 이벤트 기간/시즌별 이미지 교체 |
1279
- | **오버레이** | `.heroBgOverlay`, `.eventBgOverlay` | 투명도/그라데이션 독립 조절 |
1280
- | **패턴/텍스처** | `.sectionPattern`, `.headerTexture` | `background-repeat`/`size` 별도 제어 |
1281
- | **파티클/장식 효과** | `.heroParticle`, `.sparkleEffect` | 애니메이션 on/off, 성능 이슈 시 제거 |
1282
- | **캐릭터/일러스트** | `.heroCharacter`, `.eventIllust` | 콜라보/캐릭터별 교체, position 조절 |
1283
- | **그라데이션** | `.sectionGradient`, `.fadeBottom` | 테마별 색상 변경 |
1284
- | **비디오 포스터** | `.videoPoster` | 비디오 로드 전 폴백, JS에서 교체 |
1285
-
1286
- ##### Multi-Layer Pattern (섹션 배경 기본 구조)
1287
-
1288
- Figma에서 배경 이미지가 있는 섹션은 다음 레이어 구조로 생성:
1289
-
1290
- ```
1291
- .{section}Section ← 레이아웃 (position, size, padding, overflow)
1292
- .{section}Bg ← 배경 이미지 (URL, size, position) — z-index: 0
1293
- .{section}BgOverlay ← 오버레이 (gradient, opacity) — z-index: 1
1294
- .{section}Character ← 캐릭터/일러스트 (선택) — z-index: 2
1295
- .{section}Pattern ← 패턴/텍스처 (선택) — z-index: 1
1296
- .{section}Content ← 텍스트/버튼/UI — z-index: 최상위
1297
- ```
1298
-
1299
- ```tsx
1300
- // 실제 마크업 예시 — 게임 이벤트 히어로 섹션
1301
- <section className={styles.heroSection}>
1302
- <div className={styles.heroBg} />
1303
- <div className={styles.heroBgOverlay} />
1304
- <div className={styles.heroCharacter} />
1305
- <div className={styles.heroContent}>
1306
- <h1 className={styles.heroTitle}>Stellar Blade × PUBG</h1>
1307
- <p className={styles.heroDescription}>기간한정 콜라보 이벤트</p>
1308
- <a href="#rewards" className={styles.heroCta}>보상 확인하기</a>
1309
- </div>
1310
- </section>
1311
- ```
1312
-
1313
- ```css
1314
- /* heroSection.module.css */
1315
- .heroSection { position: relative; overflow: hidden; min-height: 100vh; }
1316
-
1317
- .heroBg {
1318
- position: absolute; inset: 0; z-index: 0;
1319
- background-image: url('/assets/hero-bg.webp');
1320
- background-size: cover;
1321
- background-position: center;
1322
- }
1323
-
1324
- .heroBgOverlay {
1325
- position: absolute; inset: 0; z-index: 1;
1326
- background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.7));
1327
- }
1328
-
1329
- .heroCharacter {
1330
- position: absolute; bottom: 0; right: 5%; z-index: 2;
1331
- width: 40%; height: 80%;
1332
- background-image: url('/assets/hero-character.webp');
1333
- background-size: contain;
1334
- background-position: bottom center;
1335
- background-repeat: no-repeat;
1336
- }
1337
-
1338
- .heroContent { position: relative; z-index: 3; }
1339
- ```
1340
-
1341
- **모든 배경 관련 이미지가 독립 클래스**이므로:
1342
- - JS에서 `.heroBg`만 교체하면 배경만 바뀜
1343
- - `.heroCharacter`만 교체하면 캐릭터만 바뀜
1344
- - `.heroBgOverlay`의 opacity를 조절하면 텍스트 가독성만 조절 가능
1345
- - 성능 이슈 시 `.heroParticle`만 `display: none`
1346
-
1347
- #### Responsive Background Image (반응형 배경 — PC/Mobile 분기)
1348
-
1349
- ```css
1350
- /* 배경 이미지 클래스 안에서만 반응형 처리 */
1351
- .heroBg {
1352
- background-image: url('/assets/hero-mobile.webp');
1353
- background-size: cover;
1354
- background-position: center;
1355
- position: absolute;
1356
- inset: 0;
1357
- z-index: 0;
1358
- }
1359
-
1360
- @media (min-width: 1024px) { /* {breakpoint}px */
1361
- .heroBg {
1362
- background-image: url('/assets/hero-pc.webp');
1363
- }
1364
- }
1365
- ```
1366
-
1367
- **섹션별 배경 이미지가 여러 개인 경우** — 각각 고유 클래스:
1368
-
1369
- ```css
1370
- .heroBg { background-image: url('/assets/hero-bg.webp'); /* ... */ }
1371
- .eventBg { background-image: url('/assets/event-bg.webp'); /* ... */ }
1372
- .rewardsBg { background-image: url('/assets/rewards-bg.webp'); /* ... */ }
1373
- ```
1374
-
1375
- **Figma 오버레이 감지**: 레이어에 `opacity < 1` 또는 `fills`에 반투명 색상이 IMAGE 위에 있으면 → `{section}BgOverlay` 클래스로 처리.
1376
-
1377
- #### Content Image (독립적인 이미지 콘텐츠)
1378
-
1379
- ```tsx
1380
- // React / Next.js
1381
- <img
1382
- src="/assets/product.webp"
1383
- alt="상품 설명" // Figma 레이어 이름 기반
1384
- width={600} // Figma 레이어 width (scaled)
1385
- height={400} // Figma 레이어 height (scaled)
1386
- loading="lazy" // 뷰포트 밖이면 lazy
1387
- />
1388
-
1389
- // Next.js — Image 컴포넌트 우선
1390
- import Image from 'next/image';
1391
- <Image
1392
- src="/assets/product.webp"
1393
- alt="상품 설명"
1394
- width={600}
1395
- height={400}
1396
- priority={false} // hero 이미지만 priority={true}
1397
- />
1398
- ```
1399
-
1400
- ```vue
1401
- <!-- Nuxt — NuxtImg 우선 -->
1402
- <NuxtImg
1403
- src="/assets/product.webp"
1404
- alt="상품 설명"
1405
- width="600"
1406
- height="400"
1407
- loading="lazy"
1408
- />
1409
- ```
1410
-
1411
- #### Responsive Content Image (뷰포트별 다른 이미지)
1412
-
1413
- ```html
1414
- <picture>
1415
- <source media="(min-width: 1024px)" srcset="/assets/hero-pc.webp" />
1416
- <img src="/assets/hero-mobile.webp" alt="히어로 이미지" loading="eager" />
1417
- </picture>
1418
- ```
1419
-
1420
- #### 이미지 공통 규칙
1421
-
1422
- | 규칙 | 설명 |
1423
- |------|------|
1424
- | **format** | `.webp` 우선 (fallback: `.png`/`.jpg`) |
1425
- | **alt** | Figma 레이어 이름에서 파생, 장식 이미지는 `alt=""` + `aria-hidden="true"` |
1426
- | **width/height** | 항상 명시 (CLS 방지), Figma 레이어 크기를 스케일 팩터 적용 후 사용 |
1427
- | **loading** | 뷰포트 상단(hero, header) → `eager`, 나머지 → `lazy` |
1428
- | **object-fit** | `cover` (배경/히어로), `contain` (로고/아이콘), `fill` 사용 금지 |
1429
- | **반응형 크기** | Content image는 `max-width: 100%; height: auto;` 기본 |
1430
- | **배경 이미지 + 텍스트** | 반드시 오버레이(`::before` 또는 gradient)로 텍스트 가독성 확보 |
1431
- | **장식 패턴** | `background-repeat: repeat` + `background-size` 조절 |
1432
-
1433
- #### Anti-Patterns
1434
-
1435
- ```tsx
1436
- // WRONG: 레이아웃 클래스에 background-image를 합침
1437
- <section className={styles.hero} /> /* .hero에 bg-image + padding + flex 등 다 섞임 */
1438
-
1439
- // CORRECT: 배경 이미지는 별도 클래스
1440
- <section className={styles.heroSection}>
1441
- <div className={styles.heroBg} />
1442
- <div className={styles.heroContent}>...</div>
1443
- </section>
1444
- ```
1445
-
1446
- ```tsx
1447
- // WRONG: inline style로 배경 이미지
1448
- <div style={{ backgroundImage: `url(${bg})` }} />
1449
-
1450
- // CORRECT: 전용 클래스에 이미지 URL
1451
- <div className={styles.heroBg} />
1452
- /* JS 동적 교체 시: element.style.backgroundImage = url(...) on .heroBg만 */
1453
- ```
1454
-
1455
- ```css
1456
- /* WRONG: 배경 + 텍스트, 오버레이 없음 */
1457
- .hero { background-image: url(...); color: white; }
1458
-
1459
- /* CORRECT: 3-layer 분리 (bg / overlay / content) */
1460
- .heroSection { position: relative; }
1461
- .heroBg { background-image: url(...); position: absolute; inset: 0; z-index: 0; }
1462
- .heroBgOverlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); z-index: 1; }
1463
- .heroContent { position: relative; z-index: 2; color: white; }
1464
- ```
1465
-
1466
- ```css
1467
- /* WRONG: 의미 없는 이름 */
1468
- .bg { }
1469
- .bgImg { }
1470
- .overlay { }
1471
-
1472
- /* CORRECT: 섹션별 명시적 이름 */
1473
- .heroBg { }
1474
- .heroBgOverlay { }
1475
- .eventBg { }
1476
- .rewardsBg { }
1477
- ```
1478
-
1479
- ### 6-3. Responsive Code Generation (responsive mode only)
1480
-
1481
- When `responsive.json` exists, apply these rules on top of stack-specific rules:
1482
-
1483
- #### Principle: Fluid First, Breakpoint Second
1484
-
1485
- ```
1486
- 1. Typography & Spacing → clamp() fluid tokens (no breakpoints needed)
1487
- 2. Layout direction changes → @media at project breakpoint (flex-direction, grid-template)
1488
- 3. Visibility toggles → @media at project breakpoint (display: none/block)
1489
- 4. Component swaps → conditional render with useMediaQuery or CSS
1490
- ```
1491
-
1492
- **Breakpoint selection**: Use `{breakpoints}` from Phase 3-3. Pick the breakpoint closest to where the layout structurally changes between Figma viewports. For example:
1493
- - Figma mobile=375px, desktop=1440px → use project's `md` (typically 768px) as primary breakpoint
1494
- - If project has `tablet: 1024px` → use that instead
1495
- - If 3 viewports (mobile/tablet/desktop) → use 2 breakpoints (e.g., `sm` and `lg`)
1496
-
1497
- #### CSS Modules (responsive example)
1498
-
1499
- ```css
1500
- /* Component.module.css */
1501
- /* Breakpoints from project: {breakpoints} */
1502
-
1503
- .container {
1504
- display: flex;
1505
- flex-direction: column; /* mobile-first */
1506
- gap: var(--figma-space-content); /* fluid: clamp() */
1507
- padding: var(--figma-space-section); /* fluid: clamp() */
1508
- }
1509
-
1510
- .title {
1511
- font-size: var(--figma-text-h1); /* fluid: clamp() */
1512
- line-height: 1.2;
1513
- }
1514
-
1515
- .cardGrid {
1516
- display: grid;
1517
- grid-template-columns: 1fr; /* mobile: single column */
1518
- gap: var(--figma-space-content);
1519
- }
1520
-
1521
- /* Layout breakpoint — use project's breakpoint, NOT hardcoded */
1522
- @media (min-width: 1024px) { /* {breakpoint}px from Phase 3-3 */ /* or project's md value */
1523
- .container {
1524
- flex-direction: row;
1525
- }
1526
- .cardGrid {
1527
- grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
1528
- }
1529
- }
1530
-
1531
- /* Visibility toggle — same breakpoint */
1532
- .mobileOnly { display: block; }
1533
- .desktopOnly { display: none; }
1534
-
1535
- @media (min-width: 1024px) { /* {breakpoint}px from Phase 3-3 */
1536
- .mobileOnly { display: none; }
1537
- .desktopOnly { display: block; }
1538
- }
1539
- ```
1540
-
1541
- #### Tailwind (responsive example)
1542
-
1543
- Use project's Tailwind screen prefixes (e.g., `sm:`, `md:`, `lg:`) — NOT hardcoded pixel values.
1544
-
1545
- ```tsx
1546
- {/* Uses project's Tailwind breakpoints — md: maps to project's screens.md */}
1547
- <div className="flex flex-col md:flex-row gap-[--figma-space-content] p-[--figma-space-section]">
1548
- <h1 className="text-[length:--figma-text-h1] leading-tight">Title</h1>
1549
- <div className="grid grid-cols-1 md:grid-cols-3 gap-[--figma-space-content]">
1550
- {/* cards */}
1551
- </div>
1552
- <nav className="md:hidden">Mobile Nav</nav>
1553
- <nav className="hidden md:flex">Desktop Nav</nav>
1554
- </div>
1555
- ```
1556
-
1557
- #### Anti-Patterns (NEVER do in responsive mode)
1558
-
1559
- | Wrong | Right |
1560
- |-------|-------|
1561
- | Separate mobile/desktop component files | Single component with responsive CSS |
1562
- | `@media` for font-size/spacing | `clamp()` via fluid tokens |
1563
- | Hardcoded `@media (min-width: 768px)` | Use project breakpoint from Phase 3-3 or Tailwind prefix |
1564
- | Pixel values in responsive styles | Token variables everywhere |
1565
- | Duplicated markup for each viewport | Visibility toggles or conditional sections |
1566
- | `window.innerWidth` checks in JS | CSS-only responsive (`@media`, `clamp()`, `auto-fit`) |
1567
- | Inventing new breakpoints | Use project's existing breakpoint system |
1568
-
1569
- ---
1570
-
1571
- ## Phase 7: Token Mapping (default mode)
1572
-
1573
- **Only in default (project integration) mode.** Map extracted Figma tokens to the project's existing token system.
1574
-
1575
- ### Token Source Priority
1576
-
1577
- ```
1578
- 1. MASTER.md (.claude/vibe/design-system/{project}/MASTER.md) ← 최우선
1579
- 2. design-context.json (.claude/vibe/design-context.json) ← 보조
1580
- 3. Project theme files (tailwind.config, CSS variables, etc.) ← 폴백
1581
- 4. Generate new figma-tokens ← 마지막 수단
1582
- ```
1583
-
1584
- ### Mapping Rules
1585
-
1586
- 1. **MASTER.md exists** → authoritative token source
1587
- - Figma color ≈ MASTER.md color (ΔE < 5) → use MASTER.md token name
1588
- - Figma spacing ≈ MASTER.md spacing (±2px) → use MASTER.md token name
1589
- - Figma font ≈ MASTER.md font → use MASTER.md token name
1590
- - Unmatched Figma values → add to `figma-tokens.css` as supplementary tokens
1591
-
1592
- 2. **No MASTER.md, but design-context.json exists** →
1593
- - Use `detectedStack` info for naming convention
1594
- - Use `aesthetic.colorMood` to validate token naming (e.g., warm palette → warm- prefix)
1595
- - Generate `figma-tokens.css` grouped by category
1596
-
1597
- 3. **No design system at all** →
1598
- - Generate `figma-tokens.css` (or Tailwind extend)
1599
- - Group tokens by category (color, typography, spacing, shadow)
1600
-
1601
- ### Output Mapping Comment
1602
-
1603
- Always output token mapping as a comment block at the top of the token file:
1604
-
1605
- ```
1606
- /* Figma Token Mapping:
1607
- * Figma "Primary/Default" → var(--figma-primary) = #3B82F6
1608
- * ✅ Matched: var(--color-blue-500) from MASTER.md
1609
- * Figma "Text/Body" → var(--figma-text-base) = 1rem / 1.5
1610
- * ✅ Matched: var(--text-base) from MASTER.md
1611
- * Figma "Accent/Glow" → var(--figma-accent-glow) = #7C3AED
1612
- * ⚠️ New token: no existing match
1613
- */
1614
- ```
1615
-
1616
- ---
1617
-
1618
- ## Phase 8: Correction Notes
1619
-
1620
- After generating code, output a brief correction report:
1621
-
1622
- ```markdown
1623
- ## Correction Notes
1624
-
1625
- ### Generation Mode
1626
- - Mode: default / --new / responsive
1627
- - Output directory: {path}
1628
- - Viewports: {list of viewport labels + widths, if responsive}
1629
-
1630
- ### Files Generated
1631
- | File | Type | Description |
1632
- |------|------|-------------|
1633
- | styles/tokens.css | Global tokens | {N} colors, {N} spacing, {N} typography |
1634
- | styles/global.css | Base styles | Reset + typography + layout |
1635
- | ComponentName/ComponentName.tsx | Component | Root component |
1636
- | ComponentName/ComponentName.module.css | Styles | Component-specific styles |
1637
-
1638
- ### Responsive Summary (responsive mode only)
1639
- | Token | Mobile | Desktop | Strategy |
1640
- |-------|--------|---------|----------|
1641
- | --figma-text-h1 | 24px | 48px | clamp() |
1642
- | --figma-space-section | 16px | 48px | clamp() |
1643
- | Card grid | 1col | 3col | @media grid |
1644
- | Sidebar | hidden | visible | @media display |
1645
-
1646
- - Fluid tokens generated: {N}
1647
- - Layout breakpoints used: {list}
1648
- - Component swaps: {list or "none"}
1649
-
1650
- ### Layer Issues Found
1651
- - [Layer name] was ambiguous → interpreted as [component] based on image
1652
- - [Layer structure] didn't match visual → used image-based layout
1653
-
1654
- ### Markup Quality
1655
- - Semantic tags used: {list}
1656
- - Accessibility: {pass/fail items}
1657
-
1658
- ### Recommendations for Figma File
1659
- - Use Auto Layout for [specific frame] to improve extraction accuracy
1660
- - Name layers semantically (e.g., "login-form" not "Frame 47")
1661
- - Use consistent spacing tokens
1662
- - (responsive) Keep same component names across mobile/desktop frames for easier mapping
1663
- ```
1664
-
1665
- ---
1666
-
1667
- ## Phase 9: Visual Verification Loop
1668
-
1669
- 코드 생성 완료 후, **Figma 원본 디자인과 생성된 UI를 비교**하여 완성도를 높이는 검증 루프.
1670
-
1671
- ### 9-1. 스크린샷 비교
1672
-
1673
- ```
1674
- 1. Figma 원본 스크린샷: Phase 0에서 get_screenshot으로 획득한 이미지
1675
- 2. 생성된 UI 스크린샷: /vibe.utils --preview 또는 브라우저 스크린샷
1676
- 3. 두 이미지를 side-by-side로 비교
1677
- ```
1678
-
1679
- ### 9-2. 차이점 검출
1680
-
1681
- 이미지를 비교하여 다음 항목 체크:
1682
-
1683
- | 검증 항목 | 비교 방법 |
1684
- |----------|----------|
1685
- | **레이아웃** | 요소 배치, 정렬, 간격이 원본과 일치하는가 |
1686
- | **타이포그래피** | 폰트 크기, 굵기, 줄간격이 원본과 일치하는가 |
1687
- | **색상** | 배경, 텍스트, 버튼 색상이 원본과 일치하는가 |
1688
- | **이미지** | 배경 이미지, 에셋이 올바르게 표시되는가 |
1689
- | **간격/여백** | padding, margin, gap이 원본과 일치하는가 |
1690
- | **반응형** | (responsive mode) 모바일/데스크탑 각각 원본과 일치하는가 |
1691
- | **누락 요소** | 원본에 있는데 생성 코드에 없는 요소가 있는가 |
1692
-
1693
- ### 9-3. Diff Report 출력
1694
-
1695
- ```markdown
1696
- ## Visual Diff Report
1697
-
1698
- ### Match Score: {N}% (목표: 95%+)
1699
-
1700
- ### 불일치 항목
1701
- | # | 섹션 | 항목 | Figma 원본 | 생성 코드 | 심각도 |
1702
- |---|------|------|-----------|----------|--------|
1703
- | 1 | Hero | 제목 font-size | 48px | 36px | P1 |
1704
- | 2 | Hero | 배경 이미지 | 표시됨 | 누락 | P1 |
1705
- | 3 | Card | border-radius | 12px | 8px | P2 |
1706
-
1707
- ### 수정 필요
1708
- - P1: {count}건 (반드시 수정)
1709
- - P2: {count}건 (권장 수정)
1710
- ```
1711
-
1712
- ### 9-4. Auto-Fix Loop
1713
-
1714
- ```
1715
- P1 불일치가 있으면:
1716
- 1. 해당 컴포넌트/스타일 파일을 수정
1717
- 2. 다시 스크린샷 비교
1718
- 3. P1이 0이 될 때까지 반복 (횟수 제한 없음)
1719
-
1720
- 수렴 감지:
1721
- - 이전 라운드와 동일한 P1 항목이 반복되면 → 접근 방식 변경
1722
- - 같은 항목이 3회 연속 미해결 → 해당 항목만 사용자에게 확인 요청 후 계속
1723
- ```
1724
-
1725
- ### 9-5. 검증 완료 조건
1726
-
1727
- ```
1728
- ✅ Match Score 95% 이상
1729
- ✅ P1 불일치 0건
1730
- ✅ 모든 이미지 에셋 표시 확인
1731
- ✅ (responsive) 모바일 + 데스크탑 각각 95% 이상
1732
- ```
1733
-
1734
- ---
1735
-
1736
- ## Refine Mode (`--refine`)
1737
-
1738
- 이전 `/vibe.figma` 실행으로 생성된 코드의 완성도가 부족할 때 사용.
1739
- **새로 만들지 않고, 기존 코드를 Figma 원본과 재비교하여 수정만 한다.**
1740
-
1741
- ### Refine 플로우
1742
-
1743
- ```
1744
- Step 1: URL 재입력
1745
- → 이전과 동일한 방식으로 스토리보드/디자인 URL 입력
1746
- → 또는 "이전과 동일" 입력 시 이전 URL 재사용
1747
-
1748
- Step 2: 기존 코드 스캔
1749
- → 프로젝트에서 이전에 생성된 파일 탐색 (pages/, components/ 내 피처 폴더)
1750
- → 생성된 컴포넌트 목록 파악
1751
-
1752
- Step 3: Figma 원본 재추출
1753
- → get_design_context + get_screenshot으로 최신 디자인 데이터 획득
1754
-
1755
- Step 4: Side-by-side 비교
1756
- → Figma 스크린샷 vs 기존 코드의 렌더링 결과
1757
- → Phase 9 검증 루프와 동일한 비교 항목:
1758
- 레이아웃, 타이포, 색상, 이미지, 간격, 누락 요소
1759
-
1760
- Step 5: Diff 기반 수정
1761
- → 변경이 필요한 파일만 Edit
1762
- → 새 파일 생성 최소화
1763
- → 수정 사유를 주석으로 남기지 않음 (코드만 수정)
1764
-
1765
- Step 6: 재검증
1766
- → Phase 9 검증 루프 실행 (P1=0 될 때까지)
1767
- ```
1768
-
1769
- ### Refine에서 수정하는 항목
1770
-
1771
- | 카테고리 | 수정 내용 |
1772
- |----------|----------|
1773
- | **누락 에셋** | 다운로드 안 된 이미지 재다운로드 + 경로 설정 |
1774
- | **레이아웃 불일치** | flex/grid 방향, 정렬, 간격 보정 |
1775
- | **타이포 불일치** | font-size, weight, line-height, letter-spacing 보정 |
1776
- | **색상 불일치** | 배경, 텍스트, 보더 색상 보정 |
1777
- | **누락 컴포넌트** | Figma에 있는데 코드에 없는 섹션 추가 |
1778
- | **인터랙션 누락** | 호버/포커스/액티브 상태 추가 |
1779
- | **반응형 누락** | 브레이크포인트 대응 미흡한 부분 보정 |
1780
- | **이미지 경로** | 임시 URL → 로컬 경로 교체, 누락 이미지 다운로드 |
1781
-
1782
- ### Refine에서 하지 않는 것
1783
-
1784
- ```
1785
- ❌ 파일 구조 변경 (이미 생성된 폴더/파일 구조 유지)
1786
- ❌ 컴포넌트 분리/통합 (구조적 리팩토링은 수동으로)
1787
- ❌ 토큰 파일 재생성 (기존 토큰에 누락분만 추가)
1788
- ❌ 전체 재작성 (diff 기반 최소 수정만)
1789
- ```
1790
-
1791
- ---
1792
-
1793
- ## Tool Usage Rules
1794
-
1795
- | Tool | When |
1796
- |------|------|
1797
- | **MCP: get_design_context** | Figma 추출 — 코드 + 스크린샷 + 메타데이터 (토큰 불필요) |
1798
- | **MCP: get_metadata** | 레이어 구조 XML (노드 ID, 크기, 위치) |
1799
- | **MCP: get_screenshot** | 프레임 이미지 렌더링 |
1800
- | Read | Project config, existing components, design-context.json |
1801
- | Glob | Find existing components, theme files, design tokens |
1802
- | Grep | Search for existing color/spacing/typography definitions |
1803
- | Write | Create new component files and style files |
1804
- | Edit | Update existing theme/token files to add new tokens (default mode) |
1805
-
1806
- ## Important
1807
-
1808
- - **Never guess colors** — extract from layers.json or image analysis
1809
- - **Never invent spacing** — use extracted values mapped to token scale
1810
- - **Never hardcode values** — all visual properties reference token variables
1811
- - **Preserve existing patterns** — match the project's existing component style (default mode)
1812
- - **Image is truth** — when layer structure is confusing, trust what the image shows
1813
- - **Ask before overwriting** — if a component file already exists, ask the user first
1814
- - **No console.log** — never include debug logging in generated code
1815
- - **No div soup** — every element uses the correct semantic tag
1816
- - **Component size limit** — split components exceeding 50 lines
1817
- - **Style separation** — global tokens file + per-component style files, always
1818
-
1819
- ## Next Steps: Design Quality Pipeline
1820
-
1821
- After generating code, present the following pipeline to the user:
1822
-
1823
- ### Quick (default recommendation)
1824
- ```
1825
- /design-normalize → /design-audit
1826
- ```
1827
- - Normalize: 하드코딩 값 → MASTER.md 토큰으로 치환
1828
- - Audit: A11Y + 성능 + 반응형 + AI Slop 검출
1829
-
1830
- ### Thorough (recommended for production)
1831
- ```
1832
- /design-normalize → /design-audit → /design-critique → /design-polish
1833
- ```
1834
- - + Critique: Nielsen 10 휴리스틱 + 5 페르소나 분석
1835
- - + Polish: 인터랙션 상태 보완 (hover/focus/loading/error)
1836
-
1837
- ### Pre-requisite check
1838
- If `.claude/vibe/design-context.json` does NOT exist:
1839
- ```
1840
- ⚠️ 디자인 컨텍스트가 없습니다. /design-teach 를 먼저 실행하면
1841
- 브랜드, 접근성, 타겟 디바이스에 맞춘 더 정확한 코드를 생성할 수 있습니다.
1842
- ```
1843
-
1844
- ### Output format
1845
- ```
1846
- ## 🎨 Design Quality Pipeline
1847
-
1848
- 생성된 파일: {file list}
1849
-
1850
- 추천 다음 단계:
1851
- 1. /design-normalize — 토큰 정렬 (하드코딩 제거)
1852
- 2. /design-audit — 기술 품질 검사
1853
- 3. /design-critique — UX 휴리스틱 리뷰
1854
- 4. /design-polish — 최종 인터랙션 보완
1855
-
1856
- 💡 /design-teach 가 아직 설정되지 않았다면 먼저 실행하세요.
1857
- ```
102
+ 코드 생성 완료 Load skill `vibe-figma-pipeline`