用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/puk0806/gugbab-claude --skill design-token-scss命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
DDD(Domain-Driven Design) 아키텍처 핵심 패턴 - 유비쿼터스 언어, 서브도메인, 바운디드 컨텍스트, Aggregate, Entity/VO, 도메인 서비스/이벤트, 레이어드 아키텍처
대규모 React/Next.js 프로젝트를 layer-first(types/·utils/·hooks/·api/·components/ 밑에 도메인이 반복되는 구조)에서 domain-first(feature/도메인 우선) 구조로 전환하는 설계 기준과 절차. Feature-Sliced Design 2.1 정본(layers 6종·slices·segments·import 규칙·@x 크로스임포트·public API), FSD를 쓰지 않는 경량 대안(features + shared 2~3계층 + ESLint import/no-restricted-paths), Next.js App Router 공존 전략(route group `()`·private folder `_`·colocation), Turborepo/Nx 모노레포에서 폴더↔패키지 승격 기준, colocation과 배럴 파일 성능 트레이드오프, 도메인 경계 역추출(import 그래프·change coupling·용어 클러스터), 전환 실패 패턴(shared 비대화·entities 남용·순환 의존·도메인=라우트 착각·조기 추상화). 도메인 개념 자체(바운디드 컨텍스트·유비쿼터스 언어)는 `architecture/ddd` 스킬을 참조한다.
소스 파일 수천 개 규모 프론트엔드 코드베이스를 멈추지 않고 점진 재구조화하는 실행 전략 - Strangler Fig / Branch by Abstraction / Parallel Change, ts-morph·jscodeshift codemod, PR 분할·검증 게이트·되돌리기, 테스트 없는 코드의 안전망, 작업 순서 설계와 위반 수 기반 진행 추적
基于 SOC 职业分类
正在显示 SKILL.md
| name | design-token-scss |
| description | 디자인 토큰 3계층 설계, Figma 토큰 추출, Style Dictionary v4 SCSS/CSS 변환, 테마 전환 패턴 |
소스: https://styledictionary.com/ | https://sass-lang.com/documentation/ | https://tr.designtokens.org/format/ | https://docs.tokens.studio/ 검증일: 2026-04-17
주의: Primitive/Semantic/Component 3계층은 W3C DTCG 공식 용어가 아닌 업계 통용 패턴이다. DTCG 스펙은
$value,$type만 정의한다.
Primitive (Global) → Semantic (Alias) → Component
──────────────── ────────────────── ─────────
blue-500: #3b82f6 color-primary: {blue-500} button-bg: {color-primary}
gray-100: #f3f4f6 color-surface: {gray-100} card-bg: {color-surface}
16px spacing-md: {16px} button-padding: {spacing-md}
Primitive: 색상 팔레트, 타이포그래피 스케일, 간격 스케일 등 raw 값. 의미(semantic)를 부여하지 않는다.
Semantic: 용도별 별칭(alias). 테마 전환 시 이 계층에서 값을 교체한다.
Component: 특정 컴포넌트에 바인딩된 토큰. 선택적 계층으로, 소규모 시스템에서는 Semantic까지만 사용해도 충분하다.
{
"color": {
"primitive": {
"blue-500": { "$value": "#3b82f6", "$type": "color" },
"blue-700": { "$value": "#1d4ed8", "$type": "color" }
},
"semantic": {
"primary": { "$value": "{color.primitive.blue-500}", "$type": "color" },
"primary-hover": { "$value": "{color.primitive.blue-700}", "$type": "color" }
},
"component": {
"button-bg": { "$value": "{color.semantic.primary}", "$type": "color" },
"button-bg-hover": { "$value": "{color.semantic.primary-hover}", "$type": "color" }
}
}
}
Figma에서 토큰을 직접 관리하고 JSON으로 내보내는 플러그인.
Tokens Studio → Export → Style Dictionary 호환 JSON
워크플로우:
Figma Variables(네이티브 기능)를 REST API로 추출.
# Figma REST API로 변수 추출
curl -H "X-FIGMA-TOKEN: ${FIGMA_TOKEN}" \
"https://api.figma.com/v1/files/${FILE_KEY}/variables/local"
주의: Figma Variables REST API는 Enterprise plan에서만 사용 가능하다. Professional 이하 plan에서는 접근 불가.
API 응답을 Style Dictionary JSON으로 변환하는 스크립트가 필요하다. Figma API 응답 구조는 Style Dictionary 포맷과 다르므로 변환 레이어를 작성해야 한다.
| 기준 | Tokens Studio | Figma Variables + API |
|---|---|---|
| 설정 난이도 | 낮음 (플러그인 설치) | 높음 (변환 스크립트 필요) |
| Figma 네이티브 통합 | 별도 플러그인 | 네이티브 |
| SD 호환성 | 직접 호환 | 변환 필요 |
| 팀 협업 | GitHub 연동 | API 자동화 |
| 비용 | 무료/Pro | Professional plan 이상 |
sd.config.mjs)Style Dictionary v4는 ESM 기반 설정 파일을 사용한다.
// sd.config.mjs
import StyleDictionary from 'style-dictionary';
const sd = new StyleDictionary({
source: ['tokens/**/*.json'],
platforms: {
scss: {
transformGroup: 'scss',
buildPath: 'build/scss/',
files: [
{
destination: '_variables.scss',
format: 'scss/variables',
},
{
destination: '_map.scss',
format: 'scss/map-deep',
},
],
},
css: {
transformGroup: 'css',
buildPath: 'build/css/',
files: [
{
destination: 'variables.css',
format: 'css/variables',
},
],
},
},
});
await sd.buildAllPlatforms();
| v3 | v4 |
|---|---|
config.json 또는 config.js | sd.config.mjs (ESM) |
StyleDictionary.registerTransform() | hooks.transforms 객체에 정의 |
StyleDictionary.registerFormat() | hooks.formats 객체에 정의 |
value 키 | $value 키 (DTCG 호환) |
type 키 | $type 키 (DTCG 호환) |
StyleDictionary.extend(config).buildAllPlatforms() | new StyleDictionary(config) + await sd.buildAllPlatforms() |
// sd.config.mjs
import StyleDictionary from 'style-dictionary';
const sd = new StyleDictionary({
hooks: {
transforms: {
'size/pxToRem': {
type: 'value',
filter: (token) => token.$type === 'dimension',
transform: (token) => {
const val = parseFloat(token.$value);
return `${val / 16}rem`;
},
},
},
},
source: ['tokens/**/*.json'],
platforms: {
scss: {
transforms: ['attribute/cti', 'name/kebab', 'size/pxToRem'],
buildPath: 'build/scss/',
files: [
{ destination: '_variables.scss', format: 'scss/variables' },
],
},
},
});
await sd.buildAllPlatforms();
// build/scss/_variables.scss (scss/variables 포맷)
$color-primitive-blue-500: #3b82f6;
$color-semantic-primary: #3b82f6;
$spacing-md: 1rem;
/* build/css/variables.css (css/variables 포맷) */
:root {
--color-primitive-blue-500: #3b82f6;
--color-semantic-primary: #3b82f6;
--spacing-md: 1rem;
}
| 기준 | SCSS 변수 ($var) | CSS Custom Properties (--var) |
|---|---|---|
| 평가 시점 | 컴파일 타임 | 런타임 |
| 테마 전환 | 불가 (빌드 시 고정) | 가능 (JS/클래스로 동적 변경) |
| 조건 분기 | @if/@each 등 SCSS 로직 | 미디어 쿼리 / 클래스 스코프 |
| 번들 크기 | 사용된 곳에 값이 인라인됨 | 변수 선언 1회 + 참조 |
| 폴백 | 불필요 (컴파일 시 해결) | var(--x, fallback) 가능 |
| JS 접근 | 불가 | getComputedStyle / setProperty |
// _tokens.scss — SCSS 변수로 정적 값 정의 (컴파일 타임 로직용)
$color-primary: #3b82f6;
$spacing-md: 16px;
$breakpoint-md: 768px; // 미디어 쿼리에는 SCSS 변수만 사용 가능
// _theme.scss — CSS Custom Properties로 런타임 테마용 노출
:root {
--color-primary: #{$color-primary};
--spacing-md: #{$spacing-md};
}
// 컴포넌트에서 사용
.button {
// 런타임 테마가 필요한 속성 → CSS Custom Property
background: var(--color-primary);
color: var(--color-text);
// 정적 레이아웃 → SCSS 변수 직접 사용도 가능
padding: $spacing-md;
// 미디어 쿼리 조건 → SCSS 변수 필수 (CSS 변수 사용 불가)
@media (min-width: $breakpoint-md) {
padding: $spacing-md * 1.5;
}
}
핵심 규칙:
@each, @if, math.div)은 SCSS 변수@use 'sass:map';
$colors: (
'primary': #3b82f6,
'primary-hover': #2563eb,
'secondary': #8b5cf6,
'error': #ef4444,
'success': #22c55e,
);
$spacing: (
'xs': 4px,
'sm': 8px,
'md': 16px,
'lg': 24px,
'xl': 32px,
);
// 유틸리티 함수로 접근
@function color($key) {
@if not map.has-key($colors, $key) {
@error "색상 '#{$key}'가 $colors 맵에 존재하지 않습니다.";
}
@return map.get($colors, $key);
}
@function spacing($key) {
@if not map.has-key($spacing, $key) {
@error "간격 '#{$key}'가 $spacing 맵에 존재하지 않습니다.";
}
@return map.get($spacing, $key);
}
// 사용
.card {
background: color('primary');
: ();
}
@use 'sass:map';
// SCSS map에서 CSS Custom Properties 일괄 생성
@mixin generate-css-vars($map, $prefix) {
@each $key, $value in $map {
--#{$prefix}-#{$key}: #{$value};
}
}
:root {
@include generate-css-vars($colors, 'color');
@include generate-css-vars($spacing, 'spacing');
}
// 출력:
// :root {
// --color-primary: #3b82f6;
// --color-primary-hover: #2563eb;
// --spacing-xs: 4px;
// --spacing-sm: 8px;
// ...
// }
scss/map-deep 산출물 활용)@use 'sass:map';
// Style Dictionary의 scss/map-deep 포맷 산출물
$tokens: (
'color': (
'primitive': (
'blue-500': #3b82f6,
'gray-100': #f3f4f6,
),
'semantic': (
'primary': #3b82f6,
'surface': #f3f4f6,
),
),
'spacing': (
'md': 16px,
'lg': 24px,
),
);
// deep-get 유틸리티
@function token($keys...) {
$result: $tokens;
@each $key in $keys {
$result: map.get($result, $key);
}
@return $result;
}
// 사용
.card {
background: token('color', 'semantic', 'surface');
padding: token('spacing', 'md');
}
상세 레퍼런스 (예제·고급 패턴·흔한 실수) →
references/REFERENCE.md