@sugar-crash-studios/vibe-forge 0.4.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.
Files changed (201) hide show
  1. package/.claude/commands/clear-attention.md +63 -0
  2. package/.claude/commands/compact-context.md +52 -0
  3. package/.claude/commands/configure-vcs.md +102 -0
  4. package/.claude/commands/forge.md +171 -0
  5. package/.claude/commands/need-help.md +77 -0
  6. package/.claude/commands/update-status.md +64 -0
  7. package/.claude/commands/worker-loop.md +106 -0
  8. package/.claude/hooks/worker-loop.js +198 -0
  9. package/.claude/scripts/setup-worker-loop.sh +45 -0
  10. package/.claude/settings.local.json +46 -0
  11. package/LICENSE +21 -0
  12. package/README.md +238 -0
  13. package/agents/aegis/personality.md +294 -0
  14. package/agents/anvil/personality.md +276 -0
  15. package/agents/architect/personality.md +258 -0
  16. package/agents/crucible/personality.md +360 -0
  17. package/agents/ember/personality.md +291 -0
  18. package/agents/forge-master/capabilities.md +144 -0
  19. package/agents/forge-master/context-template.md +128 -0
  20. package/agents/forge-master/personality.md +138 -0
  21. package/agents/furnace/personality.md +340 -0
  22. package/agents/herald/personality.md +247 -0
  23. package/agents/loki/personality.md +108 -0
  24. package/agents/oracle/personality.md +283 -0
  25. package/agents/pixel/personality.md +113 -0
  26. package/agents/planning-hub/personality.md +320 -0
  27. package/agents/scribe/personality.md +251 -0
  28. package/agents/temper/personality.md +218 -0
  29. package/bin/cli.js +375 -0
  30. package/bin/dashboard/api/agents.js +333 -0
  31. package/bin/dashboard/api/dispatch.js +483 -0
  32. package/bin/dashboard/api/tasks.js +416 -0
  33. package/bin/dashboard/frontend/index.html +13 -0
  34. package/bin/dashboard/frontend/package.json +16 -0
  35. package/bin/dashboard/frontend/src/App.svelte +222 -0
  36. package/bin/dashboard/frontend/src/app.css +1777 -0
  37. package/bin/dashboard/frontend/src/lib/components/AgentCard.svelte +60 -0
  38. package/bin/dashboard/frontend/src/lib/components/AgentsPanel.svelte +57 -0
  39. package/bin/dashboard/frontend/src/lib/components/DispatchModal.svelte +180 -0
  40. package/bin/dashboard/frontend/src/lib/components/Footer.svelte +33 -0
  41. package/bin/dashboard/frontend/src/lib/components/Header.svelte +84 -0
  42. package/bin/dashboard/frontend/src/lib/components/IssueCard.svelte +33 -0
  43. package/bin/dashboard/frontend/src/lib/components/IssuesPanel.svelte +73 -0
  44. package/bin/dashboard/frontend/src/lib/components/KeyboardShortcutsModal.svelte +108 -0
  45. package/bin/dashboard/frontend/src/lib/components/MobileTabs.svelte +52 -0
  46. package/bin/dashboard/frontend/src/lib/components/NotificationCard.svelte +60 -0
  47. package/bin/dashboard/frontend/src/lib/components/NotificationsPanel.svelte +44 -0
  48. package/bin/dashboard/frontend/src/lib/components/TaskCard.svelte +63 -0
  49. package/bin/dashboard/frontend/src/lib/components/TasksPanel.svelte +82 -0
  50. package/bin/dashboard/frontend/src/lib/components/Toast.svelte +45 -0
  51. package/bin/dashboard/frontend/src/lib/stores/agents.js +34 -0
  52. package/bin/dashboard/frontend/src/lib/stores/issues.js +54 -0
  53. package/bin/dashboard/frontend/src/lib/stores/notifications.js +48 -0
  54. package/bin/dashboard/frontend/src/lib/stores/tasks.js +63 -0
  55. package/bin/dashboard/frontend/src/lib/stores/theme.js +33 -0
  56. package/bin/dashboard/frontend/src/lib/stores/toast.js +35 -0
  57. package/bin/dashboard/frontend/src/lib/stores/ui.js +25 -0
  58. package/bin/dashboard/frontend/src/lib/stores/voice.js +275 -0
  59. package/bin/dashboard/frontend/src/lib/stores/websocket.js +295 -0
  60. package/bin/dashboard/frontend/src/lib/utils/api.js +101 -0
  61. package/bin/dashboard/frontend/src/lib/utils/formatters.js +54 -0
  62. package/bin/dashboard/frontend/src/main.js +9 -0
  63. package/bin/dashboard/frontend/svelte.config.js +5 -0
  64. package/bin/dashboard/frontend/vite.config.js +20 -0
  65. package/bin/dashboard/public/assets/index-DnfVj9Ce.css +1 -0
  66. package/bin/dashboard/public/assets/index-Ze5h0kXQ.js +2 -0
  67. package/bin/dashboard/public/index.html +14 -0
  68. package/bin/dashboard/server.js +566 -0
  69. package/bin/forge-daemon.sh +463 -0
  70. package/bin/forge-setup.sh +645 -0
  71. package/bin/forge-spawn.sh +164 -0
  72. package/bin/forge.cmd +83 -0
  73. package/bin/forge.sh +533 -0
  74. package/bin/lib/agents.sh +177 -0
  75. package/bin/lib/colors.sh +44 -0
  76. package/bin/lib/config.sh +347 -0
  77. package/bin/lib/constants.sh +241 -0
  78. package/bin/lib/daemon/display.sh +128 -0
  79. package/bin/lib/daemon/notifications.sh +263 -0
  80. package/bin/lib/daemon/routing.sh +77 -0
  81. package/bin/lib/daemon/state.sh +115 -0
  82. package/bin/lib/daemon/sync.sh +95 -0
  83. package/bin/lib/database.sh +310 -0
  84. package/bin/lib/heimdall-setup.js +113 -0
  85. package/bin/lib/heimdall.js +265 -0
  86. package/bin/lib/json.sh +264 -0
  87. package/bin/lib/terminal.js +451 -0
  88. package/bin/lib/util.sh +126 -0
  89. package/bin/lib/vcs.js +349 -0
  90. package/config/agent-manifest.yaml +203 -0
  91. package/config/agents.json +168 -0
  92. package/config/task-template.md +159 -0
  93. package/config/task-types.yaml +106 -0
  94. package/context/agent-status/aegis.json +7 -0
  95. package/context/agent-status/anvil.json +7 -0
  96. package/context/agent-status/architect.json +7 -0
  97. package/context/agent-status/crucible.json +7 -0
  98. package/context/agent-status/ember.json +7 -0
  99. package/context/agent-status/furnace.json +7 -0
  100. package/context/agent-status/loki.json +7 -0
  101. package/context/agent-status/oracle.json +7 -0
  102. package/context/agent-status/pixel.json +7 -0
  103. package/context/agent-status/planning-hub.json +7 -0
  104. package/context/agent-status/scribe.json +7 -0
  105. package/context/agent-status/temper.json +7 -0
  106. package/context/feature-brainstorm.md +426 -0
  107. package/context/forge-state.yaml +19 -0
  108. package/context/modern-conventions.md +129 -0
  109. package/context/project-context-template.md +122 -0
  110. package/context/project-context.md +122 -0
  111. package/docs/TODO.md +150 -0
  112. package/docs/agents.md +409 -0
  113. package/docs/architecture/decisions/ADR-001-daemon-modularization.md +122 -0
  114. package/docs/architecture/vibe-lab-integration.md +684 -0
  115. package/docs/architecture.md +194 -0
  116. package/docs/bmad-gap-analysis-2026-03-31.md +444 -0
  117. package/docs/cleanup-workflow.md +329 -0
  118. package/docs/commands.md +451 -0
  119. package/docs/dashboard-mockup.html +989 -0
  120. package/docs/getting-started.md +261 -0
  121. package/docs/integration/forge-ownership-policy.md +112 -0
  122. package/docs/npm-publishing.md +132 -0
  123. package/docs/roadmap-2026.md +519 -0
  124. package/docs/security.md +144 -0
  125. package/docs/wireframes/dashboard-mvp.md +1164 -0
  126. package/docs/workflows/README.md +32 -0
  127. package/docs/workflows/azure-devops.md +108 -0
  128. package/docs/workflows/bitbucket.md +104 -0
  129. package/docs/workflows/git-only.md +130 -0
  130. package/docs/workflows/gitea.md +168 -0
  131. package/docs/workflows/github.md +103 -0
  132. package/docs/workflows/gitlab.md +105 -0
  133. package/docs/workflows.md +454 -0
  134. package/package.json +73 -0
  135. package/tasks/completed/ARCH-001-duplicate-agent-config.md +121 -0
  136. package/tasks/completed/ARCH-002-mixed-bash-node-implementation.md +88 -0
  137. package/tasks/completed/ARCH-003-worker-loop-hook-duplication.md +77 -0
  138. package/tasks/completed/ARCH-009-test-organization.md +78 -0
  139. package/tasks/completed/ARCH-011-jq-vs-nodejs-json.md +94 -0
  140. package/tasks/completed/ARCH-012-tmp-files-in-root.md +71 -0
  141. package/tasks/completed/ARCH-013-exit-code-constants.md +65 -0
  142. package/tasks/completed/ARCH-014-sed-incompatibility.md +96 -0
  143. package/tasks/completed/ARCH-015-docs-todo-tracking.md +83 -0
  144. package/tasks/completed/BUG-dash-001-tasks-filter-error.md +31 -0
  145. package/tasks/completed/BUG-dash-002-agents-unknown.md +41 -0
  146. package/tasks/completed/CLEAN-001.md +38 -0
  147. package/tasks/completed/CLEAN-002.md +43 -0
  148. package/tasks/completed/CLEAN-003.md +47 -0
  149. package/tasks/completed/CLEAN-004.md +56 -0
  150. package/tasks/completed/CLEAN-005.md +75 -0
  151. package/tasks/completed/CLEAN-006.md +47 -0
  152. package/tasks/completed/CLEAN-007.md +34 -0
  153. package/tasks/completed/CLEAN-008.md +49 -0
  154. package/tasks/completed/CLEAN-012.md +58 -0
  155. package/tasks/completed/CLEAN-013.md +45 -0
  156. package/tasks/completed/FEATURE-001a-dashboard-wireframes.md +162 -0
  157. package/tasks/completed/IMPL-007a-daemon-notifications-module.md +82 -0
  158. package/tasks/completed/IMPL-007b-daemon-sync-module.md +71 -0
  159. package/tasks/completed/IMPL-007c-daemon-state-module.md +80 -0
  160. package/tasks/completed/IMPL-007d-daemon-routing-module.md +77 -0
  161. package/tasks/completed/IMPL-007e-daemon-display-module.md +77 -0
  162. package/tasks/completed/IMPL-007f-daemon-integration.md +124 -0
  163. package/tasks/completed/PLAT-1-heimdall.md +420 -0
  164. package/tasks/completed/SEC-001-sql-injection-fix.md +58 -0
  165. package/tasks/completed/SEC-002-notification-injection-fix.md +45 -0
  166. package/tasks/completed/SEC-003-eval-injection-fix.md +54 -0
  167. package/tasks/completed/SEC-004-pid-race-condition-fix.md +49 -0
  168. package/tasks/completed/SEC-005-worker-loop-path-fix.md +51 -0
  169. package/tasks/completed/SEC-006-eval-agent-names.md +55 -0
  170. package/tasks/completed/SEC-007-spawn-escaping.md +67 -0
  171. package/tasks/completed/TASK-DASH-001-server-infrastructure.md +185 -0
  172. package/tasks/completed/TASK-anvil-001-dashboard-frontend.md +133 -0
  173. package/tasks/completed/review-bmad-aegis.md +89 -0
  174. package/tasks/completed/review-bmad-anvil.md +80 -0
  175. package/tasks/completed/review-bmad-crucible.md +81 -0
  176. package/tasks/completed/review-bmad-ember.md +90 -0
  177. package/tasks/completed/review-bmad-furnace.md +79 -0
  178. package/tasks/completed/review-bmad-pixel.md +82 -0
  179. package/tasks/completed/review-bmad-scribe.md +92 -0
  180. package/tasks/completed/review-bmad-sentinel.md +83 -0
  181. package/tasks/pending/ARCH-004-git-bash-detection-duplication.md +72 -0
  182. package/tasks/pending/ARCH-005-missing-src-directory.md +95 -0
  183. package/tasks/pending/ARCH-006-task-template-location.md +64 -0
  184. package/tasks/pending/ARCH-008-forge-master-vs-hub.md +81 -0
  185. package/tasks/pending/ARCH-010-missing-index-files.md +84 -0
  186. package/tasks/pending/CLEAN-009.md +31 -0
  187. package/tasks/pending/CLEAN-010.md +30 -0
  188. package/tasks/pending/CLEAN-011.md +30 -0
  189. package/tasks/pending/CLEAN-014.md +32 -0
  190. package/tasks/pending/DESIGN-dash-001-layout-review.md +45 -0
  191. package/tasks/pending/FEATURE-001-dashboard-mvp.md +268 -0
  192. package/tasks/review/ARCH-007-daemon-monolith.md +162 -0
  193. package/tasks/review/bmad-review-aegis.md +349 -0
  194. package/tasks/review/bmad-review-anvil.md +259 -0
  195. package/tasks/review/bmad-review-crucible.md +277 -0
  196. package/tasks/review/bmad-review-ember.md +307 -0
  197. package/tasks/review/bmad-review-furnace.md +285 -0
  198. package/tasks/review/bmad-review-pixel.md +329 -0
  199. package/tasks/review/bmad-review-scribe.md +361 -0
  200. package/tasks/review/bmad-review-sentinel.md +242 -0
  201. package/tasks/review/task-001.md +78 -0
@@ -0,0 +1,329 @@
1
+ # Vibe-Code Lifecycle: Build → Test → Cleanup → Ship
2
+
3
+ **Version:** 1.0.0
4
+ **Last Updated:** 2026-02-04
5
+ **Author:** SpasticPalate
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ Vibe coding with AI produces working code fast, but accumulates three categories of technical debt:
12
+
13
+ | Debt Type | Symptom | Tool |
14
+ |-----------|---------|------|
15
+ | **Duplication** | Same logic copy-pasted across files | [jscpd](https://jscpd.dev) |
16
+ | **Dead Code** | Unused files, exports, dependencies | [Knip](https://knip.dev) |
17
+ | **Pattern Inconsistency** | Mixed syntax for equivalent operations | [ast-grep](https://ast-grep.github.io) |
18
+
19
+ This workflow inserts a structured cleanup gate between "it works" and "it ships."
20
+
21
+ ---
22
+
23
+ ## The Lifecycle
24
+
25
+ ```
26
+ ┌─────────────────────────────────────────────────────────┐
27
+ │ VIBE-CODE LIFECYCLE │
28
+ │ │
29
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
30
+ │ │ 1. VIBE │──▶│ 2. TEST │──▶│3. CLEANUP│ │
31
+ │ │ (build) │ │ (verify) │ │ (refine) │ │
32
+ │ └──────────┘ └──────────┘ └────┬─────┘ │
33
+ │ │ │
34
+ │ ▼ │
35
+ │ ┌──────────┐ ┌──────────┐ │
36
+ │ │ 5. DEPLOY│◀──│ 4. TEST │ │
37
+ │ │ (ship) │ │(confirm) │ │
38
+ │ └──────────┘ └──────────┘ │
39
+ └─────────────────────────────────────────────────────────┘
40
+ ```
41
+
42
+ ### Phase 1: VIBE (Build)
43
+
44
+ **Goal:** Get working features fast. Don't overthink structure.
45
+
46
+ This is the creative phase. Use Claude, Cursor, Copilot — whatever gets features working. Accept that the output will have rough edges. That's what the cleanup phase is for.
47
+
48
+ **Rules during vibe phase:**
49
+ - Commit often to a feature branch
50
+ - Don't refactor while building — that's a different phase
51
+ - Capture TODO comments for things you know are messy
52
+ - Focus on behavior, not beauty
53
+
54
+ **Exit criteria:** Feature works as intended.
55
+
56
+ ### Phase 2: TEST (Verify)
57
+
58
+ **Goal:** Confirm the vibe-coded feature actually works.
59
+
60
+ Run your test suite. If tests don't exist yet, this is Crucible's domain — write them now before touching the code further. You need a passing baseline before cleanup or you won't know if cleanup broke something.
61
+
62
+ ```bash
63
+ npm test # Unit/integration tests
64
+ npm run test:e2e # E2E if applicable
65
+ ```
66
+
67
+ **Exit criteria:** All tests pass. You have a green baseline.
68
+
69
+ ### Phase 3: CLEANUP (Refine)
70
+
71
+ **Goal:** Eliminate the three categories of vibe-coding debt.
72
+
73
+ This is the core of the workflow. Run the three tools in order — each one's output informs the next.
74
+
75
+ #### Step 3a: Detect Duplicates (jscpd)
76
+
77
+ **Why first:** Duplication is the most common vibe-coding sin. Fixing it first reduces the surface area for the other tools.
78
+
79
+ ```bash
80
+ npm run cleanup:duplicates
81
+ # or directly:
82
+ npx jscpd ./src --min-tokens 50 --reporters console --format "typescript,javascript,tsx,jsx"
83
+ ```
84
+
85
+ **What to do with results:**
86
+ - **Exact clones (>30 lines):** Extract to a shared utility/hook/component
87
+ - **Near-clones (similar structure, different details):** Generalize with parameters
88
+ - **Small clones (<10 lines):** Probably fine — not everything needs DRYing
89
+
90
+ **Judgment call:** Don't extract something into a shared utility if it's only used in 2 places and the abstraction would be harder to understand than the duplication. The goal is maintainability, not minimum line count.
91
+
92
+ #### Step 3b: Remove Dead Code (Knip)
93
+
94
+ **Why second:** After extracting duplicates into shared code, some of the original files/exports become unused. Knip catches that, plus all the other dead code from iterative prompting.
95
+
96
+ ```bash
97
+ npm run cleanup:deadcode
98
+ # or directly:
99
+ npx knip
100
+ ```
101
+
102
+ **What Knip finds:**
103
+ - Unused files (whole files nothing imports)
104
+ - Unused exports (exported but never imported)
105
+ - Unused dependencies (in package.json but never imported)
106
+ - Unused dev dependencies
107
+
108
+ **What to do with results:**
109
+ - **Unused files:** Delete them. If you need them later, they're in git.
110
+ - **Unused exports:** Remove the `export` keyword, or delete if the function itself is unused
111
+ - **Unused deps:** `npm uninstall <package>`
112
+ - **False positives:** Add to `knip.json` ignore list (dynamic imports, entry points Knip doesn't know about)
113
+
114
+ #### Step 3c: Normalize Patterns (ast-grep)
115
+
116
+ **Why last:** With duplicates extracted and dead code removed, you're working with a leaner codebase. Now standardize the patterns.
117
+
118
+ ```bash
119
+ npm run cleanup:patterns
120
+ # or directly:
121
+ npx @ast-grep/cli scan --config .ast-grep/sgconfig.yml
122
+ ```
123
+
124
+ **Common patterns to normalize (React/TS projects):**
125
+
126
+ ```yaml
127
+ # .ast-grep/rules/optional-chaining.yml
128
+ id: use-optional-chaining
129
+ language: typescript
130
+ rule:
131
+ pattern: $A && $A.$B
132
+ fix: $A?.$B
133
+ message: "Use optional chaining instead of && guard"
134
+ severity: warning
135
+
136
+ # .ast-grep/rules/no-console-log.yml
137
+ id: no-console-log
138
+ language: typescript
139
+ rule:
140
+ pattern: console.log($$$ARGS)
141
+ message: "Remove console.log before shipping"
142
+ severity: warning
143
+
144
+ # .ast-grep/rules/prefer-const.yml
145
+ id: prefer-const
146
+ language: typescript
147
+ rule:
148
+ pattern: let $VAR = $INIT
149
+ constraints:
150
+ # Only when variable is never reassigned
151
+ message: "Use const for variables that are never reassigned"
152
+ severity: hint
153
+ ```
154
+
155
+ **Interactive rewrite mode** (review each change):
156
+ ```bash
157
+ npx @ast-grep/cli scan --config .ast-grep/sgconfig.yml --interactive
158
+ ```
159
+
160
+ ### Phase 4: TEST (Confirm)
161
+
162
+ **Goal:** Verify cleanup didn't break anything.
163
+
164
+ ```bash
165
+ npm test # Same tests as Phase 2
166
+ npm run test:e2e # Same E2E
167
+ npm run build # Verify the build still works
168
+ ```
169
+
170
+ If anything fails, the cleanup introduced a regression. Fix it before proceeding.
171
+
172
+ **Exit criteria:** All tests pass again. Build succeeds.
173
+
174
+ ### Phase 5: DEPLOY (Ship)
175
+
176
+ **Goal:** Push clean, tested code.
177
+
178
+ ```bash
179
+ git add -A
180
+ git commit -m "cleanup: deduplicate, remove dead code, normalize patterns"
181
+ git push
182
+ ```
183
+
184
+ Then follow your normal deploy process (PR, CI, Dockhand webhook, etc.).
185
+
186
+ ---
187
+
188
+ ## Running the Full Cleanup
189
+
190
+ One command to run all three tools in sequence:
191
+
192
+ ```bash
193
+ npm run cleanup
194
+ ```
195
+
196
+ This runs the cleanup script which executes all three tools, collects results, and produces a summary. See the `scripts/cleanup.sh` section below for implementation.
197
+
198
+ ---
199
+
200
+ ## Project Setup
201
+
202
+ ### Install Tools
203
+
204
+ ```bash
205
+ # Global (available across all projects)
206
+ npm install -g jscpd @ast-grep/cli
207
+
208
+ # Per-project (recommended for CI)
209
+ npm install -D jscpd @ast-grep/cli knip
210
+ ```
211
+
212
+ ### package.json Scripts
213
+
214
+ Add to any project's `package.json`:
215
+
216
+ ```json
217
+ {
218
+ "scripts": {
219
+ "cleanup": "node scripts/cleanup.mjs",
220
+ "cleanup:duplicates": "jscpd ./src --min-tokens 50 --reporters console",
221
+ "cleanup:deadcode": "knip",
222
+ "cleanup:patterns": "sg scan",
223
+ "cleanup:fix": "sg scan --interactive"
224
+ }
225
+ }
226
+ ```
227
+
228
+ ### Configuration Files
229
+
230
+ Drop these into any project root. See the `_cleanup-kit/` directory for ready-to-copy templates.
231
+
232
+ ---
233
+
234
+ ## Integration with Vibe Forge Agents
235
+
236
+ ### Crucible (Testing)
237
+
238
+ Crucible owns Phases 2 and 4. The cleanup phase sits between Crucible's two test runs. Crucible should be aware that cleanup may change file structure (extracted utilities, deleted files) and should re-run the full suite, not just affected tests.
239
+
240
+ ### Sentinel (Code Review)
241
+
242
+ Sentinel can use cleanup tool output as review signals:
243
+ - **jscpd clones remaining after cleanup** = reviewer should question why
244
+ - **Knip unused exports after cleanup** = missed cleanup items
245
+ - **ast-grep warnings after cleanup** = pattern violations to flag
246
+
247
+ ### Aegis (Security)
248
+
249
+ ast-grep rules can include security patterns. Aegis-authored rules live alongside pattern normalization rules:
250
+
251
+ ```yaml
252
+ # .ast-grep/rules/aegis-no-eval.yml
253
+ id: no-eval
254
+ language: typescript
255
+ rule:
256
+ pattern: eval($$$ARGS)
257
+ message: "eval() is a security risk. Use safer alternatives."
258
+ severity: error
259
+ ```
260
+
261
+ ### New: Refinery Agent (Optional)
262
+
263
+ If you want to formalize the cleanup phase as a Vibe Forge agent, a "Refinery" agent would own Phase 3 exclusively. Its personality: methodical, numbers-driven, focused on codebase hygiene rather than features. It receives code after Crucible's first pass and hands back cleaned code for Crucible's second pass.
264
+
265
+ ---
266
+
267
+ ## Metrics and Thresholds
268
+
269
+ Track these over time to measure vibe-coding debt accumulation:
270
+
271
+ | Metric | Source | Healthy | Warning | Action Required |
272
+ |--------|--------|---------|---------|-----------------|
273
+ | Clone percentage | jscpd | <3% | 3-5% | >5% |
274
+ | Unused files | Knip | 0 | 1-3 | >3 |
275
+ | Unused dependencies | Knip | 0 | 1-2 | >2 |
276
+ | Unused exports | Knip | <5 | 5-15 | >15 |
277
+ | Pattern violations | ast-grep | 0 | 1-5 | >5 |
278
+
279
+ ### CI Gate (Optional)
280
+
281
+ Add to your GitHub Actions / CI pipeline:
282
+
283
+ ```yaml
284
+ cleanup-check:
285
+ runs-on: ubuntu-latest
286
+ steps:
287
+ - uses: actions/checkout@v4
288
+ - uses: actions/setup-node@v4
289
+ - run: npm ci
290
+ - run: npx jscpd ./src --threshold 5 --reporters console
291
+ - run: npx knip --no-exit-code # Report only, don't fail yet
292
+ - run: npx @ast-grep/cli scan # Fail on error-severity rules
293
+ ```
294
+
295
+ ---
296
+
297
+ ## When to Skip Cleanup
298
+
299
+ Not every commit needs the full cycle:
300
+
301
+ - **Hotfix:** Skip cleanup, go straight from vibe → test → deploy. Come back for cleanup later.
302
+ - **Prototype/spike:** Don't cleanup throwaway code. Mark the branch as experimental.
303
+ - **Config-only changes:** Compose files, env vars, nginx configs — static analysis tools won't help.
304
+ - **Documentation:** No code to clean up.
305
+
306
+ Apply cleanup when you're shipping a feature or before merging to main.
307
+
308
+ ---
309
+
310
+ ## FAQ
311
+
312
+ **Q: How long does cleanup take?**
313
+ A: 5-15 minutes for a typical feature. The tools run in seconds; the human decisions (what to extract, what to delete) take the time.
314
+
315
+ **Q: Should I cleanup every commit?**
316
+ A: No. Cleanup per feature, not per commit. Batch your vibe-coding commits, then cleanup once before the PR.
317
+
318
+ **Q: What if jscpd finds clones I want to keep?**
319
+ A: Add them to `.jscpd.json` ignore patterns. Some duplication is intentional (test fixtures, similar-but-different components).
320
+
321
+ **Q: What if Knip says something is unused but it's actually used dynamically?**
322
+ A: Add it to `knip.json` entry or ignore patterns. Common with dynamic imports, plugin systems, and barrel files.
323
+
324
+ **Q: Can I use ast-grep to auto-fix everything?**
325
+ A: You can, but use `--interactive` mode to review each change. Automated rewrites without review are just a different flavor of vibe coding.
326
+
327
+ ---
328
+
329
+ *This workflow is designed for React/TypeScript projects but the tools and process apply to any JavaScript/TypeScript codebase.*