designsnitch 0.2.0 → 0.3.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
@@ -23,7 +23,7 @@ designsnitch는 디자인 시스템이 없거나 이름뿐인 프로젝트에서
23
23
 
24
24
  **Tailwind CSS v4를 쓰는 React/Next.js 프로젝트**를 지원합니다.
25
25
 
26
- > **상태:** MVP(0.2.x). CLI 메시지는 아직 한국어로만 나옵니다. JSON 출력에는 같은 정보가 언어와 무관한 필드로 들어 있습니다.
26
+ > **상태:** MVP(0.2.x). 메시지는 기본이 영어이고 한국어로 바꿀 수 있습니다. 이 문서의 출력 예시는 한국어로 설정했을 때의 모습입니다. [언어](#언어)를 보세요.
27
27
 
28
28
  ## 시작하기
29
29
 
@@ -32,7 +32,26 @@ npm install --save-dev designsnitch
32
32
  npx designsnitch install
33
33
  ```
34
34
 
35
- 두 번째 명령은 에이전트 스킬을 `.claude/skills`에 복사하고, 에이전트 훅을 `.claude/settings.json`에 등록합니다. 지금은 Claude Code에 맞춰져 있습니다. Node.js 22 이상이 필요합니다.
35
+ 두 번째 명령은 에이전트 스킬을 설치하고 에이전트 훅을 등록합니다. Node.js 22 이상이 필요합니다.
36
+
37
+ | 에이전트 | 명령 | 스킬 위치 | 훅 위치 |
38
+ | --- | --- | --- | --- |
39
+ | Claude Code | `npx designsnitch install` | `.claude/skills` | `.claude/settings.json` |
40
+ | Codex | `npx designsnitch install --agent codex` | `.agents/skills` | `.codex/hooks.json` |
41
+ | Gemini CLI | `npx designsnitch install --agent gemini` | `.agents/skills` | `.gemini/settings.json` |
42
+ | Grok Build | `npx designsnitch install --agent grok` | `.grok/skills` | `.grok/hooks/designsnitch.json` |
43
+ | 모두 | `npx designsnitch install --agent all` | | |
44
+
45
+ Codex, Gemini CLI, Grok Build는 새 프로젝트 훅을 승인하거나 프로젝트를 신뢰한 뒤에만 실행합니다. 프로젝트에서 에이전트를 열고, 요청이 나오면 승인하세요. Grok Build에서는 `/hooks-trust`를 쓰거나 `--trust`로 시작합니다.
46
+
47
+ | 에이전트 | 훅을 확인한 방법 |
48
+ | --- | --- |
49
+ | Claude Code | 실제 에이전트로 돌려 봤습니다. hex 색을 썼다가 훅의 안내를 받고 토큰 클래스로 바꿨습니다. |
50
+ | Codex | 실제 에이전트로 돌려 봤습니다. 결과가 같았습니다. |
51
+ | Gemini CLI | **테스트하지 못했습니다.** 공식 Gemini CLI 문서를 기준으로 만들었습니다. |
52
+ | Grok Build | **테스트하지 못했습니다.** 공식 xAI 문서를 기준으로 만들었습니다. [에이전트 훅](#에이전트-훅)의 안내를 보세요. |
53
+
54
+ 스킬은 공개 표준인 Agent Skills 형식이라, 이 형식을 지원하는 에이전트라면 어디서든 쓸 수 있습니다. 표준 설치 도구가 에이전트마다 맞는 위치에 넣어 줍니다: `npx skills add icecokel/designsnitch`. 이 도구는 스킬만 설치하고 훅은 설치하지 않습니다.
36
55
 
37
56
  그다음 코딩 에이전트에게 이렇게 요청합니다.
38
57
 
@@ -85,12 +104,12 @@ npx designsnitch install
85
104
 
86
105
  | 명령 | 하는 일 |
87
106
  | --- | --- |
88
- | `designsnitch install` | 스킬을 복사하고 에이전트 훅을 프로젝트에 등록합니다. |
107
+ | `designsnitch install` | 스킬을 복사하고 에이전트 훅을 프로젝트에 등록합니다. `--agent claude`(기본), `codex`, `gemini`, `grok`, `all`을 받습니다. |
89
108
  | `designsnitch colors` | 코드가 쓰는 색을 모아 보여줍니다. 설정 파일이 없어도 됩니다. |
90
109
  | `designsnitch check` | 코드를 기준에 비춰 검사하고, 위반마다 무엇을 하면 되는지 알려줍니다. |
91
110
  | `designsnitch hook` | 에이전트의 훅에서 부릅니다. 에이전트가 방금 바꾼 파일을 검사합니다. |
92
111
 
93
- `check`와 `colors`는 경로, `--format json`, `--config <파일>`을 받습니다.
112
+ `check`와 `colors`는 경로, `--format json`, `--config <파일>`을 받습니다. 모든 명령은 `--lang en|ko`를 받습니다.
94
113
 
95
114
  ## 직접 설정하기
96
115
 
@@ -103,11 +122,12 @@ npm install --save-dev designsnitch
103
122
  ```json
104
123
  {
105
124
  "tokens": "./app/globals.css",
125
+ "lang": "ko",
106
126
  "components": {
107
127
  "path": "./components/ui",
108
128
  "replaces": {
109
129
  "button": ["SolidButton", "IconButton"],
110
- "input": "Input",
130
+ "input": { "component": "Input", "when": { "type": ["text", "email", null] } },
111
131
  "dialog": "Dialog"
112
132
  }
113
133
  }
@@ -165,10 +185,21 @@ Tailwind 기본 팔레트
165
185
  | --- | --- |
166
186
  | `tokens` | 토큰이 정의된 CSS 파일입니다. 필수입니다. |
167
187
  | `components.path` | 디자인 시스템 컴포넌트가 있는 경로입니다. 이 안에서는 raw 태그를 써도 됩니다. |
168
- | `components.replaces` | raw 태그와 그것을 대체하는 컴포넌트입니다. 한 태그를 대체하는 컴포넌트가 여러 개면 배열로 적습니다. |
188
+ | `components.replaces` | raw 태그와 그것을 대체하는 컴포넌트입니다. 한 태그를 대체하는 컴포넌트가 여러 개면 배열로 적습니다. 컴포넌트가 태그의 일부 변형만 맡으면 `{ "component": ..., "when": { ... } }`로 적습니다(아래 참고). |
189
+ | `lang` | 메시지의 언어입니다. `en`(기본) 또는 `ko`입니다. |
169
190
 
170
191
  `components`를 생략하면 컴포넌트 검사를 하지 않습니다. 다른 경로의 설정 파일을 쓰려면 `--config <파일>`을 붙입니다.
171
192
 
193
+ 공용 컴포넌트가 태그의 일부 변형만 맡는 경우가 많습니다. `Input` 컴포넌트는 텍스트 입력은 맡아도 `<input type="file">`은 맡지 않을 수 있습니다. `when`에 컴포넌트가 맡는 속성 값을 적습니다. `null`은 그 속성이 없다는 뜻입니다.
194
+
195
+ ```json
196
+ "input": { "component": "Input", "when": { "type": ["text", "email", null] } }
197
+ ```
198
+
199
+ - `<input type="file">`은 컴포넌트가 맡지 않으므로 보고하지 않습니다.
200
+ - `<input type="text">`와 `<input>`은 바로 바꿀 수 있는 오류로 보고합니다.
201
+ - `<input type={kind}>`와 `<input {...props}>`는 보고하되 `ask`로 표시합니다. 값을 실행할 때에야 알 수 있거나 spread가 값을 덮어쓸 수 있어서, 바꿔도 안전한지 알 수 없기 때문입니다.
202
+
172
203
  토큰 CSS에서 읽는 것은 다음과 같습니다.
173
204
 
174
205
  | 변수 | 쓰임 | 없을 때 |
@@ -193,6 +224,12 @@ Tailwind 기본 팔레트
193
224
  }
194
225
  ```
195
226
 
227
+ ## 언어
228
+
229
+ 메시지는 기본이 영어입니다. 한국어로 보려면 `designsnitch.config.json`에 `"lang": "ko"`를 적거나, 환경 변수 `DESIGNSNITCH_LANG=ko`를 설정하거나, `--lang ko`를 붙입니다. 여러 개를 함께 주면 `--lang`, 설정 파일, 환경 변수 순으로 우선합니다.
230
+
231
+ ESLint 플러그인도 설정의 같은 `lang`을 읽습니다. 규칙 이름, 출력의 구조, JSON 필드 이름은 두 언어에서 같습니다.
232
+
196
233
  ## 출력
197
234
 
198
235
  ```
@@ -245,7 +282,7 @@ src/PayButton.tsx
245
282
  | `problems` | 결과를 믿기 어렵게 만드는 설정 문제. 정상이면 빈 배열입니다. |
246
283
  | `violations[].found` | 위반한 코드 조각 |
247
284
  | `violations[].candidates` | 대신 쓸 클래스나 컴포넌트. 없으면 빈 배열입니다. |
248
- | `violations[].action` | 이 위반을 어떻게 다룰지입니다. `replace`: 후보가 하나뿐인 오류라서 `found`를 그 후보로 바꾸면 됩니다. `ask`: 사람이 정해야 합니다(후보가 여러 개이거나 토큰이 없는 색). `repair`: 파일을 읽지 못했습니다. |
285
+ | `violations[].action` | 이 위반을 어떻게 다룰지입니다. `replace`: `found`를 하나뿐인 후보로 바꿔도 화면과 동작이 같습니다. `ask`: 사람이 정해야 합니다. 후보가 여러 개이거나, 토큰이 없는 색이거나, 테마마다 값이 다른 토큰이거나, 컴포넌트의 속성이 동적이거나 spread된 경우입니다. `repair`: 파일을 읽지 못했습니다. |
249
286
  | `next` | 이 결과를 받은 에이전트가 할 일을 순서대로 적은 것 |
250
287
 
251
288
  | 종료 코드 | 의미 |
@@ -276,7 +313,7 @@ CSS 파일에서는 선언 바로 앞줄에 이 주석을 답니다.
276
313
 
277
314
  ## 에이전트 스킬
278
315
 
279
- `npx designsnitch install`이 스킬을 `.claude/skills`에 복사합니다. 패키지를 올린 뒤에는 다시 실행해서 스킬을 최신으로 맞추세요. 다른 곳에 복사하려면 패키지의 `skills/` 디렉터리에 있는 것을 쓰면 됩니다.
316
+ `npx designsnitch install`은 Claude Code용으로 스킬을 `.claude/skills`에 복사하고, `--agent codex`나 `--agent gemini`를 붙이면 Codex와 Gemini CLI가 읽는 `.agents/skills`에, `--agent grok`을 붙이면 Grok Build가 읽는 `.grok/skills`에 복사합니다. 패키지를 올린 뒤에는 다시 실행해서 스킬을 최신으로 맞추세요. 다른 곳에 복사하려면 패키지의 `skills/` 디렉터리에 있는 것을 쓰면 됩니다.
280
317
 
281
318
  스킬 하나가 일 하나를 맡습니다.
282
319
 
@@ -349,13 +386,21 @@ CLI와 스킬은 AI 에이전트가 제대로 할 수 있는 상태를 만들어
349
386
  }
350
387
  ```
351
388
 
352
- `designsnitch hook`은 에이전트가 방금 바꾼 파일만 검사합니다.
389
+ `designsnitch hook`은 에이전트가 방금 바꾼 파일만 검사하고, 그 변경으로 새로 생긴 오류만 막습니다.
390
+
391
+ - 파일마다 git `HEAD` 버전과 비교합니다. 같은 규칙, 같은 코드의 오류가 `HEAD`보다 많아졌으면 새 오류입니다. 원래 있던 오류는 줄이 밀려도 막지 않습니다. `HEAD`에 아직 없는 파일은 모든 오류가 새것입니다.
392
+ - 파일을 고친 뒤 새 오류가 있으면, 에이전트는 오류와 다음에 할 일을 전달받습니다.
393
+ - 에이전트가 작업을 끝내려 할 때 스스로 고칠 수 있는 새 오류가 남아 있으면 끝내지 못합니다. 사람이 정해야 하는 오류는 막지 않습니다. 물어보려면 멈춰야 하기 때문입니다.
394
+ - 경고는 막지 않고, 에이전트가 건드리지 않은 파일은 보지 않습니다.
395
+ - git 저장소가 아니거나 첫 커밋 전이면, 바꾼 파일의 오류를 모두 셉니다.
396
+
397
+ Codex에는 `npx designsnitch install --agent codex`가 같은 두 훅을 `.codex/hooks.json`에 씁니다. 파일 수정 쪽은 `apply_patch`에 걸립니다. Codex는 셸 명령으로 파일을 고치는 일이 많은데, 그런 수정은 이 조건에 걸리지 않습니다. 대신 Codex가 작업을 끝내려 할 때 잡힙니다. 그때 훅이 git에서 바뀐 파일을 모두 검사하기 때문입니다.
398
+
399
+ Gemini CLI에는 `npx designsnitch install --agent gemini`가 훅을 `.gemini/settings.json`에 씁니다. 이벤트 이름이 다릅니다. 파일 수정 직후는 `write_file`과 `replace`에 걸리는 `AfterTool`이고, 답하기 직전은 `AfterAgent`입니다. `AfterAgent`에서 종료 코드 2를 받으면 Gemini CLI는 오류를 피드백 삼아 다시 시도합니다. 공식 Gemini CLI 문서를 기준으로 만들었고, Gemini CLI에서 테스트하지 못했습니다.
353
400
 
354
- - 파일을 고친 뒤 그 파일에 오류가 있으면, 에이전트는 오류와 다음에 할 일을 전달받습니다.
355
- - 에이전트가 작업을 끝내려 할 때 스스로 고칠 수 있는 오류가 남아 있으면 끝내지 못합니다. 사람이 정해야 하는 오류는 막지 않습니다. 물어보려면 멈춰야 하기 때문입니다.
356
- - 경고는 막지 않고, 에이전트가 건드리지 않은 파일의 위반은 그대로 둡니다.
401
+ Grok Build에는 `npx designsnitch install --agent grok`이 `PostToolUse`와 `Stop` 훅을 `.grok/hooks/designsnitch.json`에 씁니다. 공식 xAI 문서를 기준으로 만들었고 Grok Build에서 테스트하지 못했습니다. 불확실한 점이 하나 있습니다. 문서는 `PreToolUse`만 막는 이벤트라고 하고, 도구 실행 뒤나 작업을 끝낼 때 종료 코드 2가 무엇을 하는지는 적지 않았습니다. 그래서 Grok Build에서는 오류를 알리기만 하고 에이전트를 멈추지 못할 수 있습니다. 또 Grok Build는 Claude Code의 `.claude/settings.json`도 읽기 때문에, `--agent all`로 설치하면 Grok Build에서 훅이 두 번 돌 수 있습니다. 해는 없습니다.
357
402
 
358
- 이 명령은 표준 입력으로 JSON을 받을 수 있습니다(`tool_input.file_path`, `hook_event_name`, `stop_hook_active`). 막을 때는 종료 코드 2로 끝나며 stderr에 내용을 쓰고, 파일이 주어지지 않으면 git에서 바뀐 파일을 검사합니다. 같은 방식의 명령 훅을 지원하는 다른 에이전트에서도 쓸 수 있습니다. `designsnitch-hooks` 스킬이 이 설정을 해 줍니다.
403
+ 이 명령은 표준 입력으로 JSON을 받을 수 있습니다(`tool_input.file_path`, `hook_event_name`, `stop_hook_active`, 또는 Grok Build가 보내는 camelCase 형식의 같은 필드). 막을 때는 종료 코드 2로 끝나며 stderr에 내용을 쓰고, 파일이 주어지지 않으면 git에서 바뀐 파일을 검사합니다. 같은 방식의 명령 훅을 지원하는 다른 에이전트에서도 쓸 수 있습니다. `designsnitch-hooks` 스킬이 이 설정을 해 줍니다.
359
404
 
360
405
  ### Tailwind 기본 팔레트
361
406
 
@@ -372,7 +417,7 @@ designsnitch는 `bg-blue-500` 같은 기본 팔레트 클래스를 위반으로
372
417
 
373
418
  - **JS와 TS에서 보는 곳:** 문자열과 템플릿 리터럴입니다. `className`과 `cn()`, `clsx()`, `cva()`의 인자가 여기에 들어갑니다. 주석은 보지 않습니다.
374
419
  - **CSS에서 보는 곳:** `.css` 파일(CSS Modules 포함)의 선언 값에 있는 hex 색입니다. 변수를 정의하는 선언(`--이름: ...`)은 토큰을 정의하는 곳이므로 건너뜁니다. CSS에서는 아직 색만 검사합니다.
375
- - **테마:** 토큰이 테마마다 다른 값을 가지면 그 값들을 모두 그 토큰의 값으로 봅니다.
420
+ - **테마:** 토큰이 테마마다 다른 값을 가지면 그 값들을 모두 그 토큰의 값으로 봅니다. hex 색을 그런 토큰으로 바꾸면 다른 테마에서 색이 바뀌므로 `ask`로 표시합니다.
376
421
  - **수정:** designsnitch는 후보를 알려줄 뿐, 후보가 하나여도 코드를 직접 고치지 않습니다.
377
422
 
378
423
  ### 아직 안 되는 것
@@ -386,7 +431,7 @@ designsnitch는 `bg-blue-500` 같은 기본 팔레트 클래스를 위반으로
386
431
  - 간격, 폰트 크기, radius. 이번 버전에서는 일부러 뺐습니다.
387
432
  - `@apply` 안의 클래스
388
433
  - 직접 만든 컴포넌트와 디자인 시스템 컴포넌트의 스타일 비교
389
- - Claude Code가 아닌 에이전트에 스킬과 훅 설치하기
434
+ - Claude Code, Codex, Gemini CLI, Grok Build가 아닌 에이전트에 훅 설치하기
390
435
 
391
436
  Figma 같은 시안 파일과 화면을 비교하는 일은 범위 밖입니다. 기준은 디자인 시스템 하나입니다.
392
437
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # designsnitch
2
2
 
3
- English | [한국어](./README.ko.md)
3
+ English | [Korean](./README.ko.md)
4
4
 
5
5
  designsnitch helps keep a UI codebase manageable and consistent when the project has no design system, or has one in name only. It is built for code written by AI agents, which produce plausible UI quickly and scatter colors, spacing and components across screens as they go.
6
6
 
@@ -23,7 +23,7 @@ It has four parts.
23
23
 
24
24
  It supports **React/Next.js projects that use Tailwind CSS v4**.
25
25
 
26
- > **Status:** MVP (0.2.x). CLI messages are in Korean for now. The JSON output carries the same information in language-neutral fields.
26
+ > **Status:** MVP (0.2.x). 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,26 @@ npm install --save-dev designsnitch
32
32
  npx designsnitch install
33
33
  ```
34
34
 
35
- The second command copies the agent skills into `.claude/skills` and registers the agent hook in `.claude/settings.json`. It targets Claude Code for now. Node.js 22 or later is required.
35
+ The second command installs the agent skills and registers the agent hook. Node.js 22 or later is required.
36
+
37
+ | Agent | Command | Skills go to | Hook goes to |
38
+ | --- | --- | --- | --- |
39
+ | Claude Code | `npx designsnitch install` | `.claude/skills` | `.claude/settings.json` |
40
+ | Codex | `npx designsnitch install --agent codex` | `.agents/skills` | `.codex/hooks.json` |
41
+ | Gemini CLI | `npx designsnitch install --agent gemini` | `.agents/skills` | `.gemini/settings.json` |
42
+ | Grok Build | `npx designsnitch install --agent grok` | `.grok/skills` | `.grok/hooks/designsnitch.json` |
43
+ | All of them | `npx designsnitch install --agent all` | | |
44
+
45
+ Codex, Gemini CLI and Grok Build run a new project hook only after you approve or trust it. Open the agent in the project and approve when it asks. In Grok Build, use `/hooks-trust` or start it with `--trust`.
46
+
47
+ | Agent | How the hook was checked |
48
+ | --- | --- |
49
+ | Claude Code | Run with the real agent. It wrote a hex color, was told by the hook, and switched to the token class. |
50
+ | Codex | Run with the real agent. Same result. |
51
+ | Gemini CLI | **Not tested.** Built from the official Gemini CLI documentation. |
52
+ | Grok Build | **Not tested.** Built from the official xAI documentation. See the note under [Agent hook](#agent-hook). |
53
+
54
+ The skills follow the open Agent Skills format, so any agent that supports it can use them. The standard installer puts them where each agent looks: `npx skills add icecokel/designsnitch`. It installs the skills only, not the hook.
36
55
 
37
56
  Then ask your coding agent:
38
57
 
@@ -85,12 +104,12 @@ Every error comes with what to use instead: a class or component in JS and TS fi
85
104
 
86
105
  | Command | What it does |
87
106
  | --- | --- |
88
- | `designsnitch install` | Copies the skills and registers the agent hook in the project. |
107
+ | `designsnitch install` | Copies the skills and registers the agent hook in the project. `--agent claude` (default), `codex`, `gemini`, `grok` or `all`. |
89
108
  | `designsnitch colors` | Lists the colors the code uses. Works without a config file. |
90
109
  | `designsnitch check` | Checks code against the standard and says what to do with each violation. |
91
110
  | `designsnitch hook` | Called from the agent's hook. Checks the files the agent just changed. |
92
111
 
93
- `check` and `colors` take paths, `--format json`, and `--config <file>`.
112
+ `check` and `colors` take paths, `--format json`, and `--config <file>`. Every command takes `--lang en|ko`.
94
113
 
95
114
  ## Setting up by hand
96
115
 
@@ -107,7 +126,7 @@ Create `designsnitch.config.json` in the project root.
107
126
  "path": "./components/ui",
108
127
  "replaces": {
109
128
  "button": ["SolidButton", "IconButton"],
110
- "input": "Input",
129
+ "input": { "component": "Input", "when": { "type": ["text", "email", null] } },
111
130
  "dialog": "Dialog"
112
131
  }
113
132
  }
@@ -134,28 +153,28 @@ npx designsnitch colors --format json
134
153
  ```
135
154
 
136
155
  ```
137
- 코드에서 쓰는 색: hex 5개, 기본 팔레트 1개 (사용 10곳, 파일 1개 검사)
156
+ Colors used in the code: 5 hex, 1 from the default palette (10 uses, 1 file checked)
138
157
 
139
- hex 색
140
- #3a11d8 3곳 파일 1개 bg 2, 문자열 1
141
- #484646 2곳 파일 1개 text 2
142
- #ffffff 2곳 파일 1개 bg 1, text 1
143
- #484645 1곳 파일 1개 text 1
144
- #e2e1e5 1곳 파일 1개 border 1
158
+ Hex colors
159
+ #3a11d8 3 uses 1 file bg 2, string 1
160
+ #484646 2 uses 1 file text 2
161
+ #ffffff 2 uses 1 file bg 1, text 1
162
+ #484645 1 use 1 file text 1
163
+ #e2e1e5 1 use 1 file border 1
145
164
 
146
- Tailwind 기본 팔레트
147
- gray-700 1곳 파일 1개 text 1
165
+ Tailwind default palette
166
+ gray-700 1 use 1 file text 1
148
167
  ```
149
168
 
150
169
  | Part of the output | Meaning |
151
170
  | --- | --- |
152
- | `hex 색` (hex colors) | Hex colors, most used first, with the number of uses (`곳`) and files (`파일`). |
171
+ | `Hex colors` | Hex colors, most used first, with the number of uses and files. |
153
172
  | `bg 2`, `text 1` | Uses per Tailwind utility. `bg-[#3a11d8]` counts under `bg`. |
154
- | `문자열 1` (strings) | Strings that are a hex color on their own, such as inline styles and chart options. |
173
+ | `string 1` | Strings that are a hex color on their own, such as inline styles and chart options. |
155
174
  | `CSS 2` | Uses in CSS declarations. The JSON output breaks these down by property. |
156
- | `Tailwind 기본 팔레트` (default palette) | Colors from Tailwind's default palette used by name, such as `text-gray-700`. |
175
+ | `Tailwind default palette` | Colors from Tailwind's default palette used by name, such as `text-gray-700`. |
157
176
 
158
- When a config file exists, each color also shows the tokens that already have that value (`토큰: --color-brand`), or `토큰 없음` when there is none. The JSON output has the same data plus a few example locations per color.
177
+ When a config file exists, each color also shows the tokens that already have that value (`token: --color-brand`), or `no token` when there is none. The JSON output has the same data plus a few example locations per color.
159
178
 
160
179
  The [`designsnitch-palette` skill](#agent-skills) uses this output to propose tokens, and writes them after you approve.
161
180
 
@@ -165,10 +184,21 @@ The [`designsnitch-palette` skill](#agent-skills) uses this output to propose to
165
184
  | --- | --- |
166
185
  | `tokens` | The CSS file that defines the tokens. Required. |
167
186
  | `components.path` | The directory that holds the design system components. Raw tags are allowed inside it. |
168
- | `components.replaces` | Raw tags and the components that replace them. Use an array when several components replace one tag. |
187
+ | `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). |
188
+ | `lang` | The language of the messages: `en` (default) or `ko`. |
169
189
 
170
190
  Without `components`, the component check is skipped. Use `--config <file>` to read a config file from another path.
171
191
 
192
+ A shared component often covers only some variants of a tag. An `Input` component may cover text fields but not `<input type="file">`. `when` lists the attribute values the component covers. `null` means the attribute is absent.
193
+
194
+ ```json
195
+ "input": { "component": "Input", "when": { "type": ["text", "email", null] } }
196
+ ```
197
+
198
+ - `<input type="file">` is not reported, because the component does not cover it.
199
+ - `<input type="text">` and `<input>` are reported as errors that can be replaced.
200
+ - `<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.
201
+
172
202
  This is what is read from the token CSS.
173
203
 
174
204
  | Variable | Used for | When missing |
@@ -193,21 +223,27 @@ Both of these shapes work.
193
223
  }
194
224
  ```
195
225
 
226
+ ## Language
227
+
228
+ 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.
229
+
230
+ The ESLint plugin reads the same `lang` from its settings. Rule names, the layout of the output and the JSON field names are the same in both languages.
231
+
196
232
  ## Output
197
233
 
198
234
  ```
199
- 디자인 시스템: 색 토큰 2개, 컴포넌트 2개
235
+ Design system: 2 color tokens, 2 components
200
236
 
201
237
  src/PayButton.tsx
202
- 5:6 오류 <button> 대신 디자인 시스템 컴포넌트를 사용하세요: Button (./components/ui) (use-ds-component)
203
- 7:55 오류 bg-[#3B82F6]의 색은 토큰 --color-primary-500의 값입니다. 대신 사용: bg-primary-500 (color-use-token)
204
- 8:26 경고 bg-[#3B82F5]의 색은 토큰에 없습니다. (color-unknown)
238
+ 5:6 error Use a design system component instead of <button>: Button (./components/ui) (use-ds-component)
239
+ 7:55 error bg-[#3B82F6] has the same color as --color-primary-500. Use instead: bg-primary-500 (color-use-token)
240
+ 8:26 warning The color of bg-[#3B82F5] is not in the tokens. (color-unknown)
205
241
 
206
- 오류 2개, 경고 1개 (파일 3개 검사)
207
- 바로 바꿀 수 있는 것 2건, 사람이 정해야 하는 것 1건
242
+ 2 errors, 1 warning (3 files checked)
243
+ 2 can be replaced right away, 1 needs a person's decision
208
244
  ```
209
245
 
210
- 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 `주의:` (notice) explains why. `오류` means error and `경고` means warning. The last line says how many violations can be replaced right away (`바로 바꿀 수 있는 것`) and how many need a person's decision (`사람이 정해야 하는 것`).
246
+ 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 and how many need a person's decision.
211
247
 
212
248
  `--format json` prints the same result as structured data.
213
249
 
@@ -216,9 +252,9 @@ The first line shows how many tokens and components were read from the config. A
216
252
  "designSystem": { "colorTokens": 2, "components": 2, "replacedTags": 2 },
217
253
  "problems": [],
218
254
  "next": [
219
- "action이 replace인 2건은 found를 candidates의 값으로 바꾸세요.",
220
- "action이 ask인 1건은 바꾸지 말고 사용자에게 물으세요. ...",
221
- "고친 뒤 같은 명령을 다시 실행하세요."
255
+ "action \"replace\" (2): replace found with the value in candidates.",
256
+ "action \"ask\" (1): do not change these. Ask the user, and include how often and for what each color is used, which `designsnitch colors` shows.",
257
+ "After fixing, run the same command again."
222
258
  ],
223
259
  "summary": { "files": 3, "errors": 2, "warnings": 1 },
224
260
  "violations": [
@@ -230,7 +266,7 @@ The first line shows how many tokens and components were read from the config. A
230
266
  "endColumn": 67,
231
267
  "rule": "color-use-token",
232
268
  "severity": "error",
233
- "message": "bg-[#3B82F6]의 색은 토큰 --color-primary-500의 값입니다. 대신 사용: bg-primary-500",
269
+ "message": "bg-[#3B82F6] has the same color as --color-primary-500. Use instead: bg-primary-500",
234
270
  "found": "bg-[#3B82F6]",
235
271
  "candidates": ["bg-primary-500"],
236
272
  "action": "replace"
@@ -245,7 +281,7 @@ The first line shows how many tokens and components were read from the config. A
245
281
  | `problems` | Config problems that make the result unreliable. Empty when everything is fine. |
246
282
  | `violations[].found` | The offending piece of code |
247
283
  | `violations[].candidates` | The classes or components to use instead. Empty when there are none. |
248
- | `violations[].action` | How to handle the violation. `replace`: an error with exactly one candidate, so replace `found` with it. `ask`: a person has to decide (several candidates, or a color with no token). `repair`: the file could not be parsed. |
284
+ | `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. |
249
285
  | `next` | What an agent should do with this result, in order |
250
286
 
251
287
  | Exit code | Meaning |
@@ -276,7 +312,7 @@ In a CSS file, put this comment on the line before the declaration.
276
312
 
277
313
  ## Agent skills
278
314
 
279
- `npx designsnitch install` copies the skills into `.claude/skills`. Run it again after upgrading the package to get the current versions. The skills are in the `skills/` directory of the package if you want to copy them somewhere else.
315
+ `npx designsnitch install` copies the skills into `.claude/skills` for Claude Code, into `.agents/skills` for Codex and Gemini CLI with `--agent codex` or `--agent gemini`, and into `.grok/skills` for Grok Build with `--agent grok`. Run it again after upgrading the package to get the current versions. The skills are in the `skills/` directory of the package if you want to copy them somewhere else.
280
316
 
281
317
  Each skill does one job.
282
318
 
@@ -349,13 +385,21 @@ A skill is advice that an agent may not follow. A hook is run by the agent's run
349
385
  }
350
386
  ```
351
387
 
352
- `designsnitch hook` checks only the files the agent just changed.
388
+ `designsnitch hook` checks only the files the agent just changed, and blocks only errors the change added.
389
+
390
+ - 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.
391
+ - After an edit, if the file has new errors, the agent receives them along with what to do next.
392
+ - 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.
393
+ - Warnings never block, and files the agent did not touch are left alone.
394
+ - Outside a git repository, or before the first commit, every error in the changed files counts.
395
+
396
+ 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.
397
+
398
+ 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.
353
399
 
354
- - After an edit, if the file has errors, the agent receives them along with what to do next.
355
- - When the agent is about to finish, it is stopped if 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.
356
- - Warnings never block, and violations in files the agent did not touch are left alone.
400
+ For Grok Build, `npx designsnitch install --agent grok` writes `.grok/hooks/designsnitch.json` with `PostToolUse` and `Stop`, following the official xAI documentation. It has not been tested with Grok Build, and one point is uncertain: the documentation calls `PreToolUse` the only blocking event and does not say what exit code 2 does after a tool or at the end of a turn. Grok Build may therefore report the errors without stopping the agent. Grok Build also reads Claude Code's `.claude/settings.json`, so with `--agent all` the hook can run twice in Grok Build. That is harmless.
357
401
 
358
- The command reads an optional JSON object from stdin (`tool_input.file_path`, `hook_event_name`, `stop_hook_active`), exits with 2 and writes to stderr when it blocks, and falls back to the files git reports as changed when no file is given. Other agents with command hooks that follow these conventions can use it too. The `designsnitch-hooks` skill sets this up.
402
+ The command reads an optional JSON object from stdin (`tool_input.file_path`, `hook_event_name`, `stop_hook_active`, or the same fields in camelCase as Grok Build sends them), exits with 2 and writes to stderr when it blocks, and falls back to the files git reports as changed when no file is given. Other agents with command hooks that follow these conventions can use it too. The `designsnitch-hooks` skill sets this up.
359
403
 
360
404
  ### Tailwind's default palette
361
405
 
@@ -372,7 +416,7 @@ designsnitch does not flag default palette classes such as `bg-blue-500`. If the
372
416
 
373
417
  - **Where it looks in JS and TS:** string literals and template literals. This covers `className` and the arguments of `cn()`, `clsx()` and `cva()`. Comments are ignored.
374
418
  - **Where it looks in CSS:** hex colors in declaration values, in `.css` files including CSS Modules. Declarations that define a variable (`--name: ...`) are skipped, since that is where tokens are defined. Only colors are checked in CSS for now.
375
- - **Themes:** when a token has different values per theme, all of them count as that token's value.
419
+ - **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`.
376
420
  - **Fixes:** designsnitch reports candidates and never rewrites code by itself, even when there is only one candidate.
377
421
 
378
422
  ### Not supported yet
@@ -386,7 +430,7 @@ designsnitch does not flag default palette classes such as `bg-blue-500`. If the
386
430
  - Spacing, font size and radius. They were left out of this version on purpose.
387
431
  - Classes inside `@apply`
388
432
  - Comparing a hand-made component's styles with the design system component
389
- - Installing the skills and the hook for agents other than Claude Code
433
+ - Installing the hook for agents other than Claude Code, Codex, Gemini CLI and Grok Build
390
434
 
391
435
  Comparing a screen with a design file such as Figma is out of scope. The standard is the design system alone.
392
436
 
@@ -1,21 +1,55 @@
1
1
  #!/usr/bin/env node
2
- import { run } from "../src/cli.js";
3
-
4
- // 출력을 받는 쪽이 먼저 닫으면(예: `designsnitch check | head`) 조용히 끝낸다.
5
- process.stdout.on("error", (error) => {
6
- if (error.code === "EPIPE") process.exit();
7
- throw error;
8
- });
9
-
10
- const argv = process.argv.slice(2);
11
-
12
- process.exitCode = await run(argv, {
13
- cwd: process.cwd(),
14
- // hook 명령은 에이전트가 표준 입력으로 주는 JSON 을 읽는다.
15
- stdin: argv[0] === "hook" && !process.stdin.isTTY ? await readStdin() : undefined,
16
- stdout: process.stdout,
17
- stderr: process.stderr,
18
- });
2
+
3
+ const MINIMUM_NODE_MAJOR = 22;
4
+
5
+ /** @param {string} version process.versions.node 와 같은 형식의 버전 */
6
+ export function isSupportedNodeVersion(version) {
7
+ return Number(version.split(".", 1)[0]) >= MINIMUM_NODE_MAJOR;
8
+ }
9
+
10
+ const version = process.versions.node;
11
+ const supported = isSupportedNodeVersion(version);
12
+ if (await isEntrypoint()) await main();
13
+
14
+ async function isEntrypoint() {
15
+ const entry = process.argv[1];
16
+ if (!entry) return false;
17
+ // 설치된 실행 파일은 심볼릭 링크일 수 있다.
18
+ const { existsSync, realpathSync } = await import("node:fs");
19
+ return existsSync(entry) && realpathSync(entry) === realpathSync(new URL(import.meta.url));
20
+ }
21
+
22
+ async function main() {
23
+ const argv = process.argv.slice(2);
24
+ if (!supported) {
25
+ let flagLang;
26
+ for (const [index, arg] of argv.entries()) {
27
+ if (arg === "--") break;
28
+ if (arg === "--lang") flagLang = argv[index + 1];
29
+ else if (arg.startsWith("--lang=")) flagLang = arg.slice("--lang=".length);
30
+ }
31
+ const { messages, resolveLang } = await import("../src/messages.js");
32
+ const message = messages(resolveLang(flagLang)).nodeVersionUnsupported;
33
+ process.stderr.write(`${message({ minimum: MINIMUM_NODE_MAJOR, version })}\n`);
34
+ process.exitCode = 2;
35
+ return;
36
+ }
37
+
38
+ // 출력을 받는 쪽이 먼저 닫으면(예: `designsnitch check | head`) 조용히 끝낸다.
39
+ process.stdout.on("error", (error) => {
40
+ if (error.code === "EPIPE") process.exit();
41
+ throw error;
42
+ });
43
+
44
+ const { run } = await import("../src/cli.js");
45
+ process.exitCode = await run(argv, {
46
+ cwd: process.cwd(),
47
+ // hook 명령은 에이전트가 표준 입력으로 주는 JSON 을 읽는다.
48
+ stdin: argv[0] === "hook" && !process.stdin.isTTY ? await readStdin() : undefined,
49
+ stdout: process.stdout,
50
+ stderr: process.stderr,
51
+ });
52
+ }
19
53
 
20
54
  // 입력이 끝나지 않는 환경에서도 멈추지 않도록 잠깐만 기다린다.
21
55
  function readStdin(timeoutMs = 2000) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "designsnitch",
3
- "version": "0.2.0",
4
- "description": "AI가 만든 UI 코드에서 디자인 시스템을 벗어난 곳을 찾는 CLI와 ESLint 플러그인",
3
+ "version": "0.3.0",
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",
7
7
  "exports": "./src/index.js",
@@ -16,14 +16,14 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@typescript-eslint/parser": "^8.73.0",
19
- "eslint": ">=9",
19
+ "eslint": "^9 || ^10",
20
20
  "postcss": "^8.4.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "vitest": "^3.0.0"
24
24
  },
25
25
  "bin": {
26
- "designsnitch": "./bin/designsnitch.js"
26
+ "designsnitch": "bin/designsnitch.js"
27
27
  },
28
28
  "engines": {
29
29
  "node": ">=22"
@@ -27,9 +27,9 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
27
27
  "designSystem": { "colorTokens": 175, "components": 4, "replacedTags": 2 },
28
28
  "problems": [],
29
29
  "next": [
30
- "action이 replace인 1건은 found를 candidates의 값으로 바꾸세요.",
31
- "action이 ask인 1건은 바꾸지 말고 사용자에게 물으세요. ...",
32
- "고친 뒤 같은 명령을 다시 실행하세요."
30
+ "action \"replace\" (1): replace found with the value in candidates.",
31
+ "action \"ask\" (1): do not change these. Ask the user, and include how often and for what each color is used, which `designsnitch colors` shows.",
32
+ "After fixing, run the same command again."
33
33
  ],
34
34
  "summary": { "files": 1, "errors": 2, "warnings": 0 },
35
35
  "violations": [
@@ -41,7 +41,7 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
41
41
  "endColumn": 40,
42
42
  "rule": "color-use-token",
43
43
  "severity": "error",
44
- "message": "bg-[#3B82F6]의 색은 토큰 --color-primary-500의 값입니다. 대신 사용: bg-primary-500",
44
+ "message": "bg-[#3B82F6] has the same color as --color-primary-500. Use instead: bg-primary-500",
45
45
  "found": "bg-[#3B82F6]",
46
46
  "candidates": ["bg-primary-500"],
47
47
  "action": "replace"
@@ -50,7 +50,7 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
50
50
  }
51
51
  ```
52
52
 
53
- - `next` lists what to do, in order. It is written in Korean, like `message`. The fields below carry the same information, so you do not need to parse either.
53
+ - `next` lists what to do, in order. `next` and `message` are sentences, in English or in Korean depending on the project's `lang` setting. The fields below carry the same information, so you never need to parse them.
54
54
  - `action` says how to handle each violation. Section 3 covers each value.
55
55
  - `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 `.css` files.
56
56
  - `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.
@@ -67,8 +67,8 @@ The exit code is 0 (no errors), 1 (errors found), or 2 (could not run). On 2, re
67
67
 
68
68
  | `action` | What it means | What to do |
69
69
  | --- | --- | --- |
70
- | `replace` | An error with exactly one candidate. | Replace `found` with the candidate. |
71
- | `ask` | A person has to decide: an error with several candidates, or a color that has no token. | Do not change it. Ask the user as described in section 4. |
70
+ | `replace` | An error whose only candidate keeps the screen and the behavior the same. | Replace `found` with the candidate. |
71
+ | `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. |
72
72
  | `repair` | The file could not be parsed. | Fix the syntax error, then check again. |
73
73
 
74
74
  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.