safeword 0.7.6 → 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 +1 -1
- package/templates/SAFEWORD.md +11 -0
- package/templates/guides/architecture-guide.md +5 -7
- package/templates/guides/cli-reference.md +8 -0
- package/templates/guides/code-philosophy.md +9 -0
- package/templates/guides/context-files-guide.md +9 -0
- package/templates/guides/data-architecture-guide.md +9 -0
- package/templates/guides/design-doc-guide.md +21 -0
- package/templates/guides/development-workflow.md +9 -0
- package/templates/guides/learning-extraction.md +9 -0
- package/templates/guides/llm-guide.md +49 -0
- package/templates/guides/tdd-best-practices.md +9 -1
- package/templates/guides/test-definitions-guide.md +9 -1
- package/templates/guides/user-story-guide.md +9 -0
- package/templates/guides/zombie-process-cleanup.md +9 -0
package/package.json
CHANGED
package/templates/SAFEWORD.md
CHANGED
|
@@ -306,3 +306,14 @@ When markdown lint reports MD040 (missing language), choose:
|
|
|
306
306
|
- Integration struggle between tools
|
|
307
307
|
|
|
308
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
|
|
416
|
+
## Key Takeaways
|
|
417
417
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
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 document—update 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
|