safeword 0.2.3 → 0.2.4

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 (235) hide show
  1. package/.claude/commands/arch-review.md +32 -0
  2. package/.claude/commands/lint.md +6 -0
  3. package/.claude/commands/quality-review.md +13 -0
  4. package/.claude/commands/setup-linting.md +6 -0
  5. package/.claude/hooks/auto-lint.sh +6 -0
  6. package/.claude/hooks/auto-quality-review.sh +170 -0
  7. package/.claude/hooks/check-linting-sync.sh +17 -0
  8. package/.claude/hooks/inject-timestamp.sh +6 -0
  9. package/.claude/hooks/question-protocol.sh +12 -0
  10. package/.claude/hooks/run-linters.sh +8 -0
  11. package/.claude/hooks/run-quality-review.sh +76 -0
  12. package/.claude/hooks/version-check.sh +10 -0
  13. package/.claude/mcp/README.md +96 -0
  14. package/.claude/mcp/arcade.sample.json +9 -0
  15. package/.claude/mcp/context7.sample.json +7 -0
  16. package/.claude/mcp/playwright.sample.json +7 -0
  17. package/.claude/settings.json +62 -0
  18. package/.claude/skills/quality-reviewer/SKILL.md +190 -0
  19. package/.claude/skills/safeword-quality-reviewer/SKILL.md +13 -0
  20. package/.env.arcade.example +4 -0
  21. package/.env.example +11 -0
  22. package/.gitmodules +4 -0
  23. package/.safeword/SAFEWORD.md +33 -0
  24. package/.safeword/eslint/eslint-base.mjs +101 -0
  25. package/.safeword/guides/architecture-guide.md +404 -0
  26. package/.safeword/guides/code-philosophy.md +174 -0
  27. package/.safeword/guides/context-files-guide.md +405 -0
  28. package/.safeword/guides/data-architecture-guide.md +183 -0
  29. package/.safeword/guides/design-doc-guide.md +165 -0
  30. package/.safeword/guides/learning-extraction.md +515 -0
  31. package/.safeword/guides/llm-instruction-design.md +239 -0
  32. package/.safeword/guides/llm-prompting.md +95 -0
  33. package/.safeword/guides/tdd-best-practices.md +570 -0
  34. package/.safeword/guides/test-definitions-guide.md +243 -0
  35. package/.safeword/guides/testing-methodology.md +573 -0
  36. package/.safeword/guides/user-story-guide.md +237 -0
  37. package/.safeword/guides/zombie-process-cleanup.md +214 -0
  38. package/{templates → .safeword}/hooks/agents-md-check.sh +0 -0
  39. package/{templates → .safeword}/hooks/post-tool.sh +0 -0
  40. package/{templates → .safeword}/hooks/pre-commit.sh +0 -0
  41. package/.safeword/planning/002-user-story-quality-evaluation.md +1840 -0
  42. package/.safeword/planning/003-langsmith-eval-setup-prompt.md +363 -0
  43. package/.safeword/planning/004-llm-eval-test-cases.md +3226 -0
  44. package/.safeword/planning/005-architecture-enforcement-system.md +169 -0
  45. package/.safeword/planning/006-reactive-fix-prevention-research.md +135 -0
  46. package/.safeword/planning/011-cli-ux-vision.md +330 -0
  47. package/.safeword/planning/012-project-structure-cleanup.md +154 -0
  48. package/.safeword/planning/README.md +39 -0
  49. package/.safeword/planning/automation-plan-v2.md +1225 -0
  50. package/.safeword/planning/automation-plan-v3.md +1291 -0
  51. package/.safeword/planning/automation-plan.md +3058 -0
  52. package/.safeword/planning/design/005-cli-implementation.md +343 -0
  53. package/.safeword/planning/design/013-cli-self-contained-templates.md +596 -0
  54. package/.safeword/planning/design/013a-eslint-plugin-suite.md +256 -0
  55. package/.safeword/planning/design/013b-implementation-snippets.md +385 -0
  56. package/.safeword/planning/design/013c-config-isolation-strategy.md +242 -0
  57. package/.safeword/planning/design/code-philosophy-improvements.md +60 -0
  58. package/.safeword/planning/mcp-analysis.md +545 -0
  59. package/.safeword/planning/phase2-subagents-vs-skills-analysis.md +451 -0
  60. package/.safeword/planning/settings-improvements.md +970 -0
  61. package/.safeword/planning/test-definitions/005-cli-implementation.md +1301 -0
  62. package/.safeword/planning/test-definitions/cli-self-contained-templates.md +205 -0
  63. package/.safeword/planning/user-stories/001-guides-review-user-stories.md +1381 -0
  64. package/.safeword/planning/user-stories/003-reactive-fix-prevention.md +132 -0
  65. package/.safeword/planning/user-stories/004-technical-constraints.md +86 -0
  66. package/.safeword/planning/user-stories/005-cli-implementation.md +311 -0
  67. package/.safeword/planning/user-stories/cli-self-contained-templates.md +172 -0
  68. package/.safeword/planning/versioned-distribution.md +740 -0
  69. package/.safeword/prompts/arch-review.md +43 -0
  70. package/.safeword/prompts/quality-review.md +11 -0
  71. package/.safeword/scripts/arch-review.sh +235 -0
  72. package/.safeword/scripts/check-linting-sync.sh +58 -0
  73. package/.safeword/scripts/setup-linting.sh +559 -0
  74. package/.safeword/templates/architecture-template.md +136 -0
  75. package/.safeword/templates/ci/architecture-check.yml +79 -0
  76. package/.safeword/templates/design-doc-template.md +127 -0
  77. package/.safeword/templates/test-definitions-feature.md +100 -0
  78. package/.safeword/templates/ticket-template.md +74 -0
  79. package/.safeword/templates/user-stories-template.md +82 -0
  80. package/.safeword/tickets/001-guides-review-user-stories.md +83 -0
  81. package/.safeword/tickets/002-architecture-enforcement.md +211 -0
  82. package/.safeword/tickets/003-reactive-fix-prevention.md +57 -0
  83. package/.safeword/tickets/004-technical-constraints-in-user-stories.md +39 -0
  84. package/.safeword/tickets/005-cli-implementation.md +248 -0
  85. package/.safeword/tickets/006-flesh-out-skills.md +43 -0
  86. package/.safeword/tickets/007-flesh-out-questioning.md +44 -0
  87. package/.safeword/tickets/008-upgrade-questioning.md +58 -0
  88. package/.safeword/tickets/009-naming-conventions.md +41 -0
  89. package/.safeword/tickets/010-safeword-md-cleanup.md +34 -0
  90. package/.safeword/tickets/011-cursor-setup.md +86 -0
  91. package/.safeword/tickets/README.md +73 -0
  92. package/.safeword/version +1 -0
  93. package/AGENTS.md +59 -0
  94. package/CLAUDE.md +12 -0
  95. package/README.md +347 -0
  96. package/docs/001-cli-implementation-plan.md +856 -0
  97. package/docs/elite-dx-implementation-plan.md +1034 -0
  98. package/framework/README.md +131 -0
  99. package/framework/mcp/README.md +96 -0
  100. package/framework/mcp/arcade.sample.json +8 -0
  101. package/framework/mcp/context7.sample.json +6 -0
  102. package/framework/mcp/playwright.sample.json +6 -0
  103. package/framework/scripts/arch-review.sh +235 -0
  104. package/framework/scripts/check-linting-sync.sh +58 -0
  105. package/framework/scripts/load-env.sh +49 -0
  106. package/framework/scripts/setup-claude.sh +223 -0
  107. package/framework/scripts/setup-linting.sh +559 -0
  108. package/framework/scripts/setup-quality.sh +477 -0
  109. package/framework/scripts/setup-safeword.sh +550 -0
  110. package/framework/templates/ci/architecture-check.yml +78 -0
  111. package/learnings/ai-sdk-v5-breaking-changes.md +178 -0
  112. package/learnings/e2e-test-zombie-processes.md +231 -0
  113. package/learnings/milkdown-crepe-editor-property.md +96 -0
  114. package/learnings/prosemirror-fragment-traversal.md +119 -0
  115. package/package.json +19 -43
  116. package/packages/cli/AGENTS.md +1 -0
  117. package/packages/cli/ARCHITECTURE.md +279 -0
  118. package/packages/cli/package.json +51 -0
  119. package/packages/cli/src/cli.ts +63 -0
  120. package/packages/cli/src/commands/check.ts +166 -0
  121. package/packages/cli/src/commands/diff.ts +209 -0
  122. package/packages/cli/src/commands/reset.ts +190 -0
  123. package/packages/cli/src/commands/setup.ts +325 -0
  124. package/packages/cli/src/commands/upgrade.ts +163 -0
  125. package/packages/cli/src/index.ts +3 -0
  126. package/packages/cli/src/templates/config.ts +58 -0
  127. package/packages/cli/src/templates/content.ts +18 -0
  128. package/packages/cli/src/templates/index.ts +12 -0
  129. package/packages/cli/src/utils/agents-md.ts +66 -0
  130. package/packages/cli/src/utils/fs.ts +179 -0
  131. package/packages/cli/src/utils/git.ts +124 -0
  132. package/packages/cli/src/utils/hooks.ts +29 -0
  133. package/packages/cli/src/utils/output.ts +60 -0
  134. package/packages/cli/src/utils/project-detector.test.ts +185 -0
  135. package/packages/cli/src/utils/project-detector.ts +44 -0
  136. package/packages/cli/src/utils/version.ts +28 -0
  137. package/packages/cli/src/version.ts +6 -0
  138. package/packages/cli/templates/SAFEWORD.md +776 -0
  139. package/packages/cli/templates/doc-templates/architecture-template.md +136 -0
  140. package/packages/cli/templates/doc-templates/design-doc-template.md +134 -0
  141. package/packages/cli/templates/doc-templates/test-definitions-feature.md +131 -0
  142. package/packages/cli/templates/doc-templates/ticket-template.md +82 -0
  143. package/packages/cli/templates/doc-templates/user-stories-template.md +92 -0
  144. package/packages/cli/templates/guides/architecture-guide.md +423 -0
  145. package/packages/cli/templates/guides/code-philosophy.md +195 -0
  146. package/packages/cli/templates/guides/context-files-guide.md +457 -0
  147. package/packages/cli/templates/guides/data-architecture-guide.md +200 -0
  148. package/packages/cli/templates/guides/design-doc-guide.md +171 -0
  149. package/packages/cli/templates/guides/learning-extraction.md +552 -0
  150. package/packages/cli/templates/guides/llm-instruction-design.md +248 -0
  151. package/packages/cli/templates/guides/llm-prompting.md +102 -0
  152. package/packages/cli/templates/guides/tdd-best-practices.md +615 -0
  153. package/packages/cli/templates/guides/test-definitions-guide.md +334 -0
  154. package/packages/cli/templates/guides/testing-methodology.md +618 -0
  155. package/packages/cli/templates/guides/user-story-guide.md +256 -0
  156. package/packages/cli/templates/guides/zombie-process-cleanup.md +219 -0
  157. package/packages/cli/templates/hooks/agents-md-check.sh +27 -0
  158. package/packages/cli/templates/hooks/post-tool.sh +4 -0
  159. package/packages/cli/templates/hooks/pre-commit.sh +10 -0
  160. package/packages/cli/templates/prompts/arch-review.md +43 -0
  161. package/packages/cli/templates/prompts/quality-review.md +10 -0
  162. package/packages/cli/templates/skills/safeword-quality-reviewer/SKILL.md +207 -0
  163. package/packages/cli/tests/commands/check.test.ts +129 -0
  164. package/packages/cli/tests/commands/cli.test.ts +89 -0
  165. package/packages/cli/tests/commands/diff.test.ts +115 -0
  166. package/packages/cli/tests/commands/reset.test.ts +310 -0
  167. package/packages/cli/tests/commands/self-healing.test.ts +170 -0
  168. package/packages/cli/tests/commands/setup-blocking.test.ts +71 -0
  169. package/packages/cli/tests/commands/setup-core.test.ts +135 -0
  170. package/packages/cli/tests/commands/setup-git.test.ts +139 -0
  171. package/packages/cli/tests/commands/setup-hooks.test.ts +334 -0
  172. package/packages/cli/tests/commands/setup-linting.test.ts +189 -0
  173. package/packages/cli/tests/commands/setup-noninteractive.test.ts +80 -0
  174. package/packages/cli/tests/commands/setup-templates.test.ts +181 -0
  175. package/packages/cli/tests/commands/upgrade.test.ts +215 -0
  176. package/packages/cli/tests/helpers.ts +243 -0
  177. package/packages/cli/tests/npm-package.test.ts +83 -0
  178. package/packages/cli/tests/technical-constraints.test.ts +96 -0
  179. package/packages/cli/tsconfig.json +25 -0
  180. package/packages/cli/tsup.config.ts +11 -0
  181. package/packages/cli/vitest.config.ts +23 -0
  182. package/promptfoo.yaml +3270 -0
  183. package/dist/check-3NGQ4NR5.js +0 -129
  184. package/dist/check-3NGQ4NR5.js.map +0 -1
  185. package/dist/chunk-2XWIUEQK.js +0 -190
  186. package/dist/chunk-2XWIUEQK.js.map +0 -1
  187. package/dist/chunk-GZRQL3SX.js +0 -146
  188. package/dist/chunk-GZRQL3SX.js.map +0 -1
  189. package/dist/chunk-ORQHKDT2.js +0 -10
  190. package/dist/chunk-ORQHKDT2.js.map +0 -1
  191. package/dist/chunk-W66Z3C5H.js +0 -21
  192. package/dist/chunk-W66Z3C5H.js.map +0 -1
  193. package/dist/cli.d.ts +0 -1
  194. package/dist/cli.js +0 -34
  195. package/dist/cli.js.map +0 -1
  196. package/dist/diff-Y6QTAW4O.js +0 -166
  197. package/dist/diff-Y6QTAW4O.js.map +0 -1
  198. package/dist/index.d.ts +0 -11
  199. package/dist/index.js +0 -7
  200. package/dist/index.js.map +0 -1
  201. package/dist/reset-3ACTIYYE.js +0 -143
  202. package/dist/reset-3ACTIYYE.js.map +0 -1
  203. package/dist/setup-RR4M334C.js +0 -266
  204. package/dist/setup-RR4M334C.js.map +0 -1
  205. package/dist/upgrade-6AR3DHUV.js +0 -134
  206. package/dist/upgrade-6AR3DHUV.js.map +0 -1
  207. /package/{templates → framework}/SAFEWORD.md +0 -0
  208. /package/{templates → framework}/guides/architecture-guide.md +0 -0
  209. /package/{templates → framework}/guides/code-philosophy.md +0 -0
  210. /package/{templates → framework}/guides/context-files-guide.md +0 -0
  211. /package/{templates → framework}/guides/data-architecture-guide.md +0 -0
  212. /package/{templates → framework}/guides/design-doc-guide.md +0 -0
  213. /package/{templates → framework}/guides/learning-extraction.md +0 -0
  214. /package/{templates → framework}/guides/llm-instruction-design.md +0 -0
  215. /package/{templates → framework}/guides/llm-prompting.md +0 -0
  216. /package/{templates → framework}/guides/tdd-best-practices.md +0 -0
  217. /package/{templates → framework}/guides/test-definitions-guide.md +0 -0
  218. /package/{templates → framework}/guides/testing-methodology.md +0 -0
  219. /package/{templates → framework}/guides/user-story-guide.md +0 -0
  220. /package/{templates → framework}/guides/zombie-process-cleanup.md +0 -0
  221. /package/{templates → framework}/prompts/arch-review.md +0 -0
  222. /package/{templates → framework}/prompts/quality-review.md +0 -0
  223. /package/{templates/skills/safeword-quality-reviewer → framework/skills/quality-reviewer}/SKILL.md +0 -0
  224. /package/{templates/doc-templates → framework/templates}/architecture-template.md +0 -0
  225. /package/{templates/doc-templates → framework/templates}/design-doc-template.md +0 -0
  226. /package/{templates/doc-templates → framework/templates}/test-definitions-feature.md +0 -0
  227. /package/{templates/doc-templates → framework/templates}/ticket-template.md +0 -0
  228. /package/{templates/doc-templates → framework/templates}/user-stories-template.md +0 -0
  229. /package/{templates → packages/cli/templates}/commands/arch-review.md +0 -0
  230. /package/{templates → packages/cli/templates}/commands/lint.md +0 -0
  231. /package/{templates → packages/cli/templates}/commands/quality-review.md +0 -0
  232. /package/{templates → packages/cli/templates}/hooks/inject-timestamp.sh +0 -0
  233. /package/{templates → packages/cli/templates}/lib/common.sh +0 -0
  234. /package/{templates → packages/cli/templates}/lib/jq-fallback.sh +0 -0
  235. /package/{templates → packages/cli/templates}/markdownlint.jsonc +0 -0
@@ -0,0 +1,1225 @@
1
+ # Claude Code Automation Plan v2: Quality Control Workflow
2
+
3
+ ## THE GOAL
4
+
5
+ **Problem**: You type the same quality control prompt 347+ times across projects:
6
+
7
+ ```
8
+ "double check and critique your work again just in case.
9
+ is it correct? is it elegant? does it adhere to [plan/template]?
10
+ does it follow the latest best practices and documentation for [stack/domain]?
11
+ avoid bloat."
12
+ ```
13
+
14
+ **Goal**: Reduce this repetitive typing by 60-90% while maintaining quality standards.
15
+
16
+ **Solution**: 2-phase automation using Claude Code's built-in mechanisms (Slash Commands, Skills, Hooks).
17
+
18
+ **Success Criteria**:
19
+
20
+ - **Phase 1**: 60% reduction in prompt length (250 → 100 chars)
21
+ - **Phase 2**: 50-70% reduction in quality check prompts (15 → 4-8 per session)
22
+ - **Reality check**: Skills activate 50-70% of time, NOT 100% - manual fallback needed 30-50%
23
+
24
+ **Based on**: Analysis of 1,319 messages (soulless-monorepo) + 8,732 messages (bitd)
25
+
26
+ - 7% of soulless-monorepo prompts = quality control rituals
27
+ - 4% of bitd prompts = quality control rituals
28
+
29
+ **Updated**: 2025-10-31 - Meta-level critique: Removed 1,000+ lines of bloat, fixed contradictions, reduced from 29 automations to 5 core mechanisms
30
+
31
+ ---
32
+
33
+ ## 🚨 CRITICAL WARNINGS - READ FIRST
34
+
35
+ ### Warning 1: Hooks Broken in Current Versions
36
+
37
+ **AS OF 2025-10-30: All hooks silently fail in Claude Code v2.0.27 and v2.0.29**
38
+
39
+ **Check your version**:
40
+
41
+ ```bash
42
+ claude --version
43
+ ```
44
+
45
+ **Workaround** (required for Phase 2):
46
+
47
+ ```bash
48
+ # Launch with debug flag
49
+ claude --debug
50
+
51
+ # Or create alias
52
+ alias claude='claude --debug'
53
+ ```
54
+
55
+ **Test hooks work before Phase 2**:
56
+
57
+ ```bash
58
+ # Create test hook
59
+ mkdir -p ~/.claude/hooks
60
+ echo '#!/bin/bash' > ~/.claude/hooks/test.sh
61
+ echo 'echo "🎉 Hook fired!"' >> ~/.claude/hooks/test.sh
62
+ chmod +x ~/.claude/hooks/test.sh
63
+
64
+ # Add to settings.json
65
+ jq '.hooks.Stop = [{matcher: "*", hooks: [{type: "command", command: "~/.claude/hooks/test.sh"}]}]' ~/.claude/settings.json > tmp.json && mv tmp.json ~/.claude/settings.json
66
+
67
+ # Test
68
+ claude --debug
69
+ # (Ask Claude something, should see "🎉 Hook fired!" when it finishes)
70
+ ```
71
+
72
+ **Impact**: Phase 2 requires workaround or downgrade to v2.0.25. Phase 1 unaffected.
73
+
74
+ **Source**: [GitHub Issue #10399](https://github.com/anthropics/claude-code/issues/10399)
75
+
76
+ ---
77
+
78
+ ### Warning 2: Skills Don't Activate Reliably
79
+
80
+ **Reality**: Skills activation rate = 30-70% typical, NOT 100%
81
+
82
+ **What this means**:
83
+
84
+ - ❌ You CANNOT eliminate 100% of quality check prompts
85
+ - ✅ You CAN reduce by 50-70% (still need manual checks 30-50% of time)
86
+
87
+ **Why Skills fail to activate**:
88
+
89
+ - Vague descriptions (Claude doesn't know when to use them)
90
+ - Missing trigger keywords (no pattern matching)
91
+ - Description >1024 chars (reduces reliability)
92
+ - Unpredictable behavior (works perfectly for days, then stops)
93
+
94
+ **Mitigation**: Always provide Slash Command alternatives for manual invocation when Skills don't fire.
95
+
96
+ **Community quote**: "The #1 problem with Claude Code skills is they don't activate on their own. They just sit there and you have to remember to use them."
97
+
98
+ **Success metrics adjusted accordingly** - See Phase 2 section.
99
+
100
+ ---
101
+
102
+ ## Recommended Approach: 2 Phases
103
+
104
+ | Phase | Mechanisms | Impact | Effort | Status |
105
+ | ----------- | -------------------------- | -------------------- | --------- | -------------------------- |
106
+ | **Phase 1** | Slash Commands + CLAUDE.md | 60% prompt reduction | 30 min | ⭐ START HERE |
107
+ | **Phase 2** | 2-3 Skills + 1-2 Hooks | 50-70% automation | 2-3 hours | ⭐ IF PHASE 1 INSUFFICIENT |
108
+
109
+ **Why 2 phases, not 5**:
110
+
111
+ - Test Phase 1 for 1 week before building Phase 2
112
+ - Iterate based on real usage patterns
113
+ - Avoid over-engineering (automation anti-pattern)
114
+
115
+ **Why NOT more**:
116
+
117
+ - ❌ Subagents: Too slow (context switching), lack conversation history
118
+ - ❌ MCP Servers: External dependencies, cost, no conversation context
119
+ - ❌ Plugin Distribution: Premature - test locally first
120
+
121
+ ---
122
+
123
+ ## Phase 1: Slash Commands + CLAUDE.md (START HERE)
124
+
125
+ **Goal**: Immediate 60% reduction in repetitive prompts
126
+
127
+ **Effort**: 30 minutes
128
+
129
+ **Impact**: Replaces 250-char prompt with 10-char command
130
+
131
+ **Pros**:
132
+
133
+ - ✅ Works immediately (no complex setup)
134
+ - ✅ Easy to test and iterate
135
+ - ✅ No risk of automation misbehaving
136
+ - ✅ Foundation for Phase 2
137
+
138
+ **Cons**:
139
+
140
+ - ❌ Still requires manual invocation (not automatic)
141
+
142
+ ---
143
+
144
+ ### 1.1: Slash Commands (20 min)
145
+
146
+ Create in `~/.claude/commands/`:
147
+
148
+ #### Command 1: `/critique` (PRIMARY)
149
+
150
+ **File**: `~/.claude/commands/critique.md`
151
+
152
+ ```markdown
153
+ ---
154
+ description: Run quality critique on current work
155
+ ---
156
+
157
+ Double check and critique your work again just in case.
158
+
159
+ Evaluate against these criteria:
160
+
161
+ 1. **Correctness**
162
+ - Will it actually work?
163
+ - Edge cases handled?
164
+ - Error handling complete?
165
+
166
+ 2. **Elegance**
167
+ - Simplest solution possible?
168
+ - Any bloat or over-engineering?
169
+ - Readable and maintainable?
170
+
171
+ 3. **Standards Adherence**
172
+ - Follows project CLAUDE.md conventions?
173
+ - Matches existing code patterns?
174
+ - Latest best practices for: $ARGUMENTS
175
+
176
+ 4. **Testing**
177
+ - Can we test this?
178
+ - Test strategy clear?
179
+
180
+ Ask any non-obvious questions you need answered that you can't research yourself online or in the codebase. Don't be lazy.
181
+
182
+ Provide your critique, then wait for approval before implementing.
183
+ ```
184
+
185
+ **Usage**:
186
+
187
+ - `/critique react typescript blades`
188
+ - `/critique electron desktop-app`
189
+
190
+ ---
191
+
192
+ #### Command 2: `/latest-docs` (DOCUMENTATION LOOKUP)
193
+
194
+ **File**: `~/.claude/commands/latest-docs.md`
195
+
196
+ ```markdown
197
+ ---
198
+ description: Look up latest documentation before proceeding
199
+ ---
200
+
201
+ Before proceeding, look up the very latest documentation for: $ARGUMENTS
202
+
203
+ For each library/framework, verify:
204
+
205
+ - API compatibility with our version (check package.json)
206
+ - Best practices haven't changed since your training data
207
+ - No deprecated patterns in our current approach
208
+ - New features that might be better
209
+
210
+ Then provide your findings and continue with your recommendation.
211
+ ```
212
+
213
+ **Usage**:
214
+
215
+ - `/latest-docs @anthropic/sdk react-19`
216
+ - `/latest-docs playwright zustand`
217
+
218
+ ---
219
+
220
+ #### Command 3: `/check-and-proceed` (ONE-SHOT)
221
+
222
+ **File**: `~/.claude/commands/check-and-proceed.md`
223
+
224
+ ```markdown
225
+ ---
226
+ description: Quality check then immediate implementation
227
+ ---
228
+
229
+ Run full quality verification, then implement if passing:
230
+
231
+ **STEP 1: Quality Check**
232
+
233
+ - Correct? Elegant? Standards-compliant?
234
+ - Latest docs verified?
235
+ - Tests planned?
236
+ - Bloat avoided?
237
+
238
+ **STEP 2: If all checks pass**
239
+
240
+ - Implement immediately (approval implicit)
241
+ - Run tests
242
+ - Report results
243
+
244
+ **STEP 3: If issues found**
245
+
246
+ - List concerns
247
+ - Wait for user guidance
248
+
249
+ This is a "one-shot" command - check thoroughly, then proceed automatically if confident.
250
+ ```
251
+
252
+ **Usage**: `/check-and-proceed` (combines critique + approval + implementation)
253
+
254
+ ---
255
+
256
+ ### 1.2: Enhanced CLAUDE.md (10 min)
257
+
258
+ Add to `~/.claude/CLAUDE.md`:
259
+
260
+ ```markdown
261
+ ## Quality Standards (CRITICAL - Always Follow)
262
+
263
+ ### 0. Explore → Plan → Code Workflow
264
+
265
+ **Before ANY code changes:**
266
+
267
+ **EXPLORE FIRST:**
268
+
269
+ 1. Read relevant existing files (do NOT write code yet)
270
+ 2. Understand current patterns and architecture
271
+ 3. Identify what needs to change
272
+
273
+ **THEN PLAN:** 4. Create implementation plan 5. Get user approval on plan
274
+
275
+ **THEN CODE:** 6. Implement with verification steps 7. Run tests 8. Report results
276
+
277
+ **When to skip**: Trivial changes (typos, formatting) or user says "just do it"
278
+
279
+ ---
280
+
281
+ ### 1. Latest Documentation Check
282
+
283
+ NEVER assume API compatibility. Training cutoff: January 2025.
284
+
285
+ **Process**:
286
+
287
+ - Identify libraries/frameworks used
288
+ - Check package.json for versions
289
+ - Look up latest docs (WebFetch/WebSearch)
290
+ - Verify API still works as expected
291
+ - Note deprecated patterns
292
+ - Report findings before proposing
293
+
294
+ ---
295
+
296
+ ### 2. Self-Critique Against Quality Criteria
297
+
298
+ Every proposal must pass:
299
+
300
+ **Correctness**: Works? Edge cases? Errors? Type-safe?
301
+
302
+ **Elegance**: Simplest solution? Any bloat? Readable?
303
+
304
+ **Standards**: Matches CLAUDE.md? Follows patterns? File organization?
305
+
306
+ **Testability**: Can write tests? Strategy clear?
307
+
308
+ ---
309
+
310
+ ### 3. Output Format for Proposals
311
+ ```
312
+
313
+ PROPOSAL:
314
+ [What you want to implement]
315
+
316
+ QUALITY CHECK:
317
+ ✓ Latest docs verified: [libraries checked]
318
+ ✓ Correct: [reasoning - edge cases, errors]
319
+ ✓ Elegant: [why this approach, not simpler]
320
+ ✓ Standards: [how it matches conventions]
321
+ ✓ Testable: [testing strategy]
322
+
323
+ CONCERNS (if any):
324
+ ⚠️ [Trade-offs, limitations, uncertainties]
325
+
326
+ READY FOR APPROVAL
327
+ (Awaiting "yes"/"proceed"/"implement" to execute)
328
+
329
+ ```
330
+
331
+ ---
332
+
333
+ ### 4. When User Approves
334
+
335
+ When user says "yes"/"proceed"/"implement":
336
+ 1. ✓ Execute immediately (approval given)
337
+ 2. ✓ Run relevant tests after implementation
338
+ 3. ✓ Report test results
339
+ 4. ✓ Only then mark complete
340
+
341
+ Do not ask for approval again or skip tests.
342
+
343
+ ---
344
+
345
+ ### 5. Non-Obvious Questions Only
346
+
347
+ **Ask user ONLY if**:
348
+ - Multiple valid approaches with unclear trade-offs
349
+ - Domain knowledge required (business rules, UX preferences)
350
+ - Breaking changes need approval
351
+ - Can't find answer after thorough search
352
+
353
+ **DO NOT ask**:
354
+ - Questions in official docs → Look them up
355
+ - Implementation details → Figure them out
356
+ - Preferences in CLAUDE.md → Read it
357
+ - Standard practices → Research best practices
358
+
359
+ **Remember**: "Don't be lazy" - research first, ask when stuck.
360
+
361
+ ---
362
+
363
+ ### 6. Avoid Bloat
364
+
365
+ **Red flags**:
366
+ - Adding dependencies when stdlib sufficient
367
+ - Over-abstraction (framework for 1 use case)
368
+ - Premature optimization (no performance issue)
369
+ - Duplicating existing functionality
370
+
371
+ **Principle**: Simplest solution that solves the problem.
372
+
373
+ ---
374
+
375
+ ### 7. Context Management
376
+
377
+ **Critical**: Use `/clear` frequently to prevent "dumber after compaction" issue.
378
+
379
+ **When to use /clear**:
380
+ - ✓ After completing a task (before starting next)
381
+ - ✓ When switching topics/features
382
+ - ✓ When conversation feels unfocused
383
+
384
+ **When NOT to use /clear**:
385
+ - ✗ In middle of multi-step task
386
+ - ✗ During active debugging
387
+
388
+ ---
389
+
390
+ ### 8. Testing Standards
391
+
392
+ **After any code changes**:
393
+ - Run existing test suite
394
+ - Report results before completion
395
+ - If tests fail: fix them (don't ask user)
396
+
397
+ For TDD workflow: See `@./.safeword/guides/testing-methodology.md`
398
+ ```
399
+
400
+ ---
401
+
402
+ ### Phase 1 Testing
403
+
404
+ **Test in both projects** (soulless-monorepo, bitd):
405
+
406
+ 1. Make small change proposal
407
+ 2. Type `/critique [stack]`
408
+ 3. Verify comprehensive review appears
409
+ 4. Type `/check-and-proceed`
410
+ 5. Verify one-shot execution
411
+
412
+ **Pass criteria**:
413
+
414
+ - Commands work reliably
415
+ - Save typing (250 → 10 chars)
416
+ - Maintain quality
417
+
418
+ **Measure after 1 week**:
419
+
420
+ - How often do you use slash commands?
421
+ - Is prompt length reduced?
422
+ - Is quality maintained?
423
+
424
+ **Then decide**: Is Phase 2 needed, or is this sufficient?
425
+
426
+ ---
427
+
428
+ ## Phase 2: Skills + Hooks (IF PHASE 1 INSUFFICIENT)
429
+
430
+ **⚠️ Prerequisites**:
431
+
432
+ - ✓ Phase 1 tested for 1 week
433
+ - ✓ Phase 1 proves insufficient (still too much manual work)
434
+ - ✓ Hooks verified working (see Critical Warning above)
435
+
436
+ **Goal**: 50-70% reduction in quality check prompts (NOT 100% - see Warning 2)
437
+
438
+ **Effort**: 2-3 hours
439
+
440
+ **Impact**: Auto-invoked checks (when Skills activate) + post-code validation
441
+
442
+ **Reality check**:
443
+
444
+ - Skills activate 50-70% of time
445
+ - Manual fallback needed 30-50% (use slash commands)
446
+ - Description tuning requires iteration
447
+
448
+ ---
449
+
450
+ ### 2.1: Recommended Skills (Choose 1-2)
451
+
452
+ **Option A: Single Quality Reviewer Skill** (simpler, broader scope)
453
+
454
+ **Option B: Split into 2-3 Focused Skills** (narrower, more reliable activation)
455
+
456
+ - Docs Verifier Skill
457
+ - Standards Checker Skill
458
+ - Quality Gates Skill
459
+
460
+ **Anthropic 2025 guidance**: "Keep Skills lean" - prefer Option B
461
+
462
+ ---
463
+
464
+ ### Skill 1: Docs Verifier (45 min)
465
+
466
+ **File**: `~/.claude/skills/docs-verifier/SKILL.md`
467
+
468
+ ````yaml
469
+ ---
470
+ name: docs-verifier
471
+ description: |
472
+ Check latest documentation before proposing code changes.
473
+
474
+ Use PROACTIVELY when:
475
+ - About to propose implementation using external libraries
476
+ - User mentions library/framework names
477
+ - Writing code that calls external APIs
478
+
479
+ DO NOT use for:
480
+ - Standard library features (Array.map, Promise, console.log)
481
+ - Reading/exploring code without proposing changes
482
+
483
+ Process:
484
+ 1. Read package.json for versions
485
+ 2. WebSearch "[library] v[version] documentation"
486
+ 3. Check for deprecated APIs
487
+ 4. Return: VERIFIED / DEPRECATED / VERSION_MISMATCH
488
+
489
+ Returns structured output (not narrative explanation).
490
+
491
+ allowed-tools: Read, WebFetch, WebSearch
492
+ ---
493
+
494
+ # Documentation Verification Protocol
495
+
496
+ ## Step 1: Detect Stack
497
+
498
+ Read `package.json` to extract:
499
+ - Library names
500
+ - Version numbers (exact versions installed)
501
+
502
+ Example:
503
+ ```json
504
+ {
505
+ "dependencies": {
506
+ "react": "18.3.1",
507
+ "vitest": "^2.1.3"
508
+ }
509
+ }
510
+ ````
511
+
512
+ ## Step 2: Build Version-Specific Searches
513
+
514
+ For each library:
515
+
516
+ - Search: "[library] v[version] documentation"
517
+ - Example: "react v18.3 documentation"
518
+ - Prefer official docs (.dev, .io, .org, GitHub official)
519
+ - Check /latest/ or /stable/ URL paths (auto-redirect to current)
520
+
521
+ ## Step 3: Check for Deprecated Patterns
522
+
523
+ Search: "[library] deprecated [version]"
524
+
525
+ - Example: "react deprecated 18.3"
526
+ - Look for migration guides
527
+ - Note breaking changes
528
+
529
+ ## Step 4: Return Structured Output
530
+
531
+ ```
532
+ DOCS VERIFICATION:
533
+ ✓ react v18.3.1 - API unchanged, no deprecations
534
+ ⚠️ electron v32 - ipcRenderer.sendSync deprecated, use invoke
535
+ ✗ zustand v4 - Project uses v3, docs for v4 (version mismatch)
536
+
537
+ RECOMMENDATION: [PROCEED / UPDATE_LIBRARY / FIX_DEPRECATED]
538
+ ```
539
+
540
+ ## Edge Cases
541
+
542
+ **No package.json**: Search "[library] latest documentation" (omit version)
543
+
544
+ **Monorepo**: Check package.json in nearest parent directory or specific package
545
+
546
+ **Version mismatch**: Warn if docs are for newer/older version than installed
547
+
548
+ ```
549
+
550
+ **Activation test**:
551
+ ```
552
+
553
+ You: "Let's add a new feature using react hooks"
554
+ Expected: Docs Verifier Skill activates, checks react docs
555
+
556
+ ````
557
+
558
+ ---
559
+
560
+ ### Skill 2: Quality Gates (45 min)
561
+
562
+ **File**: `~/.claude/skills/quality-gates/SKILL.md`
563
+
564
+ ```yaml
565
+ ---
566
+ name: quality-gates
567
+ description: |
568
+ Final review before Write/Edit tools for TypeScript/JavaScript files.
569
+
570
+ Use when Claude is ABOUT TO:
571
+ - Write new .ts/.tsx/.js/.jsx files
572
+ - Edit existing source files (not config/markdown)
573
+ - User approves implementation ("yes", "proceed", "implement")
574
+
575
+ DO NOT use for:
576
+ - Reading files without proposing changes
577
+ - Config files (package.json, tsconfig.json)
578
+ - Documentation (*.md, *.txt)
579
+
580
+ Checks:
581
+ - Edge cases handled (null, undefined, empty)
582
+ - Avoids bloat (simplest solution)
583
+ - Follows project patterns (read CLAUDE.md)
584
+
585
+ Returns: PROCEED / REVISE / USER_INPUT
586
+
587
+ allowed-tools: Read, Grep, Glob
588
+ ---
589
+
590
+ # Quality Gates Protocol
591
+
592
+ ## Step 1: Identify Proposed Changes
593
+
594
+ Extract from conversation:
595
+ - Files to be created/modified
596
+ - Code being added/changed
597
+ - Libraries/frameworks involved
598
+
599
+ ## Step 2: Edge Case Check
600
+
601
+ **Common edge cases**:
602
+ - Null/undefined inputs
603
+ - Empty arrays/objects/strings
604
+ - Boundary values (0, -1, MAX_INT)
605
+ - Async errors (network failures, timeouts)
606
+ - Race conditions (concurrent access)
607
+
608
+ **Check**: Does proposed code handle these?
609
+
610
+ ## Step 3: Bloat Check
611
+
612
+ **Red flags**:
613
+ - Adding dependency when stdlib sufficient
614
+ - Over-abstraction (class for single function)
615
+ - Premature optimization (no benchmark)
616
+ - Duplicating existing code
617
+
618
+ **Check**: Is this the simplest solution?
619
+
620
+ ## Step 4: Standards Check
621
+
622
+ **Read project CLAUDE.md**:
623
+ - File organization rules
624
+ - Naming conventions
625
+ - Coding patterns
626
+ - Project-specific gotchas
627
+
628
+ **Check**: Does proposed code follow these?
629
+
630
+ ## Step 5: Return Recommendation
631
+
632
+ ````
633
+
634
+ QUALITY GATES:
635
+ ✓ Edge cases: Handles null, empty, errors
636
+ ✓ Bloat: Uses existing utility, no new deps
637
+ ✓ Standards: Follows naming convention (camelCase)
638
+
639
+ RECOMMENDATION: PROCEED
640
+
641
+ ```
642
+
643
+ Or:
644
+
645
+ ```
646
+
647
+ QUALITY GATES:
648
+ ✗ Edge cases: Missing null check on user.profile
649
+ ⚠️ Bloat: Adding lodash just for \_.isEmpty (use !obj or Object.keys)
650
+ ✓ Standards: OK
651
+
652
+ RECOMMENDATION: REVISE
653
+
654
+ - Add null check: if (!user?.profile) return null
655
+ - Replace lodash with: Object.keys(obj).length === 0
656
+
657
+ ```
658
+
659
+ Or:
660
+
661
+ ```
662
+
663
+ QUALITY GATES:
664
+ ? Standards: Unclear if services/ or lib/ directory for this utility
665
+
666
+ RECOMMENDATION: USER_INPUT
667
+ Ask user: "Should I put this utility in services/ or lib/?"
668
+
669
+ ```
670
+
671
+ ```
672
+
673
+ **Activation test**:
674
+
675
+ ```
676
+ You: "Let's implement the login handler"
677
+ Claude: [Quality Gates Skill activates]
678
+ Claude: [Checks edge cases, bloat, standards]
679
+ Claude: "RECOMMENDATION: PROCEED" or "RECOMMENDATION: REVISE"
680
+ You: "yes" (if PROCEED)
681
+ Claude: [Implements]
682
+ ```
683
+
684
+ ---
685
+
686
+ ### Skill 3: Feature Kickoff (OPTIONAL, 1 hour)
687
+
688
+ **File**: `~/.claude/skills/feature-kickoff/SKILL.md`
689
+
690
+ ````yaml
691
+ ---
692
+ name: feature-kickoff
693
+ description: |
694
+ Auto-find user stories, test definitions, and design docs when starting features.
695
+
696
+ Use when user says:
697
+ - "implement feature X"
698
+ - "work on issue #N"
699
+ - "start on [feature name]"
700
+ - "add [feature]"
701
+
702
+ Searches for:
703
+ - planning/user-stories/ or docs/user-stories/
704
+ - planning/test-definitions/ or docs/test-definitions/
705
+ - planning/design/ or docs/design/ (if feature is complex)
706
+
707
+ Returns: FOUND / NOT_FOUND / CREATE_SUGGESTED
708
+
709
+ allowed-tools: Glob, Grep, Read
710
+ ---
711
+
712
+ # Feature Kickoff Protocol
713
+
714
+ ## Step 1: Detect Feature Context
715
+
716
+ **Extract from user message**:
717
+ - Feature name (e.g., "dark mode toggle")
718
+ - Issue number (e.g., "#123")
719
+ - Keywords (e.g., "authentication", "payment")
720
+
721
+ ## Step 2: Search for Planning Docs
722
+
723
+ **User Stories**:
724
+ ```bash
725
+ # Search patterns
726
+ planning/user-stories/*[feature]*.md
727
+ docs/user-stories/*[feature]*.md
728
+ user-stories/*[feature]*.md
729
+ ````
730
+
731
+ **Test Definitions**:
732
+
733
+ ```bash
734
+ # Search patterns
735
+ planning/test-definitions/*[feature]*.md
736
+ docs/test-definitions/*[feature]*.md
737
+ test-definitions/*[feature]*.md
738
+ ```
739
+
740
+ **Design Docs** (complex features only):
741
+
742
+ ```bash
743
+ # Search patterns
744
+ planning/design/*[feature]*.md
745
+ docs/design/*[feature]*.md
746
+ design/*[feature]*.md
747
+ ```
748
+
749
+ ## Step 3: Return Results
750
+
751
+ ```
752
+ FEATURE KICKOFF: [feature name]
753
+
754
+ ✓ User stories found: planning/user-stories/dark-mode.md
755
+ ✓ Test definitions found: planning/test-definitions/dark-mode-tests.md
756
+ ✗ Design doc: Not found
757
+
758
+ RECOMMENDATION: Read user stories and test definitions, proceed with TDD workflow.
759
+ ```
760
+
761
+ Or:
762
+
763
+ ```
764
+ FEATURE KICKOFF: [feature name]
765
+
766
+ ✗ User stories: Not found
767
+ ✗ Test definitions: Not found
768
+ ✗ Design doc: Not found
769
+
770
+ RECOMMENDATION: CREATE_SUGGESTED
771
+ Ask user: "Should I create user stories and test definitions for this feature?"
772
+ ```
773
+
774
+ ```
775
+
776
+ **Activation test**:
777
+ ```
778
+
779
+ You: "Let's implement the dark mode toggle feature"
780
+ Expected: Feature Kickoff Skill activates, searches for docs
781
+
782
+ ````
783
+
784
+ ---
785
+
786
+ ### Skills: Common Mistakes & Fixes
787
+
788
+ | Mistake | Symptom | Fix | Verify |
789
+ |---------|---------|-----|--------|
790
+ | Invalid YAML | Skill doesn't load | Run `yamllint` | `yamllint SKILL.md` |
791
+ | Description >1024 chars | Low activation rate | Count chars, move to examples.md | `grep -A 50 "description:" \| wc -c` |
792
+ | No trigger keywords | Never activates | Add user vocab keywords (file paths, action verbs) | Test with trigger phrases |
793
+ | Name invalid format | Skill doesn't load | Lowercase, hyphens only, ≤64 chars | `echo -n "name" \| wc -c` |
794
+ | Vague description | Inconsistent activation | Add specific "Use when" bullets | Track activation rate |
795
+
796
+ **Testing protocol**:
797
+ 1. **Positive test** (should activate): Say trigger phrase → Verify Skill invoked
798
+ 2. **Negative test** (should NOT activate): Say unrelated phrase → Verify Skill NOT invoked
799
+ 3. **Iterate descriptions**: Track false positives/negatives, refine weekly
800
+
801
+ ---
802
+
803
+ ### Skills: Activation Reality & Mitigation
804
+
805
+ **Set realistic expectations**:
806
+ - ✅ Skills MAY activate 50-70% of time (not 100%)
807
+ - ❌ Skills MAY NOT activate even with perfect description
808
+ - ⚠️ No way to force activation - Claude decides autonomously
809
+ - 🔄 Description tuning is trial-and-error, requires iteration
810
+
811
+ **Mitigation strategies**:
812
+
813
+ **1. Always provide slash command alternatives**
814
+
815
+ | Skill | Slash Command Alternative | Use When |
816
+ |-------|--------------------------|----------|
817
+ | Docs Verifier | `/latest-docs [library]` | Skill doesn't activate |
818
+ | Quality Gates | `/critique` | Need to force quality check |
819
+ | Feature Kickoff | Manual search | Skill doesn't find docs |
820
+
821
+ **2. Track activation rate weekly**
822
+
823
+ ```bash
824
+ # Create activation log
825
+ ~/.claude/skills/activation-log.txt
826
+
827
+ # Format: Date | Skill | Activated (Y/N) | Expected (Y/N)
828
+ 2025-10-31 | docs-verifier | N | Y
829
+ 2025-10-31 | quality-gates | Y | Y
830
+ 2025-10-31 | docs-verifier | Y | Y
831
+
832
+ # After 1 week, calculate rate
833
+ grep docs-verifier ~/.claude/skills/activation-log.txt | \
834
+ awk '{total++; if($4=="Y" && $6=="Y") correct++} END {print "Rate:", correct/total*100"%"}'
835
+ ````
836
+
837
+ **3. Iterate descriptions based on real usage**
838
+
839
+ **Week 1**: Deploy with initial description
840
+ **Week 2**: Review log, identify false negatives
841
+ **Week 3**: Add missed trigger keywords to description
842
+ **Week 4**: Re-test and measure improvement
843
+
844
+ **Example iteration**:
845
+
846
+ ```yaml
847
+ # v1 (40% activation)
848
+ description: "Review code before Write/Edit"
849
+
850
+ # v2 (60% activation) - Added triggers
851
+ description: "Review code before Write/Edit. Use when proposing changes, user says 'implement', 'fix', 'add', 'yes'."
852
+
853
+ # v3 (70% activation) - Added file patterns
854
+ description: "Review .ts/.tsx/.js/.jsx code before Write/Edit. Use when proposing changes, user says 'implement', 'fix', 'add', 'yes'."
855
+ ```
856
+
857
+ **4. Document manual fallback**
858
+
859
+ Add to project CLAUDE.md:
860
+
861
+ ```markdown
862
+ ## When Skills Don't Activate
863
+
864
+ If Quality Gates Skill doesn't activate:
865
+
866
+ - Type: `/critique [stack]`
867
+ - Or say: "use the quality-gates skill"
868
+ - Or manual: "double check: correct? elegant? standards?"
869
+ ```
870
+
871
+ ---
872
+
873
+ ### 2.2: PostToolUse Hook (30 min)
874
+
875
+ **⚠️ Requires**: Hooks working (see Critical Warning above)
876
+
877
+ **What**: Auto-run linters/tests after every Write/Edit
878
+
879
+ **File**: Add to `~/.claude/settings.json`
880
+
881
+ ```json
882
+ {
883
+ "hooks": {
884
+ "PostToolUse": [
885
+ {
886
+ "matcher": "Write",
887
+ "hooks": [
888
+ {
889
+ "type": "command",
890
+ "command": "bash -c 'echo \"🔍 Validating...\"; npm run lint 2>&1 | tail -5 || true; [ -f tsconfig.json ] && npx tsc --noEmit 2>&1 | tail -10 || true; echo \"✅ Complete\"'"
891
+ }
892
+ ]
893
+ },
894
+ {
895
+ "matcher": "Edit",
896
+ "hooks": [
897
+ {
898
+ "type": "command",
899
+ "command": "bash -c 'echo \"🔍 Validating...\"; npm run lint 2>&1 | tail -5 || true; [ -f tsconfig.json ] && npx tsc --noEmit 2>&1 | tail -10 || true; echo \"✅ Complete\"'"
900
+ }
901
+ ]
902
+ }
903
+ ]
904
+ }
905
+ }
906
+ ```
907
+
908
+ **How it works**:
909
+
910
+ 1. Claude uses Write or Edit tool
911
+ 2. Hook fires automatically
912
+ 3. Runs linter + type checker
913
+ 4. Output shown to Claude
914
+ 5. Claude responds to results
915
+
916
+ **Environment variables available**:
917
+
918
+ - `$CLAUDE_TOOL_NAME` - Tool used (Write, Edit)
919
+ - `$CLAUDE_FILE_PATHS` - Space-separated modified files
920
+ - `$CLAUDE_PROJECT_DIR` - Absolute path to project
921
+
922
+ **Pros**:
923
+
924
+ - ✅ Deterministic (always runs after Write/Edit)
925
+ - ✅ Immediate feedback
926
+ - ✅ Integrates existing tooling (npm scripts)
927
+
928
+ **Cons**:
929
+
930
+ - ❌ Tool already executed (can't block, only validate)
931
+ - ❌ May slow iteration if linters are slow
932
+ - ❌ Broken in v2.0.27/v2.0.29 without workaround
933
+
934
+ ---
935
+
936
+ ### 2.3: SessionStart Hook (OPTIONAL, 20 min)
937
+
938
+ **What**: Load quality standards at session start
939
+
940
+ **File**: Create `~/.claude/hooks/session-start.sh`
941
+
942
+ ```bash
943
+ #!/bin/bash
944
+
945
+ echo "🚀 Session started: $CLAUDE_PROJECT_DIR"
946
+ echo ""
947
+
948
+ # Load project CLAUDE.md (first 30 lines)
949
+ if [ -f "$CLAUDE_PROJECT_DIR/.claude/CLAUDE.md" ]; then
950
+ echo "📋 Project Guidelines:"
951
+ head -30 "$CLAUDE_PROJECT_DIR/.claude/CLAUDE.md"
952
+ echo ""
953
+ fi
954
+
955
+ # Set project env vars
956
+ echo "export PROJECT_ROOT=$CLAUDE_PROJECT_DIR" >> "$CLAUDE_ENV_FILE"
957
+
958
+ # Check for uncommitted changes
959
+ cd "$CLAUDE_PROJECT_DIR"
960
+ if ! git diff --quiet 2>/dev/null; then
961
+ echo "⚠️ Warning: Uncommitted changes detected"
962
+ fi
963
+ ```
964
+
965
+ **Make executable**:
966
+
967
+ ```bash
968
+ chmod +x ~/.claude/hooks/session-start.sh
969
+ ```
970
+
971
+ **Register in settings.json**:
972
+
973
+ ```json
974
+ {
975
+ "hooks": {
976
+ "SessionStart": [
977
+ {
978
+ "matcher": "*",
979
+ "hooks": [
980
+ {
981
+ "type": "command",
982
+ "command": "~/.claude/hooks/session-start.sh"
983
+ }
984
+ ]
985
+ }
986
+ ]
987
+ }
988
+ }
989
+ ```
990
+
991
+ **Pros**:
992
+
993
+ - ✅ Loads context automatically
994
+ - ✅ Sets up environment consistently
995
+ - ✅ Runs once per session (not repeatedly)
996
+
997
+ **Cons**:
998
+
999
+ - ❌ Adds to initial context (uses tokens)
1000
+ - ❌ Broken in v2.0.27/v2.0.29 without workaround
1001
+
1002
+ ---
1003
+
1004
+ ### 2.4: Stop Hook for Context Management (OPTIONAL, 10 min)
1005
+
1006
+ **What**: Reminds to `/clear` context after tasks
1007
+
1008
+ **File**: Add to `~/.claude/settings.json`
1009
+
1010
+ ```json
1011
+ {
1012
+ "hooks": {
1013
+ "Stop": [
1014
+ {
1015
+ "matcher": "*",
1016
+ "hooks": [
1017
+ {
1018
+ "type": "command",
1019
+ "command": "echo '💡 Task complete. Consider: /clear before next task (prevents context pollution)'"
1020
+ }
1021
+ ]
1022
+ }
1023
+ ]
1024
+ }
1025
+ }
1026
+ ```
1027
+
1028
+ **Pros**:
1029
+
1030
+ - ✅ Prevents "dumber after compaction" issue
1031
+ - ✅ Non-invasive (suggestion, not manipulation)
1032
+ - ✅ No context bloat
1033
+
1034
+ **Cons**:
1035
+
1036
+ - ❌ User must manually type `/clear`
1037
+ - ❌ May be repetitive if working on single task
1038
+
1039
+ ---
1040
+
1041
+ ### Phase 2 Testing
1042
+
1043
+ **After implementing Skills + Hooks**:
1044
+
1045
+ **Skills testing**:
1046
+
1047
+ 1. Propose code change → Verify Skill activates
1048
+ 2. Answer question (no code) → Verify Skill does NOT activate
1049
+ 3. Track activation rate for 1 week
1050
+
1051
+ **Hooks testing**:
1052
+
1053
+ 1. Make code change → Verify linter runs automatically
1054
+ 2. Check Claude responds to linter results
1055
+ 3. Verify tests run (if configured)
1056
+
1057
+ **Pass criteria**:
1058
+
1059
+ - Skills activate 50-70% of time (track in log)
1060
+ - Slash commands provide smooth fallback for missed activations
1061
+ - Hooks run reliably (if working in your version)
1062
+ - Quality maintained or improved
1063
+
1064
+ **Measure after 1-2 weeks**:
1065
+
1066
+ - Quality check prompts reduced by 50-70%?
1067
+ - Skills activation trending up week-over-week?
1068
+ - Manual fallback workflow feels natural (not frustrating)?
1069
+
1070
+ ---
1071
+
1072
+ ## Success Metrics (Realistic Targets)
1073
+
1074
+ **⚠️ Updated based on Skills 50-70% activation rate**
1075
+
1076
+ ### Quantitative Targets
1077
+
1078
+ | Metric | Before | Phase 1 Target | Phase 2 Target |
1079
+ | --------------------------------- | ------ | -------------- | -------------- |
1080
+ | Avg prompt length (chars) | 250 | 150 (-40%) | 100 (-60%) |
1081
+ | Quality check prompts per session | 15 | 6 (-60%) | 4-8 (-50-70%) |
1082
+ | Time to implementation (min) | 10 | 7 (-30%) | 5-6 (-40-50%) |
1083
+ | Docs lookup prompts | 8 | 3 (-62%) | 1-3 (-62-87%) |
1084
+ | **Skills activation rate** | N/A | N/A | **50-70%** |
1085
+ | **Manual fallback needed** | N/A | N/A | **30-50%** |
1086
+
1087
+ **Key changes from original plan**:
1088
+
1089
+ - ❌ Removed "0 (-100%)" targets - unrealistic
1090
+ - ✅ Added ranges reflecting 50-70% automation success
1091
+ - ✅ Added Skills activation tracking (critical metric)
1092
+ - ✅ Accept 30-50% manual fallback as success
1093
+
1094
+ ### Qualitative Goals
1095
+
1096
+ - **Quality maintained**: No increase in bugs or refactoring needs
1097
+ - **Developer experience**: Feels faster, less repetitive _even with 30-50% manual_
1098
+ - **False positives**: <5% of hook/skill triggers are wrong
1099
+ - **Skills trending up**: Activation rate improves week-over-week with description tuning
1100
+ - **Fallback smooth**: Slash commands feel natural, not frustrating
1101
+
1102
+ **Measure at**: Week 1 (Phase 1), Week 3 (Phase 2), Week 5 (Phase 2 iteration)
1103
+
1104
+ ---
1105
+
1106
+ ## Rollback Plan
1107
+
1108
+ If automation causes issues:
1109
+
1110
+ ### Phase 1 (Slash Commands)
1111
+
1112
+ - **Issue**: Command doesn't work
1113
+ - **Fix**: Edit `.md` file, reload session
1114
+ - **Rollback**: Delete command file
1115
+
1116
+ ### Phase 2 (Skills/Hooks)
1117
+
1118
+ - **Issue**: Skill fires at wrong times
1119
+ - **Fix**: Refine description in SKILL.md
1120
+ - **Rollback**: Delete skill directory
1121
+
1122
+ - **Issue**: Hook breaks workflow
1123
+ - **Fix**: Adjust script or conditions
1124
+ - **Rollback**: Remove from settings.json
1125
+
1126
+ **Recovery**: All automation is additive - removing files returns to manual workflow
1127
+
1128
+ **Quick undo**: Press **Esc twice** to rewind conversation to last checkpoint (v2.0.10+)
1129
+
1130
+ ---
1131
+
1132
+ ## Iterative Development Process
1133
+
1134
+ **Critical principle**: Test each phase for 1 week before building next phase.
1135
+
1136
+ ### Week 1: Phase 1
1137
+
1138
+ 1. ✅ Implement slash commands + CLAUDE.md
1139
+ 2. ✅ Use in both projects (soulless-monorepo, bitd)
1140
+ 3. ✅ Measure prompt length reduction
1141
+ 4. ✅ Track command usage frequency
1142
+ 5. ❓ **Decision point**: Is this sufficient, or is Phase 2 needed?
1143
+
1144
+ ### Week 2-3: Phase 2 (if needed)
1145
+
1146
+ 1. ✅ Verify hooks working (test hook, workaround if needed)
1147
+ 2. ✅ Implement 1-2 Skills (not all 3 - start small)
1148
+ 3. ✅ Implement PostToolUse Hook (if hooks working)
1149
+ 4. ✅ Test activation with positive/negative cases
1150
+ 5. ✅ Track Skills activation rate daily
1151
+
1152
+ ### Week 4-5: Phase 2 Iteration
1153
+
1154
+ 1. ✅ Review activation log (false positives/negatives)
1155
+ 2. ✅ Refine Skill descriptions (add missed trigger keywords)
1156
+ 3. ✅ Add 3rd Skill if first 2 working well
1157
+ 4. ✅ Measure improvement (activation rate trending up?)
1158
+ 5. ❓ **Decision point**: Is 50-70% reduction sufficient?
1159
+
1160
+ ### Week 6+: Maintenance
1161
+
1162
+ - **Weekly**: Review activation logs, refine descriptions
1163
+ - **Monthly**: Assess if new repetitive patterns emerged
1164
+ - **Quarterly**: Evaluate if automation still provides value
1165
+
1166
+ **Stop building when**: You reach 60-90% reduction in repetitive prompts, NOT when you hit 100% (unrealistic).
1167
+
1168
+ ---
1169
+
1170
+ ## Appendix: Why NOT Other Approaches
1171
+
1172
+ ### Why NOT Subagents
1173
+
1174
+ **What they are**: Separate AI agents in isolated context windows
1175
+
1176
+ **Why NOT for quality checks**:
1177
+
1178
+ - ❌ Slow (context switching overhead)
1179
+ - ❌ No conversation history (can't see requirements)
1180
+ - ❌ Overkill for simple quality checks
1181
+
1182
+ **When to use instead**:
1183
+
1184
+ - ✅ Comprehensive PR reviews (entire diff analysis)
1185
+ - ✅ Architecture audits (long, detailed analysis)
1186
+ - ✅ Exhaustive code searches (already using Explore correctly)
1187
+
1188
+ ---
1189
+
1190
+ ### Why NOT MCP Servers
1191
+
1192
+ **What they are**: External integrations (GitHub, databases, external linters)
1193
+
1194
+ **Why NOT for quality checks**:
1195
+
1196
+ - ❌ External API costs ($$ for GPT-4/Gemini calls)
1197
+ - ❌ Network latency (slower than in-context)
1198
+ - ❌ No conversation context
1199
+ - ❌ Complex setup (install + config + API keys)
1200
+ - ❌ Hooks already handle linting (simpler)
1201
+
1202
+ **When to use instead** (future):
1203
+
1204
+ - ✅ GitHub PR automation ("Review PR #123 and post comments")
1205
+ - ✅ Database validation ("Will this schema change break production?")
1206
+ - ✅ Company-specific external tools
1207
+
1208
+ ---
1209
+
1210
+ ## Next Steps
1211
+
1212
+ **Choose your starting point**:
1213
+
1214
+ 1. **"implement phase 1"** → I'll create slash commands + CLAUDE.md updates
1215
+ 2. **"show me examples first"** → I'll demonstrate each command in action
1216
+ 3. **"modify the plan"** → Tell me what to change
1217
+
1218
+ **Remember**:
1219
+
1220
+ - ✅ Test Phase 1 for 1 week before Phase 2
1221
+ - ⚠️ Skills activate 50-70% (not 100%) - accept manual fallback
1222
+ - 🚨 Verify hooks working before Phase 2 (see Critical Warning)
1223
+ - 🎯 Goal is 60-90% reduction (not 100%)
1224
+
1225
+ **Ready to start?**