safeword 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/templates/SAFEWORD.md
CHANGED
|
@@ -1,26 +1,78 @@
|
|
|
1
1
|
# SAFEWORD Agent Instructions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Code Philosophy
|
|
6
|
+
|
|
7
|
+
**Optimize for:** Clarity → Simplicity → Correctness (in that order)
|
|
8
|
+
|
|
9
|
+
| Principle | Definition |
|
|
10
|
+
| ---------------- | ---------------------------------------------------------------- |
|
|
11
|
+
| Elegant code | Readable at a glance; clear naming; minimal cognitive load |
|
|
12
|
+
| No bloat | Delete unused code; no premature abstractions; no "just in case" |
|
|
13
|
+
| Explicit errors | Every catch block re-throws with context OR logs with details |
|
|
14
|
+
| Self-documenting | Comment only: business rules, workarounds, non-obvious "why" |
|
|
15
|
+
|
|
16
|
+
**Tie-breaker:** When in doubt, choose the simpler solution that works today.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Anti-Patterns
|
|
21
|
+
|
|
22
|
+
| Don't | Do | Why |
|
|
23
|
+
| ---------------------------- | ------------------------------------------------ | ------------------------- |
|
|
24
|
+
| `catch (e) {}` | `throw new Error(\`Failed to X: ${e.message}\`)` | Silent failures hide bugs |
|
|
25
|
+
| Utility class for 1 function | Single exported function | Abstraction without reuse |
|
|
26
|
+
| Factory for simple object | Direct construction | Indirection without value |
|
|
27
|
+
| `data`, `tmp`, `d` | `userProfile`, `pendingOrder` | Names should explain |
|
|
28
|
+
| Code "for later" | Delete it; add when needed | YAGNI |
|
|
29
|
+
| >50 lines for nice-to-have | Ask user: "Essential now?" | Scope creep |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Before Using Any Library API
|
|
34
|
+
|
|
35
|
+
Training data is stale. Follow this sequence:
|
|
36
|
+
|
|
37
|
+
1. Check `package.json` for installed version
|
|
38
|
+
2. Look up docs via Context7 or official site
|
|
39
|
+
3. If uncertain: ask user which version they're using
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Guides
|
|
44
|
+
|
|
45
|
+
**Read the matching guide when ANY trigger fires:**
|
|
46
|
+
|
|
47
|
+
| Trigger | Guide |
|
|
48
|
+
| --------------------------------------------------------- | ---------------------------------------------- |
|
|
49
|
+
| Starting ANY feature, bug fix, or enhancement | @./.safeword/guides/development-workflow.md |
|
|
50
|
+
| Need to write OR review user stories | @./.safeword/guides/user-story-guide.md |
|
|
51
|
+
| Need to write OR review test definitions | @./.safeword/guides/test-definitions-guide.md |
|
|
52
|
+
| Writing tests, doing TDD, or test is failing | @./.safeword/guides/tdd-best-practices.md |
|
|
53
|
+
| Creating OR updating a design doc | @./.safeword/guides/design-doc-guide.md |
|
|
54
|
+
| Making architectural decision OR writing ADR | @./.safeword/guides/architecture-guide.md |
|
|
55
|
+
| Designing data models, schemas, or database changes | @./.safeword/guides/data-architecture-guide.md |
|
|
56
|
+
| Calling LLM APIs OR writing LLM-consumable docs | @./.safeword/guides/llm-guide.md |
|
|
57
|
+
| Updating CLAUDE.md, SAFEWORD.md, or any context file | @./.safeword/guides/context-files-guide.md |
|
|
58
|
+
| Hit same bug 3+ times OR discovered undocumented gotcha | @./.safeword/guides/learning-extraction.md |
|
|
59
|
+
| Process hanging, port in use, or zombie process suspected | @./.safeword/guides/zombie-process-cleanup.md |
|
|
60
|
+
| Using `safeword` CLI commands | @./.safeword/guides/cli-reference.md |
|
|
61
|
+
| Debugging issues OR need git/cross-platform guidance | @./.safeword/guides/code-philosophy.md |
|
|
4
62
|
|
|
5
63
|
---
|
|
6
64
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
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 |
|
|
65
|
+
## Templates
|
|
66
|
+
|
|
67
|
+
**Use the matching template when ANY trigger fires:**
|
|
68
|
+
|
|
69
|
+
| Trigger | Template |
|
|
70
|
+
| ---------------------------------------------------------- | -------------------------------------------------- |
|
|
71
|
+
| User asks for user story OR planning new feature scope | @./.safeword/templates/user-stories-template.md |
|
|
72
|
+
| Need test definitions for a feature OR acceptance criteria | @./.safeword/templates/test-definitions-feature.md |
|
|
73
|
+
| Feature spans 3+ components OR needs technical spec | @./.safeword/templates/design-doc-template.md |
|
|
74
|
+
| Making decision with long-term impact OR trade-offs | @./.safeword/templates/architecture-template.md |
|
|
75
|
+
| Task needs context anchoring (see Ticket System below) | @./.safeword/templates/ticket-template.md |
|
|
24
76
|
|
|
25
77
|
---
|
|
26
78
|
|
|
@@ -28,10 +80,12 @@ Core guidance for AI coding agents. Uses imports for detailed workflows.
|
|
|
28
80
|
|
|
29
81
|
**Location:** `.safeword/planning/` at project root
|
|
30
82
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
83
|
+
| Type | Path |
|
|
84
|
+
| ---------------- | -------------------------------------- |
|
|
85
|
+
| User stories | `.safeword/planning/user-stories/` |
|
|
86
|
+
| Test definitions | `.safeword/planning/test-definitions/` |
|
|
87
|
+
| Design docs | `.safeword/planning/design/` |
|
|
88
|
+
| Issues | `.safeword/planning/issues/` |
|
|
35
89
|
|
|
36
90
|
**Archive:** Move completed docs to `archive/` subfolder within each.
|
|
37
91
|
|
|
@@ -76,15 +130,13 @@ status: in_progress
|
|
|
76
130
|
|
|
77
131
|
- Log immediately after each action
|
|
78
132
|
- Re-read ticket before significant actions
|
|
79
|
-
- **CRITICAL:** Never mark `done` without user confirmation
|
|
80
|
-
|
|
81
|
-
**Full template:** `.safeword/templates/ticket-template.md`
|
|
133
|
+
- **CRITICAL:** Never mark `done` without user confirmation
|
|
82
134
|
|
|
83
135
|
---
|
|
84
136
|
|
|
85
|
-
## Feature Development
|
|
137
|
+
## Feature Development
|
|
86
138
|
|
|
87
|
-
**
|
|
139
|
+
**Follow this order:**
|
|
88
140
|
|
|
89
141
|
1. **Check/create ticket** if context-loss risk exists (see decision tree above)
|
|
90
142
|
2. **Read user stories** (`.safeword/planning/user-stories/`)
|
|
@@ -101,41 +153,23 @@ status: in_progress
|
|
|
101
153
|
| Test defs exist, user stories don't | Ask if user stories needed |
|
|
102
154
|
| Neither exist | Create both before implementation |
|
|
103
155
|
|
|
104
|
-
**Full workflow:** @./.safeword/guides/development-workflow.md
|
|
105
|
-
|
|
106
156
|
---
|
|
107
157
|
|
|
108
|
-
## Self-Testing
|
|
158
|
+
## Self-Testing
|
|
109
159
|
|
|
110
160
|
**Never ask the user to test what you can test yourself.**
|
|
111
161
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
162
|
+
| After... | Do |
|
|
163
|
+
| ----------------- | ------------------------ |
|
|
164
|
+
| Fixes | Run relevant tests |
|
|
165
|
+
| Features | Run affected test suites |
|
|
166
|
+
| Before completion | Verify everything passes |
|
|
115
167
|
|
|
116
168
|
**Anti-patterns:**
|
|
117
169
|
|
|
118
170
|
- ❌ "Please refresh and test"
|
|
119
171
|
- ❌ "Can you verify it works?"
|
|
120
|
-
- ✅ "Fixed. Running tests..." → "Tests pass
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Code Quality
|
|
125
|
-
|
|
126
|
-
**Avoid over-engineering:**
|
|
127
|
-
|
|
128
|
-
| ❌ Over-engineering | ✅ Keep it simple |
|
|
129
|
-
| --------------------------------- | ------------------- |
|
|
130
|
-
| Utility class for one function | Single function |
|
|
131
|
-
| Factory/builder for simple object | Direct construction |
|
|
132
|
-
| Config file for 2 options | Hardcode or params |
|
|
133
|
-
|
|
134
|
-
**Rules:**
|
|
135
|
-
|
|
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)
|
|
172
|
+
- ✅ "Fixed. Running tests..." → "Tests pass"
|
|
139
173
|
|
|
140
174
|
---
|
|
141
175
|
|
|
@@ -143,11 +177,11 @@ status: in_progress
|
|
|
143
177
|
|
|
144
178
|
**Use for:** 3+ step tasks, non-trivial work, multiple user requests.
|
|
145
179
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
180
|
+
| Rule | Why |
|
|
181
|
+
| -------------------------------- | ----------------------- |
|
|
182
|
+
| Create as first tool call | Plan before acting |
|
|
183
|
+
| One task `in_progress` at a time | Focus |
|
|
184
|
+
| Mark completed immediately | Don't batch completions |
|
|
151
185
|
|
|
152
186
|
---
|
|
153
187
|
|
|
@@ -159,18 +193,17 @@ End every response with:
|
|
|
159
193
|
{"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}
|
|
160
194
|
```
|
|
161
195
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
196
|
+
| Field | True when... |
|
|
197
|
+
| --------------- | ----------------------------------------------- |
|
|
198
|
+
| proposedChanges | Suggested changes to files in this response |
|
|
199
|
+
| madeChanges | Modified files using Write/Edit tools |
|
|
200
|
+
| askedQuestion | Asked question, need response before proceeding |
|
|
165
201
|
|
|
166
202
|
---
|
|
167
203
|
|
|
168
204
|
## Commit Frequently
|
|
169
205
|
|
|
170
|
-
|
|
171
|
-
- Before refactoring
|
|
172
|
-
- After successful refactor
|
|
173
|
-
- When switching tasks
|
|
206
|
+
Commit after: GREEN phase, before/after refactoring, when switching tasks.
|
|
174
207
|
|
|
175
208
|
---
|
|
176
209
|
|
|
@@ -184,5 +217,3 @@ End every response with:
|
|
|
184
217
|
- Integration struggle between tools
|
|
185
218
|
|
|
186
219
|
**Before extracting:** Check `.safeword/learnings/` for existing similar learnings—update, don't duplicate.
|
|
187
|
-
|
|
188
|
-
**Full workflow:** @./.safeword/guides/learning-extraction.md
|
|
@@ -3,4 +3,11 @@
|
|
|
3
3
|
# Outputs current timestamp for Claude's context awareness
|
|
4
4
|
# Helps with accurate ticket timestamps and time-based reasoning
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# Natural language day/time in UTC
|
|
7
|
+
natural=$(date -u +"%A, %B %d, %Y at %H:%M UTC")
|
|
8
|
+
# ISO 8601 UTC
|
|
9
|
+
iso=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
10
|
+
# Local timezone
|
|
11
|
+
local_time=$(date +"%H:%M %Z")
|
|
12
|
+
|
|
13
|
+
echo "Current time: $natural ($iso) | Local: $local_time"
|
|
@@ -60,7 +60,7 @@ if [ -z "$json_blob" ]; then
|
|
|
60
60
|
# No valid JSON blob found - remind about required format
|
|
61
61
|
echo "SAFEWORD: Response missing required JSON summary. Add to end of response:" >&2
|
|
62
62
|
echo '{"proposedChanges": boolean, "madeChanges": boolean, "askedQuestion": boolean}' >&2
|
|
63
|
-
exit
|
|
63
|
+
exit 2
|
|
64
64
|
fi
|
|
65
65
|
|
|
66
66
|
# Parse the boolean values (already validated, safe to extract)
|