safeword 0.8.4 → 0.8.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.
Files changed (32) hide show
  1. package/dist/{check-OUVIK2O6.js → check-I2J6THGQ.js} +3 -3
  2. package/dist/{chunk-QYCKBF57.js → chunk-DES5CSPH.js} +2 -2
  3. package/dist/{chunk-SIK3BC7F.js → chunk-DXT6TWW4.js} +33 -8
  4. package/dist/{chunk-SIK3BC7F.js.map → chunk-DXT6TWW4.js.map} +1 -1
  5. package/dist/{chunk-TP334635.js → chunk-VXKJ5ZIV.js} +2 -2
  6. package/dist/cli.js +6 -6
  7. package/dist/{diff-ASRWAPYJ.js → diff-4YFDNEZB.js} +3 -3
  8. package/dist/{reset-4G5DEEMY.js → reset-QVERBAQJ.js} +3 -3
  9. package/dist/{setup-URK77YMR.js → setup-ZSMZ7HZG.js} +3 -3
  10. package/dist/sync-VQW5DSTV.js +9 -0
  11. package/dist/{upgrade-IDR2ZALG.js → upgrade-WILVVHUY.js} +4 -4
  12. package/package.json +1 -1
  13. package/templates/cursor/rules/safeword-brainstorming.mdc +198 -0
  14. package/templates/cursor/rules/safeword-debugging.mdc +202 -0
  15. package/templates/cursor/rules/safeword-enforcing-tdd.mdc +207 -0
  16. package/templates/cursor/rules/safeword-quality-reviewer.mdc +158 -0
  17. package/templates/cursor/rules/safeword-refactoring.mdc +175 -0
  18. package/templates/cursor/rules/safeword-writing-plans.mdc +218 -0
  19. package/templates/skills/safeword-brainstorming/SKILL.md +210 -0
  20. package/templates/skills/{safeword-systematic-debugger → safeword-debugging}/SKILL.md +1 -71
  21. package/templates/skills/{safeword-tdd-enforcer → safeword-enforcing-tdd}/SKILL.md +17 -17
  22. package/templates/skills/safeword-quality-reviewer/SKILL.md +17 -67
  23. package/templates/skills/safeword-writing-plans/SKILL.md +219 -0
  24. package/dist/sync-AOKWEHCY.js +0 -9
  25. /package/dist/{check-OUVIK2O6.js.map → check-I2J6THGQ.js.map} +0 -0
  26. /package/dist/{chunk-QYCKBF57.js.map → chunk-DES5CSPH.js.map} +0 -0
  27. /package/dist/{chunk-TP334635.js.map → chunk-VXKJ5ZIV.js.map} +0 -0
  28. /package/dist/{diff-ASRWAPYJ.js.map → diff-4YFDNEZB.js.map} +0 -0
  29. /package/dist/{reset-4G5DEEMY.js.map → reset-QVERBAQJ.js.map} +0 -0
  30. /package/dist/{setup-URK77YMR.js.map → setup-ZSMZ7HZG.js.map} +0 -0
  31. /package/dist/{sync-AOKWEHCY.js.map → sync-VQW5DSTV.js.map} +0 -0
  32. /package/dist/{upgrade-IDR2ZALG.js.map → upgrade-WILVVHUY.js.map} +0 -0
@@ -0,0 +1,158 @@
1
+ ---
2
+ description: Deep code quality review with web research. Use when user explicitly requests verification against latest docs ('double check against latest', 'verify versions', 'check security'), needs deeper analysis beyond automatic hook, or is working on projects without SAFEWORD.md/CLAUDE.md. Fetches current documentation, checks latest versions, and provides deep analysis (performance, security, alternatives).
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Quality Reviewer
7
+
8
+ Deep quality review with web research to verify code against the latest ecosystem state.
9
+
10
+ **Primary differentiator**: Web research to verify against current versions, documentation, and best practices.
11
+
12
+ **Triggers**:
13
+
14
+ - **Explicit web research request**: "double check against latest docs", "verify we're using latest version", "check for security issues"
15
+ - **Deep dive needed**: User wants analysis beyond automatic hook (performance, architecture alternatives, trade-offs)
16
+ - **No SAFEWORD.md/CLAUDE.md**: Projects without context files (automatic hook won't run, manual review needed)
17
+ - **Pre-change review**: User wants review before making changes (automatic hook only triggers after changes)
18
+ - **Model-invoked**: Claude determines web research would be valuable
19
+
20
+ **Relationship to automatic quality hook**:
21
+
22
+ - **Automatic hook**: Fast quality check using existing knowledge + project context (guaranteed, runs on every change)
23
+ - **This skill**: Deep review with web research when verification against current ecosystem is needed (on-demand, 2-3 min)
24
+
25
+ ## Review Protocol
26
+
27
+ ### 1. Identify What Changed
28
+
29
+ Understand context:
30
+
31
+ - What files were just modified?
32
+ - What problem is being solved?
33
+ - What was the implementation approach?
34
+
35
+ ### 2. Read Project Standards
36
+
37
+ ```bash
38
+ ls CLAUDE.md SAFEWORD.md ARCHITECTURE.md .claude/
39
+ ```
40
+
41
+ Read relevant standards:
42
+
43
+ - `CLAUDE.md` or `SAFEWORD.md` - Project-specific guidelines
44
+ - `ARCHITECTURE.md` - Architectural principles
45
+ - `@./.safeword/guides/code-philosophy.md` - Core coding principles
46
+
47
+ ### 3. Evaluate Correctness
48
+
49
+ **Will it work?**
50
+
51
+ - Does the logic make sense?
52
+ - Are there obvious bugs?
53
+
54
+ **Edge cases:**
55
+
56
+ - Empty inputs, null/undefined, boundary conditions (0, -1, max)?
57
+ - Concurrent access, network failures?
58
+
59
+ **Error handling:**
60
+
61
+ - Are errors caught appropriately?
62
+ - Helpful error messages?
63
+ - Cleanup handled (resources, connections)?
64
+
65
+ **Logic errors:**
66
+
67
+ - Off-by-one errors, race conditions, wrong assumptions?
68
+
69
+ ### 4. Evaluate Anti-Bloat
70
+
71
+ - Are all dependencies necessary? Could we use stdlib/built-ins?
72
+ - Are abstractions solving real problems or imaginary ones?
73
+ - YAGNI: Is this feature actually needed now?
74
+
75
+ ### 5. Evaluate Elegance
76
+
77
+ - Is the code easy to understand?
78
+ - Are names clear and descriptive?
79
+ - Is the intent obvious?
80
+ - Will this be easy to change later?
81
+
82
+ ### 6. Check Standards Compliance
83
+
84
+ **Project standards** (from CLAUDE.md/SAFEWORD.md/ARCHITECTURE.md):
85
+
86
+ - Does it follow established patterns?
87
+ - Does it violate any documented principles?
88
+
89
+ **Library best practices:**
90
+
91
+ - Are we using libraries correctly?
92
+ - Are we following official documentation?
93
+
94
+ ### 7. Verify Latest Versions
95
+
96
+ **CRITICAL**: This is your main differentiator from automatic hook. ALWAYS check versions.
97
+
98
+ Search for:
99
+ - "[library name] latest stable version 2025"
100
+ - "[library name] security vulnerabilities"
101
+
102
+ **Flag if outdated:**
103
+
104
+ - Major versions behind → WARN (e.g., React 17 when 19 is stable)
105
+ - Minor versions behind → NOTE (e.g., React 19.0.0 when 19.1.0 is stable)
106
+ - Security vulnerabilities → CRITICAL (must upgrade)
107
+ - Using latest → Confirm
108
+
109
+ ### 8. Verify Latest Documentation
110
+
111
+ **CRITICAL**: This is your main differentiator from automatic hook. ALWAYS verify against current docs.
112
+
113
+ Fetch documentation from official sources:
114
+ - https://react.dev (for React)
115
+ - https://vitejs.dev (for Vite)
116
+
117
+ **Look for:**
118
+
119
+ - Are we using deprecated APIs?
120
+ - Are there newer, better patterns?
121
+ - Did the library's recommendations change since training data?
122
+
123
+ ## Output Format
124
+
125
+ **Simple question** ("is it correct?"):
126
+
127
+ ```text
128
+ **Correctness:** ✓ Logic is sound, edge cases handled, no obvious errors.
129
+ ```
130
+
131
+ **Full review** ("double check and critique"):
132
+
133
+ ```markdown
134
+ ## Quality Review
135
+
136
+ **Correctness:** [✓/⚠️/❌] [Brief assessment]
137
+ **Anti-Bloat:** [✓/⚠️/❌] [Brief assessment]
138
+ **Elegance:** [✓/⚠️/❌] [Brief assessment]
139
+ **Standards:** [✓/⚠️/❌] [Brief assessment]
140
+ **Versions:** [✓/⚠️/❌] [Latest version check with WebSearch]
141
+ **Documentation:** [✓/⚠️/❌] [Current docs check with WebFetch]
142
+
143
+ **Verdict:** [APPROVE / REQUEST CHANGES / NEEDS DISCUSSION]
144
+
145
+ **Critical issues:** [List or "None"]
146
+ **Suggested improvements:** [List or "None"]
147
+ ```
148
+
149
+ ## Critical Reminders
150
+
151
+ 1. **Primary value: Web research** - Verify against current ecosystem (versions, docs, security)
152
+ 2. **Complement automatic hook** - Hook does fast check with existing knowledge, you do deep dive with web research
153
+ 3. **Explicit triggers matter** - "double check against latest docs", "verify versions", "check security" = invoke web research
154
+ 4. **Always check latest docs** - Verify patterns are current, not outdated
155
+ 5. **Always verify versions** - Flag outdated dependencies
156
+ 6. **Be thorough but concise** - Cover all areas but keep explanations brief
157
+ 7. **Provide actionable feedback** - Specific line numbers, concrete suggestions
158
+ 8. **Clear verdict** - Always end with APPROVE/REQUEST CHANGES/NEEDS DISCUSSION
@@ -0,0 +1,175 @@
1
+ ---
2
+ description: Systematic refactoring with small-step discipline. Use when user says 'refactor', 'clean up', 'restructure', 'extract', 'rename', 'simplify', or mentions code smells. Enforces one change → test → commit cycle. For structural improvements, NOT style/formatting (use /lint). NOT for adding features or fixing bugs.
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Refactoring
7
+
8
+ Improve code structure without changing behavior. One small step at a time.
9
+
10
+ **Iron Law:** ONE REFACTORING → TEST → COMMIT. Never batch changes.
11
+
12
+ ## When to Use
13
+
14
+ Answer IN ORDER. Stop at first match:
15
+
16
+ 1. User says "refactor", "clean up", "restructure"? → Use this skill
17
+ 2. User asks to "extract", "rename", "simplify"? → Use this skill
18
+ 3. Code smell identified? → Use this skill
19
+ 4. User wants to add feature or fix bug? → Skip (use tdd-enforcer)
20
+ 5. User wants formatting/style fixes? → Skip (use /lint)
21
+
22
+ **Code smells** (common triggers):
23
+
24
+ - Duplicated code (same logic in multiple places)
25
+ - Long function (>30 lines, doing too much)
26
+ - Magic numbers/strings (unexplained literals)
27
+ - Deep nesting (>3 levels of indentation)
28
+ - Dead code (unused functions, unreachable branches)
29
+ - Poor naming (unclear what something does)
30
+
31
+ ---
32
+
33
+ ## Phase 1: ASSESS
34
+
35
+ **Is this actually refactoring?**
36
+
37
+ | User Intent | Action |
38
+ | ------------------- | ----------------------------------------------- |
39
+ | "Make this cleaner" | ✓ Refactoring |
40
+ | "Add validation" | ✗ New behavior → tdd-enforcer |
41
+ | "Fix this bug" | ✗ Bug fix → tdd-enforcer or systematic-debugger |
42
+ | "Format this code" | ✗ Style → /lint |
43
+
44
+ **If not refactoring:** Explain and suggest correct approach.
45
+
46
+ ---
47
+
48
+ ## Phase 2: PROTECT
49
+
50
+ **Does the code have tests?**
51
+
52
+ | Coverage | Action |
53
+ | ---------------- | --------------------------------------------- |
54
+ | Well-tested | Skip to Phase 3 |
55
+ | Partial coverage | Add characterization tests for untested parts |
56
+ | No tests | Add characterization tests first |
57
+
58
+ ### Characterization Tests
59
+
60
+ Capture current behavior before refactoring:
61
+
62
+ ```typescript
63
+ // Characterization test - captures ACTUAL behavior
64
+ it('processOrder returns current behavior', () => {
65
+ const result = processOrder({ items: [], user: null });
66
+ // Whatever it returns NOW is the expected value
67
+ expect(result).toEqual({ status: 'empty', total: 0 });
68
+ });
69
+ ```
70
+
71
+ **Purpose:** Safety net, not specification. Test what the code DOES, not what it SHOULD do.
72
+
73
+ ---
74
+
75
+ ## Phase 3: REFACTOR
76
+
77
+ **Iron Law:** ONE refactoring at a time. Run tests after EVERY change.
78
+
79
+ ### Refactoring Catalog
80
+
81
+ **Tier 1 - Always Safe** (no behavior change possible):
82
+
83
+ | Smell | Refactoring | Example |
84
+ | -------------------- | -------------------- | -------------------------------------- |
85
+ | Unclear name | **Rename** | `d` → `discountAmount` |
86
+ | Long function | **Extract Function** | Pull 10 lines into `calculateTax()` |
87
+ | Unnecessary variable | **Inline Variable** | Remove `temp = x; return temp;` |
88
+ | Misplaced code | **Move Function** | Move `validate()` to `Validator` class |
89
+
90
+ **Tier 2 - Safe with Tests** (low risk if tests exist):
91
+
92
+ | Smell | Refactoring | Example |
93
+ | ------------------- | ------------------------- | ------------------------------------------------- |
94
+ | Repeated expression | **Extract Variable** | `order.items.length > 0` → `const hasItems = ...` |
95
+ | Complex conditional | **Decompose Conditional** | Extract `if` branches to named functions |
96
+ | Nested conditionals | **Guard Clauses** | Early returns instead of deep nesting |
97
+ | Magic literal | **Replace Magic Literal** | `0.2` → `VIP_DISCOUNT_RATE` |
98
+ | Unused code | **Remove Dead Code** | Delete unreachable branches |
99
+
100
+ **Tier 3 - Requires Care** (higher risk, break into smaller steps):
101
+
102
+ | Smell | Refactoring | Caution |
103
+ | -------------------------- | ------------------------------ | ------------------------------------------- |
104
+ | God class | **Extract Class** | Do incrementally, move one method at a time |
105
+ | Type-checking conditionals | **Replace with Polymorphism** | Requires class hierarchy |
106
+ | Too many parameters | **Introduce Parameter Object** | Changes function signature |
107
+
108
+ **Tie-breaker:** If multiple refactorings apply, choose smallest scope first (Rename < Extract Variable < Extract Function < Extract Class).
109
+
110
+ ---
111
+
112
+ ## Phase 4: VERIFY
113
+
114
+ After each refactoring:
115
+
116
+ 1. **Run tests** - Must pass
117
+ 2. **If tests pass:** Commit with `refactor: [what changed]`
118
+ 3. **If tests fail:** Revert immediately
119
+
120
+ ### Revert Protocol
121
+
122
+ ```bash
123
+ git checkout -- <changed-files>
124
+ ```
125
+
126
+ **After revert:**
127
+
128
+ - Was the refactoring too large? → Try smaller step
129
+ - Did it accidentally change behavior? → Reconsider approach
130
+ - DO NOT attempt to "fix" a failed refactoring
131
+
132
+ ### After 2 Failed Attempts
133
+
134
+ **STOP.** Ask user:
135
+
136
+ > "I've attempted this refactoring twice and tests keep failing. This suggests either:
137
+ >
138
+ > 1. The refactoring is too large (need smaller steps)
139
+ > 2. The code has hidden dependencies
140
+ > 3. Tests are brittle
141
+ >
142
+ > How would you like to proceed?"
143
+
144
+ ---
145
+
146
+ ## Phase 5: ITERATE
147
+
148
+ ```text
149
+ More refactoring needed?
150
+ ├─ Yes → Return to Phase 3 (one more refactoring)
151
+ └─ No → Done
152
+ └─ Report: "Refactoring complete. Changes: [summary]"
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Anti-Patterns
158
+
159
+ | Don't | Do |
160
+ | ------------------------------- | ------------------------------------- |
161
+ | Batch multiple refactorings | One refactoring → test → commit |
162
+ | "Fix" a failed refactoring | Revert, then try smaller step |
163
+ | Refactor without tests | Add characterization tests first |
164
+ | Change behavior during refactor | That's a feature/fix, not refactoring |
165
+ | Skip the commit | Commit after every green test |
166
+
167
+ ---
168
+
169
+ ## Key Takeaways
170
+
171
+ 1. **One change at a time** - Never batch refactorings
172
+ 2. **Tests before refactoring** - No safety net = no refactoring
173
+ 3. **Revert on failure** - Don't fix, revert and retry smaller
174
+ 4. **Commit after each success** - `refactor: [description]`
175
+ 5. **Smallest scope first** - Rename < Extract < Move < Restructure
@@ -0,0 +1,218 @@
1
+ ---
2
+ description: Use when spec is complete and you need detailed implementation tasks for LLM agents. Creates execution plans with exact file paths, complete code examples, and verification steps. Triggers: 'write plan', 'execution plan', 'implementation plan', 'break down into tasks', 'detailed steps'.
3
+ alwaysApply: false
4
+ ---
5
+
6
+ # Writing Execution Plans
7
+
8
+ Convert specs into detailed implementation plans for LLM agents.
9
+
10
+ **Iron Law:** EXACT PATHS. COMPLETE CODE. VERIFICATION GATES.
11
+
12
+ ## When to Use
13
+
14
+ Answer IN ORDER. Stop at first match:
15
+
16
+ 1. Spec exists and is approved? → Use this skill
17
+ 2. No spec yet? → Use brainstorming skill first
18
+ 3. Simple task, obvious steps? → Skip (use enforcing-tdd directly)
19
+
20
+ ---
21
+
22
+ ## Phase 1: CONTEXT
23
+
24
+ **Purpose:** Understand the spec and identify all affected files.
25
+
26
+ **Protocol:**
27
+
28
+ 1. Read the spec from `.safeword/planning/specs/`
29
+ 2. Identify all files that will be created or modified
30
+ 3. Check existing patterns in the codebase
31
+ 4. Note test file locations and naming conventions
32
+
33
+ **Exit Criteria:**
34
+
35
+ - [ ] Spec read and understood
36
+ - [ ] All affected files identified
37
+ - [ ] Existing patterns noted
38
+
39
+ ---
40
+
41
+ ## Phase 2: DECOMPOSE
42
+
43
+ **Purpose:** Break the spec into atomic tasks.
44
+
45
+ **Protocol:**
46
+
47
+ 1. Each task = one logical unit (one component, one function, one integration point)
48
+ 2. Order tasks by dependency (foundations first)
49
+ 3. Each task must be independently verifiable
50
+
51
+ **Task sizing guide:**
52
+
53
+ | Too Big | Right Size | Too Small |
54
+ | ----------------- | ---------------------------------- | ---------------- |
55
+ | "Add auth system" | "Add password validation function" | "Import bcrypt" |
56
+ | "Build API" | "Add POST /users endpoint" | "Add route file" |
57
+
58
+ **Exit Criteria:**
59
+
60
+ - [ ] Tasks are atomic and ordered
61
+ - [ ] No task depends on uncommitted work from another
62
+ - [ ] Each task has clear boundaries
63
+
64
+ ---
65
+
66
+ ## Phase 3: DETAIL
67
+
68
+ **Purpose:** Write exact implementation details for each task.
69
+
70
+ **Protocol:**
71
+
72
+ For each task, provide:
73
+
74
+ 1. **Files** - Exact paths (create/modify/test)
75
+ 2. **Test code** - Complete, runnable test
76
+ 3. **Implementation code** - Complete, minimal code to pass
77
+ 4. **Verification command** - Exact command with expected output
78
+ 5. **Commit message** - Ready to use
79
+
80
+ **Task Format** (adapt syntax to project's language/test framework):
81
+
82
+ ````markdown
83
+ ### Task N: [Name]
84
+
85
+ **Files:**
86
+
87
+ - Create: `src/path/to/file.ext`
88
+ - Test: `src/path/to/file.test.ext`
89
+
90
+ **Step 1: Write failing test**
91
+
92
+ ```
93
+ [Complete test code using project's test framework]
94
+ ```
95
+
96
+ **Step 2: Verify test fails**
97
+
98
+ Run: `[exact test command]`
99
+ Expected: FAIL - "[specific error message]"
100
+
101
+ **Step 3: Implement**
102
+
103
+ ```
104
+ [Complete implementation code]
105
+ ```
106
+
107
+ **Step 4: Verify test passes**
108
+
109
+ Run: `[exact test command]`
110
+ Expected: PASS
111
+
112
+ **Step 5: Commit**
113
+
114
+ ```bash
115
+ git add [files]
116
+ git commit -m "[type]: [description]"
117
+ ```
118
+ ````
119
+
120
+ **Exit Criteria:**
121
+
122
+ - [ ] Every task has complete code (no "add validation here")
123
+ - [ ] Every task has exact verification command
124
+ - [ ] Every task has commit message
125
+
126
+ ---
127
+
128
+ ## Phase 4: SAVE
129
+
130
+ **Purpose:** Write the plan to disk.
131
+
132
+ **Protocol:**
133
+
134
+ 1. Create plan file at `.safeword/planning/plans/{slug}.md`
135
+ 2. Include header with metadata
136
+ 3. Include all tasks in order
137
+
138
+ **Plan Header:**
139
+
140
+ ```markdown
141
+ # [Feature Name] Execution Plan
142
+
143
+ **Source Spec:** `.safeword/planning/specs/{spec-file}.md`
144
+ **Created:** YYYY-MM-DD
145
+ **Status:** Ready
146
+
147
+ **Goal:** [One sentence]
148
+
149
+ **Tasks:** N tasks
150
+
151
+ ---
152
+ ```
153
+
154
+ **Exit Criteria:**
155
+
156
+ - [ ] Plan saved to `.safeword/planning/plans/`
157
+ - [ ] Header includes source spec reference
158
+ - [ ] All tasks included
159
+
160
+ ---
161
+
162
+ ## Phase 5: HANDOFF
163
+
164
+ **Purpose:** Transition to execution.
165
+
166
+ **Protocol:**
167
+
168
+ 1. Summarize the plan (task count, scope)
169
+ 2. Offer execution options:
170
+
171
+ ```text
172
+ Plan saved to `.safeword/planning/plans/{slug}.md`
173
+
174
+ **Execution options:**
175
+
176
+ 1. **Continue here** - I'll execute tasks one-by-one using enforcing-tdd
177
+ 2. **Fresh session** - Open new session, reference the plan file
178
+
179
+ Which approach?
180
+ ```
181
+
182
+ 3. If continuing: Start with Task 1, use enforcing-tdd skill
183
+
184
+ **Exit Criteria:**
185
+
186
+ - [ ] User chose execution approach
187
+ - [ ] Handed off appropriately
188
+
189
+ ---
190
+
191
+ ## Key Principles
192
+
193
+ | Principle | Why |
194
+ | ------------------ | -------------------------------------------------- |
195
+ | Exact file paths | LLMs hallucinate paths without specifics |
196
+ | Complete code | "Add X here" leads to inconsistent implementations |
197
+ | Verification gates | LLMs need explicit pass/fail criteria |
198
+ | Atomic tasks | Fresh context per task = less drift |
199
+ | TDD per task | Catches errors immediately |
200
+
201
+ ---
202
+
203
+ ## Anti-Patterns
204
+
205
+ | Don't | Do |
206
+ | ------------------------------ | ---------------------------------- |
207
+ | "Add error handling" | Show exact try/catch code |
208
+ | "Create test file" | Show complete test with assertions |
209
+ | "Run tests" | `npm test -- path/to/file.test.ts` |
210
+ | Combine 3 features in one task | One feature per task |
211
+ | Skip verification step | Always: Run X, expect Y |
212
+
213
+ ---
214
+
215
+ ## Related
216
+
217
+ - @./.safeword/guides/planning-guide.md
218
+ - @./.safeword/guides/testing-guide.md