safeword 0.2.4 → 0.2.6

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/dist/check-3NGQ4NR5.js +129 -0
  2. package/dist/check-3NGQ4NR5.js.map +1 -0
  3. package/dist/chunk-2XWIUEQK.js +190 -0
  4. package/dist/chunk-2XWIUEQK.js.map +1 -0
  5. package/dist/chunk-GZRQL3SX.js +146 -0
  6. package/dist/chunk-GZRQL3SX.js.map +1 -0
  7. package/dist/chunk-ORQHKDT2.js +10 -0
  8. package/dist/chunk-ORQHKDT2.js.map +1 -0
  9. package/dist/chunk-W66Z3C5H.js +21 -0
  10. package/dist/chunk-W66Z3C5H.js.map +1 -0
  11. package/dist/cli.d.ts +1 -0
  12. package/dist/cli.js +34 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/diff-Y6QTAW4O.js +166 -0
  15. package/dist/diff-Y6QTAW4O.js.map +1 -0
  16. package/dist/index.d.ts +11 -0
  17. package/dist/index.js +7 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/reset-3ACTIYYE.js +143 -0
  20. package/dist/reset-3ACTIYYE.js.map +1 -0
  21. package/dist/setup-AIL5RL45.js +276 -0
  22. package/dist/setup-AIL5RL45.js.map +1 -0
  23. package/dist/upgrade-6AR3DHUV.js +134 -0
  24. package/dist/upgrade-6AR3DHUV.js.map +1 -0
  25. package/package.json +44 -19
  26. package/{.safeword → templates}/hooks/agents-md-check.sh +0 -0
  27. package/{.safeword → templates}/hooks/post-tool.sh +0 -0
  28. package/{.safeword → templates}/hooks/pre-commit.sh +0 -0
  29. package/.claude/commands/arch-review.md +0 -32
  30. package/.claude/commands/lint.md +0 -6
  31. package/.claude/commands/quality-review.md +0 -13
  32. package/.claude/commands/setup-linting.md +0 -6
  33. package/.claude/hooks/auto-lint.sh +0 -6
  34. package/.claude/hooks/auto-quality-review.sh +0 -170
  35. package/.claude/hooks/check-linting-sync.sh +0 -17
  36. package/.claude/hooks/inject-timestamp.sh +0 -6
  37. package/.claude/hooks/question-protocol.sh +0 -12
  38. package/.claude/hooks/run-linters.sh +0 -8
  39. package/.claude/hooks/run-quality-review.sh +0 -76
  40. package/.claude/hooks/version-check.sh +0 -10
  41. package/.claude/mcp/README.md +0 -96
  42. package/.claude/mcp/arcade.sample.json +0 -9
  43. package/.claude/mcp/context7.sample.json +0 -7
  44. package/.claude/mcp/playwright.sample.json +0 -7
  45. package/.claude/settings.json +0 -62
  46. package/.claude/skills/quality-reviewer/SKILL.md +0 -190
  47. package/.claude/skills/safeword-quality-reviewer/SKILL.md +0 -13
  48. package/.env.arcade.example +0 -4
  49. package/.env.example +0 -11
  50. package/.gitmodules +0 -4
  51. package/.safeword/SAFEWORD.md +0 -33
  52. package/.safeword/eslint/eslint-base.mjs +0 -101
  53. package/.safeword/guides/architecture-guide.md +0 -404
  54. package/.safeword/guides/code-philosophy.md +0 -174
  55. package/.safeword/guides/context-files-guide.md +0 -405
  56. package/.safeword/guides/data-architecture-guide.md +0 -183
  57. package/.safeword/guides/design-doc-guide.md +0 -165
  58. package/.safeword/guides/learning-extraction.md +0 -515
  59. package/.safeword/guides/llm-instruction-design.md +0 -239
  60. package/.safeword/guides/llm-prompting.md +0 -95
  61. package/.safeword/guides/tdd-best-practices.md +0 -570
  62. package/.safeword/guides/test-definitions-guide.md +0 -243
  63. package/.safeword/guides/testing-methodology.md +0 -573
  64. package/.safeword/guides/user-story-guide.md +0 -237
  65. package/.safeword/guides/zombie-process-cleanup.md +0 -214
  66. package/.safeword/planning/002-user-story-quality-evaluation.md +0 -1840
  67. package/.safeword/planning/003-langsmith-eval-setup-prompt.md +0 -363
  68. package/.safeword/planning/004-llm-eval-test-cases.md +0 -3226
  69. package/.safeword/planning/005-architecture-enforcement-system.md +0 -169
  70. package/.safeword/planning/006-reactive-fix-prevention-research.md +0 -135
  71. package/.safeword/planning/011-cli-ux-vision.md +0 -330
  72. package/.safeword/planning/012-project-structure-cleanup.md +0 -154
  73. package/.safeword/planning/README.md +0 -39
  74. package/.safeword/planning/automation-plan-v2.md +0 -1225
  75. package/.safeword/planning/automation-plan-v3.md +0 -1291
  76. package/.safeword/planning/automation-plan.md +0 -3058
  77. package/.safeword/planning/design/005-cli-implementation.md +0 -343
  78. package/.safeword/planning/design/013-cli-self-contained-templates.md +0 -596
  79. package/.safeword/planning/design/013a-eslint-plugin-suite.md +0 -256
  80. package/.safeword/planning/design/013b-implementation-snippets.md +0 -385
  81. package/.safeword/planning/design/013c-config-isolation-strategy.md +0 -242
  82. package/.safeword/planning/design/code-philosophy-improvements.md +0 -60
  83. package/.safeword/planning/mcp-analysis.md +0 -545
  84. package/.safeword/planning/phase2-subagents-vs-skills-analysis.md +0 -451
  85. package/.safeword/planning/settings-improvements.md +0 -970
  86. package/.safeword/planning/test-definitions/005-cli-implementation.md +0 -1301
  87. package/.safeword/planning/test-definitions/cli-self-contained-templates.md +0 -205
  88. package/.safeword/planning/user-stories/001-guides-review-user-stories.md +0 -1381
  89. package/.safeword/planning/user-stories/003-reactive-fix-prevention.md +0 -132
  90. package/.safeword/planning/user-stories/004-technical-constraints.md +0 -86
  91. package/.safeword/planning/user-stories/005-cli-implementation.md +0 -311
  92. package/.safeword/planning/user-stories/cli-self-contained-templates.md +0 -172
  93. package/.safeword/planning/versioned-distribution.md +0 -740
  94. package/.safeword/prompts/arch-review.md +0 -43
  95. package/.safeword/prompts/quality-review.md +0 -11
  96. package/.safeword/scripts/arch-review.sh +0 -235
  97. package/.safeword/scripts/check-linting-sync.sh +0 -58
  98. package/.safeword/scripts/setup-linting.sh +0 -559
  99. package/.safeword/templates/architecture-template.md +0 -136
  100. package/.safeword/templates/ci/architecture-check.yml +0 -79
  101. package/.safeword/templates/design-doc-template.md +0 -127
  102. package/.safeword/templates/test-definitions-feature.md +0 -100
  103. package/.safeword/templates/ticket-template.md +0 -74
  104. package/.safeword/templates/user-stories-template.md +0 -82
  105. package/.safeword/tickets/001-guides-review-user-stories.md +0 -83
  106. package/.safeword/tickets/002-architecture-enforcement.md +0 -211
  107. package/.safeword/tickets/003-reactive-fix-prevention.md +0 -57
  108. package/.safeword/tickets/004-technical-constraints-in-user-stories.md +0 -39
  109. package/.safeword/tickets/005-cli-implementation.md +0 -248
  110. package/.safeword/tickets/006-flesh-out-skills.md +0 -43
  111. package/.safeword/tickets/007-flesh-out-questioning.md +0 -44
  112. package/.safeword/tickets/008-upgrade-questioning.md +0 -58
  113. package/.safeword/tickets/009-naming-conventions.md +0 -41
  114. package/.safeword/tickets/010-safeword-md-cleanup.md +0 -34
  115. package/.safeword/tickets/011-cursor-setup.md +0 -86
  116. package/.safeword/tickets/README.md +0 -73
  117. package/.safeword/version +0 -1
  118. package/AGENTS.md +0 -59
  119. package/CLAUDE.md +0 -12
  120. package/README.md +0 -347
  121. package/docs/001-cli-implementation-plan.md +0 -856
  122. package/docs/elite-dx-implementation-plan.md +0 -1034
  123. package/framework/README.md +0 -131
  124. package/framework/mcp/README.md +0 -96
  125. package/framework/mcp/arcade.sample.json +0 -8
  126. package/framework/mcp/context7.sample.json +0 -6
  127. package/framework/mcp/playwright.sample.json +0 -6
  128. package/framework/scripts/arch-review.sh +0 -235
  129. package/framework/scripts/check-linting-sync.sh +0 -58
  130. package/framework/scripts/load-env.sh +0 -49
  131. package/framework/scripts/setup-claude.sh +0 -223
  132. package/framework/scripts/setup-linting.sh +0 -559
  133. package/framework/scripts/setup-quality.sh +0 -477
  134. package/framework/scripts/setup-safeword.sh +0 -550
  135. package/framework/templates/ci/architecture-check.yml +0 -78
  136. package/learnings/ai-sdk-v5-breaking-changes.md +0 -178
  137. package/learnings/e2e-test-zombie-processes.md +0 -231
  138. package/learnings/milkdown-crepe-editor-property.md +0 -96
  139. package/learnings/prosemirror-fragment-traversal.md +0 -119
  140. package/packages/cli/AGENTS.md +0 -1
  141. package/packages/cli/ARCHITECTURE.md +0 -279
  142. package/packages/cli/package.json +0 -51
  143. package/packages/cli/src/cli.ts +0 -63
  144. package/packages/cli/src/commands/check.ts +0 -166
  145. package/packages/cli/src/commands/diff.ts +0 -209
  146. package/packages/cli/src/commands/reset.ts +0 -190
  147. package/packages/cli/src/commands/setup.ts +0 -325
  148. package/packages/cli/src/commands/upgrade.ts +0 -163
  149. package/packages/cli/src/index.ts +0 -3
  150. package/packages/cli/src/templates/config.ts +0 -58
  151. package/packages/cli/src/templates/content.ts +0 -18
  152. package/packages/cli/src/templates/index.ts +0 -12
  153. package/packages/cli/src/utils/agents-md.ts +0 -66
  154. package/packages/cli/src/utils/fs.ts +0 -179
  155. package/packages/cli/src/utils/git.ts +0 -124
  156. package/packages/cli/src/utils/hooks.ts +0 -29
  157. package/packages/cli/src/utils/output.ts +0 -60
  158. package/packages/cli/src/utils/project-detector.test.ts +0 -185
  159. package/packages/cli/src/utils/project-detector.ts +0 -44
  160. package/packages/cli/src/utils/version.ts +0 -28
  161. package/packages/cli/src/version.ts +0 -6
  162. package/packages/cli/templates/SAFEWORD.md +0 -776
  163. package/packages/cli/templates/doc-templates/architecture-template.md +0 -136
  164. package/packages/cli/templates/doc-templates/design-doc-template.md +0 -134
  165. package/packages/cli/templates/doc-templates/test-definitions-feature.md +0 -131
  166. package/packages/cli/templates/doc-templates/ticket-template.md +0 -82
  167. package/packages/cli/templates/doc-templates/user-stories-template.md +0 -92
  168. package/packages/cli/templates/guides/architecture-guide.md +0 -423
  169. package/packages/cli/templates/guides/code-philosophy.md +0 -195
  170. package/packages/cli/templates/guides/context-files-guide.md +0 -457
  171. package/packages/cli/templates/guides/data-architecture-guide.md +0 -200
  172. package/packages/cli/templates/guides/design-doc-guide.md +0 -171
  173. package/packages/cli/templates/guides/learning-extraction.md +0 -552
  174. package/packages/cli/templates/guides/llm-instruction-design.md +0 -248
  175. package/packages/cli/templates/guides/llm-prompting.md +0 -102
  176. package/packages/cli/templates/guides/tdd-best-practices.md +0 -615
  177. package/packages/cli/templates/guides/test-definitions-guide.md +0 -334
  178. package/packages/cli/templates/guides/testing-methodology.md +0 -618
  179. package/packages/cli/templates/guides/user-story-guide.md +0 -256
  180. package/packages/cli/templates/guides/zombie-process-cleanup.md +0 -219
  181. package/packages/cli/templates/hooks/agents-md-check.sh +0 -27
  182. package/packages/cli/templates/hooks/post-tool.sh +0 -4
  183. package/packages/cli/templates/hooks/pre-commit.sh +0 -10
  184. package/packages/cli/templates/prompts/arch-review.md +0 -43
  185. package/packages/cli/templates/prompts/quality-review.md +0 -10
  186. package/packages/cli/templates/skills/safeword-quality-reviewer/SKILL.md +0 -207
  187. package/packages/cli/tests/commands/check.test.ts +0 -129
  188. package/packages/cli/tests/commands/cli.test.ts +0 -89
  189. package/packages/cli/tests/commands/diff.test.ts +0 -115
  190. package/packages/cli/tests/commands/reset.test.ts +0 -310
  191. package/packages/cli/tests/commands/self-healing.test.ts +0 -170
  192. package/packages/cli/tests/commands/setup-blocking.test.ts +0 -71
  193. package/packages/cli/tests/commands/setup-core.test.ts +0 -135
  194. package/packages/cli/tests/commands/setup-git.test.ts +0 -139
  195. package/packages/cli/tests/commands/setup-hooks.test.ts +0 -334
  196. package/packages/cli/tests/commands/setup-linting.test.ts +0 -189
  197. package/packages/cli/tests/commands/setup-noninteractive.test.ts +0 -80
  198. package/packages/cli/tests/commands/setup-templates.test.ts +0 -181
  199. package/packages/cli/tests/commands/upgrade.test.ts +0 -215
  200. package/packages/cli/tests/helpers.ts +0 -243
  201. package/packages/cli/tests/npm-package.test.ts +0 -83
  202. package/packages/cli/tests/technical-constraints.test.ts +0 -96
  203. package/packages/cli/tsconfig.json +0 -25
  204. package/packages/cli/tsup.config.ts +0 -11
  205. package/packages/cli/vitest.config.ts +0 -23
  206. package/promptfoo.yaml +0 -3270
  207. /package/{framework → templates}/SAFEWORD.md +0 -0
  208. /package/{packages/cli/templates → templates}/commands/arch-review.md +0 -0
  209. /package/{packages/cli/templates → templates}/commands/lint.md +0 -0
  210. /package/{packages/cli/templates → templates}/commands/quality-review.md +0 -0
  211. /package/{framework/templates → templates/doc-templates}/architecture-template.md +0 -0
  212. /package/{framework/templates → templates/doc-templates}/design-doc-template.md +0 -0
  213. /package/{framework/templates → templates/doc-templates}/test-definitions-feature.md +0 -0
  214. /package/{framework/templates → templates/doc-templates}/ticket-template.md +0 -0
  215. /package/{framework/templates → templates/doc-templates}/user-stories-template.md +0 -0
  216. /package/{framework → templates}/guides/architecture-guide.md +0 -0
  217. /package/{framework → templates}/guides/code-philosophy.md +0 -0
  218. /package/{framework → templates}/guides/context-files-guide.md +0 -0
  219. /package/{framework → templates}/guides/data-architecture-guide.md +0 -0
  220. /package/{framework → templates}/guides/design-doc-guide.md +0 -0
  221. /package/{framework → templates}/guides/learning-extraction.md +0 -0
  222. /package/{framework → templates}/guides/llm-instruction-design.md +0 -0
  223. /package/{framework → templates}/guides/llm-prompting.md +0 -0
  224. /package/{framework → templates}/guides/tdd-best-practices.md +0 -0
  225. /package/{framework → templates}/guides/test-definitions-guide.md +0 -0
  226. /package/{framework → templates}/guides/testing-methodology.md +0 -0
  227. /package/{framework → templates}/guides/user-story-guide.md +0 -0
  228. /package/{framework → templates}/guides/zombie-process-cleanup.md +0 -0
  229. /package/{packages/cli/templates → templates}/hooks/inject-timestamp.sh +0 -0
  230. /package/{packages/cli/templates → templates}/lib/common.sh +0 -0
  231. /package/{packages/cli/templates → templates}/lib/jq-fallback.sh +0 -0
  232. /package/{packages/cli/templates → templates}/markdownlint.jsonc +0 -0
  233. /package/{framework → templates}/prompts/arch-review.md +0 -0
  234. /package/{framework → templates}/prompts/quality-review.md +0 -0
  235. /package/{framework/skills/quality-reviewer → templates/skills/safeword-quality-reviewer}/SKILL.md +0 -0
@@ -1,237 +0,0 @@
1
- # User Story Guide for Claude Code
2
-
3
- ## How to Fill Out Feature User Stories
4
-
5
- **Template:** `@.safeword/templates/user-stories-template.md`
6
-
7
- **When user asks:** "Create user stories for issue #N" or "Create user stories for [feature]"
8
-
9
- **What you do:**
10
- 1. Read `@.safeword/templates/user-stories-template.md`
11
- 2. Fill in feature name, issue number, status
12
- 3. Create numbered stories (Story 1, Story 2, etc.)
13
- 4. Add acceptance criteria with ✅/❌ checkboxes for tracking
14
- 5. Include test file references
15
- 6. Add summary with completion % and phases
16
- 7. Save to project location (e.g., `planning/user-stories/45-feature-name.md`)
17
-
18
- **DO include:**
19
- - Status tracking (✅/❌ per story and AC)
20
- - Test file references
21
- - Implementation status
22
- - Completion percentage
23
- - Phase tracking
24
- - Next steps
25
-
26
- ---
27
-
28
- ## INVEST Validation (Do This Before Saving)
29
-
30
- After filling out story, mentally check:
31
-
32
- ✅ **Independent** - Can be done without other stories?
33
- ✅ **Negotiable** - Are details left for conversation?
34
- ✅ **Valuable** - Does "So that" clearly state value?
35
- ✅ **Estimable** - Can team estimate this (1-5 days)?
36
- ✅ **Small** - Completable in one sprint?
37
- ✅ **Testable** - Are acceptance criteria specific?
38
-
39
- **If ANY check fails → Refine or split the story**
40
-
41
- ---
42
-
43
- ## Writing Good Acceptance Criteria
44
-
45
- **✅ GOOD - Specific, user-facing, testable:**
46
- - User can switch campaigns without page reload
47
- - Response time is under 200ms
48
- - Current campaign is visually highlighted
49
- - Error message explains what went wrong
50
-
51
- **❌ BAD - Vague, technical, or implementation:**
52
- - Campaign switching works ← Too vague
53
- - Use Zustand for state ← Implementation detail
54
- - Database is fast ← Not user-facing
55
- - Code is clean ← Not testable
56
-
57
- ---
58
-
59
- ## Size Guidelines
60
-
61
- | Indicator | Too Big | Just Right | Too Small |
62
- |-----------|---------|------------|-----------|
63
- | Acceptance Criteria | 6+ | 1-5 | 0 |
64
- | Personas/Screens | 3+ | 1-2 | N/A |
65
- | Duration | 6+ days | 1-5 days | <1 hour |
66
- | **Action** | Split | ✅ Ship | Combine |
67
-
68
- **Decision rule:** When borderline (e.g., 5 AC but 2 personas), err on the side of splitting. Smaller stories are easier to estimate and complete.
69
-
70
- ---
71
-
72
- ## Examples
73
-
74
- ### ✅ GOOD Story
75
-
76
- **As a** player with multiple campaigns
77
- **I want** to switch between campaigns from the sidebar
78
- **So that** I can quickly resume different games
79
-
80
- **Acceptance Criteria:**
81
- - [ ] Sidebar shows all campaigns with last-played date
82
- - [ ] Clicking campaign loads it within 200ms
83
- - [ ] Current campaign is highlighted
84
-
85
- ### ❌ BAD Story (Too Big)
86
-
87
- **As a** user
88
- **I want** a complete campaign management system
89
- **So that** I can organize my games
90
-
91
- **Acceptance Criteria:**
92
- - [ ] Create, edit, delete campaigns
93
- - [ ] Share campaigns with other players
94
- - [ ] Export/import campaign data
95
- - [ ] Search and filter campaigns
96
- - [ ] Tag campaigns by theme
97
-
98
- **Problem:** This is 5+ separate stories. Split it.
99
-
100
- ### ❌ BAD Story (No Value)
101
-
102
- **As a** developer
103
- **I want** to refactor the GameStore
104
- **So that** code is cleaner
105
-
106
- **Problem:**
107
- - Developer is not a user
108
- - "Cleaner code" is not user-facing value
109
- - This is a technical task, not a user story
110
-
111
- ### ✅ BETTER (Technical Story)
112
-
113
- **Technical Task:** Refactor GameStore to use Immer
114
-
115
- **Why:** Prevent state mutation bugs (3 bugs in last sprint)
116
- **Effort:** 2-3 hours
117
- **Test:** All existing tests pass, no new mutations
118
-
119
- ---
120
-
121
- ## Conversation Starter, Not Contract
122
-
123
- **Remember:** User story is a placeholder for conversation.
124
-
125
- **During planning, discuss:**
126
- - Edge cases not in acceptance criteria
127
- - Technical approach (but don't document it in story)
128
- - Open questions or dependencies
129
- - How to split if too big
130
-
131
- **The story should NOT contain:**
132
- - Technical implementation details
133
- - Test strategies
134
- - UI mockups (link to them instead)
135
- - Definition of done (that's team-wide)
136
-
137
- ---
138
-
139
- ## Technical Constraints Section
140
-
141
- **Purpose:** Capture non-functional requirements that inform test definitions. These are NOT user stories but constrain how stories are implemented.
142
-
143
- **When to use:** Fill in constraints BEFORE writing test definitions. Delete sections that don't apply—keep it lean.
144
-
145
- ### Categories
146
-
147
- | Category | What It Captures | Examples |
148
- |----------|-----------------|----------|
149
- | Performance | Speed, throughput, capacity | Response time < 200ms, 1000 concurrent users |
150
- | Security | Auth, validation, rate limiting | Sanitized inputs, session required, 100 req/min |
151
- | Compatibility | Browsers, devices, accessibility | Chrome 100+, iOS 14+, WCAG 2.1 AA |
152
- | Data | Privacy, retention, compliance | GDPR delete in 72h, 90-day log retention |
153
- | Dependencies | Existing systems, restrictions | Use AuthService, no new packages |
154
- | Infrastructure | Resources, offline, deployment | < 512MB memory, offline-capable |
155
-
156
- ### ✅ GOOD Constraints (Specific, Testable)
157
-
158
- ```markdown
159
- ### Performance
160
- - [ ] API response < 200ms at P95 under 100 concurrent users
161
- - [ ] Initial page load < 3s on simulated 3G
162
-
163
- ### Security
164
- - [ ] All user inputs sanitized via DOMPurify
165
- - [ ] Rate limited: 100 requests/min per IP
166
- ```
167
-
168
- ### ❌ BAD Constraints (Vague, Untestable)
169
-
170
- ```markdown
171
- ### Performance
172
- - [ ] Should be fast ← How fast? Under what conditions?
173
- - [ ] Good performance ← Not measurable
174
-
175
- ### Security
176
- - [ ] Secure ← What does this mean?
177
- - [ ] Protected from hackers ← Not specific
178
- ```
179
-
180
- ### Decision Rule
181
-
182
- **Include a constraint if:**
183
- - It affects how you write tests (performance tests, security tests)
184
- - It limits implementation choices (must use X, can't use Y)
185
- - Violating it would fail an audit or break SLAs
186
-
187
- **Skip if:**
188
- - It's a project-wide standard already in ARCHITECTURE.md
189
- - It's obvious (don't document "code must compile")
190
-
191
- ### Tie-Breaking
192
-
193
- **If constraint fits multiple categories:** Choose the most specific one.
194
-
195
- | Constraint | Could Fit | Best Category | Why |
196
- |------------|-----------|---------------|-----|
197
- | API rate limit 100 req/min | Security, Performance | Security | Rate limiting is access control |
198
- | Page load < 3s on 3G | Performance, Compatibility | Performance | Speed is primary concern |
199
- | Must work offline | Infrastructure, Compatibility | Infrastructure | Offline is deployment concern |
200
-
201
- **Edge case:** If truly cross-cutting (e.g., "GDPR compliance" spans Data + Security), pick one and add a note: "See also: Security constraints"
202
-
203
- ---
204
-
205
- ## LLM Optimization Tips
206
-
207
- **Core principle:** User stories are instructions that LLMs read and follow. Apply LLM instruction design best practices.
208
-
209
- **See:** `@.safeword/guides/llm-instruction-design.md` for comprehensive framework on writing LLM-consumable documentation.
210
-
211
- **When filling templates:**
212
- - Use specific, concrete language (not vague)
213
- - Avoid generic phrases ("improve UX", "make better")
214
- - Include numbers where relevant (200ms, 3 items, under 5 clicks)
215
- - Use concrete examples over abstract rules
216
- - Define all terms explicitly
217
- - Write for humans, not robots
218
-
219
- **Token efficiency:**
220
- - Template is 9 lines (minimal prompt caching cost)
221
- - No nested sections (flat structure)
222
- - No validation metadata in file
223
-
224
- ---
225
-
226
- ## File Naming Convention
227
-
228
- Save stories as: `.safeword/planning/user-stories/[slug].md`
229
-
230
- **Good filenames:**
231
- - `campaign-switching.md`
232
- - `export-character-pdf.md`
233
- - `stress-tracking.md`
234
-
235
- **Bad filenames:**
236
- - `user-story-1.md` ← Not descriptive
237
- - `STORY_CAMPAIGN_SWITCHING_FINAL_v2.md` ← Bloated
@@ -1,214 +0,0 @@
1
- # Zombie Process Cleanup (Multi-Project Environments)
2
-
3
- **When to use:** Working on multiple projects simultaneously, especially when they share tech stacks (Next.js, Playwright, etc.)
4
-
5
- ---
6
-
7
- ## The Problem
8
-
9
- When running dev servers and E2E tests across multiple projects, zombie processes accumulate:
10
- - Dev servers holding ports
11
- - Playwright browser instances
12
- - Test runners stuck in background
13
- - Build processes from previous sessions
14
-
15
- **CRITICAL:** NEVER use `killall node` or `pkill -9 node` when working on multiple projects - this kills processes from ALL projects.
16
-
17
- ---
18
-
19
- ## Port-Based Cleanup (Safest for Multi-Project)
20
-
21
- **Prerequisite:** Each project must use a different port (e.g., Project A: 3000, Project B: 3001)
22
-
23
- **Port convention:** Dev and test instances use different ports within the same project:
24
- - **Dev port**: Project's configured port (e.g., 3000, 5173, 8080) - manual testing
25
- - **Test port**: Dev port + 1000 (e.g., 4000, 6173, 9080) - Playwright managed
26
-
27
- See `testing-methodology.md` → "E2E Testing with Persistent Dev Servers" for full port isolation strategy.
28
-
29
- **Decision rule:** If unsure which cleanup method to use → port-based first (safest), then project script, then tmux.
30
-
31
- **Recommended cleanup pattern** (replace ports with your project's ports):
32
-
33
- ```bash
34
- # Kill both dev server AND test server ports
35
- # Example: Next.js (3000/4000), Vite (5173/6173), or your project's ports
36
- lsof -ti:3000 -ti:4000 | xargs kill -9 2>/dev/null
37
-
38
- # Kill Playwright processes launched from THIS directory
39
- pkill -f "playwright.*$(pwd)" 2>/dev/null
40
-
41
- # Wait for cleanup
42
- sleep 2
43
- ```
44
-
45
- **Why this works:**
46
- - ✅ Dev + test ports are unique to this project → safe to kill
47
- - ✅ `$(pwd)` ensures only THIS project's tests are killed
48
- - ✅ Other projects completely untouched
49
-
50
- ---
51
-
52
- ## Project-Specific Cleanup Script
53
-
54
- For frequent cleanup needs, create `scripts/cleanup.sh` in each project:
55
-
56
- ```bash
57
- #!/bin/bash
58
- # scripts/cleanup.sh - Kill only THIS project's processes
59
-
60
- DEV_PORT=3000 # Dev server port (change per project)
61
- TEST_PORT=$((DEV_PORT + 1000)) # Test server port (Playwright managed)
62
- PROJECT_DIR="$(pwd)"
63
-
64
- echo "Cleaning up $PROJECT_DIR (dev: $DEV_PORT, test: $TEST_PORT)..."
65
-
66
- # Kill both dev and test servers by port
67
- lsof -ti:$DEV_PORT -ti:$TEST_PORT | xargs kill -9 2>/dev/null
68
-
69
- # Kill Playwright browsers for this project
70
- ps aux | grep -E "(playwright|chromium)" | grep "$PROJECT_DIR" | grep -v grep | awk '{print $2}' | xargs kill -9 2>/dev/null
71
-
72
- # Kill test runners
73
- pgrep -f "playwright test.*$(basename $PROJECT_DIR)" | xargs kill -9 2>/dev/null
74
-
75
- echo "Cleanup complete!"
76
- ```
77
-
78
- **Make executable:** `chmod +x scripts/cleanup.sh`
79
-
80
- **Usage:** `./scripts/cleanup.sh`
81
-
82
- ---
83
-
84
- ## Common Patterns by Tech Stack
85
-
86
- ### Next.js Projects
87
-
88
- ```bash
89
- # Kill Next.js dev server (port 3000)
90
- lsof -ti:3000 | xargs kill -9 2>/dev/null
91
-
92
- # Kill Next.js build processes for this project
93
- ps aux | grep "next dev" | grep "$(pwd)" | grep -v grep | awk '{print $2}' | xargs kill -9 2>/dev/null
94
- ```
95
-
96
- ### Playwright E2E Tests
97
-
98
- ```bash
99
- # Kill Playwright browsers and test runners
100
- pkill -f "playwright.*$(pwd)" 2>/dev/null
101
-
102
- # Or more specific (by project name)
103
- pkill -f "playwright.*my-project-name" 2>/dev/null
104
- ```
105
-
106
- ### Vite Projects
107
-
108
- ```bash
109
- # Kill Vite dev server (typically port 5173)
110
- lsof -ti:5173 | xargs kill -9 2>/dev/null
111
- ```
112
-
113
- ### React Native / Expo
114
-
115
- ```bash
116
- # Kill Metro bundler (port 8081)
117
- lsof -ti:8081 | xargs kill -9 2>/dev/null
118
-
119
- # Kill Expo dev tools (port 19000-19006)
120
- lsof -ti:19000-19006 | xargs kill -9 2>/dev/null
121
- ```
122
-
123
- ---
124
-
125
- ## Alternative: tmux/Screen Sessions
126
-
127
- For complete isolation, run each project in its own terminal session:
128
-
129
- ```bash
130
- # Start project in named session
131
- tmux new -s project-name
132
- # Run dev server here
133
-
134
- # Kill everything in this session only
135
- tmux kill-session -t project-name
136
- ```
137
-
138
- **Pros:**
139
- - ✅ Complete isolation between projects
140
- - ✅ One command kills everything
141
- - ✅ Can detach/reattach sessions
142
-
143
- **Cons:**
144
- - ⚠️ Requires learning tmux
145
- - ⚠️ Different workflow
146
-
147
- ---
148
-
149
- ## Best Practices
150
-
151
- 1. **Assign unique ports** - Set `PORT=3000` in one project, `PORT=3001` in another
152
- 2. **Use port-based cleanup first** - Simplest and safest
153
- 3. **Create project cleanup scripts** - Reusable, documented
154
- 4. **Never `killall node`** - Too broad when working on multiple projects
155
- 5. **Clean up before starting** - Run cleanup script before `npm run dev`
156
- 6. **Check what's running** - Use `lsof -i:PORT` to see what's using a port
157
-
158
- ---
159
-
160
- ## Debugging Zombie Processes
161
-
162
- ### Find What's Using a Port
163
-
164
- ```bash
165
- # Check what's on port 3000
166
- lsof -i:3000
167
-
168
- # More details
169
- lsof -i:3000 -P -n
170
- ```
171
-
172
- ### Find All Node Processes
173
-
174
- ```bash
175
- # List all node processes
176
- ps aux | grep -E "(node|playwright|chromium)"
177
-
178
- # More detailed (with working directory)
179
- lsof -p $(pgrep node) | grep cwd
180
- ```
181
-
182
- ### Find Processes by Project Directory
183
-
184
- ```bash
185
- # Find processes running in specific directory
186
- ps aux | grep "/Users/alex/projects/my-project"
187
- ```
188
-
189
- ---
190
-
191
- ## Quick Reference
192
-
193
- | Situation | Command |
194
- |-----------|---------|
195
- | Kill dev + test servers (use your ports) | `lsof -ti:$DEV_PORT -ti:$TEST_PORT \| xargs kill -9 2>/dev/null` |
196
- | Kill Playwright (this project) | `pkill -f "playwright.*$(pwd)"` |
197
- | Kill all for this project | `./scripts/cleanup.sh` |
198
- | Check what's on port | `lsof -i:3000` |
199
- | Find zombie processes | `ps aux \| grep -E "(node\|playwright\|chromium)"` |
200
- | Kill by process ID | `kill -9 <PID>` |
201
-
202
- ---
203
-
204
- ## What NOT to Do
205
-
206
- ❌ **DON'T:** `killall node` (kills all projects)
207
- ❌ **DON'T:** `pkill -9 node` (kills all projects)
208
- ❌ **DON'T:** Kill processes without checking working directory
209
- ❌ **DON'T:** Assume zombie browsers will clean themselves up (they won't)
210
-
211
- ✅ **DO:** Use port-based cleanup
212
- ✅ **DO:** Filter by project directory with `$(pwd)`
213
- ✅ **DO:** Create project-specific cleanup scripts
214
- ✅ **DO:** Clean up before AND after development sessions