safeword 0.6.3 → 0.6.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.
- package/dist/{check-PECCGHEA.js → check-OYYSYHFP.js} +41 -23
- package/dist/check-OYYSYHFP.js.map +1 -0
- package/dist/chunk-LNSEDZIW.js +454 -0
- package/dist/chunk-LNSEDZIW.js.map +1 -0
- package/dist/chunk-ZS3Z3Q37.js +729 -0
- package/dist/chunk-ZS3Z3Q37.js.map +1 -0
- package/dist/cli.js +7 -7
- package/dist/cli.js.map +1 -1
- package/dist/diff-325TIZ63.js +168 -0
- package/dist/diff-325TIZ63.js.map +1 -0
- package/dist/reset-ZGJIKMUW.js +74 -0
- package/dist/reset-ZGJIKMUW.js.map +1 -0
- package/dist/setup-GAMXTFM2.js +103 -0
- package/dist/setup-GAMXTFM2.js.map +1 -0
- package/dist/{sync-4XBMKLXS.js → sync-BFMXZEHM.js} +33 -32
- package/dist/sync-BFMXZEHM.js.map +1 -0
- package/dist/upgrade-X4GREJXN.js +73 -0
- package/dist/upgrade-X4GREJXN.js.map +1 -0
- package/package.json +15 -14
- package/templates/SAFEWORD.md +101 -689
- package/templates/guides/architecture-guide.md +1 -1
- package/templates/guides/cli-reference.md +35 -0
- package/templates/guides/code-philosophy.md +22 -19
- package/templates/guides/context-files-guide.md +2 -2
- package/templates/guides/data-architecture-guide.md +1 -1
- package/templates/guides/design-doc-guide.md +1 -1
- package/templates/guides/{testing-methodology.md → development-workflow.md} +1 -1
- package/templates/guides/learning-extraction.md +1 -1
- package/templates/guides/{llm-instruction-design.md → llm-guide.md} +93 -29
- package/templates/guides/tdd-best-practices.md +2 -2
- package/templates/guides/test-definitions-guide.md +1 -1
- package/templates/guides/user-story-guide.md +1 -1
- package/templates/guides/zombie-process-cleanup.md +1 -1
- package/dist/check-PECCGHEA.js.map +0 -1
- package/dist/chunk-6CVTH67L.js +0 -43
- package/dist/chunk-6CVTH67L.js.map +0 -1
- package/dist/chunk-75FKNZUM.js +0 -15
- package/dist/chunk-75FKNZUM.js.map +0 -1
- package/dist/chunk-ARIAOK2F.js +0 -110
- package/dist/chunk-ARIAOK2F.js.map +0 -1
- package/dist/chunk-FRPJITGG.js +0 -35
- package/dist/chunk-FRPJITGG.js.map +0 -1
- package/dist/chunk-IWWBZVHT.js +0 -274
- package/dist/chunk-IWWBZVHT.js.map +0 -1
- package/dist/diff-ZACVJKOU.js +0 -171
- package/dist/diff-ZACVJKOU.js.map +0 -1
- package/dist/reset-5SRM3P6J.js +0 -145
- package/dist/reset-5SRM3P6J.js.map +0 -1
- package/dist/setup-65EVU5OT.js +0 -437
- package/dist/setup-65EVU5OT.js.map +0 -1
- package/dist/sync-4XBMKLXS.js.map +0 -1
- package/dist/upgrade-P3WX3ODU.js +0 -153
- package/dist/upgrade-P3WX3ODU.js.map +0 -1
- package/templates/guides/llm-prompting.md +0 -102
- /package/templates/prompts/{review.md → quality-review.md} +0 -0
package/templates/SAFEWORD.md
CHANGED
|
@@ -1,134 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SAFEWORD Agent Instructions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Core guidance for AI coding agents. Uses imports for detailed workflows.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Quick Reference
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
**Fallback:** If project uses `docs/` structure instead, follow existing convention.
|
|
9
|
+
| Task | Guide |
|
|
10
|
+
| ------------------------ | ---------------------------------------------- |
|
|
11
|
+
| Feature development | @./.safeword/guides/development-workflow.md |
|
|
12
|
+
| User stories | @./.safeword/guides/user-story-guide.md |
|
|
13
|
+
| Test definitions | @./.safeword/guides/test-definitions-guide.md |
|
|
14
|
+
| TDD patterns / examples | @./.safeword/guides/tdd-best-practices.md |
|
|
15
|
+
| Design docs | @./.safeword/guides/design-doc-guide.md |
|
|
16
|
+
| Architecture decisions | @./.safeword/guides/architecture-guide.md |
|
|
17
|
+
| Data architecture | @./.safeword/guides/data-architecture-guide.md |
|
|
18
|
+
| LLM integration & docs | @./.safeword/guides/llm-guide.md |
|
|
19
|
+
| Context file maintenance | @./.safeword/guides/context-files-guide.md |
|
|
20
|
+
| Learning extraction | @./.safeword/guides/learning-extraction.md |
|
|
21
|
+
| Process cleanup | @./.safeword/guides/zombie-process-cleanup.md |
|
|
22
|
+
| Code standards | @./.safeword/guides/code-philosophy.md |
|
|
23
|
+
| Safeword CLI | @./.safeword/guides/cli-reference.md |
|
|
26
24
|
|
|
27
25
|
---
|
|
28
26
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
**Purpose:** Self-contained setup scripts for installing Claude Code hooks and configurations in your projects.
|
|
32
|
-
|
|
33
|
-
**Available scripts:**
|
|
34
|
-
|
|
35
|
-
- `setup-safeword.sh` - **One-command installer** (copies guides/templates, planning/tickets/learnings, adds triggers)
|
|
36
|
-
- `setup-claude.sh` - Sets up Claude hooks, Arcade MCP gateway, CLAUDE.md trigger
|
|
37
|
-
- `setup-linting.sh` - Auto-linting on file changes (ESLint + Prettier)
|
|
38
|
-
- `setup-quality.sh` - Quality review prompts (Stop hook) and settings
|
|
39
|
-
|
|
40
|
-
**Usage:**
|
|
41
|
-
|
|
42
|
-
**One-command setup (recommended):**
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
cd /path/to/your/project
|
|
46
|
-
bash ./framework/scripts/setup-safeword.sh # Install SAFEWORD structure + docs
|
|
47
|
-
bash ./framework/scripts/setup-claude.sh # Install Claude hooks (+ MCP gateway)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Auto-detection:** Automatically detects project type from package.json and config files:
|
|
51
|
-
|
|
52
|
-
- Next.js → if next in dependencies (ESLint + React plugins)
|
|
53
|
-
- Electron → if electron in dependencies
|
|
54
|
-
- Astro → if astro in dependencies
|
|
55
|
-
- React → if react in dependencies
|
|
56
|
-
- TypeScript → if typescript in dependencies or tsconfig.json exists
|
|
57
|
-
- Minimal → otherwise
|
|
58
|
-
|
|
59
|
-
**Individual scripts (advanced):**
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
cd /path/to/your/project
|
|
63
|
-
bash ./framework/scripts/setup-linting.sh --typescript # Linting only
|
|
64
|
-
bash ./framework/scripts/setup-quality.sh # Quality review only
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Linting:** Auto-detects TypeScript, React, Astro from package.json.
|
|
68
|
-
|
|
69
|
-
- Two-file architecture:
|
|
70
|
-
- `.safeword/eslint/eslint-base.mjs` - Auto-generated every run (DO NOT EDIT)
|
|
71
|
-
- `eslint.config.mjs` - Your config (customize freely, never overwritten)
|
|
72
|
-
- After adding/removing frameworks: just re-run `bash setup-linting.sh`
|
|
73
|
-
- Override detection: `--no-typescript`, `--no-react`, `--no-astro`
|
|
74
|
-
|
|
75
|
-
**What they create:**
|
|
76
|
-
|
|
77
|
-
- `.safeword/SAFEWORD.md` - Global patterns and workflows (copied from this file)
|
|
78
|
-
- `.safeword/guides/` - Reference documentation
|
|
79
|
-
- `.claude/hooks/` - Hook scripts (with version comments)
|
|
80
|
-
- `.claude/commands/` - Slash commands (`/lint`, `/review`, `/architecture`)
|
|
81
|
-
- `.claude/settings.json` - Hook configuration (appends to existing)
|
|
82
|
-
- `SAFEWORD.md` or `CLAUDE.md` - Project context file with ALWAYS trigger for @./.safeword/SAFEWORD.md
|
|
83
|
-
- If CLAUDE.md exists → prepends trigger
|
|
84
|
-
- If SAFEWORD.md exists → ensure it references @./.safeword/SAFEWORD.md
|
|
85
|
-
- If neither exists → creates SAFEWORD.md with trigger
|
|
86
|
-
- Config files if needed (`eslint.config.mjs`, `.prettierrc`)
|
|
87
|
-
|
|
88
|
-
**Key features:**
|
|
89
|
-
|
|
90
|
-
- ✅ **Fully standalone** - All files copied to project, no external dependencies
|
|
91
|
-
- ✅ **Version tracking** - Generated files include version comments
|
|
92
|
-
- ✅ **Idempotent** - Safe to run multiple times, won't duplicate hooks
|
|
93
|
-
- ✅ **Append-only** - Preserves existing custom hooks
|
|
94
|
-
- ✅ **Order-independent** - Can run scripts in any order
|
|
95
|
-
|
|
96
|
-
**Documentation:**
|
|
27
|
+
## Planning Documentation
|
|
97
28
|
|
|
98
|
-
|
|
29
|
+
**Location:** `.safeword/planning/` at project root
|
|
99
30
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
cd /path/to/project
|
|
106
|
-
bash ./framework/scripts/setup-safeword.sh # One command, full setup
|
|
107
|
-
```
|
|
108
|
-
3. **Result**: Project becomes standalone with:
|
|
109
|
-
- `.safeword/SAFEWORD.md` - Global patterns (copy of this file)
|
|
110
|
-
- `.safeword/guides/` - Reference documentation
|
|
111
|
-
- `.claude/` - Hooks and commands
|
|
112
|
-
|
|
113
|
-
- `SAFEWORD.md` or `CLAUDE.md` - Project context with @./.safeword/SAFEWORD.md reference
|
|
31
|
+
- User stories → `.safeword/planning/user-stories/`
|
|
32
|
+
- Test definitions → `.safeword/planning/test-definitions/`
|
|
33
|
+
- Design docs → `.safeword/planning/design/`
|
|
34
|
+
- Issues → `.safeword/planning/issues/`
|
|
114
35
|
|
|
115
|
-
|
|
116
|
-
5. **Delete source**: Can delete setup scripts/repo after running - project is fully portable
|
|
36
|
+
**Archive:** Move completed docs to `archive/` subfolder within each.
|
|
117
37
|
|
|
118
38
|
---
|
|
119
39
|
|
|
120
|
-
## Ticket System
|
|
40
|
+
## Ticket System
|
|
121
41
|
|
|
122
|
-
**Purpose:**
|
|
42
|
+
**Purpose:** Context anchor to prevent LLM loops during complex work.
|
|
123
43
|
|
|
124
|
-
**
|
|
44
|
+
**Location:** `.safeword/tickets/{id}-{slug}.md`
|
|
125
45
|
|
|
126
|
-
**
|
|
46
|
+
**Create ticket? Answer IN ORDER, stop at first match:**
|
|
127
47
|
|
|
128
|
-
|
|
48
|
+
1. Multiple attempts likely needed? → Create ticket
|
|
49
|
+
2. Multi-step with dependencies? → Create ticket
|
|
50
|
+
3. Investigation/debugging required? → Create ticket
|
|
51
|
+
4. Risk of losing context mid-session? → Create ticket
|
|
52
|
+
5. None of above? → Skip ticket
|
|
129
53
|
|
|
130
|
-
|
|
131
|
-
- Planning docs (if needed) share same prefix: `002-add-oauth.md` in planning subfolders
|
|
54
|
+
**Examples:** "Fix typo" → skip. "Debug slow login" → ticket. "Add OAuth" → ticket.
|
|
132
55
|
|
|
133
56
|
**Minimal structure:**
|
|
134
57
|
|
|
@@ -136,641 +59,130 @@ bash ./framework/scripts/setup-quality.sh # Quality review only
|
|
|
136
59
|
---
|
|
137
60
|
id: 001
|
|
138
61
|
status: in_progress
|
|
139
|
-
created: 2025-11-24T19:00:00Z
|
|
140
|
-
last_modified: 2025-11-24T19:09:00Z
|
|
141
62
|
---
|
|
142
63
|
|
|
143
|
-
#
|
|
144
|
-
|
|
145
|
-
**Goal:** Make login button respond to clicks
|
|
64
|
+
# [Title]
|
|
146
65
|
|
|
147
|
-
**
|
|
66
|
+
**Goal:** [one sentence]
|
|
148
67
|
|
|
149
68
|
## Work Log
|
|
150
69
|
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
-
|
|
154
|
-
- 2025-11-24T19:08:15Z GREEN: Added onClick handler; test passing (refs: 7f3e2a9)
|
|
155
|
-
- 2025-11-24T19:09:00Z Complete: Button fixed, verified with test
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**For complex features, add optional sections:**
|
|
159
|
-
|
|
160
|
-
```markdown
|
|
161
|
-
### Planning Docs
|
|
162
|
-
|
|
163
|
-
- .safeword/planning/user-stories/002-oauth-login.md
|
|
164
|
-
- .safeword/planning/test-definitions/002-oauth-login.md
|
|
165
|
-
|
|
166
|
-
### Scope
|
|
167
|
-
|
|
168
|
-
**In scope:** Google OAuth, account linking, token refresh
|
|
169
|
-
**Out of scope:** Other providers (separate ticket)
|
|
170
|
-
|
|
171
|
-
### Acceptance Criteria
|
|
172
|
-
|
|
173
|
-
- [ ] All user stories completed
|
|
174
|
-
- [ ] Security review passed
|
|
70
|
+
- [timestamp] Started: [task]
|
|
71
|
+
- [timestamp] Found: [finding]
|
|
72
|
+
- [timestamp] Complete: [result]
|
|
175
73
|
```
|
|
176
74
|
|
|
177
|
-
**
|
|
178
|
-
|
|
179
|
-
**Work Log is critical:** Log immediately after each action. Re-read ticket frequently to prevent loops.
|
|
180
|
-
|
|
181
|
-
**When to create tickets (context-loss risk assessment):**
|
|
182
|
-
|
|
183
|
-
**Create ticket if ANY of these apply:**
|
|
184
|
-
|
|
185
|
-
- Work might require multiple attempts/approaches (styling bugs, performance issues)
|
|
186
|
-
- Work has multiple steps with dependencies (A must work before B)
|
|
187
|
-
- Investigation/debugging required (unknown cause, non-obvious solution)
|
|
188
|
-
- Anything that might cause you to lose context or loop mid-session
|
|
189
|
-
|
|
190
|
-
**Skip ticket if:**
|
|
191
|
-
|
|
192
|
-
- Obvious one-shot change (fix typo, update constant, change text label)
|
|
193
|
-
- Takes <2 minutes with zero risk of confusion or cascading issues
|
|
194
|
-
- No investigation needed, solution is clear
|
|
195
|
-
|
|
196
|
-
**Examples:**
|
|
197
|
-
|
|
198
|
-
- "Fix typo in README" → No ticket (obvious, one-shot)
|
|
199
|
-
- "Make button red" → Ticket (might break mobile, cascade issues)
|
|
200
|
-
- "Debug slow login" → Ticket (investigation needed, multiple hypotheses)
|
|
201
|
-
- "Add OAuth" → Ticket (complex, multi-step, planning docs needed)
|
|
202
|
-
|
|
203
|
-
**Relationship to planning docs:**
|
|
204
|
-
|
|
205
|
-
- **Ticket** = Context anchor (prevents loops, tracks attempts)
|
|
206
|
-
- **Planning docs** = Detailed specs for complex features (user stories, test definitions)
|
|
207
|
-
- **TodoWrite** = Task-level tracking within current work session
|
|
208
|
-
|
|
209
|
-
**Workflow:**
|
|
210
|
-
|
|
211
|
-
1. **Create ticket:** `.safeword/tickets/{id}-{slug}.md`
|
|
212
|
-
2. **Fill in Goal + Why** (one sentence each) - This is your anchor
|
|
213
|
-
3. **Add initial work log entry:** "Started: [task]"
|
|
214
|
-
4. **Re-read ticket before EVERY significant action** - Check what you're trying to do
|
|
215
|
-
5. **Log immediately** after each attempt, finding, commit, or blocker
|
|
216
|
-
6. **For complex features:** Add planning docs, reference them in optional sections
|
|
217
|
-
7. **When stuck:** Re-read work log - what have you tried? What's the goal?
|
|
218
|
-
8. **When complete:** Log final entry, update status to `done`, ask user to confirm
|
|
219
|
-
9. **After confirmation:** Move to `.safeword/tickets/completed/{id}-{slug}.md`
|
|
220
|
-
|
|
221
|
-
**CRITICAL:** NEVER mark ticket as `done` or archive without explicit user confirmation. User must verify:
|
|
222
|
-
|
|
223
|
-
- All acceptance criteria met
|
|
224
|
-
- All tests passing
|
|
225
|
-
- Feature works as expected
|
|
226
|
-
- No regressions introduced
|
|
227
|
-
|
|
228
|
-
**Archiving:**
|
|
229
|
-
|
|
230
|
-
- Completed tickets → `.safeword/tickets/completed/`
|
|
231
|
-
- Blocked/cancelled tickets → `.safeword/tickets/archived/`
|
|
232
|
-
- Active tickets stay in `.safeword/tickets/`
|
|
233
|
-
|
|
234
|
-
**Why confirm:** Prevents premature closure and ensures quality standards met.
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## Feature Development Workflow (CRITICAL - Always Follow)
|
|
239
|
-
|
|
240
|
-
**When to read:** ALWAYS - Before starting ANY new feature, bug fix, or code change. This is the entry point for all development work.
|
|
241
|
-
|
|
242
|
-
### Starting a New Feature
|
|
243
|
-
|
|
244
|
-
**When user requests a new feature or references an issue number:**
|
|
245
|
-
|
|
246
|
-
**IN ORDER:**
|
|
247
|
-
|
|
248
|
-
**0. Check for Ticket / Create If Needed** (context-loss prevention)
|
|
249
|
-
|
|
250
|
-
- Search `.safeword/tickets/` for matching ticket file
|
|
251
|
-
- **If found:**
|
|
252
|
-
- **Read ticket first** - What's the goal? What have I tried?
|
|
253
|
-
- Check work log for previous attempts/findings
|
|
254
|
-
- Log: "Resumed work on [task]"
|
|
255
|
-
- **Re-read ticket before each significant action**
|
|
256
|
-
- For complex features: Follow planning docs if referenced
|
|
257
|
-
- **If not found:**
|
|
258
|
-
- **Assess context-loss risk:**
|
|
259
|
-
- Obvious one-shot (<2 min, no investigation)? → Skip ticket, skip to TDD (step 4)
|
|
260
|
-
- Might require multiple attempts? → Create ticket, skip to TDD (step 4)
|
|
261
|
-
- Investigation/debugging needed? → Create ticket, skip to TDD (step 4)
|
|
262
|
-
- Complex feature (multi-story)? → Create ticket, continue to planning docs (step 1)
|
|
263
|
-
|
|
264
|
-
1. **User Stories + Technical Constraints** - Search `.safeword/planning/user-stories/` or `docs/user-stories/`
|
|
265
|
-
- Not found → Ask user if they exist elsewhere or offer to create
|
|
266
|
-
- Found → Read them (including Technical Constraints section)
|
|
267
|
-
- **Technical Constraints:** Non-functional requirements (performance, security, compatibility) that inform test definitions
|
|
268
|
-
- **Guide:** `@./.safeword/guides/user-story-guide.md`
|
|
269
|
-
|
|
270
|
-
2. **Test Definitions** - Search `.safeword/planning/test-definitions/` or `docs/test-definitions/`
|
|
271
|
-
- Not found → Ask user if they exist elsewhere or offer to create
|
|
272
|
-
- Found → Read them
|
|
273
|
-
- **Guide:** `@./.safeword/guides/test-definitions-guide.md`
|
|
274
|
-
|
|
275
|
-
3. **Design Doc** (complex features only) - Search `.safeword/planning/design/` or `docs/design/`
|
|
276
|
-
- Complex = >3 components, spans 2+ user stories, new data model, or architectural decisions
|
|
277
|
-
- Not found → Ask if needed, create if yes
|
|
278
|
-
- Found → Read it
|
|
279
|
-
- **Guide:** `@./.safeword/guides/design-doc-guide.md`
|
|
280
|
-
|
|
281
|
-
4. **Follow STRICT TDD Workflow** (RED → GREEN → REFACTOR)
|
|
282
|
-
- Write failing tests first (RED phase)
|
|
283
|
-
- Implement minimum code to pass (GREEN phase)
|
|
284
|
-
- Refactor while keeping tests green
|
|
285
|
-
- **Workflow:** `@./.safeword/guides/testing-methodology.md` (comprehensive TDD guidance and test type decision tree)
|
|
286
|
-
|
|
287
|
-
5. **Update Ticket** (if applicable)
|
|
288
|
-
- **Re-read ticket frequently** - Before each action, check: What's the goal? What have I tried?
|
|
289
|
-
- **Log immediately** after each action - Don't batch; log as you go
|
|
290
|
-
- Log: attempts (tried X, result Y), findings (found Z), commits, blockers, decisions
|
|
291
|
-
- When work complete: Log final entry, update status to `done`
|
|
292
|
-
- **Ask user to confirm** completion before archiving
|
|
293
|
-
- After confirmation: Move to `.safeword/tickets/completed/`
|
|
294
|
-
|
|
295
|
-
**IMPORTANT:** Do not skip to implementation without user stories and test definitions. Follow TDD strictly.
|
|
296
|
-
|
|
297
|
-
**Edge cases:**
|
|
298
|
-
|
|
299
|
-
- User stories exist but test definitions don't → Create test definitions before implementation
|
|
300
|
-
- User stories missing Technical Constraints → Add constraints before test definitions
|
|
301
|
-
- Test definitions exist but user stories don't → Ask if user stories needed
|
|
302
|
-
- Neither exist → Create both before implementation
|
|
303
|
-
- Ticket references non-existent planning docs → Create them first
|
|
304
|
-
|
|
305
|
-
---
|
|
306
|
-
|
|
307
|
-
### Commit Frequently
|
|
308
|
-
|
|
309
|
-
**Commit early, commit often:** Small, atomic commits after each meaningful change.
|
|
310
|
-
|
|
311
|
-
**When to commit:**
|
|
312
|
-
|
|
313
|
-
- After each test passes (GREEN phase)
|
|
314
|
-
- Before refactoring (safe point to revert)
|
|
315
|
-
- After successful refactor
|
|
316
|
-
- When switching context or tasks
|
|
317
|
-
- After completing a logical unit of work
|
|
318
|
-
|
|
319
|
-
**Why:** Prevents work loss, enables easy rollback, creates reviewable history.
|
|
320
|
-
|
|
321
|
-
---
|
|
322
|
-
|
|
323
|
-
### When to Update Architecture Docs
|
|
324
|
-
|
|
325
|
-
**Update project/package ARCHITECTURE.md when:**
|
|
326
|
-
|
|
327
|
-
- Making technology choices (state management, database, frameworks)
|
|
328
|
-
- Designing data models or schemas
|
|
329
|
-
- Establishing project-wide patterns/conventions
|
|
330
|
-
- Discovering architectural insights during implementation
|
|
331
|
-
- Recording "why" behind major decisions
|
|
332
|
-
|
|
333
|
-
**Use Design Doc instead when:**
|
|
334
|
-
|
|
335
|
-
- Implementing a specific feature
|
|
336
|
-
- Documenting component interactions for one feature
|
|
337
|
-
- Feature-specific technical decisions
|
|
338
|
-
- Implementation details (not project-wide principles)
|
|
339
|
-
|
|
340
|
-
**Quick Decision Matrix:**
|
|
341
|
-
|
|
342
|
-
| Question | Architecture Doc | Design Doc |
|
|
343
|
-
| --------------------------- | ---------------- | ------------- |
|
|
344
|
-
| Tech/framework choice? | ✅ | — |
|
|
345
|
-
| Data model design? | ✅ | References it |
|
|
346
|
-
| New feature implementation? | — | ✅ |
|
|
347
|
-
| Component breakdown? | — | ✅ |
|
|
348
|
-
|
|
349
|
-
**Tie-breaking rule:** If decision affects 2+ features or multiple developers → Architecture doc. If feature-specific only → Design doc.
|
|
350
|
-
|
|
351
|
-
**Reference:** `@./.safeword/guides/architecture-guide.md`
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
### Layers & Boundaries
|
|
356
|
-
|
|
357
|
-
**When to read:**
|
|
358
|
-
|
|
359
|
-
- Setting up code organization for a new project
|
|
360
|
-
- Questions about layer structure (app, domain, infra, shared)
|
|
361
|
-
- Dependency rules between layers
|
|
362
|
-
- Setting up `eslint-plugin-boundaries` for enforcement
|
|
363
|
-
- Architectural boundary violations in code review
|
|
364
|
-
|
|
365
|
-
4-layer architecture (app, domain, infra, shared), allowed dependency matrix, and static enforcement via ESLint.
|
|
366
|
-
|
|
367
|
-
**Guide:** `@./.safeword/guides/architecture-guide.md` → Layers & Boundaries section
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
### Architecture Review (LLM)
|
|
372
|
-
|
|
373
|
-
**When to read:**
|
|
374
|
-
|
|
375
|
-
- Running semantic architecture review on code changes
|
|
376
|
-
- Setting up pre-commit hook for architecture enforcement
|
|
377
|
-
- Setting up CI workflow for PR architecture checks
|
|
378
|
-
- Understanding architecture review verdicts (clean/minor/refactor_needed)
|
|
379
|
-
- Checking for: god modules, leaky abstractions, misplaced logic, tight coupling
|
|
380
|
-
|
|
381
|
-
**Command:** `/architecture`
|
|
382
|
-
**Prompt:** `.safeword/prompts/architecture.md`
|
|
383
|
-
**CI Template:** `.safeword/templates/ci/architecture-check.yml`
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
### Creating Documentation (Explicit User Requests)
|
|
388
|
-
|
|
389
|
-
**Note**: When user explicitly requests documentation, skip the workflow questions and create directly.
|
|
390
|
-
|
|
391
|
-
**User Stories:**
|
|
392
|
-
|
|
393
|
-
- **Trigger (Create):** User says "Create user stories for issue #N" or "Create user stories for [feature]"
|
|
394
|
-
- **Trigger (Review):** User asks "Is this story good?" or "Review my user story"
|
|
395
|
-
- **Trigger (Constraint Review):** User asks "Is this constraint good?" or "Review my constraints"
|
|
396
|
-
- Skip the "Do user stories exist?" question (user is explicitly requesting creation)
|
|
397
|
-
- **Include Technical Constraints:** Fill in performance, security, compatibility, data, dependencies, infrastructure constraints that will inform test definitions
|
|
398
|
-
- **Template:** `@./.safeword/templates/user-stories-template.md`
|
|
399
|
-
- **Guide:** `@./.safeword/guides/user-story-guide.md`
|
|
400
|
-
|
|
401
|
-
**Test Definitions:**
|
|
402
|
-
|
|
403
|
-
- **Trigger:** User says "Create test definitions for issue #N" or "Create test definitions for [feature]"
|
|
404
|
-
- Skip the "Do test definitions exist?" question (user is explicitly requesting creation)
|
|
405
|
-
- **Template:** `@./.safeword/templates/test-definitions-feature.md`
|
|
406
|
-
- **Guide:** `@./.safeword/guides/test-definitions-guide.md`
|
|
75
|
+
**Rules:**
|
|
407
76
|
|
|
408
|
-
|
|
77
|
+
- Log immediately after each action
|
|
78
|
+
- Re-read ticket before significant actions
|
|
79
|
+
- **CRITICAL:** Never mark `done` without user confirmation (prevents premature closure)
|
|
409
80
|
|
|
410
|
-
|
|
411
|
-
- Skip the "Does design doc exist?" question (user is explicitly requesting creation)
|
|
412
|
-
- **Prerequisites:** Verify user stories and test definitions exist first (create if not)
|
|
413
|
-
|
|
414
|
-
**Required sections checklist:**
|
|
415
|
-
|
|
416
|
-
- [ ] **Architecture** — 1-2 paragraphs on high-level approach
|
|
417
|
-
- [ ] **Components** — [N] and [N+1] examples with name, responsibility, interface, dependencies
|
|
418
|
-
- [ ] **User Flow** — Step-by-step with concrete examples
|
|
419
|
-
- [ ] **Key Decisions** — What, why, trade-off, alternatives considered
|
|
420
|
-
- [ ] **Data Model** — (if applicable) State shape, relationships
|
|
421
|
-
- [ ] **Component Interaction** — (if applicable) How components communicate
|
|
422
|
-
- [ ] **Implementation Notes** — (if applicable) Constraints, error handling, gotchas
|
|
423
|
-
|
|
424
|
-
- **Template:** `@./.safeword/templates/design-doc-template.md`
|
|
425
|
-
- **Guide:** `@./.safeword/guides/design-doc-guide.md`
|
|
426
|
-
|
|
427
|
-
**Architecture Doc:**
|
|
428
|
-
|
|
429
|
-
- **Trigger (Create):** Starting a new project/package, or no `ARCHITECTURE.md` exists yet
|
|
430
|
-
- **Trigger (Update):** User says "Update architecture doc" or "Document [architectural decision]"
|
|
431
|
-
- **Trigger (Implicit):** After discussing architectural decisions, proactively ask: "Should I document this in ARCHITECTURE.md?"
|
|
432
|
-
- **Recognize architectural discussions when user mentions:**
|
|
433
|
-
- Technology choices (state management, database, frameworks)
|
|
434
|
-
- Data model design
|
|
435
|
-
- Project-wide patterns/conventions
|
|
436
|
-
|
|
437
|
-
**Required sections checklist** (verify all present when creating/reviewing):
|
|
438
|
-
|
|
439
|
-
- [ ] **Header** — Version, Last Updated, Status (Production/Design/Proposed)
|
|
440
|
-
- [ ] **Table of Contents** — Section links
|
|
441
|
-
- [ ] **Overview** — Technology choices, data model philosophy, high-level architecture
|
|
442
|
-
- [ ] **Data Architecture Principles** — What, Why, Trade-off for each principle
|
|
443
|
-
- [ ] **Data Model / Schema** — Tables, types, relationships
|
|
444
|
-
- [ ] **Component Design** — Major components and responsibilities
|
|
445
|
-
- [ ] **Data Flow Patterns** — How data moves through the system
|
|
446
|
-
- [ ] **Key Decisions** — What, Why, Trade-off, Alternatives Considered
|
|
447
|
-
- [ ] **Best Practices** — Domain-specific patterns
|
|
448
|
-
- [ ] **Migration Strategy** — How to evolve architecture
|
|
449
|
-
- [ ] **Code References** — Link to implementations (`src/file.ts:line` or function names)
|
|
450
|
-
|
|
451
|
-
**Anti-patterns to avoid:**
|
|
452
|
-
|
|
453
|
-
- ❌ ADR sprawl (many separate files) → consolidate into one doc
|
|
454
|
-
- ❌ Missing rationale → every decision needs "Why" with specifics
|
|
455
|
-
- ❌ Implementation details → keep high-level principles only
|
|
456
|
-
|
|
457
|
-
- **Template:** `@./.safeword/templates/architecture-template.md`
|
|
458
|
-
- **Guide:** `@./.safeword/guides/architecture-guide.md`
|
|
459
|
-
|
|
460
|
-
**Data Architecture Doc:**
|
|
461
|
-
|
|
462
|
-
- **Trigger (Explicit):** User says "Document data architecture" or "Design data model"
|
|
463
|
-
- **Trigger (Implicit):** When discussing database schema, data flows, or storage decisions
|
|
464
|
-
- **Recognize data architecture discussions when user mentions:**
|
|
465
|
-
- Database/storage technology choices
|
|
466
|
-
- Schema design (entities, relationships, constraints)
|
|
467
|
-
- Data validation rules, access policies, lifecycle
|
|
468
|
-
- Data flows (sources, transformations, destinations)
|
|
469
|
-
- **Section in ARCHITECTURE.md or separate file** - Depends on project complexity
|
|
470
|
-
- **Guide:** `@./.safeword/guides/data-architecture-guide.md`
|
|
81
|
+
**Full template:** `.safeword/templates/ticket-template.md`
|
|
471
82
|
|
|
472
83
|
---
|
|
473
84
|
|
|
474
|
-
##
|
|
475
|
-
|
|
476
|
-
**When to use:** Complex multi-step tasks (3+ distinct steps), non-trivial tasks requiring planning, or when user provides multiple tasks.
|
|
477
|
-
|
|
478
|
-
**Critical rules:**
|
|
85
|
+
## Feature Development (CRITICAL)
|
|
479
86
|
|
|
480
|
-
|
|
481
|
-
- ✓ **Use VERY frequently** - Track tasks and give user visibility into progress
|
|
482
|
-
- ✓ **Mark in_progress BEFORE work** - Ideally only ONE task in_progress at a time
|
|
483
|
-
- ✓ **Complete immediately** - Mark completed as soon as done, don't batch
|
|
484
|
-
- ✓ **Two forms required** - `content` (imperative: "Run tests") + `activeForm` (continuous: "Running tests")
|
|
485
|
-
- ✓ **Replace entire list** - Updates replace complete list, not incremental changes
|
|
87
|
+
**Always follow this order:**
|
|
486
88
|
|
|
487
|
-
**
|
|
89
|
+
1. **Check/create ticket** if context-loss risk exists (see decision tree above)
|
|
90
|
+
2. **Read user stories** (`.safeword/planning/user-stories/`)
|
|
91
|
+
3. **Read test definitions** (`.safeword/planning/test-definitions/`)
|
|
92
|
+
4. **Read design doc** if complex (>3 components OR 2+ user stories)
|
|
93
|
+
5. **TDD: RED → GREEN → REFACTOR**
|
|
94
|
+
6. **Update ticket** with progress, ask user to confirm completion
|
|
488
95
|
|
|
489
|
-
|
|
490
|
-
- Trivial operations (1-2 simple steps)
|
|
491
|
-
- Purely conversational requests
|
|
96
|
+
**Edge cases:**
|
|
492
97
|
|
|
493
|
-
|
|
98
|
+
| Situation | Action |
|
|
99
|
+
| ----------------------------------- | --------------------------------- |
|
|
100
|
+
| User stories exist, test defs don't | Create test defs first |
|
|
101
|
+
| Test defs exist, user stories don't | Ask if user stories needed |
|
|
102
|
+
| Neither exist | Create both before implementation |
|
|
494
103
|
|
|
495
|
-
|
|
496
|
-
{
|
|
497
|
-
"todos": [
|
|
498
|
-
{
|
|
499
|
-
"content": "Write failing tests",
|
|
500
|
-
"status": "completed",
|
|
501
|
-
"activeForm": "Writing failing tests"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
"content": "Implement minimum code to pass",
|
|
505
|
-
"status": "in_progress",
|
|
506
|
-
"activeForm": "Implementing minimum code"
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
"content": "Refactor while keeping tests green",
|
|
510
|
-
"status": "pending",
|
|
511
|
-
"activeForm": "Refactoring code"
|
|
512
|
-
}
|
|
513
|
-
]
|
|
514
|
-
}
|
|
515
|
-
```
|
|
104
|
+
**Full workflow:** @./.safeword/guides/development-workflow.md
|
|
516
105
|
|
|
517
106
|
---
|
|
518
107
|
|
|
519
|
-
##
|
|
520
|
-
|
|
521
|
-
At the end of EVERY response, include a JSON summary with this exact structure:
|
|
108
|
+
## Self-Testing (CRITICAL)
|
|
522
109
|
|
|
523
|
-
|
|
524
|
-
{"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}
|
|
525
|
-
```
|
|
110
|
+
**Never ask the user to test what you can test yourself.**
|
|
526
111
|
|
|
527
|
-
|
|
112
|
+
- After fixes → run relevant tests
|
|
113
|
+
- After features → run affected tests
|
|
114
|
+
- Before completion → verify everything passes
|
|
528
115
|
|
|
529
|
-
-
|
|
530
|
-
- `madeChanges`: `true` if you **modified files in this response** using Write/Edit tools
|
|
531
|
-
- `askedQuestion`: `true` if you asked the user a question and need their response before proceeding
|
|
532
|
-
|
|
533
|
-
Examples:
|
|
116
|
+
**Anti-patterns:**
|
|
534
117
|
|
|
535
|
-
-
|
|
536
|
-
-
|
|
537
|
-
-
|
|
538
|
-
- Proposed AND made edits: `{"proposedChanges": true, "madeChanges": true, "askedQuestion": false}`
|
|
539
|
-
- Asked user a question: `{"proposedChanges": false, "madeChanges": false, "askedQuestion": true}`
|
|
540
|
-
- **Quality review response** (no new changes): `{"proposedChanges": false, "madeChanges": false, "askedQuestion": false}`
|
|
118
|
+
- ❌ "Please refresh and test"
|
|
119
|
+
- ❌ "Can you verify it works?"
|
|
120
|
+
- ✅ "Fixed. Running tests..." → "Tests pass ✓"
|
|
541
121
|
|
|
542
122
|
---
|
|
543
123
|
|
|
544
|
-
##
|
|
545
|
-
|
|
546
|
-
**Trigger:** Before adding any abstraction, utility, or "future-proofing" code.
|
|
124
|
+
## Code Quality
|
|
547
125
|
|
|
548
|
-
**
|
|
126
|
+
**Avoid over-engineering:**
|
|
549
127
|
|
|
550
128
|
| ❌ Over-engineering | ✅ Keep it simple |
|
|
551
129
|
| --------------------------------- | ------------------- |
|
|
552
130
|
| Utility class for one function | Single function |
|
|
553
131
|
| Factory/builder for simple object | Direct construction |
|
|
554
132
|
| Config file for 2 options | Hardcode or params |
|
|
555
|
-
| Abstract class with one impl | Concrete class |
|
|
556
|
-
|
|
557
|
-
**When to push back:** If feature adds >50 lines for "nice to have", ask user if essential now.
|
|
558
|
-
|
|
559
|
-
**Self-documenting code:** Use descriptive names (`calculateTotalWithTax` not `calcTot`). Comment only non-obvious logic.
|
|
560
|
-
|
|
561
|
-
**Error handling:** Never swallow errors. Include context: `Failed to read ${filePath}: ${e.message}`
|
|
562
133
|
|
|
563
|
-
**
|
|
134
|
+
**Rules:**
|
|
564
135
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
136
|
+
- If feature adds >50 lines for "nice to have", ask user first
|
|
137
|
+
- Never swallow errors—include context: `Failed to X: ${e.message}`
|
|
138
|
+
- Verify library APIs against package.json version + Context7 (training data is stale)
|
|
568
139
|
|
|
569
140
|
---
|
|
570
141
|
|
|
571
|
-
##
|
|
572
|
-
|
|
573
|
-
**The user's time is precious. Always test your own work before declaring it complete.**
|
|
574
|
-
|
|
575
|
-
**Core principle:** NEVER ask the user to verify or test something you can test yourself. Run tests, verify fixes, and confirm functionality before reporting completion.
|
|
576
|
-
|
|
577
|
-
**When to self-test:**
|
|
578
|
-
|
|
579
|
-
- ✓ **After fixing bugs** - Run the relevant tests to verify the fix works
|
|
580
|
-
- ✓ **After implementing features** - Run all affected tests (unit, integration, E2E)
|
|
581
|
-
- ✓ **After making changes** - Verify the change has the intended effect
|
|
582
|
-
- ✓ **Before declaring completion** - Always run tests yourself, don't ask the user to do it
|
|
583
|
-
- ✓ **When uncertain** - If you're not sure it works, TEST IT before claiming success
|
|
584
|
-
|
|
585
|
-
**Tools for self-testing:**
|
|
586
|
-
|
|
587
|
-
- E2E tests: `pnpm test:e2e` or specific test files
|
|
588
|
-
- Unit tests: `pnpm test` or `pnpm test:unit`
|
|
589
|
-
- Integration tests: `pnpm test:integration`
|
|
590
|
-
- Manual verification: Use curl, check browser console, verify API responses
|
|
591
|
-
- Dev server: Check compilation errors, hot reload, runtime errors
|
|
592
|
-
|
|
593
|
-
**Capturing test output:**
|
|
594
|
-
|
|
595
|
-
Don't pipe through `head`/`tail` directly—capture to a timestamped log file first, then analyze:
|
|
596
|
-
|
|
597
|
-
```bash
|
|
598
|
-
# ✅ GOOD - Capture to file, then analyze
|
|
599
|
-
mkdir -p /tmp/test-logs
|
|
600
|
-
LOG=/tmp/test-logs/$(date +%s)-e2e.log
|
|
601
|
-
pnpm test:e2e 2>&1 | tee $LOG
|
|
602
|
-
tail -100 $LOG # Check summary
|
|
603
|
-
cat $LOG # Full output if needed
|
|
604
|
-
|
|
605
|
-
# ❌ BAD - Can't dig deeper without re-running tests
|
|
606
|
-
pnpm test:e2e 2>&1 | tail -50
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
**Anti-patterns:**
|
|
610
|
-
|
|
611
|
-
- ❌ **DON'T:** "I've made the changes. Please refresh your browser and test."
|
|
612
|
-
- ❌ **DON'T:** "The fix should work now. Can you verify?"
|
|
613
|
-
- ❌ **DON'T:** "Try it now and let me know if it works."
|
|
142
|
+
## TodoWrite
|
|
614
143
|
|
|
615
|
-
**
|
|
144
|
+
**Use for:** 3+ step tasks, non-trivial work, multiple user requests.
|
|
616
145
|
|
|
617
|
-
|
|
618
|
-
- ✅ **DO:** "Fixed the bug. Running E2E tests to confirm..." [runs tests] "All tests passing ✓"
|
|
619
|
-
- ✅ **DO:** "Implemented the feature. Testing now..." [runs tests] "Tests confirm it works ✓"
|
|
146
|
+
**Rules:**
|
|
620
147
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
1. User reports bug: "Button doesn't enable when typing"
|
|
625
|
-
2. Investigate and fix the bug
|
|
626
|
-
3. Run tests yourself: AUTH_MODE=demo pnpm exec playwright test
|
|
627
|
-
4. Verify tests pass
|
|
628
|
-
5. Report to user: "Fixed. Tests confirm button now enables correctly ✓"
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
**Edge cases:**
|
|
632
|
-
|
|
633
|
-
- If tests require special setup (API keys, credentials): Mention requirements but still run what you can
|
|
634
|
-
- If tests are slow (>5 min): Run them in background, show progress, report when done
|
|
635
|
-
- If no automated tests exist: Create them as part of the fix, then run them
|
|
636
|
-
|
|
637
|
-
**Remember:** The user should only test when they want to verify the UX/experience themselves, not to confirm your code works. Your code working is YOUR responsibility to verify.
|
|
638
|
-
|
|
639
|
-
**Before declaring complete:** Run self-review checklist (correctness, elegance, best practices, docs/versions, tests). Note any deferred issues.
|
|
148
|
+
- Create as first tool call
|
|
149
|
+
- One task `in_progress` at a time
|
|
150
|
+
- Mark completed immediately (don't batch)
|
|
640
151
|
|
|
641
152
|
---
|
|
642
153
|
|
|
643
|
-
##
|
|
644
|
-
|
|
645
|
-
**When to read:** Before writing code, when making architectural decisions, or when unsure about coding standards and best practices.
|
|
646
|
-
|
|
647
|
-
**Documentation verification:** Before using any library API, check `package.json` for version and verify with Context7 or official docs. Training data is stale.
|
|
648
|
-
|
|
649
|
-
Core coding principles, testing philosophy (TDD), communication style, best practices, and tooling currency.
|
|
154
|
+
## Response Format
|
|
650
155
|
|
|
651
|
-
|
|
156
|
+
End every response with:
|
|
652
157
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
**When to read:** When creating user stories, test definitions, design docs, or evaluations. Provides templates and examples of good vs bad practices.
|
|
658
|
-
|
|
659
|
-
**Triggers:**
|
|
660
|
-
|
|
661
|
-
- Creating user stories, test definitions, or design docs
|
|
662
|
-
- User asks "Which template should I use?" or "What doc type for X?"
|
|
663
|
-
- Need examples of good vs bad user stories or tests
|
|
664
|
-
|
|
665
|
-
User story templates (As a X / Given-When-Then), test definition patterns, and concrete examples.
|
|
666
|
-
|
|
667
|
-
@./.safeword/guides/tdd-best-practices.md
|
|
668
|
-
|
|
669
|
-
---
|
|
670
|
-
|
|
671
|
-
## Testing Methodology
|
|
672
|
-
|
|
673
|
-
**When to read:** Before starting ANY feature (TDD workflow), when choosing test type (unit/integration/E2E/LLM eval), or when writing tests.
|
|
674
|
-
|
|
675
|
-
Comprehensive TDD workflow (RED → GREEN → REFACTOR), test pyramid, decision trees, async testing, project-specific docs guidance.
|
|
676
|
-
|
|
677
|
-
@./.safeword/guides/testing-methodology.md
|
|
678
|
-
|
|
679
|
-
---
|
|
680
|
-
|
|
681
|
-
## LLM Prompting Best Practices
|
|
682
|
-
|
|
683
|
-
**When to read:** When working with AI features, writing prompts, implementing LLM evaluations, or optimizing AI costs.
|
|
684
|
-
|
|
685
|
-
Prompt engineering, cost optimization (caching strategies), and testing AI outputs (LLM-as-judge).
|
|
686
|
-
|
|
687
|
-
@./.safeword/guides/llm-prompting.md
|
|
688
|
-
|
|
689
|
-
---
|
|
690
|
-
|
|
691
|
-
## Writing Instructions for LLMs
|
|
692
|
-
|
|
693
|
-
**When to read:** When creating or updating ANY documentation that LLMs will read (CLAUDE.md, AGENTS.md, user stories, test definitions, design docs, architecture docs, guides).
|
|
694
|
-
|
|
695
|
-
13 core principles for LLM-consumable documentation: MECE decision trees, explicit definitions, concrete examples, no contradictions, edge cases explicit, actionable language, sequential decision trees, tie-breaking rules, lookup tables, no caveats in tables, percentages with context, specific technical terms, and re-evaluation paths.
|
|
696
|
-
|
|
697
|
-
@./.safeword/guides/llm-instruction-design.md
|
|
698
|
-
|
|
699
|
-
---
|
|
700
|
-
|
|
701
|
-
## AGENTS.md/CLAUDE.md File Structure & Maintenance
|
|
702
|
-
|
|
703
|
-
**When to read:** When creating or updating project AGENTS.md/CLAUDE.md files, organizing documentation, or setting up new projects.
|
|
704
|
-
|
|
705
|
-
How to write, organize, and maintain AGENTS.md/CLAUDE.md files across projects. Anti-patterns, examples, and modular approaches.
|
|
706
|
-
|
|
707
|
-
@./.safeword/guides/context-files-guide.md
|
|
708
|
-
|
|
709
|
-
---
|
|
710
|
-
|
|
711
|
-
## Project Memory
|
|
712
|
-
|
|
713
|
-
**Context:** After extracting learnings (see Learning Extraction section below), add them to project documentation for team knowledge sharing.
|
|
714
|
-
|
|
715
|
-
**Where to add:**
|
|
716
|
-
|
|
717
|
-
- Architecture decisions: Add to ARCHITECTURE.md (or AGENTS.md if no ARCHITECTURE.md exists)
|
|
718
|
-
- Common gotchas (1-2 sentences): Add to AGENTS.md → Common Gotchas section
|
|
719
|
-
- Detailed learnings (needs examples): Extract to `.safeword/learnings/` and cross-reference in SAFEWORD.md
|
|
158
|
+
```json
|
|
159
|
+
{"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}
|
|
160
|
+
```
|
|
720
161
|
|
|
721
|
-
|
|
162
|
+
- `proposedChanges`: suggested changes to files in this response
|
|
163
|
+
- `madeChanges`: modified files using Write/Edit tools
|
|
164
|
+
- `askedQuestion`: asked question, need response before proceeding
|
|
722
165
|
|
|
723
166
|
---
|
|
724
167
|
|
|
725
|
-
##
|
|
726
|
-
|
|
727
|
-
**When to read:**
|
|
728
|
-
|
|
729
|
-
- Working on multiple projects simultaneously
|
|
730
|
-
- Port already in use errors (`EADDRINUSE`, `address already in use`)
|
|
731
|
-
- Stuck processes (dev server won't start, tests hang)
|
|
732
|
-
- Tech stacks: Next.js, Playwright, Vite, Expo
|
|
733
|
-
|
|
734
|
-
Port-based cleanup strategies, project-specific scripts, and multi-project isolation techniques.
|
|
168
|
+
## Commit Frequently
|
|
735
169
|
|
|
736
|
-
|
|
170
|
+
- After each GREEN phase
|
|
171
|
+
- Before refactoring
|
|
172
|
+
- After successful refactor
|
|
173
|
+
- When switching tasks
|
|
737
174
|
|
|
738
175
|
---
|
|
739
176
|
|
|
740
177
|
## Learning Extraction
|
|
741
178
|
|
|
742
|
-
**
|
|
743
|
-
|
|
744
|
-
**Suggest extraction when you observe:**
|
|
745
|
-
|
|
746
|
-
1. **Observable debugging complexity** - User says "stuck", 5+ debug cycles, 3+ error states, or 3+ files modified
|
|
747
|
-
2. **Trial and error** - Tried 3+ different approaches
|
|
748
|
-
3. **Undocumented gotcha** - Not in official library/framework docs
|
|
749
|
-
4. **Integration struggle** - Two tools don't work together smoothly
|
|
750
|
-
5. **Testing trap** - Tests pass but UX broken (or vice versa)
|
|
751
|
-
6. **Architectural insight** - Discovered during implementation, not planned upfront
|
|
752
|
-
|
|
753
|
-
**CRITICAL: Before extracting, ALWAYS check for existing learnings** to prevent duplication:
|
|
754
|
-
|
|
755
|
-
- **Before debugging** - Check if similar issue has learning: `ls .safeword/learnings/*[technology]*.md`
|
|
756
|
-
- **When user mentions technology/pattern** - Check for `*hooks*.md`, `*electron*.md`, etc.
|
|
757
|
-
- **During architectural discussions** - Check for `*pattern*.md`, `*architecture*.md`
|
|
758
|
-
- **After suggesting extraction** - Check if learning already exists, update instead of duplicate
|
|
759
|
-
|
|
760
|
-
**When to reference existing learnings:**
|
|
761
|
-
|
|
762
|
-
- Found → Read and apply: "I found an existing learning about [concept] at [path]. Applying it now."
|
|
763
|
-
- Similar but different → Reference and note difference
|
|
764
|
-
|
|
765
|
-
**Where to extract:**
|
|
766
|
-
|
|
767
|
-
- `.safeword/learnings/[concept].md` - General patterns and best practices (React patterns, Git workflows, testing)
|
|
768
|
-
- `.safeword/learnings/[concept].md` - Project-specific (custom architecture, unique patterns for this codebase)
|
|
179
|
+
**Suggest extraction when ANY apply:**
|
|
769
180
|
|
|
770
|
-
|
|
181
|
+
- 5+ debug cycles on same issue
|
|
182
|
+
- 3+ approaches tried
|
|
183
|
+
- Undocumented gotcha discovered
|
|
184
|
+
- Integration struggle between tools
|
|
771
185
|
|
|
772
|
-
|
|
773
|
-
- Multiple learnings cover similar topic → Consolidate
|
|
774
|
-
- Technology deprecated → Archive with "OBSOLETE:" prefix
|
|
186
|
+
**Before extracting:** Check `.safeword/learnings/` for existing similar learnings—update, don't duplicate.
|
|
775
187
|
|
|
776
|
-
**Full workflow
|
|
188
|
+
**Full workflow:** @./.safeword/guides/learning-extraction.md
|