@su-record/vibe 3.2.6 → 3.2.8

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.
Files changed (160) hide show
  1. package/CLAUDE.md +5 -2
  2. package/README.en.md +1 -1
  3. package/README.md +1 -1
  4. package/agents/build-error-resolver.md +1 -1
  5. package/agents/code-reviewer.md +1 -1
  6. package/agents/e2e-tester.md +1 -1
  7. package/agents/event/event-ops.md +1 -1
  8. package/agents/event/event-planner.md +1 -1
  9. package/agents/implementer.md +1 -1
  10. package/agents/security-reviewer.md +1 -1
  11. package/agents/tester.md +1 -1
  12. package/agents/ui/design-reviewer.md +1 -1
  13. package/agents/ui/design-system-gen.md +1 -1
  14. package/dist/cli/commands/info.d.ts +9 -0
  15. package/dist/cli/commands/info.d.ts.map +1 -1
  16. package/dist/cli/commands/info.js +32 -0
  17. package/dist/cli/commands/info.js.map +1 -1
  18. package/dist/cli/commands/info.test.js +34 -1
  19. package/dist/cli/commands/info.test.js.map +1 -1
  20. package/dist/cli/commands/upgrade.d.ts +18 -0
  21. package/dist/cli/commands/upgrade.d.ts.map +1 -1
  22. package/dist/cli/commands/upgrade.js +60 -2
  23. package/dist/cli/commands/upgrade.js.map +1 -1
  24. package/dist/cli/commands/upgrade.test.js +51 -1
  25. package/dist/cli/commands/upgrade.test.js.map +1 -1
  26. package/dist/cli/generate-release-notes.js +8 -6
  27. package/dist/cli/generate-release-notes.js.map +1 -1
  28. package/dist/cli/postinstall/claude-agents.d.ts.map +1 -1
  29. package/dist/cli/postinstall/claude-agents.js +3 -1
  30. package/dist/cli/postinstall/claude-agents.js.map +1 -1
  31. package/dist/cli/postinstall/constants.d.ts.map +1 -1
  32. package/dist/cli/postinstall/constants.js +27 -21
  33. package/dist/cli/postinstall/constants.js.map +1 -1
  34. package/dist/tests/curated-release-notes.test.js +55 -1
  35. package/dist/tests/curated-release-notes.test.js.map +1 -1
  36. package/dist/tools/release/releaseNotes.d.ts +22 -0
  37. package/dist/tools/release/releaseNotes.d.ts.map +1 -1
  38. package/dist/tools/release/releaseNotes.js +45 -0
  39. package/dist/tools/release/releaseNotes.js.map +1 -1
  40. package/hooks/scripts/__tests__/.vibe/command-log.txt +3 -3
  41. package/hooks/scripts/__tests__/code-check-detectors.test.js +58 -0
  42. package/hooks/scripts/code-check.js +7 -0
  43. package/package.json +2 -2
  44. package/skills/vibe/SKILL.md +27 -86
  45. package/skills/vibe/references/routing-examples.md +85 -0
  46. package/skills/vibe.agents-md/SKILL.md +12 -10
  47. package/skills/vibe.analyze/SKILL.md +22 -211
  48. package/skills/vibe.analyze/references/mode1-feature.md +81 -0
  49. package/skills/vibe.analyze/references/mode2-document.md +50 -0
  50. package/skills/vibe.analyze/references/mode3-website.md +47 -0
  51. package/skills/vibe.analyze/references/mode4-quality.md +35 -0
  52. package/skills/vibe.analyze/references/output-templates.md +2 -2
  53. package/skills/vibe.brand-assets/SKILL.md +2 -2
  54. package/skills/vibe.brand-assets/references/mobile-assets.md +6 -0
  55. package/skills/vibe.capability-loop/SKILL.md +14 -80
  56. package/skills/vibe.capability-loop/references/escalate.md +86 -0
  57. package/skills/vibe.chub-usage/SKILL.md +3 -132
  58. package/skills/vibe.clone/SKILL.md +43 -358
  59. package/skills/vibe.clone/references/phase-commands.md +118 -0
  60. package/skills/vibe.clone/references/setup-and-layout.md +34 -0
  61. package/skills/vibe.clone/references/verification-loops.md +64 -0
  62. package/skills/vibe.commit-push-pr/SKILL.md +10 -4
  63. package/skills/vibe.context7-usage/SKILL.md +3 -99
  64. package/skills/vibe.continue/SKILL.md +17 -7
  65. package/skills/{vibe.handoff → vibe.continue}/agents/context-summarizer.md +1 -1
  66. package/skills/{vibe.handoff → vibe.continue}/agents/document-writer.md +1 -1
  67. package/skills/{vibe.handoff → vibe.continue}/agents/state-collector.md +1 -1
  68. package/skills/{vibe.handoff → vibe.continue}/agents/verifier.md +1 -1
  69. package/skills/{vibe.handoff/rubrics/completeness.md → vibe.continue/references/handoff-completeness.md} +1 -1
  70. package/skills/{vibe.handoff/templates → vibe.continue/references}/handoff.md +37 -2
  71. package/skills/vibe.contract/SKILL.md +4 -27
  72. package/skills/vibe.create-prd/SKILL.md +8 -1
  73. package/skills/vibe.design/SKILL.md +18 -5
  74. package/skills/vibe.design/references/design-context.md +184 -0
  75. package/skills/vibe.design-refine/SKILL.md +7 -0
  76. package/skills/vibe.design-review/SKILL.md +7 -0
  77. package/skills/vibe.design-teach/SKILL.md +2 -175
  78. package/skills/vibe.devlog/SKILL.md +14 -11
  79. package/skills/vibe.devlog/references/auto-push.md +10 -0
  80. package/skills/vibe.docs/SKILL.md +27 -198
  81. package/skills/vibe.docs/references/agent.md +55 -0
  82. package/skills/vibe.docs/references/arch.md +28 -0
  83. package/skills/vibe.docs/references/codemaps.md +17 -0
  84. package/skills/vibe.docs/references/diagram.md +24 -0
  85. package/skills/vibe.docs/references/guide.md +23 -0
  86. package/skills/vibe.docs/references/readme.md +45 -0
  87. package/skills/vibe.docs/references/release.md +31 -0
  88. package/skills/vibe.documentation-provider/SKILL.md +22 -0
  89. package/skills/vibe.documentation-provider/references/chub.md +141 -0
  90. package/skills/vibe.documentation-provider/references/context7.md +107 -0
  91. package/skills/vibe.educational-content/SKILL.md +7 -0
  92. package/skills/vibe.event/SKILL.md +47 -146
  93. package/skills/vibe.event/references/comms.md +173 -0
  94. package/skills/vibe.event/references/operations.md +208 -0
  95. package/skills/vibe.event/references/orchestration-legacy.md +97 -0
  96. package/skills/vibe.event/references/planning.md +145 -0
  97. package/skills/vibe.event-comms/SKILL.md +3 -165
  98. package/skills/vibe.event-ops/SKILL.md +3 -200
  99. package/skills/vibe.event-planning/SKILL.md +3 -137
  100. package/skills/vibe.figma/SKILL.md +26 -692
  101. package/skills/vibe.figma/references/branch1-read-convention.md +82 -0
  102. package/skills/vibe.figma/references/branch2-read-standalone.md +69 -0
  103. package/skills/vibe.figma/references/branch3-write.md +122 -0
  104. package/skills/vibe.figma/references/core-implementation.md +453 -0
  105. package/skills/vibe.git-worktree/SKILL.md +2 -6
  106. package/skills/vibe.git-worktree/references/troubleshooting.md +9 -0
  107. package/skills/vibe.handoff/SKILL.md +2 -103
  108. package/skills/vibe.harness/SKILL.md +17 -12
  109. package/skills/vibe.image/SKILL.md +8 -1
  110. package/skills/vibe.llm/SKILL.md +8 -1
  111. package/skills/vibe.loop/SKILL.md +9 -11
  112. package/skills/vibe.loop/references/install-adapters.md +10 -0
  113. package/skills/vibe.presentation/SKILL.md +7 -0
  114. package/skills/vibe.prioritization/SKILL.md +7 -0
  115. package/skills/vibe.priority-todos/SKILL.md +2 -57
  116. package/skills/vibe.react-best-practices/SKILL.md +1 -1
  117. package/skills/vibe.reason/SKILL.md +9 -2
  118. package/skills/vibe.regress/SKILL.md +6 -28
  119. package/skills/vibe.regress/templates/{test-jest.md → test-template.md} +1 -0
  120. package/skills/vibe.review/SKILL.md +62 -52
  121. package/skills/vibe.review/references/priority-todos.md +66 -0
  122. package/skills/vibe.review/references/ui-ux-review.md +39 -0
  123. package/skills/vibe.run/SKILL.md +63 -660
  124. package/skills/vibe.run/references/arch-guard.md +178 -0
  125. package/skills/vibe.run/references/e2e-and-autofix.md +40 -0
  126. package/skills/vibe.run/references/exec-plan.md +145 -0
  127. package/skills/vibe.run/references/guidelines-and-tools.md +84 -0
  128. package/skills/vibe.run/references/parallel-agents.md +44 -60
  129. package/skills/vibe.run/references/process-steps.md +179 -0
  130. package/skills/vibe.run/references/restraint.md +66 -0
  131. package/skills/vibe.run/references/ultrawork-mode.md +1 -1
  132. package/skills/vibe.scaffold/SKILL.md +9 -13
  133. package/skills/vibe.scaffold/references/clean-architecture.md +17 -0
  134. package/skills/vibe.spec/SKILL.md +13 -9
  135. package/skills/vibe.spec/references/legacy-artifacts.md +6 -0
  136. package/skills/vibe.test/SKILL.md +93 -70
  137. package/skills/vibe.test/references/report-template.md +101 -0
  138. package/skills/vibe.tool-fallback/SKILL.md +10 -32
  139. package/skills/vibe.tool-fallback/references/external-llm.md +10 -0
  140. package/skills/vibe.tool-fallback/references/file-lookup.md +9 -0
  141. package/skills/vibe.tool-fallback/references/web-search.md +11 -0
  142. package/skills/vibe.trace/SKILL.md +2 -264
  143. package/skills/vibe.ui-ux-pro-max/SKILL.md +1 -3
  144. package/skills/vibe.ui-ux-pro-max/references/charts-and-data.md +7 -0
  145. package/skills/vibe.user-personas/SKILL.md +8 -1
  146. package/skills/vibe.verify/SKILL.md +30 -4
  147. package/skills/vibe.verify/references/trace-mode.md +271 -0
  148. package/vibe/rules/principles/dual-harness-doctrine.md +10 -9
  149. package/skills/vibe.regress/templates/test-vitest.md +0 -30
  150. /package/skills/{vibe.design-teach/rubrics → vibe.design/references}/brand-personality.md +0 -0
  151. /package/skills/{vibe.design-teach → vibe.design}/templates/design-context.json +0 -0
  152. /package/skills/{vibe.context7-usage/rubrics/when-to-use.md → vibe.documentation-provider/references/context7-when-to-use.md} +0 -0
  153. /package/skills/{vibe.event-ops/rubrics → vibe.event/references}/contingency.md +0 -0
  154. /package/skills/{vibe.event-ops/templates/d-day-checklist.md → vibe.event/references/d-day-checklist-template.md} +0 -0
  155. /package/skills/{vibe.event-comms/templates/email-invite.md → vibe.event/references/email-invite-template.md} +0 -0
  156. /package/skills/{vibe.event-planning/templates/event-plan.md → vibe.event/references/event-plan-template.md} +0 -0
  157. /package/skills/{vibe.event-comms/templates/sns-post.md → vibe.event/references/sns-post-template.md} +0 -0
  158. /package/skills/{vibe.event-planning/rubrics → vibe.event/references}/timeline.md +0 -0
  159. /package/skills/{vibe.priority-todos/templates/todo-board.md → vibe.review/references/todo-board-template.md} +0 -0
  160. /package/skills/{vibe.priority-todos/rubrics/prioritization.md → vibe.review/references/todo-prioritization.md} +0 -0
@@ -1,12 +1,19 @@
1
1
  ---
2
2
  name: vibe.run
3
- description: Execute implementation from SPEC
3
+ description: 승인된 SPEC이 있고 구현을 시작할 때 — `.vibe/specs/<feature>.md`를 읽어 코드와 검증 산출물로 전개한다.
4
4
  argument-hint: '"feature name" or --phase N'
5
5
  user-invocable: true
6
6
  ---
7
7
 
8
8
  # /vibe.run
9
9
 
10
+ ## 완료 기준
11
+
12
+ - [ ] 구현 요구사항이 승인된 SPEC의 REQ ID로 추적된다.
13
+ - [ ] 변경 범위에 존재하는 build, lint, typecheck, test gate가 통과한다.
14
+ - [ ] run ledger에 검증 결과와 exit code가 기록되어 있다.
15
+ - [ ] 미완료 요구사항이 있으면 TODO와 사유가 기록되어 있다.
16
+
10
17
  Execute **Scenario-Driven Implementation** with automatic quality verification.
11
18
 
12
19
  > **Core Principle**: Scenarios are both the implementation unit and verification criteria. All scenarios passing = Quality guaranteed.
@@ -24,7 +31,7 @@ Execute **Scenario-Driven Implementation** with automatic quality verification.
24
31
 
25
32
  ---
26
33
 
27
- > **Timer**: Call `getCurrentTime` tool at the START. Record the result as `{start_time}`.
34
+ > **Timer**: Query the system clock at START and record the result as `{start_time}`.
28
35
 
29
36
  > **Step Counter Reset (MANDATORY at START)**: Run this Bash command once at the very start:
30
37
  >
@@ -34,10 +41,12 @@ Execute **Scenario-Driven Implementation** with automatic quality verification.
34
41
 
35
42
  ## File Reading Policy (Mandatory)
36
43
 
37
- - **SPEC/Feature 파일**: 반드시 `Read` 도구로 전체 파일을 읽을 (Grep 금지)
38
- - **소스코드 파일**: 구현/수정 대상 파일은 반드시 `Read` 도구로 전체 읽은 후 작업할 것
39
- - **Grep 사용 제한**: 파일 위치 탐색(어떤 파일에 있는지 찾기)에만 사용. 파일 내용 파악에는 반드시 Read 사용
40
- - **에이전트 spawn 시**: 프롬프트에 "대상 파일을 Read 도구로 전체 읽은 후 구현하라"를 반드시 포함할 것
44
+ > 규칙은 **전체 읽기**이지 특정 도구 이름이 아니다. 하네스가 제공하는 파일 읽기 수단을 쓴다 — Claude Code 는 `Read` 도구, Codex 셸(`cat`/`sed -n`) 등. 도구 이름이 없다고 규칙을 건너뛰지 않는다.
45
+
46
+ - **SPEC/Feature 파일**: 전체를 읽는다 (검색 결과 일부만 보고 판단 금지)
47
+ - **소스코드 파일**: 구현/수정 대상 파일은 전체를 읽은 후 작업한다
48
+ - **검색 도구 사용 제한**: grep/ripgrep 류는 **파일 위치 탐색**(어떤 파일에 있는지)에만 쓴다. 내용 파악은 전체 읽기로 한다
49
+ - **에이전트 실행 시**: 프롬프트에 "대상 파일을 전체 읽은 후 구현하라"를 포함한다
41
50
 
42
51
  ## **Scenario-Driven Development (SDD)**
43
52
 
@@ -105,41 +114,7 @@ After implementing each scenario, **automatic verification**:
105
114
  | Code quality | Complexity, style, security | Static analysis |
106
115
  | **UI behavior** | **실제 브라우저에서 동작 확인** | **E2E Closed Loop** |
107
116
 
108
- ### E2E Closed Loop (UI Scenarios)
109
-
110
- **UI 시나리오가 포함된 Feature일 때 자동 활성화.**
111
-
112
- Browser Tool Priority:
113
-
114
- | Priority | Tool | 용도 |
115
- |----------|------|------|
116
- | 1st | Agent Browser (접근성 트리) | AI 직접 조작, 최소 토큰 |
117
- | 2nd | Playwright Test Runner | 테스트 코드 실행, pass/fail 반환 |
118
- | 3rd | Playwright MCP (DOM) | 최후 수단, 토큰 비효율 |
119
-
120
- **활성화 조건:** Feature 파일에 UI 관련 시나리오 존재 + `.vibe/e2e/config.json`의 `closedLoop.enabled: true` (기본값) + dev server가 실행 중
121
-
122
- ### Auto-Fix on Failure
123
-
124
- ```
125
- Scenario verification failed
126
- ↓ [Collect evidence]
127
- ↓ [Root cause analysis]
128
- ↓ [Read target file FULLY]
129
- ↓ [Implement fix]
130
- ↓ [Re-verify failed scenario only]
131
- Repeat until pass (stuck 감지로 종료)
132
- ```
133
-
134
- **Termination conditions (loop-contract JUDGE):**
135
- - PASS → 다음 scenario
136
- - stuck (같은 failure가 이전 라운드와 동일, `loop-ledger.js check-stuck`) → automationLevel confirm: 사용자 질문; autonomous: TODO + next scenario
137
-
138
- **Stakes 프로파일 (SSOT: `vibe/rules/loop-contract.md` Stakes 표):**
139
- - `demo`/`prototype` → max_iterations 1, 리뷰 1패스, **검증 스크립트 신규 생성 금지** — 검증은 기존 테스트 러너·브라우저 게이트만 사용한다. 새 verify_*.py / 검증 전용 스크립트 파일을 만들지 않는다.
140
- - JUDGE 검증 산출물 절제 (모든 stakes): 이번 feature 신규 검증 코드 바이트 합이 신규 구현 코드 바이트 합을 초과하면 (`git diff --numstat` 기준) P2 경고를 run-ledger 에 기록한다. advisory — 게이트 통과 여부는 불변.
141
-
142
- ---
117
+ > **E2E Closed Loop (UI 시나리오) 와 실패 시 Auto-Fix 절차**: `references/e2e-and-autofix.md`
143
118
 
144
119
  ## **ULTRAWORK Mode** (ulw) — deprecated alias
145
120
 
@@ -154,11 +129,18 @@ Scenario verification failed
154
129
 
155
130
  ---
156
131
 
132
+ ## Stakes 프로파일 (실행 강도 조절)
133
+
134
+ **Stakes 프로파일 (SSOT: `vibe/rules/loop-contract.md` Stakes 표):**
135
+ - `demo`/`prototype` → max_iterations 1, 리뷰 1패스, **검증 스크립트 신규 생성 금지** — 검증은 기존 테스트 러너·브라우저 게이트만 사용한다. 새 verify_*.py / 검증 전용 스크립트 파일을 만들지 않는다.
136
+ - JUDGE 검증 산출물 절제 (모든 stakes): 이번 feature 신규 검증 코드 바이트 합이 신규 구현 코드 바이트 합을 초과하면 (`git diff --numstat` 기준) P2 경고를 run-ledger 에 기록한다. advisory — 게이트 통과 여부는 불변.
137
+ ---
138
+
157
139
  ## Scope & Ledger Rules
158
140
 
159
141
  ### Run Ledger Tracking
160
142
 
161
- Every `/vibe.run` invocation is automatically recorded in `.vibe/metrics/run-ledger.json` (fields: `runStarted`, `runFeature`, `verifyPassed`, `verifyAt`). The `verifyPassed` flag is reset to `false` at run start and only set to `true` when `/vibe.verify` completes and records its result via `verify-ledger.js`. If the session ends without running `/vibe.verify`, the Stop hook will emit a warning to stderr; if `verifyGate.mode` is set to `"block"` in `.vibe/config.json`, the first Stop event will be blocked (once per run, loop-prevention flag prevents repeated blocking). The auto-commit hook also skips the commit unless `verifyPassed === true` and `verifyAt > runStarted`.
143
+ Every `/vibe.run` invocation must explicitly initialize `.vibe/metrics/run-ledger.json` (fields: `runStarted`, `runFeature`, `verifyPassed`, `verifyAt`) and reset `verifyPassed` to `false`. Before completion, invoke `/vibe.verify`; its `verify-ledger.js` step must record `verifyPassed`, `verifyAt`, and command evidence, then read the ledger back and enforce `verifyPassed === true && verifyAt > runStarted`. Stop/auto-commit hooks may warn or short-circuit this sequence when available, but they are acceleration only and never the correctness basis.
162
144
 
163
145
  ### Interactive Checkpoints
164
146
 
@@ -188,256 +170,31 @@ Default: a
188
170
 
189
171
  ## Process
190
172
 
191
- ### 1. Load SPEC + Feature
192
-
193
- **Search order:**
194
- ```
195
- Step 1: Check split structure (folder)
196
- .vibe/specs/{feature-name}/ → Folder: _index.md + phase files
197
- .vibe/features/{feature-name}/ → Folder: _index.feature + phase files
198
-
199
- Step 2: If no folder, check single file
200
- .vibe/specs/{feature-name}.md
201
- .vibe/features/{feature-name}.feature
202
-
203
- Step 3: If neither → Error: "Run /vibe.spec first"
204
- ```
205
-
206
- **Split structure:** Load `_index.md` first, then phase files in order. Execute phases sequentially (or per `--phase` flag).
207
-
208
- ### 1-0. Compile + validate execution packet (MANDATORY)
209
-
210
- For a monolithic SPEC, compile it after resolving the canonical path. For a split SPEC, do not compile `_index.md`; defer this step until each active phase file is loaded in Phase Isolation Step B. Compile with `writeExecutionPacket`, then immediately verify the saved artifact with `validateExecutionPacket`.
211
-
212
- ```bash
213
- node -e "import('file://{{VIBE_PATH}}/dist/tools/index.js').then(t => {
214
- const projectPath=process.cwd(), specPath='.vibe/specs/{feature-name}.md';
215
- const profile='{codex-or-claude-code}';
216
- const written=t.writeExecutionPacket({projectPath,specPath,profile});
217
- if(!written.ok){console.error(JSON.stringify(written.errors));process.exit(1)}
218
- const checked=t.validateExecutionPacket({projectPath,specPath,packetPath:written.packetPath});
219
- if(!checked.valid){console.error(checked.code);process.exit(1)}
220
- console.log(written.packetPath);
221
- })"
222
- ```
223
-
224
- - Codex uses profile `codex`; Claude Code uses `claude-code`.
225
- - Split SPECs compile each active `phase-N-*.md` immediately before that phase runs; `_index.md` remains the overview ANCHOR and is not treated as a phase contract.
226
- - Use the packet only when validation returns `valid: true`.
227
- - `STALE_PACKET`, invalid packet, preservation-audit failure, or budget failure is blocking: recompile from the canonical SPEC and never silently fall back to an unvalidated packet.
228
- - The packet is a derived execution view. The canonical SPEC remains the ANCHOR and source of truth.
229
-
230
- ### 1-1. Phase Isolation Protocol (Large SPEC Guard, MANDATORY for 3+ phases)
231
-
232
- ```
233
- Step A: Read _index.md (overview only — phase list, REQ IDs)
234
- Step B: For each Phase N:
235
- 1. RE-READ Phase N SPEC section (every time, no memory)
236
- 2. Compile + validate Phase N execution packet using the phase file path
237
- 3. RE-READ Phase N Feature scenarios
238
- 4. Extract Phase N scope: files, scenarios, requirements
239
- 5. Implement Phase N scenarios
240
- 6. Verify Phase N
241
- 7. Write Phase Checkpoint → .vibe/checkpoints/
242
- 8. DISCARD Phase N details from working memory
243
- Step C: Next Phase
244
- ```
245
-
246
- **Phase Checkpoint** (`.vibe/checkpoints/{feature}-phase-{N}.md`):
247
-
248
- ```markdown
249
- # Checkpoint: {feature} Phase {N}
250
-
251
- ## Completed
252
- - Scenario 1: {name} ✅
253
-
254
- ## Files Changed
255
- - src/auth.service.ts (added login(), validateToken())
256
-
257
- ## State for Next Phase
258
- - Auth service exports: login(), logout(), validateToken()
259
-
260
- ## Remaining Phases
261
- - Phase {N+1}: {name} — {scenario count} scenarios
262
- ```
263
-
264
- **SPEC Re-anchoring (Before EVERY scenario):** Re-read the EXACT Given/When/Then from Feature file (not from memory). Compare: "Am I implementing what the SPEC says, or what I think it says?"
265
-
266
- **Scope Lock (Per Phase):**
267
-
268
- ```
269
- At Phase start, declare:
270
- MODIFY: [list of files this phase will touch]
271
- CREATE: [list of files this phase will create]
272
- DO NOT TOUCH: everything else
273
- ```
274
-
275
- **Context Pressure:**
276
-
277
- | Context Level | Action |
278
- |---------------|--------|
279
- | < 50% | Normal execution |
280
- | 50-85% | Save checkpoint, trim exploration results |
281
- | 85%+ | Save checkpoint → `/new` → resume from checkpoint |
282
- | Phase boundary | Always save checkpoint |
283
-
284
- ### 1-2. SPEC-First Gate
285
-
286
- > SPEC is the source of truth for code. To modify code, update the SPEC first.
287
-
288
- ```
289
- Discovery: "An API endpoint not in SPEC is needed"
290
- ├─ Already in SPEC? YES → Implement
291
- ├─ Not in SPEC but within scope? → Add to SPEC + Feature → Implement
292
- └─ Outside scope? → TODO in .vibe/todos/out-of-scope-{item}.md
293
- ```
294
-
295
- SPEC changes and code changes must be in the **same commit**.
296
-
297
- ### 2. Extract Scenario List
298
-
299
- ```markdown
300
- | # | Scenario | Status |
301
- |---|----------|--------|
302
- | 1 | Valid login success | ⬜ |
303
- | 2 | Invalid password error | ⬜ |
304
- ```
305
-
306
- ### 3. Scenario-by-Scenario Implementation
307
-
308
- > Read `references/parallel-agents.md` for full parallel exploration patterns, background agents, parallel subagent group selection, and model routing.
309
-
310
- **For each scenario:**
311
- 1. [Parallel exploration] Task(haiku) × 3 — related code, deps, patterns
312
- 2. [Implement] Write/edit the minimum required code
313
- 3. [Verify] Check Given/When/Then; E2E if UI scenario
314
- 4. [Auto-fix loop] On failure: collect evidence → root cause → fix → re-verify
315
-
316
- **UI/UX Design Intelligence (auto-triggered before Phase 1 if UI keywords in SPEC):**
317
- - Task(haiku, `design-system-gen`): framework-specific component guidelines + chart/viz library advice (viz advice conditional on chart keywords)
318
- - Load `.vibe/design-system/{project}/MASTER.md` if present
319
-
320
- ### 4. Brand Assets (New project only)
321
-
322
- > Read `references/brand-assets.md` when SPEC contains brand context and this is the first run.
323
-
324
- Trigger conditions: first run (no favicon.ico) + SPEC has brand context + Antigravity API key configured.
325
-
326
- ### 5. Race Code Review
327
-
328
- > Read `references/race-review.md` for full Race Review invocation, confidence matrix, and quality gate thresholds.
329
-
330
- After all scenarios: GPT + Antigravity review in parallel. ULTRAWORK enables this by default.
331
-
332
- ### 6. Quality Report (Auto-generated)
333
-
334
- ```
335
- ┌─────────────────────────────────────────────────────────────────┐
336
- │ QUALITY REPORT: {feature} │
337
- ├─────────────────────────────────────────────────────────────────┤
338
- │ Scenarios: N/N passed │
339
- │ Quality score: 94/100 │
340
- │ Build: ✅ | Tests: ✅ | Types: ✅ | Race review: ✅ │
341
- │ Started: {start_time} Completed: {getCurrentTime} │
342
- └─────────────────────────────────────────────────────────────────┘
343
- ```
344
-
345
- ### 7. Update Feature File
346
-
347
- Auto-update scenario status with `Last verified` timestamp and quality score.
348
-
349
- ### 8. Coverage Verification Loop (RTM)
350
-
351
- > 루프 시맨틱은 `vibe/rules/loop-contract.md`를 따른다. 여기서의 exit 기준은 `coveragePercent === 100`. RTM 다이어그램, 출력 형식, 반복 규칙: `references/ralph-loop.md`
352
-
353
- After ALL phases complete:
354
-
355
- ```bash
356
- # generateTraceabilityMatrix is synchronous — no .then()
357
- node -e "import('{{VIBE_PATH_URL}}/node_modules/@su-record/vibe/dist/tools/index.js').then(t => { const r = t.generateTraceabilityMatrix('{feature-name}', {projectPath: process.cwd()}); console.log(JSON.stringify(r, null, 2)); })"
358
- ```
359
-
360
- > Default SPEC path is `.vibe/specs/<feature>.md`. `status === 'empty'` must be treated as failed/not-applicable — never as 100% pass.
361
-
362
- JUDGE: `coveragePercent === 100` → 루프 종료. stuck(연속 2회 동일 커버리지) → automationLevel confirm이면 사용자 질문; autonomous이면 TODO + done.
363
-
364
- ---
365
-
366
- ## Core Tools (Semantic Analysis & Memory)
367
-
368
- ```bash
369
- # All tools via:
370
- node -e "import('{{VIBE_PATH_URL}}/node_modules/@su-record/vibe/dist/tools/index.js').then(t => t.TOOL_NAME({...args}).then(r => console.log(r.content[0].text)))"
371
- ```
372
-
373
- | Tool | Purpose |
374
- |------|---------|
375
- | `analyzeComplexity` | Analyze code complexity |
376
- | `validateCodeQuality` | Validate code quality |
377
- | `saveMemory` | Save important decisions |
378
- | `recallMemory` | Recall saved memory |
379
- | `listMemories` | List all memories |
380
-
381
- Session management: start hook auto-calls `startSession`; context 80%+ triggers `autoSaveContext`.
382
-
383
- ---
384
-
385
- ## Coding Guidelines (Mandatory)
386
-
387
- > Read `references/race-review.md` for full type safety guidelines, language-specific examples, and the type-violation detection/escalation table.
173
+ ### Process 단계 (전체 절차: `references/process-steps.md`)
388
174
 
389
- **TypeScript core rule:**
390
- ```typescript
391
- // BAD
392
- function process(data: any): any { return data.foo; }
393
-
394
- // GOOD
395
- function process(data: unknown): Result {
396
- if (isValidData(data)) return data.foo;
397
- throw new Error('Invalid');
398
- }
399
- ```
400
-
401
- No `any` / `as any` / `@ts-ignore` fix at root. Explicit return types on all functions.
402
-
403
- **Detection outcome:** Type violations are detected by static analysis and injected as `additionalContext`; commit-level enforcement occurs at the auto-commit verify gate.
404
-
405
- ---
406
-
407
- ## Rules Reference
408
-
409
- - `core/development-philosophy.md` — Surgical precision, modify only requested scope
410
- - `core/quick-start.md` — Korean, DRY, SRP, YAGNI
411
- - `standards/complexity-metrics.md` — Functions ≤50 lines, nesting ≤3 levels
412
- - `quality/checklist.md` — Code quality checklist
413
- - Language guide: `~/.claude/vibe/languages/{stack}.md`
414
-
415
- ---
416
-
417
- ## TRUST 5 Principles
418
-
419
- | Principle | Description |
420
- |-----------|-------------|
421
- | **T**est-first | Write tests first |
422
- | **R**eadable | Clear code |
423
- | **U**nified | Consistent style |
424
- | **S**ecured | Consider security |
425
- | **T**rackable | Logging, monitoring |
426
-
427
- ---
428
-
429
- ## Auto-Retrospective (Post-Implementation)
175
+ | # | 단계 | 핵심 게이트 |
176
+ |---|---|---|
177
+ | 1 | Load SPEC + Feature | SPEC 부재 시 진행 금지 |
178
+ | 1-0 | Compile + validate execution packet | **MANDATORY** — 컴파일 실패 시 중단 (`references/exec-plan.md`) |
179
+ | 1-1 | Phase Isolation Protocol | 3+ phase SPEC 은 phase 단위 격리 + 체크포인트 필수 |
180
+ | 1-2 | SPEC-First Gate | SPEC 에 없는 것을 구현하지 않는다 |
181
+ | 2 | Extract Scenario List | Feature 파일의 시나리오가 작업 단위 |
182
+ | 3 | Scenario-by-Scenario Implementation | 기본 순차. **구현→검증 쌍은 시나리오 단위로 쪼개지 않는다**. `autonomous` 에서 서로 의존하지 않는 시나리오는 병렬 가능하되 검증은 시나리오별로 각각 (SSOT: 위 "하네스-안전 증분") |
183
+ | 4 | Brand Assets | 신규 프로젝트만 (`references/brand-assets.md`) |
184
+ | 5 | Race Code Review | `references/race-review.md` |
185
+ | 6 | Quality Report | 자동 생성 |
186
+ | 7 | Update Feature File | 시나리오 상태 반영 |
187
+ | 8 | Coverage Verification Loop (RTM) | 커버리지 미달 루프 |
430
188
 
431
- After ALL phases complete, save to `.vibe/retros/{feature-name}.md`:
189
+ > 도구·코딩 가이드라인·TRUST 5·자동 회고: `references/guidelines-and-tools.md`
432
190
 
433
- ```markdown
434
- ## Retrospective: {feature-name}
435
- ### What Worked / What Didn't / Key Decisions / Lessons Learned
436
- ```
191
+ ### 1-0. Execution packet (MANDATORY — 본문 유지)
437
192
 
438
- Keep under 20 lines. Save key lessons via `core_save_memory`. Update `claude-progress.txt`.
193
+ 단일 SPEC canonical path 해석 컴파일한다. 분할 SPEC `_index.md` 를 컴파일하지 않고, Phase Isolation Step B 에서 각 활성 phase 파일이 로드될 때까지 미룬다.
194
+ `writeExecutionPacket` 으로 컴파일한 뒤 **즉시** `validateExecutionPacket` 으로 저장 산출물을 검증한다.
195
+ `STALE_PACKET`·invalid packet·preservation-audit 실패·budget 실패는 **blocking** 이다 — canonical SPEC 에서 재컴파일하며, 검증되지 않은 패킷으로 조용히 폴백하지 않는다.
439
196
 
440
- ---
197
+ > 전체 절차와 코드: `references/exec-plan.md` · `references/process-steps.md`
441
198
 
442
199
  ## Input / Output
443
200
 
@@ -457,389 +214,35 @@ Keep under 20 lines. Save key lessons via `core_save_memory`. Update `claude-pro
457
214
 
458
215
  ARGUMENTS: $ARGUMENTS
459
216
 
460
- ## Bundled internal: arch-guard
461
-
462
-
463
- # Arch Guard — Architecture Boundary Test Generator
464
-
465
- > **Principle**: "Mechanical enforcement over documentation." If a rule exists only in docs, it will be violated. Turn architecture constraints into failing tests.
466
-
467
- ## When to Use
468
-
469
- | Scenario | Signal |
470
- |----------|--------|
471
- | `vibe init` / `vibe update` | Auto-generate for detected stack |
472
- | New layer/module added | Boundaries need enforcement |
473
- | Architecture violation found in review | Prevent recurrence with test |
474
- | "Services should not import UI" type rules | Turn into automated check |
475
-
476
- ## Core Flow
217
+ ## Bundled internals (조건부 로드)
477
218
 
478
- ```
479
- DETECT INFER GENERATE VERIFY
480
- ```
481
-
482
- ### Step 1: DETECT — Identify Project Architecture
483
-
484
- Analyze the project to determine its layer structure:
485
-
486
- ```
487
- Parallel exploration:
488
- - Agent 1: Scan directory structure (src/, app/, lib/, etc.)
489
- - Agent 2: Read existing architecture docs (CLAUDE.md, README, ADR)
490
- - Agent 3: Analyze import graph (which files import what)
491
- ```
492
-
493
- **Common patterns to detect:**
494
-
495
- | Pattern | Layers | Typical Stacks |
496
- |---------|--------|----------------|
497
- | MVC | Controller → Service → Model | Rails, NestJS, Spring |
498
- | Clean Architecture | UI → Application → Domain → Infrastructure | General |
499
- | Feature-based | Feature A ↛ Feature B internals | Next.js, React |
500
- | Hexagonal | Adapters → Ports → Domain | DDD projects |
501
- | Component hierarchy | Page → Feature → Shared → UI Primitives | Frontend |
502
-
503
- ### Step 2: INFER — Define Boundary Rules
504
-
505
- From detected structure, generate rules:
506
-
507
- ```typescript
508
- // Rule format
509
- interface ArchRule {
510
- name: string; // "service-no-ui-import"
511
- from: string; // Glob pattern: "src/services/**"
512
- cannotImport: string[]; // ["src/components/**", "src/pages/**"]
513
- canImport: string[]; // ["src/models/**", "src/utils/**"]
514
- reason: string; // "Services must be UI-agnostic"
515
- }
516
- ```
517
-
518
- **Default rules by stack:**
519
-
520
- | Stack | Rule |
521
- |-------|------|
522
- | Next.js / React | `components/` cannot import from `pages/` or `app/` |
523
- | Next.js / React | `lib/` cannot import from `components/` |
524
- | NestJS | `*.service.ts` cannot import from `*.controller.ts` |
525
- | NestJS | `*.module.ts` is the only valid cross-boundary import |
526
- | General TS | `src/domain/` cannot import from `src/infra/` |
527
- | General TS | No circular dependencies between top-level dirs |
528
- | Python Django | `models.py` cannot import from `views.py` |
529
- | Python FastAPI | `schemas/` cannot import from `routers/` |
530
-
531
- ### Step 3: GENERATE — Create Test File
532
-
533
- Output: `tests/arch-guard.test.ts` (or equivalent for stack)
534
-
535
- ```typescript
536
- /**
537
- * Architecture Boundary Tests
538
- * Generated by arch-guard skill
539
- *
540
- * These tests enforce architectural constraints mechanically.
541
- * If a test fails, it means an import violates the intended architecture.
542
- */
543
- import { describe, it, expect } from 'vitest';
544
- import fs from 'fs';
545
- import path from 'path';
546
-
547
- // Helper: extract imports from a file
548
- function extractImports(filePath: string): string[] {
549
- const content = fs.readFileSync(filePath, 'utf-8');
550
- const importRegex = /(?:import|require)\s*\(?['"]([^'"]+)['"]\)?/g;
551
- const imports: string[] = [];
552
- let match;
553
- while ((match = importRegex.exec(content)) !== null) {
554
- imports.push(match[1]);
555
- }
556
- return imports;
557
- }
558
-
559
- // Helper: resolve relative import to absolute path
560
- function resolveImport(fromFile: string, importPath: string): string {
561
- if (importPath.startsWith('.')) {
562
- return path.resolve(path.dirname(fromFile), importPath);
563
- }
564
- return importPath; // external package
565
- }
566
-
567
- // Helper: glob files matching pattern
568
- function globFiles(pattern: string, baseDir: string): string[] {
569
- // Use fast-glob or manual recursive scan
570
- // Implementation depends on available dependencies
571
- }
572
-
573
- describe('Architecture Boundaries', () => {
574
- // GENERATED RULES GO HERE
575
- // Each rule becomes a test case:
576
-
577
- it('services cannot import UI components', () => {
578
- const serviceFiles = globFiles('src/services/**/*.ts', process.cwd());
579
- const violations: string[] = [];
580
-
581
- for (const file of serviceFiles) {
582
- const imports = extractImports(file);
583
- for (const imp of imports) {
584
- const resolved = resolveImport(file, imp);
585
- if (resolved.includes('/components/') || resolved.includes('/pages/')) {
586
- violations.push(`${file} imports ${imp}`);
587
- }
588
- }
589
- }
590
-
591
- expect(violations).toEqual([]);
592
- });
593
- });
594
- ```
595
-
596
- ### Step 4: VERIFY — Run and Fix
597
-
598
- 1. Run the generated tests: `npx vitest run tests/arch-guard.test.ts`
599
- 2. If violations found:
600
- - Report each violation with file:line
601
- - Suggest fix (move shared code to appropriate layer)
602
- - Do NOT auto-fix — violations need human review
219
+ 이 세 구현은 `vibe.run` 의 일부지만 **매 실행에 전부 필요하지는 않다.** 해당 조건에 걸릴 때만 읽는다 —
220
+ 개를 항상 로드하면 호출당 컨텍스트의 약 45%가 쓰이지 않을 자료로 채워진다.
603
221
 
604
- ## Output Files
605
-
606
- | File | Purpose |
607
- |------|---------|
608
- | `tests/arch-guard.test.ts` | Executable boundary tests |
609
- | `.vibe/arch-rules.json` | Machine-readable rules (for CI) |
610
-
611
- ## Customization
612
-
613
- Users can add custom rules to `.vibe/arch-rules.json`:
614
-
615
- ```json
616
- {
617
- "rules": [
618
- {
619
- "name": "no-direct-db-in-handlers",
620
- "from": "src/handlers/**",
621
- "cannotImport": ["src/db/**"],
622
- "reason": "Handlers must use services, not direct DB access"
623
- }
624
- ]
625
- }
626
- ```
627
-
628
- The test generator reads this file and adds custom rules to the test suite.
629
-
630
- ## Integration
631
-
632
- - `vibe init` → auto-detect and generate initial arch-guard tests
633
- - `vibe update` → refresh rules if directory structure changed
634
- - Pre-commit hook → run arch-guard tests before commit
635
- - `vibe.review` (skill) → code-reviewer (focus: architecture) checks against arch-rules.json
222
+ | 내부 구현 | 로드 조건 | 본문 |
223
+ |---|---|---|
224
+ ## Bundled internal: arch-guard
636
225
 
226
+ 번들 유지 — 별도 discovery 항목으로 노출하지 않는다. 본문: `references/arch-guard.md`
637
227
  ## Bundled internal: exec-plan
638
228
 
229
+ 번들 유지 — 별도 discovery 항목으로 노출하지 않는다. 본문: `references/exec-plan.md`
230
+ ## Bundled internal: restraint
639
231
 
640
- # ExecPlanSelf-Contained Execution Plan Generator
641
-
642
- > **Principle**: "If the agent can't see it, it doesn't exist." Every decision, file path, pattern, and verification step must be explicit in the plan — no implicit knowledge allowed.
643
-
644
- ## When to Use
645
-
646
- Before `/vibe.run`, generate an ExecPlan to make execution deterministic:
647
-
648
- | Scenario | Signal |
649
- |----------|--------|
650
- | Complex SPEC (3+ phases) | Agent needs long autonomous execution |
651
- | Team/multi-agent execution | Multiple agents need shared understanding |
652
- | Context window pressure | Plan survives `/new` session handoff |
653
- | Unfamiliar codebase | Agent can't rely on implicit knowledge |
654
-
655
- ## Core Flow
656
-
657
- ```
658
- SPEC + Feature → ANALYZE → RESOLVE → GENERATE → PERSIST
659
- ```
660
-
661
- ### Step 1: ANALYZE — Extract Everything Needed
662
-
663
- Read the SPEC and Feature files, then extract:
664
-
665
- ```
666
- For each Phase → For each Scenario:
667
- 1. Requirements (REQ-* IDs)
668
- 2. Given/When/Then conditions
669
- 3. Affected files (MUST exist — verify with Glob)
670
- 4. Dependencies (imports, packages)
671
- 5. Existing patterns to follow (read actual code, don't assume)
672
- ```
673
-
674
- **Parallel exploration** (3+ agents):
675
- - Agent 1: Map all file paths mentioned/implied in SPEC → verify they exist
676
- - Agent 2: For each affected file, extract current interfaces/types/exports
677
- - Agent 3: Find existing patterns (naming conventions, error handling, test structure)
678
-
679
- ### Step 2: RESOLVE — Eliminate All Ambiguity
680
-
681
- For every decision point in the SPEC, resolve it NOW:
682
-
683
- | Ambiguity | Resolution |
684
- |-----------|------------|
685
- | "Add validation" | → Which fields? What rules? What error messages? |
686
- | "Handle errors" | → Which error codes? What response format? |
687
- | "Follow existing pattern" | → Copy the ACTUAL pattern code into the plan |
688
- | "Update tests" | → Which test file? What test framework? What assertions? |
689
-
690
- **Rule**: If you'd need to "figure it out later", resolve it now. The plan must be executable by an agent with ZERO codebase knowledge.
691
-
692
- ### Step 3: GENERATE — Write the ExecPlan
693
-
694
- Output format: `.vibe/specs/{feature-name}-execplan.md`
695
-
696
- ```markdown
697
- # ExecPlan: {feature-name}
698
-
699
- ## Meta
700
- - SPEC: .vibe/specs/{name}.md
701
- - Feature: .vibe/features/{name}.feature
702
- - Generated: {timestamp}
703
- - Phases: {count}
704
- - Scenarios: {count}
705
-
706
- ## Pre-flight Checks
707
- - [ ] `npm run build` passes
708
- - [ ] `npx vitest run` passes (baseline)
709
- - [ ] Required files exist: {list}
710
-
711
- ## Phase {N}: {phase-name}
712
-
713
- ### Environment
714
- - Files to modify: {exact paths}
715
- - Files to create: {exact paths}
716
- - Dependencies to add: {package@version}
717
- - Patterns to follow: (inline code snippets from codebase)
718
-
719
- ### Scenario {N}.{M}: {scenario-name}
720
-
721
- **Given**: {precondition}
722
- → Setup: {exact code/commands to establish precondition}
723
-
724
- **When**: {action}
725
- → Implement: {step-by-step implementation instructions}
726
- - File: {path}
727
- - Location: after line containing `{anchor text}`
728
- - Code: (inline snippet)
729
- - Imports needed: {list}
232
+ 번들 유지별도 discovery 항목으로 노출하지 않는다. 본문: `references/restraint.md`
730
233
 
731
- **Then**: {expected result}
732
- Verify:
733
- - Command: `{test command}`
734
- - Expected: {output/behavior}
735
- - Fallback: {what to do if verification fails}
234
+ | **arch-guard** | 아키텍처 경계 테스트를 생성·검증할 때 (레이어 위반 감지가 필요한 SPEC) | `references/arch-guard.md` |
235
+ | **exec-plan** | Step 1-0 — execution packet 을 컴파일할 때 | `references/exec-plan.md` |
236
+ | **restraint** | 아래 요약으로 판단이 서지 않을 때 (전문: 사다리 단계별 근거·차단 충동 목록) | `references/restraint.md` |
736
237
 
737
- ### Phase {N} Gate
738
- - [ ] Build: `npm run build`
739
- - [ ] Tests: `npx vitest run {relevant-test-files}`
740
- - [ ] Type check: `npx tsc --noEmit`
238
+ **restraint 요약 (항상 적용 — 상세는 위 reference):**
741
239
 
742
- ## Completion Criteria
743
- - Coverage threshold: ≥95%
744
- - All scenarios passing
745
- - No regressions in existing tests
746
- - RTM: `generateTraceabilityMatrix("{feature-name}")`
747
240
  ```
241
+ YAGNI 사다리: 지금 필요한가? → 아니면 쓰지 않는다.
242
+ 추상화는 3번째 중복에서. 설정 항목은 2번째 요구에서. 플러그인 구조는 외부 사용자가 생겼을 때.
748
243
 
749
- ### Step 4: PERSIST Save and Link
750
-
751
- 1. Save ExecPlan to `.vibe/specs/{feature-name}-execplan.md`
752
- 2. Save session context: `save_memory("execplan-{feature}", {summary})`
753
- 3. Output execution command:
244
+ Pike 규칙: 측정 없이 최적화하지 않는다. 부분이 나머지를 압도하지 않으면 튜닝하지 않는다.
245
+ n 은 대체로 작다. 단순한 코드가 영리한 코드를 이긴다. 데이터가 지배한다.
754
246
 
247
+ Restraint 가 무효화하지 못하는 것: 정확성 · 보안 · 데이터 무결성 · 사용자가 명시적으로 요청한 것
755
248
  ```
756
- Ready to execute:
757
- /vibe.run "{feature-name}" ultrawork
758
-
759
- Or hand off to new session:
760
- /vibe.continue
761
- → Load: .vibe/specs/{feature-name}-execplan.md
762
- ```
763
-
764
- ## Quality Checks
765
-
766
- | Check | Criteria |
767
- |-------|----------|
768
- | No implicit knowledge | Every file path verified with Glob |
769
- | No "figure it out" | Every decision resolved with actual code |
770
- | Survives handoff | Plan readable without any prior context |
771
- | Inline patterns | Actual code snippets, not "follow existing pattern" |
772
- | Verification steps | Every scenario has a concrete verification command |
773
-
774
- ## Anti-patterns
775
-
776
- - "See the existing implementation" → Copy the relevant code inline
777
- - "Follow the pattern in X" → Show the actual pattern
778
- - "Standard error handling" → Specify exact error codes and messages
779
- - "Update tests accordingly" → Name the test file, framework, and assertions
780
-
781
- ## Bundled internal: restraint
782
-
783
-
784
- # Restraint — Don't Write It, Don't Tune It (Yet)
785
-
786
- Two constraints, one gate:
787
-
788
- - **No premature code.** New abstractions must be *pulled* by a demonstrated
789
- need, never pushed by "might need it later." Once the code exists, deleting
790
- it costs more than never writing it.
791
- - **No premature optimization.** Performance work must be *pulled* by a
792
- measurement, never by a hunch.
793
-
794
- ## The YAGNI Ladder (code axis)
795
-
796
- Satisfy the need at the **highest** rung that covers it; lower rungs are
797
- blocked while a higher one applies:
798
-
799
- 1. **Not needed** — the requirement doesn't ask for it → don't build it
800
- 2. **Stdlib / built-ins** already do it (`crypto`, `Intl`, `pathlib`, …)
801
- 3. **Native platform feature** does it (`<input type="date">`, CSS `:has()`, DB constraints)
802
- 4. **Already-installed dependency** covers it — check the lockfile, don't guess
803
- 5. **One line** — a single expression; no new file, no class
804
- 6. **Minimal code** — only now, and nothing for "later"
805
-
806
- Tie-break: native beats a one-liner; stdlib beats a dependency. Generalize
807
- only when a *second* caller exists.
808
-
809
- ## Pike's Rules (optimization axis)
810
-
811
- - You can't tell where a program spends its time — bottlenecks surprise.
812
- **Measure; don't guess.**
813
- - Don't tune until one part *measurably* overwhelms the rest.
814
- - Fancy algorithms are slow when n is small — and n is usually small.
815
- Ask "what's n?" before "what's the Big-O?"
816
- - Simple algorithms + the right data structures beat clever code. Data dominates.
817
-
818
- Optimization is justified only when ALL hold: a measured bottleneck exists →
819
- it dominates runtime → the fix is the simplest change addressing it → you
820
- re-measure after.
821
-
822
- ## Blocked Impulses
823
-
824
- | Impulse | Constraint | Counter |
825
- |---|---|---|
826
- | helper / utility / wrapper / manager class | rungs 1–5 | a stdlib call or one line usually suffices |
827
- | config system for one value | rung 1 | a `const` is the config |
828
- | generic `Processor(strategy, validator…)` | rung 1 | one concrete function until a second caller exists |
829
- | "add a cache here" / "parallelize this" | measure first | is this path even hot? Often it's I/O |
830
- | swap in a B-tree / trie / skip list | what's n? | O(n²) with n=100 is microseconds |
831
- | "this loop looks slow" | measure first | the bottleneck is probably elsewhere |
832
-
833
- ## Overrides — Restraint Never Erodes These
834
-
835
- 1. **Security and trust-boundary work are requirements**, not optional
836
- complexity. Input validation, auth checks, escaping stay in — "one line"
837
- is no excuse to drop them.
838
- 2. **Deliberate simplifications get a comment + upgrade path**, so the next
839
- reader sees a *choice*, not an oversight:
840
-
841
- ```ts
842
- // Global lock is enough at current throughput.
843
- // Switch to per-account locking if write contention shows up.
844
- const lock = new Mutex();
845
- ```