designsnitch 0.4.0 → 0.6.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.ko.md CHANGED
@@ -21,9 +21,9 @@ designsnitch는 디자인 시스템이 없거나 이름뿐인 프로젝트에서
21
21
  | ESLint 플러그인 | 막고 경고합니다. 같은 규칙이 에디터와 lint 단계에서 오류와 경고로 나옵니다. |
22
22
  | 에이전트 훅 | 코드를 쓰는 동안 막습니다. 에이전트는 파일을 고칠 때마다 오류를 전달받고, 스스로 고칠 수 있는 오류가 남아 있으면 작업을 끝내지 못합니다. |
23
23
 
24
- **Tailwind CSS v4를 쓰는 React/Next.js 프로젝트**를 지원합니다.
24
+ **Tailwind CSS v4를 쓰는 React/Next.js 프로젝트**를 지원합니다. Tailwind v3 프로젝트도 검사하지만 후보가 적습니다([Tailwind v3](#tailwind-v3) 참고).
25
25
 
26
- > **상태:** MVP(0.2.x). 메시지는 기본이 영어이고 한국어로 바꿀 수 있습니다. 이 문서의 출력 예시는 한국어로 설정했을 때의 모습입니다. [언어](#언어)를 보세요.
26
+ > **상태:** MVP(0.6.x). 지금은 색과 공용 컴포넌트를 검사합니다. 간격, 폰트 크기, radius는 아직 검사하지 않습니다([검사 범위](#검사-범위) 참고). 메시지는 기본이 영어이고 한국어로 바꿀 수 있습니다. 이 문서의 출력 예시는 한국어로 설정했을 때의 모습입니다. [언어](#언어)를 보세요.
27
27
 
28
28
  ## 시작하기
29
29
 
@@ -32,7 +32,7 @@ npm install --save-dev designsnitch
32
32
  npx designsnitch install
33
33
  ```
34
34
 
35
- 두 번째 명령은 에이전트 스킬을 설치하고 에이전트 훅을 등록합니다. Node.js 22 이상이 필요합니다.
35
+ 두 번째 명령은 에이전트 스킬을 설치하고 에이전트 훅을 등록합니다. Node.js 20.19 이상이 필요합니다.
36
36
 
37
37
  | 에이전트 | 명령 | 스킬 위치 | 훅 위치 |
38
38
  | --- | --- | --- | --- |
@@ -94,10 +94,12 @@ Codex, Gemini CLI, Grok Build는 새 프로젝트 훅을 승인하거나 프로
94
94
 
95
95
  | 규칙 | 등급 | 잡는 것 |
96
96
  | --- | --- | --- |
97
- | `color-use-token` | 오류 | 토큰이 있는 hex 색을 임의 값(`bg-[#3B82F6]`), 인라인 스타일(`style={{ color: "#3B82F6" }}`), CSS 선언(`color: #3B82F6`)에 직접 씀 |
98
- | `color-unknown` | 경고 | 맞는 토큰이 없는 hex 색 |
97
+ | `color-use-token` | 오류 | 토큰이 있는 색을 임의 값(`bg-[#3B82F6]`), 인라인 스타일(`style={{ color: "#3B82F6" }}`), CSS 선언(`color: #3B82F6`), `@apply`에 직접 씀 |
98
+ | `color-unknown` | 경고 | 직접 쓴 색인데 맞는 토큰이 없음 |
99
99
  | `use-ds-component` | 오류 | 공용 컴포넌트가 대체하는 `<button>` 같은 raw 태그를 디자인 시스템 경로 밖에서 씀 |
100
100
 
101
+ 직접 쓴 색이란 hex, 숫자를 그대로 적은 색 함수(`rgb()`, `hsl()`, `oklch()`), `white` 같은 색 이름입니다. 표기는 상관없습니다. `#3B82F6`, `rgb(59 130 246)`, `hsl(217 91% 60%)`는 검사에서 같은 색입니다.
102
+
101
103
  오류에는 대신 쓸 것이 함께 나옵니다. JS와 TS 파일에서는 클래스나 컴포넌트이고, 인라인 스타일과 CSS 파일에서는 `var(--토큰)`입니다. Tailwind v4는 소스에서 `var()`로 쓴 테마 변수를 출력하므로, 인라인 스타일의 `var(--토큰)`도 같은 색으로 보입니다.
102
104
 
103
105
  ## 명령
@@ -171,7 +173,7 @@ Tailwind 기본 팔레트
171
173
  | --- | --- |
172
174
  | `hex 색` | hex 색을 많이 쓰인 순서로 보여줍니다. 쓰인 횟수와 파일 수가 함께 나옵니다. |
173
175
  | `bg 2`, `text 1` | Tailwind 유틸리티별 사용 횟수입니다. `bg-[#3a11d8]`은 `bg`로 셉니다. |
174
- | `문자열 1` | 문자열 전체가 hex 색인 경우입니다. 인라인 스타일이나 차트 옵션이 여기에 들어갑니다. |
176
+ | `문자열 1` | 문자열 전체가 색인 경우입니다. 인라인 스타일이나 차트 옵션이 여기에 들어갑니다. |
175
177
  | `CSS 2` | CSS 선언에서 쓴 횟수입니다. JSON 출력에는 속성별로 나뉘어 들어갑니다. |
176
178
  | `Tailwind 기본 팔레트` | `text-gray-700`처럼 Tailwind 기본 팔레트의 색을 이름으로 쓴 경우입니다. |
177
179
 
@@ -186,6 +188,7 @@ Tailwind 기본 팔레트
186
188
  | `tokens` | 토큰이 정의된 CSS 파일입니다. 필수입니다. 경로를 적거나, `file`과 선택 항목 `exclude`, `prefer`를 담은 객체로 적습니다(아래 참고). |
187
189
  | `components.path` | 디자인 시스템 컴포넌트가 있는 경로입니다. 이 안에서는 raw 태그를 써도 됩니다. |
188
190
  | `components.replaces` | raw 태그와 그것을 대체하는 컴포넌트입니다. 한 태그를 대체하는 컴포넌트가 여러 개면 배열로 적습니다. 컴포넌트가 태그의 일부 변형만 맡으면 `{ "component": ..., "when": { ... } }`로 적습니다(아래 참고). |
191
+ | `palette` | `"tailwind"`로 두면 Tailwind 기본 팔레트를 기준에 넣습니다([Tailwind 기본 팔레트](#tailwind-기본-팔레트) 참고). |
189
192
  | `lang` | 메시지의 언어입니다. `en`(기본) 또는 `ko`입니다. |
190
193
 
191
194
  `components`를 생략하면 컴포넌트 검사를 하지 않습니다. 다른 경로의 설정 파일을 쓰려면 `--config <파일>`을 붙입니다. 설정 파일 안의 경로는 설정 파일이 있는 디렉터리를 기준으로 풉니다.
@@ -210,14 +213,14 @@ Tailwind 기본 팔레트
210
213
  ```
211
214
 
212
215
  - `<input type="file">`은 컴포넌트가 맡지 않으므로 보고하지 않습니다.
213
- - `<input type="text">`와 `<input>`은 바로 바꿀 수 있는 오류로 보고합니다.
216
+ - `<input type="text">`와 `<input>`은 컴포넌트로 옮길 오류(`migrate`)로 보고합니다.
214
217
  - `<input type={kind}>`와 `<input {...props}>`는 보고하되 `ask`로 표시합니다. 값을 실행할 때에야 알 수 있거나 spread가 값을 덮어쓸 수 있어서, 바꿔도 안전한지 알 수 없기 때문입니다.
215
218
 
216
219
  토큰 CSS에서 읽는 것은 다음과 같습니다.
217
220
 
218
221
  | 변수 | 쓰임 | 없을 때 |
219
222
  | --- | --- | --- |
220
- | `--color-*` | 색. 값이 hex이거나, `var()`를 따라가면 hex가 나와야 합니다. | 모든 hex 색이 경고가 됩니다 |
223
+ | `--color-*` | 색. 값이 hex, `rgb()`, `hsl()`, `oklch()` 색이거나, `var()`를 따라가면 그런 값이 나와야 합니다. | 직접 쓴 색이 모두 경고가 됩니다 |
221
224
 
222
225
  아래 두 형태를 모두 읽습니다.
223
226
 
@@ -237,6 +240,24 @@ Tailwind 기본 팔레트
237
240
  }
238
241
  ```
239
242
 
243
+ 변수를 어디에 선언했는지도 봅니다.
244
+
245
+ - `--color-*` 변수는 `@theme` 안이나 어디서나 적용되는 규칙(`:root`, `html`, `:host`)에 선언돼 있어야 토큰입니다. `.promo { --color-promo: ... }`처럼 다른 선택자 안에만 선언된 변수는 토큰이 아닙니다. 그 선택자 밖에는 없는 변수이기 때문입니다.
246
+ - 토큰을 선택자나 미디어 쿼리 안(`.dark`, `@media (prefers-color-scheme: dark)`)에서 다시 선언하면 테마마다 값이 다른 토큰이고, 색을 그 토큰으로 바꾸는 것은 `ask`로 표시합니다.
247
+ - `var(--raw, #fff)`는 `--raw`가 없는 곳에서 fallback을 씁니다. `--raw`가 일부 선택자 안에만 있으면 fallback과 그 값을 모두 토큰의 값으로 보므로, 이것도 `ask`가 됩니다.
248
+
249
+ 토큰은 Tailwind가 읽는 곳에서도 읽습니다.
250
+
251
+ - **import한 CSS.** 토큰 CSS가 다른 CSS 파일을 불러오면(`@import "../brand/theme.css"`나 패키지) 그 파일의 `@theme` 토큰도 읽습니다.
252
+ - **접두어.** `@import "tailwindcss" prefix(tw)`를 쓰면 Tailwind가 CSS 변수 이름을 `--tw-color-*`로 만들므로, `var()` 후보도 그렇게 적습니다. 클래스 후보는 `tw:` 뒤의 부분만 바꿉니다.
253
+ - **JavaScript 설정.** `@config "./tailwind.config.js"`가 있으면 `theme.extend.colors`(프리셋 포함)의 색이 토큰이 되고, `theme.colors`는 기본 팔레트를 대체합니다. Tailwind v4의 동작과 같습니다. 이 색들은 클래스로만 있습니다. Tailwind가 CSS 변수를 만들지 않기 때문입니다. 인라인 스타일이나 CSS 선언에 직접 쓰면 오류로 알리되 후보는 없고, 어떻게 할지는 사람이 정합니다. 설정을 읽으려면 그 파일을 실행하므로, 그 파일이 require하는 것이 설치돼 있어야 합니다. 불러오지 못하면 결과의 `problems`에 알립니다.
254
+
255
+ ### Tailwind v3
256
+
257
+ v3 프로젝트는 색을 `tailwind.config.js`에 두고, CSS는 `@tailwind base`로 시작합니다. `tokens`는 평소처럼 CSS 파일을 가리키면 됩니다. 그 CSS가 `@tailwind`를 쓰면 `designsnitch.config.json` 옆의 `tailwind.config.js`(또는 `.cjs`, `.mjs`, `.ts`)를 읽습니다. `tokens`에 설정 파일을 직접 적어도 됩니다. `"palette": "tailwind"`는 v3 팔레트를 `tailwindcss/colors`에서 읽습니다.
258
+
259
+ v3는 색에 CSS 변수를 만들지 않으므로 모든 토큰이 클래스 전용입니다. 임의 값 색 클래스에는 토큰 클래스를 후보로 내고, CSS 선언과 인라인 스타일에 직접 쓴 색은 후보 없이 알립니다.
260
+
240
261
  ## 언어
241
262
 
242
263
  메시지는 기본이 영어입니다. 한국어로 보려면 `designsnitch.config.json`에 `"lang": "ko"`를 적거나, 환경 변수 `DESIGNSNITCH_LANG=ko`를 설정하거나, `--lang ko`를 붙입니다. 여러 개를 함께 주면 `--lang`, 설정 파일, 환경 변수 순으로 우선합니다.
@@ -254,10 +275,10 @@ src/PayButton.tsx
254
275
  8:26 경고 bg-[#3B82F5]의 색은 토큰에 없습니다. (color-unknown)
255
276
 
256
277
  오류 2개, 경고 1개 (파일 3개 검사)
257
- 바로 바꿀 수 있는 것 2건, 사람이 정해야 하는 것 1건 (결정 1개)
278
+ 바로 바꿀 수 있는 것 1건, 컴포넌트로 옮길 것 1건, 사람이 정해야 하는 것 1건 (결정 1개)
258
279
  ```
259
280
 
260
- 첫 줄은 설정에서 읽어 낸 토큰과 컴포넌트의 개수입니다. 경로를 잘못 적으면 여기서 0개로 드러납니다. 색 토큰을 하나도 읽지 못하면 `주의:`로 시작하는 줄이 이유를 알려줍니다. 마지막 줄은 바로 바꿀 수 있는 위반과 사람이 정해야 하는 위반이 각각 몇 건이고, 사람이 정할 것이 질문 몇 개로 묶이는지 알려줍니다.
281
+ 첫 줄은 설정에서 읽어 낸 토큰과 컴포넌트의 개수입니다. 경로를 잘못 적으면 여기서 0개로 드러납니다. 색 토큰을 하나도 읽지 못하면 `주의:`로 시작하는 줄이 이유를 알려줍니다. 마지막 줄은 바로 바꿀 수 있는 위반, 컴포넌트로 옮길 태그, 사람이 정해야 하는 위반이 각각 몇 건이고, 사람이 정할 것이 질문 몇 개로 묶이는지 알려줍니다.
261
282
 
262
283
  `--format json`은 같은 결과를 구조화해서 출력합니다. 아래 예시는 위반을 종류별로 하나씩만 남기고 나머지는 생략했습니다.
263
284
 
@@ -266,7 +287,8 @@ src/PayButton.tsx
266
287
  "designSystem": { "colorTokens": 4, "components": 1, "replacedTags": 1 },
267
288
  "problems": [],
268
289
  "next": [
269
- "action이 replace인 2건은 found를 candidates의 값으로 바꾸세요.",
290
+ "action이 replace인 1건은 found를 candidates의 값으로 바꾸세요.",
291
+ "action이 migrate인 1건은 태그를 candidates의 컴포넌트로 바꾸세요. 먼저 그 컴포넌트를 읽고, import를 더하고, 컴포넌트가 받는 props를 넘기고, 컴포넌트가 이미 주는 className은 지우세요. 태그가 하던 일을 컴포넌트가 못 하면 바꾸지 말고 사용자에게 물으세요.",
270
292
  "변경하기 전에 decisions의 2건을 사용자에게 물으세요. 사용 횟수와 후보, 확인이 필요한 이유를 함께 알려 주세요.",
271
293
  "고친 뒤 같은 명령을 다시 실행하세요."
272
294
  ],
@@ -337,11 +359,11 @@ src/PayButton.tsx
337
359
  | `problems` | 결과를 믿기 어렵게 만드는 설정 문제. 정상이면 빈 배열입니다. |
338
360
  | `violations[].found` | 위반한 코드 조각 |
339
361
  | `violations[].candidates` | 대신 쓸 클래스나 컴포넌트. 없으면 빈 배열입니다. |
340
- | `violations[].recommended` | 색을 쓰는 용도에 맞는 후보입니다. `text-` 클래스면 텍스트용 이름의 토큰, 테두리면 테두리용 이름의 토큰입니다. 맞는 후보가 정확히 하나일 때만 채우고, 추천일 뿐이라 `ask`는 그대로 `ask`입니다. `replace`면 그 후보입니다. |
341
- | `violations[].action` | 이 위반을 어떻게 다룰지입니다. `replace`: `found`를 하나뿐인 후보로 바꿔도 화면과 동작이 같습니다. `ask`: 사람이 정해야 합니다. 후보가 여러 개이거나, 토큰이 없는 색이거나, 테마마다 값이 다른 토큰이거나, 컴포넌트의 속성이 동적이거나 spread된 경우입니다. `repair`: 파일을 읽지 못했습니다. |
342
- | `decisions` | `ask`인 위반을 질문 단위로 묶은 것입니다. 색이나 태그와 후보가 같으면 하나로 묶습니다. 각 항목에 얼마나 나오는지(`uses`, `files`), 위치 최대 다섯 곳(`locations`), 후보(`candidates`), 모든 위치에서 추천이 같을 때의 추천(`recommended`), 사람이 정해야 하는 이유(`reasons`: `multiple-candidates`, `no-token`, `themed-token`, `dynamic-props`)가 있습니다. 많이 나오는 순서입니다. |
362
+ | `violations[].recommended` | 색을 쓰는 용도에 맞는 후보입니다. `text-` 클래스면 텍스트용 이름의 토큰, 테두리면 테두리용 이름의 토큰입니다. 맞는 후보가 정확히 하나일 때만 채우고, 추천일 뿐이라 `ask`는 그대로 `ask`입니다. `replace`와 `migrate`면 그 후보입니다. |
363
+ | `violations[].action` | 이 위반을 어떻게 다룰지입니다. `replace`: `found`를 하나뿐인 후보로 바꿔도 화면과 동작이 같습니다. 색 오류만 해당합니다. `migrate`: raw 태그를 옮길 디자인 시스템 컴포넌트가 하나뿐입니다. 컴포넌트가 같은 props를 넘기는지, 기본 스타일이 같은지는 도구가 알 수 없으므로 컴포넌트를 먼저 읽고 태그의 props를 옮기고 컴포넌트가 이미 주는 클래스는 지웁니다. 훅은 고친 직후에 알리기만 하고, 이것 때문에 에이전트가 끝내는 것을 막지는 않습니다. `ask`: 사람이 정해야 합니다. 후보가 여러 개이거나, 토큰이 없는 색이거나, 테마마다 값이 다른 토큰이거나, 컴포넌트의 속성이 동적이거나 spread된 경우입니다. `repair`: 파일을 읽지 못했습니다. |
364
+ | `decisions` | `ask`인 위반을 질문 단위로 묶은 것입니다. 색이나 태그와 후보가 같으면 하나로 묶습니다. 각 항목에 얼마나 나오는지(`uses`, `files`), 위치 최대 다섯 곳(`locations`), 후보(`candidates`), 모든 위치에서 추천이 같을 때의 추천(`recommended`), 사람이 정해야 하는 이유(`reasons`: `multiple-candidates`, `no-token`, `themed-token`, `translucent`, `not-a-style`, `class-only-token`, `dynamic-props`)가 있습니다. 많이 나오는 순서입니다. |
343
365
  | `next` | 이 결과를 받은 에이전트가 할 일을 순서대로 적은 것 |
344
- | `unchecked` | 검사하지 못한 다른 문자열 속 hex 색의 개수(`hexColors`)와 파일 수(`files`). 하나라도 있으면 글 출력에 한 줄이 붙습니다. |
366
+ | `unchecked` | 검사하지 못한 다른 문자열 속 색의 개수(`colors`)와 파일 수(`files`). 하나라도 있으면 글 출력에 한 줄이 붙습니다. |
345
367
 
346
368
  | 종료 코드 | 의미 |
347
369
  | --- | --- |
@@ -441,6 +463,11 @@ CLI와 스킬은 AI 에이전트가 제대로 할 수 있는 상태를 만들어
441
463
  {
442
464
  "hooks": [{ "type": "command", "command": "npx designsnitch hook" }]
443
465
  }
466
+ ],
467
+ "SessionStart": [
468
+ {
469
+ "hooks": [{ "type": "command", "command": "npx designsnitch hook" }]
470
+ }
444
471
  ]
445
472
  }
446
473
  }
@@ -450,11 +477,12 @@ CLI와 스킬은 AI 에이전트가 제대로 할 수 있는 상태를 만들어
450
477
 
451
478
  - 파일마다 git `HEAD` 버전과 비교합니다. 같은 규칙, 같은 코드의 오류가 `HEAD`보다 많아졌으면 새 오류입니다. 원래 있던 오류는 줄이 밀려도 막지 않습니다. `HEAD`에 아직 없는 파일은 모든 오류가 새것입니다.
452
479
  - 파일을 고친 뒤 새 오류가 있으면, 에이전트는 오류와 다음에 할 일을 전달받습니다.
453
- - 에이전트가 작업을 끝내려 할 때 스스로 고칠 수 있는 새 오류가 남아 있으면 끝내지 못합니다. 사람이 정해야 하는 오류는 막지 않습니다. 물어보려면 멈춰야 하기 때문입니다.
480
+ - 에이전트가 작업을 끝내려 할 때, 바꿔도 화면과 동작이 같은 새 오류(`replace`와 읽지 못한 파일)가 남아 있으면 끝내지 못합니다. 사람이 정해야 하는 오류(`ask`)는 막지 않습니다. 물어보려면 멈춰야 하기 때문입니다. 컴포넌트로 옮길 태그(`migrate`)도 막지 않습니다. 컴포넌트가 똑같이 동작하는지 도구가 알 수 없으므로, 고친 직후에 알리기만 하고 판단은 에이전트와 사용자에게 맡깁니다.
481
+ - 세션이 시작되기 전부터 작업 폴더에 있던 오류는 커밋하지 않았더라도 새 오류로 치지 않습니다. 훅이 세션이 시작될 때(`SessionStart`) 적어 둡니다. 그 이벤트가 없으면 세션의 첫 수정 때, 방금 고친 파일을 뺀 나머지 바뀐 파일을 적어 둡니다. 에이전트가 세션 id를 보내 줘야 합니다.
454
482
  - 경고는 막지 않고, 에이전트가 건드리지 않은 파일은 보지 않습니다.
455
483
  - git 저장소가 아니거나 첫 커밋 전이면, 바꾼 파일의 오류를 모두 셉니다.
456
484
 
457
- Codex에는 `npx designsnitch install --agent codex`가 같은 두 훅을 `.codex/hooks.json`에 씁니다. 파일 수정 쪽은 `apply_patch`에 걸립니다. Codex는 셸 명령으로 파일을 고치는 일이 많은데, 그런 수정은 이 조건에 걸리지 않습니다. 대신 Codex가 작업을 끝내려 할 때 잡힙니다. 그때 훅이 git에서 바뀐 파일을 모두 검사하기 때문입니다.
485
+ Codex에는 `npx designsnitch install --agent codex`가 같은 훅들을 `.codex/hooks.json`에 씁니다. 파일 수정 쪽은 `apply_patch`에 걸립니다. Codex는 셸 명령으로 파일을 고치는 일이 많은데, 그런 수정은 이 조건에 걸리지 않습니다. 대신 Codex가 작업을 끝내려 할 때 잡힙니다. 그때 훅이 git에서 바뀐 파일을 모두 검사하기 때문입니다.
458
486
 
459
487
  Gemini CLI에는 `npx designsnitch install --agent gemini`가 훅을 `.gemini/settings.json`에 씁니다. 이벤트 이름이 다릅니다. 파일 수정 직후는 `write_file`과 `replace`에 걸리는 `AfterTool`이고, 답하기 직전은 `AfterAgent`입니다. `AfterAgent`에서 종료 코드 2를 받으면 Gemini CLI는 오류를 피드백 삼아 다시 시도합니다. 공식 Gemini CLI 문서를 기준으로 만들었고, Gemini CLI에서 테스트하지 못했습니다.
460
488
 
@@ -464,7 +492,20 @@ Grok Build에는 `npx designsnitch install --agent grok`이 `PostToolUse`와 `St
464
492
 
465
493
  ### Tailwind 기본 팔레트
466
494
 
467
- designsnitch는 `bg-blue-500` 같은 기본 팔레트 클래스를 위반으로 잡지 않습니다. 프로젝트가 자기 토큰만 써야 한다면, Tailwind v4에서 기본 팔레트를 없앨 수 있습니다. 그러면 그런 클래스가 아예 동작하지 않습니다.
495
+ Tailwind 기본 팔레트(`bg-slate-100`, `text-indigo-600`)를 기준으로 쓰는 프로젝트가 많습니다. `"palette": "tailwind"`를 두면 기본 팔레트를 기준에 넣습니다.
496
+
497
+ ```json
498
+ { "tokens": "app/globals.css", "palette": "tailwind" }
499
+ ```
500
+
501
+ - 팔레트는 프로젝트에 설치된 `tailwindcss/theme.css`에서 읽습니다. 토큰 CSS 위치에서 찾으므로 언제나 설치된 버전과 맞습니다. Tailwind CSS v4(4.0 이상)가 필요합니다. v3이거나 tailwindcss를 찾지 못하면 검사를 멈추고 어느 쪽인지 알립니다. 4.0.0, 4.1.0, 4.2.0, 4.3.0, 4.3.5로 확인했습니다. 버전 사이에 값이 바뀐 색은 없고, 4.2.0에서 `mauve`, `olive`, `mist`, `taupe` 계열이 추가됐습니다.
502
+ - 팔레트 색과 값이 같은 hex는 오류이고, 팔레트 클래스가 후보입니다: `bg-[#62748e]` → `bg-slate-500`. Tailwind v4는 팔레트를 `oklch()`로 적어서, 비교할 때 hex로 바꿉니다. sRGB 밖의 팔레트 색은 같은 색을 내는 hex가 없으므로 같은 `oklch()` 값과만 맞춥니다.
503
+ - 프로젝트 토큰 CSS에 팔레트와 같은 이름의 토큰이 있으면 프로젝트 값을 씁니다. Tailwind 문서의 기본색 덮어쓰기 예시처럼 hex로 적어도, `oklch()`로 적어도 됩니다.
504
+ - Tailwind 문서에 나온 대로 프로젝트가 비운 네임스페이스는 뺍니다. `--color-*: initial`은 팔레트 전체를, `--color-lime-*: initial`은 그 계열을, `--*: initial`은 기본 테마 전체를 지웁니다.
505
+ - `tokens`의 `exclude`와 `prefer`는 팔레트 색에도 적용됩니다.
506
+ - 팔레트도 토큰으로 세므로, 자기 토큰이 없는 프로젝트도 "토큰 없음"으로 보지 않습니다.
507
+
508
+ `palette`가 없으면 기본 팔레트 클래스를 위반으로 잡지 않고, hex와 비교하지도 않습니다. 프로젝트가 자기 토큰만 써야 한다면, Tailwind v4에서 기본 팔레트를 없앨 수 있습니다. 그러면 그런 클래스가 아예 동작하지 않습니다.
468
509
 
469
510
  ```css
470
511
  @theme {
@@ -475,21 +516,30 @@ designsnitch는 `bg-blue-500` 같은 기본 팔레트 클래스를 위반으로
475
516
 
476
517
  ## 검사 범위
477
518
 
478
- - **JS와 TS에서 보는 곳:** 문자열과 템플릿 리터럴 안의 임의 값 색 클래스(`className`과 `cn()`, `clsx()`, `cva()`의 인자 포함)와, JSX `style` 객체에 문자열로 적은 hex 색입니다. 주석은 보지 않습니다. 테마 객체나 차트 옵션 같은 다른 문자열의 hex 색은 코드만 보고 용도를 알 수 없어 검사하지 않습니다. 대신 있다는 것을 알 수 있도록 `unchecked`에 개수를 세고, `designsnitch colors`로 목록을 볼 수 있습니다.
479
- - **CSS에서 보는 곳:** `.css` 파일(CSS Modules 포함)의 선언 값에 있는 hex 색입니다. 토큰 CSS에서는 변수를 정의하는 선언(`--이름: ...`)을 토큰을 정의하는 곳으로 보고 건너뜁니다. 다른 CSS 파일에서는 변수 선언도 일반 선언처럼 검사합니다. CSS에서는 아직 색만 검사합니다.
480
- - **테마:** 토큰이 테마마다 다른 값을 가지면 그 값들을 모두 그 토큰의 값으로 봅니다. hex 색을 그런 토큰으로 바꾸면 다른 테마에서 색이 바뀌므로 `ask`로 표시합니다.
519
+ - **JS와 TS에서 보는 곳:** 문자열과 템플릿 리터럴 안의 임의 값 색 클래스(`className`과 `cn()`, `clsx()`, `cva()`의 인자 포함)와, 색을 받는 자리에 문자열로 적은 색입니다. `a ? "#fff" : "#000"`이나 `x || "#fff"`처럼 고르는 식의 값도 봅니다. 주석은 보지 않습니다.
520
+ - **스타일:** JSX `style` 객체, 이름이 `style`이나 `styles`로 끝나는 변수의 객체, `CSSProperties` 타입의 객체입니다. 여기서는 `var(--토큰)`이 통하므로 다른 색과 똑같이 검사합니다.
521
+ - **그 밖의 색 속성:** 이름이 CSS 색 속성이거나 `Color`로 끝나는 속성과 JSX 속성입니다. 차트 옵션의 `backgroundColor`, SVG 요소의 `stroke` 같은 것입니다. 색은 알리고 `var(--토큰)`을 후보로 주지만 `ask`로 표시합니다. 캔버스처럼 `var()`가 통하지 않는 곳에 쓰일 수 있기 때문입니다.
522
+ - **나머지:** 다른 이름의 키(`{ primary: "#3B82F6" }`)와 배열 안의 색은 코드만 보고 용도를 알 수 없어 검사하지 않습니다. 대신 있다는 것을 알 수 있도록 `unchecked`에 개수를 세고, `designsnitch colors`로 목록을 볼 수 있습니다.
523
+ - **CSS에서 보는 곳:** `.css` 파일(CSS Modules 포함)의 선언 값에 있는 색과 `@apply`의 임의 값 색 클래스입니다. 토큰 CSS에서는 변수를 정의하는 선언(`--이름: ...`)을 토큰을 정의하는 곳으로 보고 건너뜁니다. 다른 CSS 파일에서는 변수 선언도 일반 선언처럼 검사합니다. CSS에서는 아직 색만 검사합니다.
524
+ - **테마:** 토큰이 테마마다 다른 값을 가지면 그 값들을 모두 그 토큰의 값으로 봅니다. 색을 그런 토큰으로 바꾸면 다른 테마에서 색이 바뀌므로 `ask`로 표시합니다.
481
525
  - **수정:** designsnitch는 후보를 알려줄 뿐, 후보가 하나여도 코드를 직접 고치지 않습니다.
482
526
 
483
527
  ### 아직 안 되는 것
484
528
 
485
- - hex가 아닌 색(`rgb()`, `hsl()`, `oklch()`)
486
- - Tailwind 기본 테마의 값. 프로젝트의 토큰 CSS에 적힌 값만 읽습니다.
487
- - Tailwind v3(`tailwind.config.js`)
529
+ 감지는 하지만 토큰과 맞추지는 못하는 것:
530
+
531
+ - 반투명한 색(`#3B82F680`, `rgb(0 0 0 / 50%)`)은 불투명한 색의 토큰에 불투명도를 붙인 후보를 받습니다. 클래스는 `bg-brand/50`, 스타일과 CSS 선언은 `color-mix(in srgb, var(--color-brand) 50%, transparent)`입니다. 불투명도를 정수 퍼센트로 반올림하므로 `ask`로 표시합니다.
532
+ - Tailwind 플러그인이 더하는 색은 토큰으로 알지 못합니다. 그 색을 직접 쓰면 토큰 없는 색으로 알립니다.
533
+ - `hwb()`, `lab()`, `lch()`, `oklab()`, `color()` 값과 sRGB 밖의 `oklch()` 색은 같은 값으로 적은 토큰과만 맞춥니다. 같은 색을 내는 hex가 없기 때문입니다.
534
+ - 색 이름은 색 속성(`color`, `background`, `border` 등), 임의 값 클래스(`bg-[white]`), 값 전체가 색 이름인 변수 선언에서만 읽습니다. 다른 곳의 `red` 같은 단어는 색으로 보지 않습니다.
535
+
536
+ 검사하지 않는 것:
537
+
538
+ - 색 팔레트를 뺀 Tailwind 기본 테마의 값
488
539
  - 토큰이 없는 색에 가장 가까운 토큰 제시
489
- - 계산되는 인라인 스타일 값. 예: `color: active ? "#3B82F6" : "#fff"`
540
+ - 색을 뜻하지 않는 이름의 키에 적은 색(`{ primary: "#3B82F6" }`)과 배열 안의 색. `unchecked`에 개수로만 셉니다.
490
541
  - SCSS 같은 전처리기
491
542
  - 간격, 폰트 크기, radius. 이번 버전에서는 일부러 뺐습니다.
492
- - `@apply` 안의 클래스
493
543
  - 직접 만든 컴포넌트와 디자인 시스템 컴포넌트의 스타일 비교
494
544
  - Claude Code, Codex, Gemini CLI, Grok Build가 아닌 에이전트에 훅 설치하기
495
545
 
package/README.md CHANGED
@@ -21,9 +21,9 @@ It has four parts.
21
21
  | ESLint plugin | Blocks and warns. The same rules show up as errors and warnings in the editor and in the lint step. |
22
22
  | Agent hook | Blocks while the code is being written. The agent is told about errors after each edit and cannot finish while errors it can fix remain. |
23
23
 
24
- It supports **React/Next.js projects that use Tailwind CSS v4**.
24
+ It supports **React/Next.js projects that use Tailwind CSS v4**. Tailwind v3 projects are checked too, with fewer candidates (see [Tailwind v3](#tailwind-v3)).
25
25
 
26
- > **Status:** MVP (0.2.x). Messages are in English by default and can be switched to Korean. See [Language](#language).
26
+ > **Status:** MVP (0.6.x). It checks colors and shared components for now. Spacing, font size and radius are not checked yet (see [Scope](#scope)). Messages are in English by default and can be switched to Korean. See [Language](#language).
27
27
 
28
28
  ## Getting started
29
29
 
@@ -32,7 +32,7 @@ npm install --save-dev designsnitch
32
32
  npx designsnitch install
33
33
  ```
34
34
 
35
- The second command installs the agent skills and registers the agent hook. Node.js 22 or later is required.
35
+ The second command installs the agent skills and registers the agent hook. Node.js 20.19 or later is required.
36
36
 
37
37
  | Agent | Command | Skills go to | Hook goes to |
38
38
  | --- | --- | --- | --- |
@@ -94,10 +94,12 @@ Severity follows one rule.
94
94
 
95
95
  | Rule | Severity | What it catches |
96
96
  | --- | --- | --- |
97
- | `color-use-token` | Error | A hex color that has a token, written as an arbitrary value (`bg-[#3B82F6]`), in an inline style (`style={{ color: "#3B82F6" }}`) or in a CSS declaration (`color: #3B82F6`) |
98
- | `color-unknown` | Warning | A hex color with no matching token |
97
+ | `color-use-token` | Error | A color that has a token, written by hand as an arbitrary value (`bg-[#3B82F6]`), in an inline style (`style={{ color: "#3B82F6" }}`), in a CSS declaration (`color: #3B82F6`) or in `@apply` |
98
+ | `color-unknown` | Warning | A color written by hand with no matching token |
99
99
  | `use-ds-component` | Error | A raw tag such as `<button>` used outside the design system directory, when a shared component replaces it |
100
100
 
101
+ A color written by hand is a hex color, a color function with literal numbers (`rgb()`, `hsl()`, `oklch()`), or a color name such as `white`. Notation does not matter: `#3B82F6`, `rgb(59 130 246)` and `hsl(217 91% 60%)` are the same color to the check.
102
+
101
103
  Every error comes with what to use instead: a class or component in JS and TS files, and `var(--token)` in inline styles and CSS files. Tailwind v4 outputs a theme variable when the source uses it with `var()`, so `var(--token)` in an inline style renders the same color.
102
104
 
103
105
  ## Commands
@@ -170,7 +172,7 @@ Tailwind default palette
170
172
  | --- | --- |
171
173
  | `Hex colors` | Hex colors, most used first, with the number of uses and files. |
172
174
  | `bg 2`, `text 1` | Uses per Tailwind utility. `bg-[#3a11d8]` counts under `bg`. |
173
- | `string 1` | Strings that are a hex color on their own, such as inline styles and chart options. |
175
+ | `string 1` | Strings that are a color on their own, such as inline styles and chart options. |
174
176
  | `CSS 2` | Uses in CSS declarations. The JSON output breaks these down by property. |
175
177
  | `Tailwind default palette` | Colors from Tailwind's default palette used by name, such as `text-gray-700`. |
176
178
 
@@ -185,6 +187,7 @@ The [`designsnitch-palette` skill](#agent-skills) uses this output to propose to
185
187
  | `tokens` | The CSS file that defines the tokens. Required. Either a path, or an object with `file` and the optional `exclude` and `prefer` (see below). |
186
188
  | `components.path` | The directory that holds the design system components. Raw tags are allowed inside it. |
187
189
  | `components.replaces` | Raw tags and the components that replace them. Use an array when several components replace one tag. Use `{ "component": ..., "when": { ... } }` when a component covers only some variants of the tag (see below). |
190
+ | `palette` | `"tailwind"` to use Tailwind's default palette as part of the standard (see [Tailwind's default palette](#tailwinds-default-palette)). |
188
191
  | `lang` | The language of the messages: `en` (default) or `ko`. |
189
192
 
190
193
  Without `components`, the component check is skipped. Use `--config <file>` to read a config file from another path. Paths in the config file are relative to the directory of the config file.
@@ -209,14 +212,14 @@ A shared component often covers only some variants of a tag. An `Input` componen
209
212
  ```
210
213
 
211
214
  - `<input type="file">` is not reported, because the component does not cover it.
212
- - `<input type="text">` and `<input>` are reported as errors that can be replaced.
215
+ - `<input type="text">` and `<input>` are reported as errors to move to the component (`migrate`).
213
216
  - `<input type={kind}>` and `<input {...props}>` are reported, but marked `ask`: the value is only known at runtime, or a spread may override it, so replacing is not known to be safe.
214
217
 
215
218
  This is what is read from the token CSS.
216
219
 
217
220
  | Variable | Used for | When missing |
218
221
  | --- | --- | --- |
219
- | `--color-*` | Colors. The value must be a hex color, or a `var()` that leads to one. | Every hex color becomes a warning |
222
+ | `--color-*` | Colors. The value must be a hex, `rgb()`, `hsl()` or `oklch()` color, or a `var()` that leads to one. | Every color written by hand becomes a warning |
220
223
 
221
224
  Both of these shapes work.
222
225
 
@@ -236,6 +239,24 @@ Both of these shapes work.
236
239
  }
237
240
  ```
238
241
 
242
+ Where a variable is declared matters.
243
+
244
+ - A `--color-*` variable is a token when it is declared in `@theme`, or in a rule that applies everywhere (`:root`, `html`, `:host`). One declared only inside another selector, such as `.promo { --color-promo: ... }`, is not a token: it does not exist outside that selector.
245
+ - When a token is declared again inside a selector or a media query (`.dark`, `@media (prefers-color-scheme: dark)`), it has a value per theme, and replacing a color with it is marked `ask`.
246
+ - `var(--raw, #fff)` uses its fallback wherever `--raw` is not set. If `--raw` is set only inside some selector, both the fallback and that value count as the token's values, so it is also marked `ask`.
247
+
248
+ Tokens are also read from where Tailwind itself reads them.
249
+
250
+ - **Imported CSS.** If the token CSS imports other CSS files (`@import "../brand/theme.css"`, or a package), their `@theme` tokens are read too.
251
+ - **A prefix.** With `@import "tailwindcss" prefix(tw)`, Tailwind names its CSS variables `--tw-color-*`, so `var()` candidates are written that way. Class candidates replace only the part after `tw:`.
252
+ - **A JavaScript config.** With `@config "./tailwind.config.js"`, colors in `theme.extend.colors` (and in presets) become tokens, and `theme.colors` replaces the default palette, as Tailwind v4 does. These colors exist only as classes: Tailwind makes no CSS variable for them. Writing one by hand in an inline style or a CSS declaration is still reported as an error, with no candidate, and a person decides what to do. Loading the config runs it, so what it requires must be installed. If it cannot be loaded, the result says so in `problems`.
253
+
254
+ ### Tailwind v3
255
+
256
+ A v3 project keeps its colors in `tailwind.config.js`, and its CSS starts with `@tailwind base`. Point `tokens` at the CSS file as usual: when it uses `@tailwind`, the `tailwind.config.js` (or `.cjs`, `.mjs`, `.ts`) next to `designsnitch.config.json` is read. You can also point `tokens` straight at the config file. `"palette": "tailwind"` reads the v3 palette from `tailwindcss/colors`.
257
+
258
+ v3 makes no CSS variables for its colors, so every token is class-only: arbitrary color classes get token classes as candidates, and colors written by hand in CSS declarations and inline styles are reported without a candidate.
259
+
239
260
  ## Language
240
261
 
241
262
  Messages are in English by default. To read them in Korean, set `"lang": "ko"` in `designsnitch.config.json`, set the environment variable `DESIGNSNITCH_LANG=ko`, or pass `--lang ko`. When more than one is given, `--lang` wins, then the config file, then the environment variable.
@@ -253,10 +274,10 @@ src/PayButton.tsx
253
274
  8:26 warning The color of bg-[#3B82F5] is not in the tokens. (color-unknown)
254
275
 
255
276
  2 errors, 1 warning (3 files checked)
256
- 2 can be replaced right away, 1 needs a person's decision (1 decision)
277
+ 1 can be replaced right away, 1 to move to a component, 1 needs a person's decision (1 decision)
257
278
  ```
258
279
 
259
- The first line shows how many tokens and components were read from the config. A wrong path shows up here as a zero. If no color token could be read, a line starting with `Note:` explains why. The last line says how many violations can be replaced right away, how many need a person's decision, and how many separate questions those come down to.
280
+ The first line shows how many tokens and components were read from the config. A wrong path shows up here as a zero. If no color token could be read, a line starting with `Note:` explains why. The last line says how many violations can be replaced right away, how many are tags to move to a component, how many need a person's decision, and how many separate questions those come down to.
260
281
 
261
282
  `--format json` prints the same result as structured data. This example has one violation of each kind, and leaves the rest out.
262
283
 
@@ -265,7 +286,8 @@ The first line shows how many tokens and components were read from the config. A
265
286
  "designSystem": { "colorTokens": 4, "components": 1, "replacedTags": 1 },
266
287
  "problems": [],
267
288
  "next": [
268
- "action \"replace\" (2): replace found with the value in candidates.",
289
+ "action \"replace\" (1): replace found with the value in candidates.",
290
+ "action \"migrate\" (1): replace the tag with the component in candidates. Read that component first: add the import, pass on the props it accepts, and drop className values it already applies. If it cannot do what the tag did, ask the user instead.",
269
291
  "Before making changes, ask the user about the 2 entries in decisions. Include how often each comes up, the candidates, and the reasons for asking.",
270
292
  "After fixing, run the same command again."
271
293
  ],
@@ -336,11 +358,11 @@ The first line shows how many tokens and components were read from the config. A
336
358
  | `problems` | Config problems that make the result unreliable. Empty when everything is fine. |
337
359
  | `violations[].found` | The offending piece of code |
338
360
  | `violations[].candidates` | The classes or components to use instead. Empty when there are none. |
339
- | `violations[].recommended` | The candidate that fits how the color is used: a `text-` class gets the token named for text, a border gets the one named for borders. Only set when exactly one candidate fits, and only a suggestion: an `ask` stays an `ask`. For `replace`, it is the candidate. |
340
- | `violations[].action` | How to handle the violation. `replace`: replacing `found` with the only candidate keeps the screen and the behavior the same. `ask`: a person has to decide: several candidates, a color with no token, a token whose value differs between themes, or a component whose props are dynamic or spread. `repair`: the file could not be parsed. |
341
- | `decisions` | The `ask` violations grouped into questions: one per color or tag with the same candidates. Each has how often it comes up (`uses`, `files`), up to five `locations`, the `candidates`, a `recommended` candidate when every location agrees, and the `reasons` a person has to decide: `multiple-candidates`, `no-token`, `themed-token` or `dynamic-props`. Most used first. |
361
+ | `violations[].recommended` | The candidate that fits how the color is used: a `text-` class gets the token named for text, a border gets the one named for borders. Only set when exactly one candidate fits, and only a suggestion: an `ask` stays an `ask`. For `replace` and `migrate`, it is the candidate. |
362
+ | `violations[].action` | How to handle the violation. `replace`: replacing `found` with the only candidate keeps the screen and the behavior the same. Only color errors get this. `migrate`: a raw tag with exactly one design system component to move to. The tool cannot tell whether the component passes on the same props or renders the same default styles, so read the component first, then move the tag's props and drop classes the component already applies. The hook reports it after an edit but does not stop the agent from finishing over it. `ask`: a person has to decide: several candidates, a color with no token, a token whose value differs between themes, or a component whose props are dynamic or spread. `repair`: the file could not be parsed. |
363
+ | `decisions` | The `ask` violations grouped into questions: one per color or tag with the same candidates. Each has how often it comes up (`uses`, `files`), up to five `locations`, the `candidates`, a `recommended` candidate when every location agrees, and the `reasons` a person has to decide: `multiple-candidates`, `no-token`, `themed-token`, `translucent`, `not-a-style`, `class-only-token` or `dynamic-props`. Most used first. |
342
364
  | `next` | What an agent should do with this result, in order |
343
- | `unchecked` | Hex colors in other strings that were not checked (`hexColors`), and how many files they are in (`files`). The text output adds a line when there are any. |
365
+ | `unchecked` | Colors in other strings that were not checked (`colors`), and how many files they are in (`files`). The text output adds a line when there are any. |
344
366
 
345
367
  | Exit code | Meaning |
346
368
  | --- | --- |
@@ -440,6 +462,11 @@ A skill is advice that an agent may not follow. A hook is run by the agent's run
440
462
  {
441
463
  "hooks": [{ "type": "command", "command": "npx designsnitch hook" }]
442
464
  }
465
+ ],
466
+ "SessionStart": [
467
+ {
468
+ "hooks": [{ "type": "command", "command": "npx designsnitch hook" }]
469
+ }
443
470
  ]
444
471
  }
445
472
  }
@@ -449,11 +476,12 @@ A skill is advice that an agent may not follow. A hook is run by the agent's run
449
476
 
450
477
  - It compares each file with its version in git `HEAD`. An error counts as new when there are more of it (the same rule and the same code) than in `HEAD`. Errors that were already there do not block, even if lines moved. A file that is not in `HEAD` yet has only new errors.
451
478
  - After an edit, if the file has new errors, the agent receives them along with what to do next.
452
- - When the agent is about to finish, it is stopped if new errors it can fix itself remain. Errors that need a person's decision do not stop it, because it has to stop in order to ask.
479
+ - When the agent is about to finish, it is stopped if new errors remain that it can fix with the same screen and behavior (`replace`, and files that could not be parsed). Errors that need a person's decision (`ask`) do not stop it, because it has to stop in order to ask. Tags to move to a component (`migrate`) do not stop it either: the tool cannot tell whether the component behaves the same, so it reports them after the edit and leaves the call to the agent and the user.
480
+ - Errors that were in the working tree before the session started do not count as new, even when they are not committed. The hook notes them when the session starts (`SessionStart`). Without that event, it notes them at the first edit of the session, for every changed file except the one just edited. This needs the session id the agent sends.
453
481
  - Warnings never block, and files the agent did not touch are left alone.
454
482
  - Outside a git repository, or before the first commit, every error in the changed files counts.
455
483
 
456
- For Codex, `npx designsnitch install --agent codex` writes the same two hooks to `.codex/hooks.json`, with `apply_patch` as the matcher. Codex often edits files with shell commands, which that matcher does not see. Those edits are caught when Codex is about to finish, because the hook then checks every file git reports as changed.
484
+ For Codex, `npx designsnitch install --agent codex` writes the same hooks to `.codex/hooks.json`, with `apply_patch` as the matcher. Codex often edits files with shell commands, which that matcher does not see. Those edits are caught when Codex is about to finish, because the hook then checks every file git reports as changed.
457
485
 
458
486
  For Gemini CLI, `npx designsnitch install --agent gemini` writes the hooks to `.gemini/settings.json` under Gemini CLI's own event names: `AfterTool` for `write_file` and `replace`, and `AfterAgent` for when it is about to answer, where exit code 2 makes it try again with the errors as feedback. This follows the official Gemini CLI documentation and has not been tested with Gemini CLI.
459
487
 
@@ -463,7 +491,20 @@ The command reads an optional JSON object from stdin (`tool_input.file_path`, `h
463
491
 
464
492
  ### Tailwind's default palette
465
493
 
466
- designsnitch does not flag default palette classes such as `bg-blue-500`. If the project should only use its own tokens, Tailwind v4 can remove the default palette, and then those classes stop working at all.
494
+ Many projects use Tailwind's default palette (`bg-slate-100`, `text-indigo-600`) as their standard. Set `"palette": "tailwind"` to make it part of the standard.
495
+
496
+ ```json
497
+ { "tokens": "app/globals.css", "palette": "tailwind" }
498
+ ```
499
+
500
+ - The palette is read from the `tailwindcss/theme.css` installed in the project, found from the token CSS, so it always matches the installed version. This needs Tailwind CSS v4 (4.0 or later). With v3, or when tailwindcss cannot be found, the check stops and says which. Tested against 4.0.0, 4.1.0, 4.2.0, 4.3.0 and 4.3.5: no color changed value between them, and 4.2.0 added the `mauve`, `olive`, `mist` and `taupe` scales.
501
+ - A hex color with the same value as a palette color is an error, with the palette class as its candidate: `bg-[#62748e]` → `bg-slate-500`. Tailwind v4 writes the palette in `oklch()`, and it is converted to hex for the comparison. Palette colors outside sRGB have no hex value that renders the same, so they match only the same `oklch()` value.
502
+ - A token in the project's token CSS with the same name as a palette color replaces it, in hex or in `oklch()`, as in Tailwind's own example of overriding a color.
503
+ - Namespaces the project clears are left out, as Tailwind documents: `--color-*: initial` removes the whole palette, `--color-lime-*: initial` removes one scale, and `--*: initial` removes the whole default theme.
504
+ - `exclude` and `prefer` in `tokens` apply to palette colors too.
505
+ - The palette counts as tokens, so a project with no tokens of its own is not reported as having none.
506
+
507
+ Without `palette`, designsnitch does not flag default palette classes, and does not compare hex colors with them. If the project should use only its own tokens, Tailwind v4 can remove the default palette, and then those classes stop working at all.
467
508
 
468
509
  ```css
469
510
  @theme {
@@ -474,21 +515,30 @@ designsnitch does not flag default palette classes such as `bg-blue-500`. If the
474
515
 
475
516
  ## Scope
476
517
 
477
- - **Where it looks in JS and TS:** arbitrary color classes in string literals and template literals, which covers `className` and the arguments of `cn()`, `clsx()` and `cva()`, and hex colors written as strings in a JSX `style` object. Comments are ignored. Hex colors in other strings, such as theme objects and chart options, are not checked: their purpose cannot be told from the code. The check counts them in `unchecked` so that you know they are there, and `designsnitch colors` lists them.
478
- - **Where it looks in CSS:** hex colors in declaration values, in `.css` files including CSS Modules. In the token CSS, declarations that define a variable (`--name: ...`) are skipped, since that is where tokens are defined. In every other CSS file they are checked like any other declaration. Only colors are checked in CSS for now.
479
- - **Themes:** when a token has different values per theme, all of them count as that token's value. Replacing a hex color with such a token changes the color in the other themes, so those errors are marked `ask`.
518
+ - **Where it looks in JS and TS:** arbitrary color classes in string literals and template literals, which covers `className` and the arguments of `cn()`, `clsx()` and `cva()`, and colors written as strings where a color is expected, including the branches of `a ? "#fff" : "#000"` and `x || "#fff"`. Comments are ignored.
519
+ - **Styles:** a JSX `style` object, an object in a variable whose name ends in `style` or `styles`, and an object typed `CSSProperties`. `var(--token)` works there, so these are checked like any other color.
520
+ - **Other color properties:** a property or JSX attribute whose name is a CSS color property or ends in `Color`, such as `backgroundColor` in chart options or `stroke` on an SVG element. The color is reported, with `var(--token)` as a candidate, but marked `ask`: the tool cannot tell whether `var()` works where the value ends up, for example on a canvas.
521
+ - **Everything else:** colors under other keys (`{ primary: "#3B82F6" }`) and in arrays are not checked, because their purpose cannot be told from the code. The check counts them in `unchecked` so that you know they are there, and `designsnitch colors` lists them.
522
+ - **Where it looks in CSS:** colors in declaration values and arbitrary color classes in `@apply`, in `.css` files including CSS Modules. In the token CSS, declarations that define a variable (`--name: ...`) are skipped, since that is where tokens are defined. In every other CSS file they are checked like any other declaration. Only colors are checked in CSS for now.
523
+ - **Themes:** when a token has different values per theme, all of them count as that token's value. Replacing a color with such a token changes the color in the other themes, so those errors are marked `ask`.
480
524
  - **Fixes:** designsnitch reports candidates and never rewrites code by itself, even when there is only one candidate.
481
525
 
482
526
  ### Not supported yet
483
527
 
484
- - Colors that are not hex (`rgb()`, `hsl()`, `oklch()`)
485
- - Values from Tailwind's default theme. Only the values written in the project's token CSS are read.
486
- - Tailwind v3 (`tailwind.config.js`)
528
+ These are detected, but not matched to a token:
529
+
530
+ - Translucent colors (`#3B82F680`, `rgb(0 0 0 / 50%)`) get the token of the opaque color with an opacity: `bg-brand/50` for a class, `color-mix(in srgb, var(--color-brand) 50%, transparent)` for a style or a CSS declaration. The opacity is rounded to a whole percent, so these are marked `ask`.
531
+ - Colors a Tailwind plugin adds are not known as tokens, so writing one by hand is reported as a color with no token.
532
+ - `hwb()`, `lab()`, `lch()`, `oklab()` and `color()` values, and `oklch()` colors outside sRGB, match only a token written with the same value: no hex color renders the same.
533
+ - Color names are read in color properties (`color`, `background`, `border`, ...), in arbitrary classes (`bg-[white]`), and as a whole custom property value. Elsewhere a word such as `red` is not taken for a color.
534
+
535
+ These are not checked:
536
+
537
+ - Values from Tailwind's default theme other than the color palette
487
538
  - The nearest token for a color that has none
488
- - Inline style values that are computed, such as `color: active ? "#3B82F6" : "#fff"`
539
+ - Colors under keys that do not say color, such as `{ primary: "#3B82F6" }`, and colors in arrays. They are counted in `unchecked`.
489
540
  - SCSS and other preprocessors
490
541
  - Spacing, font size and radius. They were left out of this version on purpose.
491
- - Classes inside `@apply`
492
542
  - Comparing a hand-made component's styles with the design system component
493
543
  - Installing the hook for agents other than Claude Code, Codex, Gemini CLI and Grok Build
494
544
 
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const MINIMUM_NODE_MAJOR = 22;
3
+ // ESLint 10 의 최소 버전과 같다. 이보다 낮으면 ESM 으로 쓴 Tailwind 설정을 require 로 읽지 못한다.
4
+ const MINIMUM_NODE = [20, 19];
4
5
 
5
6
  /** @param {string} version process.versions.node 와 같은 형식의 버전 */
6
7
  export function isSupportedNodeVersion(version) {
7
- return Number(version.split(".", 1)[0]) >= MINIMUM_NODE_MAJOR;
8
+ const [major, minor] = version.split(".").map(Number);
9
+ return major > MINIMUM_NODE[0] || (major === MINIMUM_NODE[0] && minor >= MINIMUM_NODE[1]);
8
10
  }
9
11
 
10
12
  const version = process.versions.node;
@@ -30,7 +32,7 @@ async function main() {
30
32
  }
31
33
  const { messages, resolveLang } = await import("../src/messages.js");
32
34
  const message = messages(resolveLang(flagLang)).nodeVersionUnsupported;
33
- process.stderr.write(`${message({ minimum: MINIMUM_NODE_MAJOR, version })}\n`);
35
+ process.stderr.write(`${message({ minimum: MINIMUM_NODE.join("."), version })}\n`);
34
36
  process.exitCode = 2;
35
37
  return;
36
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "designsnitch",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Keep AI-written UI code manageable and consistent, even without a design system. CLI, agent skills, ESLint plugin and agent hook for React/Next.js with Tailwind CSS v4.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -26,7 +26,7 @@
26
26
  "designsnitch": "bin/designsnitch.js"
27
27
  },
28
28
  "engines": {
29
- "node": ">=22"
29
+ "node": ">=20.19"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",
@@ -71,15 +71,15 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
71
71
  - `action` says how to handle each violation. Section 3 covers each value.
72
72
  - `found` is the offending piece of code. `candidates` lists what to use instead: classes or components in JS and TS files, and `var(--token)` in inline styles and `.css` files.
73
73
  - `recommended` is the candidate whose token is named for how the color is used here, such as the text token for a `text-` class. It is a suggestion to put in front of the user, not permission to replace.
74
- - `decisions` groups every `ask` violation into questions: one per color or tag with the same candidates, most used first. Each has `uses`, `files`, up to five `locations`, the `candidates`, a `recommended` candidate when all locations agree, and `reasons` (`multiple-candidates`, `no-token`, `themed-token`, `dynamic-props`). Ask the user about decisions, not about single violations.
75
- - `unchecked` counts hex colors in other strings, such as theme objects and chart options, that the check could not judge. They are not violations. If the count is large and those strings feed the UI, mention it to the user: `npx designsnitch colors` lists them.
76
- - `designSystem` counts the tokens and components read from the config. `colorTokens` 0 means the project has no color tokens that can be read: follow the `designsnitch-palette` skill to establish them before touching any color.
74
+ - `decisions` groups every `ask` violation into questions: one per color or tag with the same candidates, most used first. Each has `uses`, `files`, up to five `locations`, the `candidates`, a `recommended` candidate when all locations agree, and `reasons` (`multiple-candidates`, `no-token`, `themed-token`, `translucent`, `not-a-style`, `class-only-token`, `dynamic-props`). Ask the user about decisions, not about single violations.
75
+ - `unchecked` counts colors in other strings, such as theme objects and chart options, that the check could not judge. They are not violations. If the count is large and those strings feed the UI, mention it to the user: `npx designsnitch colors` lists them.
76
+ - `designSystem` counts the tokens and components read from the config. `paletteColors` is the number of Tailwind default palette colors in the standard, when the config has `"palette": "tailwind"`. `colorTokens` 0 means the project has no color tokens that can be read: follow the `designsnitch-palette` skill to establish them before touching any color.
77
77
  - A non-empty `problems` means the config is broken and the results cannot be trusted. Tell the user before fixing anything.
78
78
 
79
79
  | `rule` | Severity | Meaning |
80
80
  | --- | --- | --- |
81
- | `color-use-token` | error | A hex color that has a token was written as an arbitrary value, in an inline style, or directly in a CSS declaration. |
82
- | `color-unknown` | warning | A hex color with no matching token. |
81
+ | `color-use-token` | error | A color that has a token was written by hand (hex, a color function such as `rgb()`, or a color name such as `white`): as an arbitrary value, in an inline style, in a CSS declaration or in `@apply`. |
82
+ | `color-unknown` | warning | A color written by hand with no matching token. |
83
83
  | `use-ds-component` | error | A raw tag was used outside the design system directory although a shared component replaces it. |
84
84
  | `parse-error` | error | The file could not be parsed. |
85
85
 
@@ -87,11 +87,12 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
87
87
 
88
88
  | `action` | What it means | What to do |
89
89
  | --- | --- | --- |
90
- | `replace` | An error whose only candidate keeps the screen and the behavior the same. | Replace `found` with the candidate. |
91
- | `ask` | A person has to decide: several candidates, a color that has no token, a token whose value differs between themes, or a component whose props are dynamic or spread. `message` says which. | Do not change it. Ask the user as described in section 4. |
90
+ | `replace` | A color error whose only candidate keeps the screen and the behavior the same. | Replace `found` with the candidate. |
91
+ | `migrate` | A raw tag with exactly one design system component to move to. Whether the component behaves like the tag is not known. | Read the component, then move the tag to it as described below. If the component cannot do what the tag did, such as not passing on `type="submit"` or an event handler, leave the tag and tell the user. The hook does not force this one. |
92
+ | `ask` | A person has to decide: several candidates, a color that has no token, a token whose value differs between themes, a translucent color (the candidate rounds its opacity), a color in a property that is not a style (such as chart options, where `var()` may not work: read how the value is used before replacing), a token that exists only as a class (no CSS variable to use in a style or a CSS declaration), or a component whose props are dynamic or spread. `message` says which. | Do not change it. Ask the user as described in section 4. |
92
93
  | `repair` | The file could not be parsed. | Fix the syntax error, then check again. |
93
94
 
94
- For `use-ds-component`, replacing means more than renaming the tag. Read the design system component file to learn its props, add the import, and remove className values that duplicate styles the component already has.
95
+ For `migrate`, replacing means more than renaming the tag. Read the design system component file to learn its props, add the import, pass on the tag's props the component accepts, and remove className values that duplicate styles the component already has. Check that event handlers such as `onClick` and attributes such as `type` still reach the rendered element.
95
96
 
96
97
  ## 4. Ask so the user can decide
97
98