safeword 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safeword",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "CLI for setting up and managing safeword development environments",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,18 +19,6 @@
19
19
  "engines": {
20
20
  "node": ">=18"
21
21
  },
22
- "scripts": {
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "test": "vitest run",
26
- "test:e2e": "vitest run tests/e2e/",
27
- "test:watch": "vitest",
28
- "test:coverage": "vitest run --coverage",
29
- "typecheck": "tsc --noEmit",
30
- "lint": "eslint src tests",
31
- "clean": "rm -rf dist",
32
- "prepublishOnly": "npm run build && npm test"
33
- },
34
22
  "dependencies": {
35
23
  "commander": "^12.1.0"
36
24
  },
@@ -48,5 +36,16 @@
48
36
  "claude-code"
49
37
  ],
50
38
  "author": "",
51
- "license": "MIT"
52
- }
39
+ "license": "MIT",
40
+ "scripts": {
41
+ "build": "tsup",
42
+ "dev": "tsup --watch",
43
+ "test": "vitest run",
44
+ "test:e2e": "vitest run tests/e2e/",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "typecheck": "tsc --noEmit",
48
+ "lint": "eslint src tests",
49
+ "clean": "rm -rf dist"
50
+ }
51
+ }
@@ -44,21 +44,21 @@ Training data is stale. Follow this sequence:
44
44
 
45
45
  **Read the matching guide when ANY trigger fires:**
46
46
 
47
- | Trigger | Guide |
48
- | --------------------------------------------------------- | ---------------------------------------------- |
49
- | Starting ANY feature, bug fix, or enhancement | @./.safeword/guides/development-workflow.md |
50
- | Need to write OR review user stories | @./.safeword/guides/user-story-guide.md |
51
- | Need to write OR review test definitions | @./.safeword/guides/test-definitions-guide.md |
52
- | Writing tests, doing TDD, or test is failing | @./.safeword/guides/tdd-best-practices.md |
53
- | Creating OR updating a design doc | @./.safeword/guides/design-doc-guide.md |
54
- | Making architectural decision OR writing ADR | @./.safeword/guides/architecture-guide.md |
55
- | Designing data models, schemas, or database changes | @./.safeword/guides/data-architecture-guide.md |
56
- | Calling LLM APIs OR writing LLM-consumable docs | @./.safeword/guides/llm-guide.md |
57
- | Updating CLAUDE.md, SAFEWORD.md, or any context file | @./.safeword/guides/context-files-guide.md |
58
- | Hit same bug 3+ times OR discovered undocumented gotcha | @./.safeword/guides/learning-extraction.md |
59
- | Process hanging, port in use, or zombie process suspected | @./.safeword/guides/zombie-process-cleanup.md |
60
- | Using `safeword` CLI commands | @./.safeword/guides/cli-reference.md |
61
- | Debugging issues OR need git/cross-platform guidance | @./.safeword/guides/code-philosophy.md |
47
+ | Trigger | Guide |
48
+ | --------------------------------------------------------- | ----------------------------------------------- |
49
+ | Starting ANY feature, bug fix, or enhancement | `./.safeword/guides/development-workflow.md` |
50
+ | Need to write OR review user stories | `./.safeword/guides/user-story-guide.md` |
51
+ | Need to write OR review test definitions | `./.safeword/guides/test-definitions-guide.md` |
52
+ | Writing tests, doing TDD, or test is failing | `./.safeword/guides/tdd-best-practices.md` |
53
+ | Creating OR updating a design doc | `./.safeword/guides/design-doc-guide.md` |
54
+ | Making architectural decision OR writing ADR | `./.safeword/guides/architecture-guide.md` |
55
+ | Designing data models, schemas, or database changes | `./.safeword/guides/data-architecture-guide.md` |
56
+ | Calling LLM APIs OR writing LLM-consumable docs | `./.safeword/guides/llm-guide.md` |
57
+ | Updating CLAUDE.md, SAFEWORD.md, or any context file | `./.safeword/guides/context-files-guide.md` |
58
+ | Hit same bug 3+ times OR discovered undocumented gotcha | `./.safeword/guides/learning-extraction.md` |
59
+ | Process hanging, port in use, or zombie process suspected | `./.safeword/guides/zombie-process-cleanup.md` |
60
+ | Using `safeword` CLI commands | `./.safeword/guides/cli-reference.md` |
61
+ | Debugging issues OR need git/cross-platform guidance | `./.safeword/guides/code-philosophy.md` |
62
62
 
63
63
  ---
64
64
 
@@ -66,15 +66,15 @@ Training data is stale. Follow this sequence:
66
66
 
67
67
  **Use the matching template when ANY trigger fires:**
68
68
 
69
- | Trigger | Template |
70
- | ---------------------------------------------------------- | -------------------------------------------------- |
71
- | Planning new feature scope OR creating feature spec | @./.safeword/templates/feature-spec-template.md |
72
- | Bug, improvement, refactor, or internal task | @./.safeword/templates/task-spec-template.md |
73
- | Need test definitions for a feature OR acceptance criteria | @./.safeword/templates/test-definitions-feature.md |
74
- | Feature spans 3+ components OR needs technical spec | @./.safeword/templates/design-doc-template.md |
75
- | Making decision with long-term impact OR trade-offs | @./.safeword/templates/architecture-template.md |
76
- | Task needs context anchoring (see Ticket System below) | @./.safeword/templates/ticket-template.md |
77
- | Starting execution of a plan, ticket, or spec | @./.safeword/templates/work-log-template.md |
69
+ | Trigger | Template |
70
+ | ---------------------------------------------------------- | --------------------------------------------------- |
71
+ | Planning new feature scope OR creating feature spec | `./.safeword/templates/feature-spec-template.md` |
72
+ | Bug, improvement, refactor, or internal task | `./.safeword/templates/task-spec-template.md` |
73
+ | Need test definitions for a feature OR acceptance criteria | `./.safeword/templates/test-definitions-feature.md` |
74
+ | Feature spans 3+ components OR needs technical spec | `./.safeword/templates/design-doc-template.md` |
75
+ | Making decision with long-term impact OR trade-offs | `./.safeword/templates/architecture-template.md` |
76
+ | Task needs context anchoring (see Ticket System below) | `./.safeword/templates/ticket-template.md` |
77
+ | Starting execution of a plan, ticket, or spec | `./.safeword/templates/work-log-template.md` |
78
78
 
79
79
  ---
80
80
 
@@ -286,9 +286,19 @@ When markdown lint reports MD040 (missing language), choose:
286
286
 
287
287
  ---
288
288
 
289
- ## Learning Extraction
289
+ ## Learnings
290
290
 
291
- **Suggest extraction when ANY apply:**
291
+ **Location:** `.safeword/learnings/`
292
+
293
+ **Check learnings FIRST when:**
294
+
295
+ 1. Stuck on an issue OR debugging same problem 2+ times
296
+ 2. Working with unfamiliar technology in this codebase
297
+ 3. Issue involves testing, processes, or integrations
298
+
299
+ **How:** `ls .safeword/learnings/` then read relevant files.
300
+
301
+ **Extract new learning when ANY apply:**
292
302
 
293
303
  - 5+ debug cycles on same issue
294
304
  - 3+ approaches tried
@@ -296,3 +306,14 @@ When markdown lint reports MD040 (missing language), choose:
296
306
  - Integration struggle between tools
297
307
 
298
308
  **Before extracting:** Check `.safeword/learnings/` for existing similar learnings—update, don't duplicate.
309
+
310
+ ---
311
+
312
+ ## Always Remember
313
+
314
+ 1. **Clarity → Simplicity → Correctness** (in that order)
315
+ 2. **Test what you can test**—never ask user to verify
316
+ 3. **RED → GREEN → REFACTOR**—never skip steps
317
+ 4. **Commit after each GREEN phase**
318
+ 5. **Read the matching guide** when a trigger fires
319
+ 6. **End every response** with: `{"proposedChanges": bool, "madeChanges": bool, "askedQuestion": bool}`
@@ -413,11 +413,9 @@ export default defineConfig([
413
413
 
414
414
  ---
415
415
 
416
- ## Key Takeaway
416
+ ## Key Takeaways
417
417
 
418
- **One comprehensive architecture document per project** > many scattered ADR files:
419
-
420
- Full context in one place
421
- Living document (update in place)
422
- ✅ LLMs consume entire architecture at once
423
- ✅ Sequential decision trees prevent ambiguity
418
+ - One Architecture Doc per project—not scattered ADRs
419
+ - Every decision needs: What / Why / Trade-off / Alternatives
420
+ - Update when adding: technology, schema, or project-wide pattern
421
+ - Living documentupdate in place with version/status tracking
@@ -33,3 +33,11 @@ Common flags:
33
33
  - `-y, --yes` - Skip confirmations (setup, reset)
34
34
  - `-v, --verbose` - Show detailed output (diff)
35
35
  - `-q, --quiet` - Suppress output (sync)
36
+
37
+ ---
38
+
39
+ ## Key Takeaways
40
+
41
+ - Always use `@latest` for setup/check/upgrade/diff to get current CLI
42
+ - Run `sync` after adding/removing frameworks to update linting plugins
43
+ - Use `diff` before `upgrade` to preview changes
@@ -196,3 +196,12 @@ Before completing any work, verify:
196
196
  # ❌ Bad: "misc fixes"
197
197
  # ✅ Good: "fix: login button not responding to clicks"
198
198
  ```
199
+
200
+ ---
201
+
202
+ ## Key Takeaways
203
+
204
+ - Clarity → Simplicity → Correctness (in that order)
205
+ - Delete unused code—no "just in case" abstractions
206
+ - Commit often with descriptive messages
207
+ - Verify library versions before using APIs (training data is stale)
@@ -455,3 +455,12 @@ Before committing:
455
455
  - Bloated files cost more tokens and introduce noise
456
456
  - Keep under 50KB for optimal performance (though no hard limit)
457
457
  - Use imports to modularize instead of monolithic files
458
+
459
+ ---
460
+
461
+ ## Key Takeaways
462
+
463
+ - Keep context files under 200 lines—use imports to modularize
464
+ - Short declarative bullets, not narrative paragraphs
465
+ - Update immediately when architecture changes (stale docs = confusion)
466
+ - Put critical rules at the END of documents (recency bias)
@@ -198,3 +198,12 @@ Before finalizing data architecture doc:
198
198
  - [ ] Migration strategy covers both additive and breaking changes
199
199
  - [ ] Version and status match codebase (verify with git/deployment)
200
200
  - [ ] Cross-referenced from root ARCHITECTURE.md or SAFEWORD.md (link exists)
201
+
202
+ ---
203
+
204
+ ## Key Takeaways
205
+
206
+ - Data quality, governance, accessibility are core principles
207
+ - Every entity needs: attributes, types, relationships, constraints
208
+ - Performance targets use concrete numbers (e.g., <100ms, not "fast")
209
+ - Migration strategy covers both additive and breaking changes
@@ -1,5 +1,17 @@
1
1
  # Design Doc Guide for Claude Code
2
2
 
3
+ ## Escalation Check
4
+
5
+ **STOP if ANY apply—use `architecture-guide.md` first:**
6
+
7
+ - [ ] Need to choose a technology or library
8
+ - [ ] Need to design a data model or schema
9
+ - [ ] Pattern will affect 2+ features
10
+
11
+ Then return here.
12
+
13
+ ---
14
+
3
15
  ## How to Fill Out Design Doc
4
16
 
5
17
  **Template:** `@.safeword/templates/design-doc-template.md`
@@ -169,3 +181,12 @@ Before saving, verify:
169
181
  **Important:** Design docs are instructions that LLMs read and follow.
170
182
 
171
183
  **See:** `@.safeword/guides/llm-guide.md` for comprehensive framework on writing clear, actionable documentation that LLMs can reliably follow.
184
+
185
+ ---
186
+
187
+ ## Key Takeaways
188
+
189
+ - Escalate to Architecture Doc if: new tech, new schema, or pattern affects 2+ features
190
+ - Reference user stories and test definitions—don't duplicate them
191
+ - Every decision needs: what, why, trade-off
192
+ - ~121 lines target (concise, LLM-optimized)
@@ -616,3 +616,12 @@ npm run test:e2e # E2E tests only
616
616
 
617
617
  1. **Global** (`~/.claude/development-workflow.md`) - Universal methodology (test type selection, TDD workflow)
618
618
  2. **Project** (`tests/SAFEWORD.md`) - Specific stack, commands, patterns
619
+
620
+ ---
621
+
622
+ ## Key Takeaways
623
+
624
+ - RED → GREEN → REFACTOR (never skip steps)
625
+ - Choose test type by answering questions IN ORDER (unit → integration → E2E)
626
+ - Never use arbitrary timeouts—poll until condition is met
627
+ - Test behavior, not implementation details
@@ -550,3 +550,12 @@ This is a **living process** - iterate and refine based on what works.
550
550
  - Refactor when multiple learnings cover similar topics (consolidate)
551
551
  - Split when learning file >200 lines (focus on single concept)
552
552
  - Update SAFEWORD.md references when learnings move or merge
553
+
554
+ ---
555
+
556
+ ## Key Takeaways
557
+
558
+ - Extract after 5+ debug cycles or 3+ approaches tried
559
+ - Check existing learnings first—update, don't duplicate
560
+ - One concept per file, under 200 lines
561
+ - Extract immediately while fresh (don't defer to "later")
@@ -259,6 +259,44 @@ When LLMs hit dead ends, provide concrete next steps.
259
259
  - Login form → Dashboard → E2E test (multi-page)"
260
260
  ```
261
261
 
262
+ ### 14. Position-Aware Writing (Recency Bias)
263
+
264
+ LLMs retain information at the **beginning and end** of context better than the middle. Structure documents accordingly.
265
+
266
+ ```markdown
267
+ ❌ BAD - Critical rules buried in middle:
268
+
269
+ # Guide
270
+
271
+ ## Background (100 lines)
272
+
273
+ ## Details (200 lines)
274
+
275
+ ## Critical Rules (10 lines) ← forgotten
276
+
277
+ ## Appendix (50 lines)
278
+
279
+ ✅ GOOD - Critical rules at end:
280
+
281
+ # Guide
282
+
283
+ ## Background (100 lines)
284
+
285
+ ## Details (200 lines)
286
+
287
+ ## Appendix (50 lines)
288
+
289
+ ## Key Takeaways (10 lines) ← retained
290
+ ```
291
+
292
+ **Application:**
293
+
294
+ - CLAUDE.md / SAFEWORD.md: Put "Always Remember" section last
295
+ - Guides: End with "Key Takeaways" section
296
+ - Templates: Put most important sections at top OR bottom, not middle
297
+
298
+ **Research basis:** "Lost in the middle" phenomenon—models show <40% recall for middle content vs >80% for beginning/end content.
299
+
262
300
  ---
263
301
 
264
302
  ## Anti-Patterns
@@ -267,6 +305,7 @@ When LLMs hit dead ends, provide concrete next steps.
267
305
  ❌ **Undefined jargon** - "Technical debt", "code smell" need definitions
268
306
  ❌ **Competing guidance** - Multiple decision frameworks that contradict each other
269
307
  ❌ **Outdated references** - Remove concepts, but forget to update all mentions
308
+ ❌ **Critical info in the middle** - Most important rules buried between background and appendix
270
309
 
271
310
  ---
272
311
 
@@ -283,6 +322,7 @@ Before saving/committing LLM-consumable documentation:
283
322
  - [ ] Tie-breaking rules provided
284
323
  - [ ] Complex decisions (3+ branches) have lookup tables
285
324
  - [ ] Dead-end paths have re-evaluation steps with examples
325
+ - [ ] Critical rules positioned at END of document (recency bias)
286
326
 
287
327
  ---
288
328
 
@@ -310,3 +350,12 @@ Edge cases:
310
350
  - React components with React Testing Library → Integration (not E2E, no real browser)
311
351
  - Non-deterministic functions (Date.now()) → Unit test with mocked time
312
352
  ```
353
+
354
+ ---
355
+
356
+ ## Key Takeaways
357
+
358
+ - Decision trees: sequential, MECE, with tie-breakers
359
+ - Every rule needs concrete examples (good vs bad)
360
+ - Define all terms explicitly—assume nothing is obvious
361
+ - Put critical rules at the END of documents (recency bias)
@@ -613,4 +613,12 @@ Before writing a story, verify it passes all six criteria:
613
613
  - **Unit:** Single function/module logic (fast, cheap, low-level confidence)
614
614
 
615
615
  **Ratio guidance:** 70% unit, 20% integration, 10% E2E (adjust based on project)
616
- ````
616
+
617
+ ---
618
+
619
+ ## Key Takeaways
620
+
621
+ - RED → GREEN → REFACTOR (commit after each GREEN)
622
+ - Test behavior, not implementation details
623
+ - One assertion per test; test names describe behavior
624
+ - User stories pass INVEST checklist before writing tests
@@ -332,4 +332,12 @@ npm run test:e2e -- tests/feature-name.spec.ts --grep "specific test name"
332
332
  - Concrete examples over abstract rules
333
333
  - Edge cases must be explicit
334
334
  - Actionable over vague language
335
- ````
335
+
336
+ ---
337
+
338
+ ## Key Takeaways
339
+
340
+ - Map each user story acceptance criterion to specific tests
341
+ - Include tests for technical constraints (performance, security, etc.)
342
+ - Test behavior, not implementation details
343
+ - Every skipped test needs documented rationale
@@ -254,3 +254,12 @@ Save specs as: `.safeword/planning/specs/feature-[slug].md`
254
254
 
255
255
  - `user-story-1.md` ← Not descriptive
256
256
  - `STORY_CAMPAIGN_SWITCHING_FINAL_v2.md` ← Bloated
257
+
258
+ ---
259
+
260
+ ## Key Takeaways
261
+
262
+ - INVEST checklist: Independent, Negotiable, Valuable, Estimable, Small, Testable
263
+ - "As a [role], I want [action], so that [value]"—always include the "so that"
264
+ - 1-3 acceptance criteria per story; split if >3
265
+ - Include technical constraints (performance, security, etc.) when relevant
@@ -217,3 +217,12 @@ ps aux | grep "/Users/alex/projects/my-project"
217
217
  ✅ **DO:** Filter by project directory with `$(pwd)`
218
218
  ✅ **DO:** Create project-specific cleanup scripts
219
219
  ✅ **DO:** Clean up before AND after development sessions
220
+
221
+ ---
222
+
223
+ ## Key Takeaways
224
+
225
+ - Use port-based cleanup, not `killall node` (affects all projects)
226
+ - Filter by project directory: `pkill -f "playwright.*$(pwd)"`
227
+ - Clean up before AND after development sessions
228
+ - Create project-specific `scripts/cleanup.sh` for consistent cleanup
File without changes