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