Figma 디자인을 분석하여 프로젝트 규칙에 맞는 React 컴포넌트를 자동 생성합니다. Figma URL을 받아서 TDD 방식으로 컴포넌트, 스타일, 테스트, Storybook을 생성합니다.
이 스킬은 Figma 디자인 URL을 받아서 프로젝트 규칙에 맞는 완전한 React 컴포넌트를 생성합니다.
사용자가 다음과 같은 요청을 할 때 이 스킬을 실행합니다:
사용자로부터 다음 정보 수집:
ProductCard, UserProfile)src/components/)Figma URL에서 fileKey와 nodeId 추출:
https://figma.com/design/:fileKey/:fileName?node-id=:int1-:int2123-456 형식을 123:456으로 변환Figma 데이터 가져오기 (병렬 실행):
// mcp__figma__get_screenshot - 시각적 디자인 확인
// mcp__figma__get_design_context - 코드 및 스타일 정보
// mcp__figma__get_metadata - 구조 및 계층 파악
디자인 철저 분석 (이 단계가 중요!):
생성할 디렉토리 구조:
component-name/
├── index.tsx # 컴포넌트 구현
├── styles.module.css # CSS Modules 스타일
├── tests/
│ ├── index.binding.hook.spec.ts # 데이터 바인딩 테스트
│ └── index.ui.spec.ts # UI 렌더링 테스트
└── stories/
└── index.stories.tsx # Storybook 스토리
먼저 테스트를 작성합니다 (프로젝트 규칙):
UI 렌더링 테스트 (index.ui.spec.ts):
test('컴포넌트가 올바르게 렌더링됨', async ({ page }) => {
await page.goto('http://localhost:3000/test-page')
await expect(page.locator('[data-testid="component-title"]')).toBeVisible()
})
데이터 바인딩 테스트 (index.binding.hook.spec.ts):
CSS 규칙 (CLAUDE.md 준수):
position: absolute 금지:global, :root, !important 금지필수 체크리스트 (이번 작업에서 발생한 문제 방지):
Grid/Flexbox 레이아웃:
minmax(0, 1fr) 사용 (텍스트 overflow 방지)grid-template-columns: 64px minmax(0, 1fr) 100px 100px고정 높이 vs 동적 높이:
height 명시.listRow { height: 44px; }텍스트 Overflow 처리:
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
min-width: 0 추가간격 구조 (Gap):
gap 속성 사용 (불필요한 div 제거)main { gap: 8px; } → 자식 간 8px 간격계층 구조:
TypeScript 컴포넌트:
/**
* [컴포넌트명] - Figma 디자인 기반 컴포넌트
*
* @description Figma 디자인을 구현한 컴포넌트입니다.
* @param props - 컴포넌트 속성
*/
export default function ComponentName(props: IComponentProps) {
// 구현
}
/** 컴포넌트 Props 인터페이스 */
interface IComponentProps {
// Figma 디자인에서 추출한 props
}
주석 작성 규칙:
// 수정 이유: [구체적인 이유] 형식으로 기록import type { Meta, StoryObj } from '@storybook/react'
import Component from '../index'
const meta: Meta<typeof Component> = {
title: 'Components/ComponentName',
component: Component,
}
export default meta
type Story = StoryObj<typeof Component>
/** 기본 상태 */
export const Default: Story = {
args: {
// Figma에서 추출한 기본 props
},
}
중요: 코드 작성 후 반드시 시각적 검증을 수행합니다.
스크린샷 캡처 및 Figma 비교:
# 개발 서버 시작
npm run dev
# Playwright로 스크린샷 캡처
# 임시 테스트 파일 생성 후 실행
npx playwright test screenshot-test.spec.ts
Figma 디자인과 비교 체크리스트:
차이점 발견 시 즉시 수정:
Playwright 테스트 실행:
# 전체 테스트
npx playwright test src/components/component-name/tests/
# 개별 테스트
npx playwright test src/components/component-name/tests/index.ui.spec.ts
테스트가 통과하고 시각적으로도 Figma와 일치할 때까지 수정합니다.
디자인 정확도:
minmax(0, 1fr) 사용 (텍스트 overflow 방지)height 명시gap으로 제어 (불필요한 div 제거)코드 품질:
mcp__figma__get_screenshot({
fileKey: "extracted-file-key",
nodeId: "123:456",
clientLanguages: "typescript",
clientFrameworks: "react,nextjs"
})
mcp__figma__get_design_context({
fileKey: "extracted-file-key",
nodeId: "123:456",
clientLanguages: "typescript",
clientFrameworks: "react,nextjs",
disableCodeConnect: false
})
mcp__figma__get_metadata({
fileKey: "extracted-file-key",
nodeId: "123:456",
clientLanguages: "typescript",
clientFrameworks: "react,nextjs"
})
mcp__figma__whoami 로 사용자 확인사용자: "https://figma.com/design/abc123/Product?node-id=1-2 이 디자인으로 ProductCard 컴포넌트 만들어줘"
스킬 실행 순서:
src/components/product-card/ 디렉토리 생성src/commons/constants/url.ts의 라우팅 규칙 활용graphql/ 폴더 생성