safeword 0.2.4 → 0.2.5

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-RR4M334C.js +266 -0
  22. package/dist/setup-RR4M334C.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,404 +0,0 @@
1
- # Architecture & Design Documentation Guide
2
-
3
- **See:** `@.safeword/guides/llm-instruction-design.md` for LLM-consumable documentation principles.
4
-
5
- ---
6
-
7
- ## Document Type Decision Tree (Follow in Order)
8
-
9
- Answer **IN ORDER**. Stop at the first "Yes":
10
-
11
- 1. **Technology or library choice?** → **Architecture Doc**
12
- 2. **New data model or schema change?** → **Architecture Doc**
13
- 3. **Project-wide pattern or convention?** → **Architecture Doc**
14
- 4. **Implementing a specific feature?** → **Design Doc**
15
-
16
- **Tie-breaker:** If a feature requires a new tech/schema choice, document the tech/schema in Architecture Doc first, then reference it in Design Doc.
17
-
18
- | Term | Definition |
19
- |------|------------|
20
- | Technology choice | Selecting a library, framework, database, or tool |
21
- | Schema change | Adding/modifying entities, tables, relationships, or data types |
22
- | Project-wide pattern | Convention that applies to 2+ features or multiple developers |
23
- | Major decision | Affects 2+ components, costs >$100/month, or cannot be easily reversed |
24
- | Living document | Updated in place (not immutable); changes tracked via version/status |
25
- | ADR | Architecture Decision Record—legacy pattern of separate files per decision |
26
-
27
- ---
28
-
29
- ## Quick Decision Matrix
30
-
31
- | Scenario | Doc Type | Rationale |
32
- |----------|----------|-----------|
33
- | Choosing between technologies | Architecture | Tech choice affects whole project |
34
- | Data model design | Architecture | Schema is project-wide |
35
- | Implementing a new feature | Design | Feature-scoped implementation |
36
- | Recording a trade-off | Architecture | Trade-offs inform future decisions |
37
- | Project-wide principles | Architecture | Principles apply everywhere |
38
- | Component breakdown for feature | Design | Implementation detail |
39
- | Feature needs new schema | Architecture first, then Design | Schema in Arch, feature in Design |
40
-
41
- ---
42
-
43
- ## Architecture Document
44
-
45
- **Use when**: Project-wide decisions, data models, system design
46
-
47
- **Characteristics**:
48
- - One per project/package (in monorepos)
49
- - Living document (updated in place—not immutable ADRs)
50
- - Documents WHY behind all major decisions
51
- - Includes version, status, table of contents
52
-
53
- **Location**: Project root (`ARCHITECTURE.md`)
54
-
55
- **Edge cases:**
56
- - Schema change for one feature → Architecture Doc (schema is project-wide)
57
- - Library for one feature → Architecture Doc if precedent-setting; Design Doc if one-off
58
- - Performance optimization → Architecture Doc if changes patterns; Design Doc if feature-specific
59
-
60
- ### Required Sections
61
-
62
- - **Header**: Version, Last Updated, Status (Production/Design/Proposed/Deprecated)
63
- - **Table of Contents**: Section links
64
- - **Overview**: Technology choices, data model philosophy, high-level architecture
65
- - **Data Model / Schema**: Tables, types, relationships
66
- - **Key Decisions**: What, Why, Trade-off, Alternatives Considered
67
- - **Best Practices**: Domain-specific patterns
68
- - **Migration Strategy**: How to evolve architecture
69
-
70
- ---
71
-
72
- ## Design Document
73
-
74
- **Use when**: Designing a specific feature implementation
75
-
76
- **Characteristics**:
77
- - Feature-focused (~121 lines)
78
- - Implementation details (components, data flow, user flow)
79
- - References architecture doc (don't duplicate)
80
-
81
- **Location**: `planning/design/` or `docs/design/`
82
-
83
- **Edge cases:**
84
- - Feature needs new data model → Schema in Architecture Doc first, then reference
85
- - Feature spans 3+ components → Still Design Doc (component count doesn't change doc type)
86
- - Feature establishes pattern others follow → Pattern in Architecture Doc, implementation in Design Doc
87
-
88
- **See:** `@.safeword/guides/design-doc-guide.md` for detailed guidance
89
-
90
- ---
91
-
92
- ## Best Practices
93
-
94
- ### 1. One Architecture Doc Per Project/Package
95
-
96
- **✅ GOOD:**
97
- ```
98
- project/
99
- ├── ARCHITECTURE.md
100
- └── docs/design/
101
- ├── feature-a.md
102
- └── feature-b.md
103
- ```
104
-
105
- **❌ BAD:** `docs/adr/001-use-typescript.md, 002-adopt-monorepo.md...` (50+ files = fragmented context)
106
-
107
- ### 2. Living Document (Not Immutable)
108
-
109
- Update in place with version/status tracking:
110
-
111
- ```markdown
112
- ### Decision: State Management
113
- **Status**: Active (Updated 2025-01-20)
114
- **What**: Migrated from localStorage to IndexedDB
115
- **Why**: Hit 5MB limit, needed unlimited storage
116
- **Migration**: Completed 2025-01-20, users auto-migrated on load
117
- ```
118
-
119
- **Edge cases:**
120
- - Decision reversed → Update original with "Superseded" status
121
- - Major shift → Bump version (v1 → v2), add migration section
122
- - Affects multiple subsystems → Update main Architecture Doc, not separate files
123
-
124
- ### 3. Document WHY, Not Just WHAT
125
-
126
- **✅ GOOD:**
127
- ```markdown
128
- ### Principle: Separation of Concerns
129
- **What**: Static data → immutable storage; Mutable state → persistent storage
130
- **Why**: Static data saves NKB per instance; updates affect all instances instantly
131
- **Trade-off**: More complex loading (fetch static + query persistent)
132
- **Alternatives Considered**: All localStorage (rejected: 5MB limit); All IndexedDB (rejected: overkill for config)
133
- ```
134
-
135
- **❌ BAD:** `Database: PostgreSQL, State: Zustand, UI: React` (no rationale)
136
-
137
- **Required fields:**
138
-
139
- | Field | Required | Description |
140
- |-------|----------|-------------|
141
- | What | Always | The decision (1-2 sentences) |
142
- | Why | Always | Rationale with specifics (numbers, metrics) |
143
- | Trade-off | Always | What we gave up or accepted |
144
- | Alternatives | Major decisions | Other options and why rejected |
145
- | Migration | If breaking | How to evolve from previous state |
146
-
147
- **Edge cases:**
148
- - Obvious choice → Still document; future devs may question
149
- - Inherited decision → Document as "Inherited: [reason]"
150
- - Temporary decision → Mark "Temporary" with planned review date
151
-
152
- ### 4. Include Code References
153
-
154
- **✅ GOOD:**
155
- ```markdown
156
- **Implementation**: See `src/stores/gameStore.ts:12-45`
157
- **Usage example**: See `src/components/GamePanel.tsx`
158
- ```
159
-
160
- **❌ BAD:** "We use Zustand for state management" (no reference to actual code)
161
-
162
- - Key patterns → file + line range
163
- - Simple utilities → file path only (no line numbers)
164
- - Frequently changing code → file path only (line numbers go stale)
165
-
166
- ### 5. Version and Track Status
167
-
168
- | Status | Meaning |
169
- |--------|---------|
170
- | Design | Initial draft, not yet implemented |
171
- | Production | Live in production |
172
- | Proposed | Planned extension to production |
173
- | Deprecated | Being phased out |
174
-
175
- **Version bumps:** Major schema changes → v1 → v2; New sections → v1.0 → v1.1; Clarifications → no bump
176
-
177
- ---
178
-
179
- ## TDD Workflow Integration
180
-
181
- **Workflow Order**:
182
- 1. User Stories → What we're building
183
- 2. Test Definitions → How we'll verify
184
- 3. Design Doc → How we'll build it
185
- 4. Check Architecture Doc → New tech/schema needed?
186
- 5. Implement (RED → GREEN → REFACTOR)
187
- 6. Update Architecture Doc if needed
188
-
189
- ### When to Update Architecture Doc
190
-
191
- | Trigger | Example |
192
- |---------|---------|
193
- | New data model concept | New "Subscription" entity |
194
- | Technology choice | "Chose Resend for email" |
195
- | New pattern/convention | "All forms use react-hook-form" |
196
- | Architectural insight during implementation | "IndexedDB needed for offline" |
197
- | Performance bottleneck requiring change | "Migrated to Redis for sessions" |
198
-
199
- ### When NOT to Update
200
-
201
- | Scenario | Where Instead |
202
- |----------|---------------|
203
- | Single feature implementation | Design Doc |
204
- | Bug fix | Code comments if complex |
205
- | Refactor without pattern change | PR description |
206
-
207
- **Edge case:** Bug fix reveals architectural flaw → Document flaw and fix in Architecture Doc.
208
-
209
- ---
210
-
211
- ## Common Mistakes
212
-
213
- ### Architecture Doc Anti-Patterns
214
-
215
- | Anti-Pattern | Fix |
216
- |--------------|-----|
217
- | ADR sprawl (001, 002...) | One comprehensive `ARCHITECTURE.md` |
218
- | No decision rationale | Add What/Why/Trade-off |
219
- | Missing version/status | Add header with Version and Status |
220
- | Implementation details | Move to Design Doc or code |
221
-
222
- **❌ BAD:** `GET /api/users → Returns users from PostgreSQL` (implementation detail)
223
-
224
- **✅ GOOD:** `API Design: RESTful routes with input validation at boundary` (principle)
225
-
226
- ### Design Doc Anti-Patterns
227
-
228
- | Anti-Pattern | Fix |
229
- |--------------|-----|
230
- | Repeating architecture content | Reference Architecture Doc |
231
- | Skipping user flow | Include step-by-step interaction |
232
- | Missing test mapping | Link to test definitions |
233
- | >200 lines | Split or extract to Architecture |
234
-
235
- ---
236
-
237
- ## Re-evaluation Path (When Unclear)
238
-
239
- Answer **IN ORDER**:
240
-
241
- 1. **Affects 2+ features?** → Architecture Doc (stop)
242
- 2. **Technology/data model choice?** → Architecture Doc (stop)
243
- 3. **Future developers need this for whole project?** → Architecture Doc
244
- 4. **Only for this feature?** → Design Doc
245
-
246
- **Tie-breaker:** When still unclear, default to Design Doc. Easier to promote later than to split.
247
-
248
- ### Worked Example: Adding User Notifications
249
-
250
- **Scenario:** Add email notifications when users complete a purchase.
251
-
252
- 1. **Affects 2+ features?** No, only checkout → Continue
253
- 2. **Tech choice?** Yes, need to choose email service (SendGrid vs SES) → **Architecture Doc**
254
-
255
- **Result:**
256
- - `ARCHITECTURE.md` → "Email Service: SendGrid (Why: deliverability, cost, SDK quality)"
257
- - `planning/design/checkout-notifications.md` → Feature implementation referencing email decision
258
-
259
- ---
260
-
261
- ## File Organization
262
-
263
- ```
264
- project/
265
- ├── ARCHITECTURE.md # Single comprehensive doc
266
- ├── .safeword/planning/
267
- │ ├── user-stories/
268
- │ ├── test-definitions/
269
- │ └── design/ # Feature-specific design docs
270
- └── src/
271
- ```
272
-
273
- ---
274
-
275
- ## Layers & Boundaries
276
-
277
- **Purpose:** Define architectural layers and enforce dependency rules to prevent circular dependencies, god modules, and leaky abstractions.
278
-
279
- ### Layer Definitions
280
-
281
- | Layer | Directory | Responsibility |
282
- |-------|-----------|----------------|
283
- | app | `src/app/` | UI, routing, composition |
284
- | domain | `src/domain/` | Business rules, pure logic |
285
- | infra | `src/infra/` | IO, APIs, DB, external SDKs |
286
- | shared | `src/shared/` | Utilities usable by all layers |
287
-
288
- ### Allowed Dependencies
289
-
290
- | From | To | Allowed | Rationale |
291
- |------|-----|---------|-----------|
292
- | app | domain | ✅ | UI composes business logic |
293
- | app | infra | ✅ | UI triggers side effects |
294
- | app | shared | ✅ | Utilities available everywhere |
295
- | domain | app | ❌ | Domain must be framework-agnostic |
296
- | domain | infra | ❌ | Domain contains pure logic only |
297
- | domain | shared | ✅ | Utilities available everywhere |
298
- | infra | domain | ✅ | Adapters may use domain types |
299
- | infra | app | ❌ | Infra should not depend on UI |
300
- | infra | shared | ✅ | Utilities available everywhere |
301
- | shared | * | ❌ | Shared has no dependencies (except external libs) |
302
-
303
- **Note:** This template allows direct app→infra. Alternative: force app→domain→infra for stricter separation (hexagonal/ports-adapters pattern).
304
-
305
- ### Edge Cases
306
-
307
- | Scenario | Solution |
308
- |----------|----------|
309
- | Project doesn't fit 3-layer model | Document actual layers, same boundary rules apply |
310
- | Feature module needs another feature | Import via public API (`index.ts`) only |
311
- | Shared utilities | Create `shared/` layer, all layers may import |
312
- | Brownfield adoption | Start with warnings-only mode, fix violations incrementally, then enforce |
313
- | Monorepo with multiple apps | Each app has own layers; shared packages are explicit dependencies |
314
-
315
- ### Enforcement with eslint-plugin-boundaries
316
-
317
- **Setup:**
318
-
319
- 1. Install: `npm install --save-dev eslint-plugin-boundaries`
320
-
321
- 2. Add to `eslint.config.mjs`:
322
-
323
- ```javascript
324
- import boundaries from 'eslint-plugin-boundaries';
325
-
326
- export default defineConfig([
327
- // ... other configs ...
328
- {
329
- name: 'boundaries-config',
330
- files: ['**/*.{js,ts,tsx}'],
331
- plugins: { boundaries },
332
- settings: {
333
- 'boundaries/include': ['src/**/*'],
334
- 'boundaries/elements': [
335
- { type: 'app', pattern: 'src/app/**/*' },
336
- { type: 'domain', pattern: 'src/domain/**/*' },
337
- { type: 'infra', pattern: 'src/infra/**/*' },
338
- { type: 'shared', pattern: 'src/shared/**/*' },
339
- ],
340
- },
341
- rules: {
342
- 'boundaries/element-types': ['error', {
343
- default: 'disallow',
344
- rules: [
345
- { from: 'app', allow: ['domain', 'infra', 'shared'] },
346
- { from: 'domain', allow: ['shared'] },
347
- { from: 'infra', allow: ['domain', 'shared'] },
348
- { from: 'shared', allow: [] },
349
- ],
350
- }],
351
- 'boundaries/no-unknown-files': 'error',
352
- },
353
- },
354
- ]);
355
- ```
356
-
357
- 3. Define layers in `ARCHITECTURE.md` (see template)
358
-
359
- 4. Errors appear in IDE + CI automatically
360
-
361
- **Common Issues:**
362
-
363
- | Issue | Fix |
364
- |-------|-----|
365
- | "Unknown file" errors | Ensure all source files are in defined layers |
366
- | False positives on tests | Exclude test files: `'boundaries/include': ['src/**/*', '!**/*.test.*']` |
367
- | External library imports flagged | External deps are allowed by default; check `boundaries/ignore` setting |
368
-
369
- ---
370
-
371
- ## Data Architecture
372
-
373
- **For data-heavy projects**, see `@.safeword/guides/data-architecture-guide.md` for:
374
- - Core principles (data quality, governance, accessibility)
375
- - What to document (conceptual/logical/physical models, flows, policies)
376
- - Integration with TDD workflow
377
-
378
- ---
379
-
380
- ## Quality Checklist
381
-
382
- **Architecture Doc:**
383
- - [ ] Sequential decision tree or clear structure
384
- - [ ] All decisions have What/Why/Trade-off
385
- - [ ] Version and Status in header
386
- - [ ] Code references for key patterns
387
- - [ ] No implementation details
388
-
389
- **Design Doc:**
390
- - [ ] References Architecture Doc (no duplication)
391
- - [ ] User flow step-by-step
392
- - [ ] Test mapping links
393
- - [ ] ~121 lines target
394
-
395
- ---
396
-
397
- ## Key Takeaway
398
-
399
- **One comprehensive architecture document per project** > many scattered ADR files:
400
-
401
- ✅ Full context in one place
402
- ✅ Living document (update in place)
403
- ✅ LLMs consume entire architecture at once
404
- ✅ Sequential decision trees prevent ambiguity
@@ -1,174 +0,0 @@
1
- # Code Philosophy & Practices
2
-
3
- **Note:** This file provides instructions for LLM-based coding agents. For comprehensive framework on writing clear, actionable LLM-consumable instructions, see `@.safeword/guides/llm-instruction-design.md`.
4
-
5
- ---
6
-
7
- ## Communication Style
8
- - Be concise, clear, direct, technical, friendly, and educational
9
- - Show reasoning when it adds value, otherwise just deliver results
10
- - No emojis unless explicitly requested
11
-
12
- ## Response Format
13
- At the end of EVERY response, include a JSON summary with this exact structure:
14
- ```json
15
- {"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}
16
- ```
17
-
18
- Where (all fields describe **this response only**, not cumulative):
19
- - `proposedChanges`: `true` if you suggested/proposed changes to specific files **in this response**
20
- - `madeChanges`: `true` if you **modified files in this response** using Write/Edit tools
21
- - `askedQuestion`: `true` if you asked the user a question and need their response before proceeding
22
-
23
- Examples:
24
- - Discussed approach only: `{"proposedChanges": false, "madeChanges": false, "askedQuestion": false}`
25
- - Proposed edits but waiting for approval: `{"proposedChanges": true, "madeChanges": false, "askedQuestion": false}`
26
- - Made edits directly: `{"proposedChanges": false, "madeChanges": true, "askedQuestion": false}`
27
- - Proposed AND made edits: `{"proposedChanges": true, "madeChanges": true, "askedQuestion": false}`
28
- - Asked user a question: `{"proposedChanges": false, "madeChanges": false, "askedQuestion": true}`
29
- - **Quality review response** (no new changes): `{"proposedChanges": false, "madeChanges": false, "askedQuestion": false}`
30
-
31
- ## Code Philosophy
32
- - **Elegant code and architecture** - Prioritize developer experience
33
- - **AVOID BLOAT** - Simple, focused solutions over complex ones
34
- - **Self-documenting code** - Minimal inline comments, clear naming and structure
35
- - **Explicit error handling** - NEVER suppress or swallow errors silently
36
-
37
- **Error handling examples:**
38
- | ❌ Bad | ✅ Good |
39
- |--------|---------|
40
- | `catch (e) {}` (swallowed) | `catch (e) { throw new Error(\`Failed to read ${filePath}: ${e.message}\`) }` |
41
- | `catch (e) { console.log(e) }` | `catch (e) { logger.error('Payment failed', { userId, amount, error: e }) }` |
42
- | Generic "Something went wrong" | "Failed to save user profile: database connection timeout" |
43
-
44
- **Naming examples:**
45
- | ❌ Bad | ✅ Good |
46
- |--------|---------|
47
- | `calcTot` | `calculateTotalWithTax` |
48
- | `d`, `tmp`, `data` | `userProfile`, `pendingOrders` |
49
- | `handleClick` | `submitPaymentForm` |
50
- | `process()` | `validateAndSaveUser()` |
51
-
52
- **When to comment:**
53
- - ✅ Non-obvious business logic ("Tax exempt for orders >$500 per policy X")
54
- - ✅ Workarounds ("Safari requires this delay due to bug #123")
55
- - ❌ Obvious code (`// increment counter` before `i++`)
56
- - ❌ Restating the function name
57
-
58
- **Bloat examples (avoid these):**
59
- | ❌ Bloat | ✅ Instead |
60
- |----------|-----------|
61
- | Utility class for one function | Single function |
62
- | Factory pattern for simple object | Direct construction |
63
- | Abstract base class with one implementation | Concrete class |
64
- | Config file for 2 options | Hardcode or simple params |
65
- | "Future-proofing" unused code paths | Delete, add when needed |
66
-
67
- **When to push back:** If a feature request would add >50 lines for a "nice to have", ask: "Is this essential now, or can we add it later?"
68
-
69
- ## Documentation Verification (CRITICAL)
70
- - **Always look up current documentation** for libraries, tools, and frameworks
71
- - Do NOT assume API compatibility - verify the actual version being used
72
- - Check docs unless they're already loaded in the context window
73
- - **NEVER assume features exist** - Training data is at least 1 year old; when uncertain, verify first
74
-
75
- **How to verify:**
76
- 1. Check `package.json` (or equivalent) for installed version
77
- 2. Use Context7 MCP or official docs for current API
78
- 3. If uncertain, ask user: "Which version of X are you using?"
79
-
80
- ## Testing Philosophy
81
-
82
- **Test what matters** - Focus on user experience and delivered features, not implementation details.
83
-
84
- **Test-Driven Development (TDD):**
85
- - Write tests BEFORE implementing features (RED → GREEN → REFACTOR)
86
- - Tests define expected behavior, code makes them pass
87
- - Refactor with confidence knowing tests catch regressions
88
-
89
- **Always test what you build** - Run tests yourself before completion. Don't ask the user to verify.
90
-
91
- **NEVER modify or skip tests without approval:**
92
- - ❌ Changing test expectations to match broken code
93
- - ❌ Adding `.skip()` or `.todo()` to make failures go away
94
- - ❌ Deleting tests you can't get passing
95
- - ✅ If a test fails, fix the implementation—not the test
96
- - ✅ If a test seems wrong or requirements changed, explain why and ask before changing it
97
-
98
- **Workflow:** See `@.safeword/guides/testing-methodology.md` for comprehensive TDD workflow (RED → GREEN → REFACTOR phases)
99
-
100
- ## Debugging & Troubleshooting
101
-
102
- **Debug Logging:**
103
- - When debugging, log **actual vs expected** values (not just pass/fail)
104
- - Use JSON.stringify() for complex objects to see structure
105
- - Remove debug logging after fixing (keep production code clean)
106
-
107
- ```javascript
108
- // ❌ Bad: console.log('here')
109
- // ✅ Good: console.log('validateUser', { expected: 'admin', actual: user.role })
110
- ```
111
-
112
- **Cross-Platform Development:**
113
- - Test on all target platforms early (macOS, Windows, Linux)
114
- - Never assume Unix-style paths (`/`) - handle both `/` and `\`
115
- - Be aware of runtime environment (browser vs Node.js, client vs server)
116
-
117
- ```javascript
118
- // ❌ Bad: dir + '/' + filename
119
- // ✅ Good: path.join(dir, filename)
120
- ```
121
-
122
- ## Best Practices (Always Apply)
123
- Before implementing, research and apply:
124
- - **Tool-specific best practices** - Use libraries/frameworks as intended
125
- - **Domain best practices** - Follow conventions for the type of app (CLI, web editor, API, etc.)
126
- - **UX best practices** - Prioritize user experience in design decisions
127
-
128
- **How to research:** Use Context7 MCP or official docs. Check for established patterns before inventing your own.
129
-
130
- ## Self-Review Checklist
131
- Before completing any work, verify:
132
- - ✓ Is it correct? Will it actually work?
133
- - ✓ Is it elegant? Does it avoid bloat?
134
- - ✓ Does it follow best practices?
135
- - ✓ Are you using the right docs/versions?
136
- - ✓ Have you tested the user-facing functionality?
137
-
138
- **Blockers:** If something can't be fixed now, note it explicitly: "Deferred: [issue] because [reason]"
139
-
140
- ## Asking Questions
141
- - **Be proactive and self-sufficient** - Don't be lazy
142
- - Only ask questions when you genuinely can't find the answer through:
143
- - Online documentation and research
144
- - Reading the codebase
145
- - Running tests or experiments
146
- - Ask non-obvious questions that require user domain knowledge or preferences
147
- - **When asking, show what you tried:** "I checked X and Y but couldn't determine Z. What's your preference?"
148
-
149
- ## Tools & CLIs
150
-
151
- **Keep these updated** (check before starting new projects):
152
- - GitHub CLI (`gh`)
153
- - AWS CLI
154
- - Railway CLI
155
- - PostHog CLI
156
-
157
- **Update workflow:**
158
- 1. Check current version: `gh --version`, `aws --version`, etc.
159
- 2. Check for updates: `brew upgrade gh` or tool-specific update command
160
- 3. Review changelog for breaking changes before major version updates
161
- 4. If breaking changes affect your workflow, pin to current version until migration planned
162
-
163
- **When to pin versions:** If a tool is used in CI/automation, pin to specific version in scripts to avoid surprise breakages.
164
-
165
- ## Git Workflow
166
- - Commit whenever work is completed
167
- - Commit often to checkpoint progress
168
- - Use descriptive commit messages
169
- - Make atomic commits (one logical change per commit)
170
-
171
- ```
172
- # ❌ Bad: "misc fixes"
173
- # ✅ Good: "fix: login button not responding to clicks"
174
- ```