safeword 0.8.3 → 0.8.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-Y3AQWR4Y.js → check-QZ3ZAHZY.js} +3 -3
- package/dist/{chunk-SIK3BC7F.js → chunk-62YXVEKM.js} +27 -9
- package/dist/{chunk-SIK3BC7F.js.map → chunk-62YXVEKM.js.map} +1 -1
- package/dist/{chunk-VLNT6YSH.js → chunk-SIEJPWQA.js} +3 -2
- package/dist/{chunk-VLNT6YSH.js.map → chunk-SIEJPWQA.js.map} +1 -1
- package/dist/{chunk-QYCKBF57.js → chunk-VZPFU4YI.js} +2 -2
- package/dist/cli.js +6 -6
- package/dist/{diff-OITRHARU.js → diff-YXUSIILN.js} +3 -3
- package/dist/{reset-D6HUKH4Z.js → reset-HQXT7SCI.js} +3 -3
- package/dist/{setup-DW7OG2QD.js → setup-JX476EH3.js} +3 -3
- package/dist/sync-A7VWZKQD.js +9 -0
- package/dist/{upgrade-FDZLLLT2.js → upgrade-45E6255Q.js} +4 -4
- package/package.json +15 -14
- package/templates/cursor/rules/safeword-brainstorming.mdc +198 -0
- package/templates/cursor/rules/safeword-debugging.mdc +202 -0
- package/templates/cursor/rules/safeword-enforcing-tdd.mdc +207 -0
- package/templates/cursor/rules/safeword-quality-reviewer.mdc +158 -0
- package/templates/cursor/rules/safeword-refactoring.mdc +175 -0
- package/templates/scripts/lint-md.sh +0 -0
- package/templates/skills/safeword-brainstorming/SKILL.md +210 -0
- package/templates/skills/{safeword-systematic-debugger → safeword-debugging}/SKILL.md +1 -71
- package/templates/skills/{safeword-tdd-enforcer → safeword-enforcing-tdd}/SKILL.md +17 -17
- package/templates/skills/safeword-quality-reviewer/SKILL.md +17 -67
- package/dist/sync-AOKWEHCY.js +0 -9
- /package/dist/{check-Y3AQWR4Y.js.map → check-QZ3ZAHZY.js.map} +0 -0
- /package/dist/{chunk-QYCKBF57.js.map → chunk-VZPFU4YI.js.map} +0 -0
- /package/dist/{diff-OITRHARU.js.map → diff-YXUSIILN.js.map} +0 -0
- /package/dist/{reset-D6HUKH4Z.js.map → reset-HQXT7SCI.js.map} +0 -0
- /package/dist/{setup-DW7OG2QD.js.map → setup-JX476EH3.js.map} +0 -0
- /package/dist/{sync-AOKWEHCY.js.map → sync-A7VWZKQD.js.map} +0 -0
- /package/dist/{upgrade-FDZLLLT2.js.map → upgrade-45E6255Q.js.map} +0 -0
|
@@ -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
|
|
File without changes
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brainstorming
|
|
3
|
+
description: Use before implementation when refining rough ideas into specs. Guides collaborative design through Socratic questioning, alternative exploration, and incremental validation. Triggers: 'brainstorm', 'design', 'explore options', 'figure out', 'think through', 'what approach'.
|
|
4
|
+
allowed-tools: '*'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Brainstorming Ideas Into Specs
|
|
8
|
+
|
|
9
|
+
Turn rough ideas into validated specs through Socratic dialogue.
|
|
10
|
+
|
|
11
|
+
**Iron Law:** ONE QUESTION AT A TIME. EXPLORE ALTERNATIVES BEFORE DECIDING.
|
|
12
|
+
|
|
13
|
+
## When to Use
|
|
14
|
+
|
|
15
|
+
Answer IN ORDER. Stop at first match:
|
|
16
|
+
|
|
17
|
+
1. Rough idea needs refinement? → Use this skill
|
|
18
|
+
2. Multiple approaches possible? → Use this skill
|
|
19
|
+
3. Unclear requirements? → Use this skill
|
|
20
|
+
4. Clear task, obvious approach? → Skip (use enforcing-tdd directly)
|
|
21
|
+
5. Pure research/investigation? → Skip
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Phase 1: CONTEXT
|
|
26
|
+
|
|
27
|
+
**Purpose:** Understand what exists before asking questions.
|
|
28
|
+
|
|
29
|
+
**Protocol:**
|
|
30
|
+
|
|
31
|
+
1. Check project state (files, recent commits, existing specs)
|
|
32
|
+
2. Review relevant docs in `.safeword/planning/`
|
|
33
|
+
3. Identify constraints and patterns already established
|
|
34
|
+
|
|
35
|
+
**Exit Criteria:**
|
|
36
|
+
|
|
37
|
+
- [ ] Reviewed relevant codebase areas
|
|
38
|
+
- [ ] Checked existing specs/designs
|
|
39
|
+
- [ ] Ready to ask informed questions
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Phase 2: QUESTION
|
|
44
|
+
|
|
45
|
+
**Iron Law:** ONE QUESTION PER MESSAGE
|
|
46
|
+
|
|
47
|
+
**Protocol:**
|
|
48
|
+
|
|
49
|
+
1. Ask one focused question
|
|
50
|
+
2. Prefer multiple choice (2-4 options) when possible
|
|
51
|
+
3. Open-ended is fine for exploratory topics
|
|
52
|
+
4. Focus on: purpose, constraints, success criteria, scope
|
|
53
|
+
|
|
54
|
+
**Question Types (in order of preference):**
|
|
55
|
+
|
|
56
|
+
| Type | When | Example |
|
|
57
|
+
| --------------- | ----------------------- | ---------------------------------------------------- |
|
|
58
|
+
| Multiple choice | Clear options exist | "Should this be (A) real-time or (B) polling-based?" |
|
|
59
|
+
| Yes/No | Binary decision | "Do we need offline support?" |
|
|
60
|
+
| Bounded open | Need specifics | "What's the max number of items to display?" |
|
|
61
|
+
| Open-ended | Exploring problem space | "What problem are you trying to solve?" |
|
|
62
|
+
|
|
63
|
+
**Exit Criteria:**
|
|
64
|
+
|
|
65
|
+
- [ ] Understand the core problem/goal
|
|
66
|
+
- [ ] Know key constraints
|
|
67
|
+
- [ ] Have success criteria
|
|
68
|
+
- [ ] Scope boundaries are clear
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Phase 3: ALTERNATIVES
|
|
73
|
+
|
|
74
|
+
**Iron Law:** ALWAYS PRESENT 2-3 OPTIONS BEFORE DECIDING
|
|
75
|
+
|
|
76
|
+
**Protocol:**
|
|
77
|
+
|
|
78
|
+
1. Present 2-3 approaches with trade-offs
|
|
79
|
+
2. Lead with your recommendation and why
|
|
80
|
+
3. Be explicit about what each gives up
|
|
81
|
+
4. Let user choose (or suggest hybrid)
|
|
82
|
+
|
|
83
|
+
**Format:**
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
I'd recommend Option A because [reason].
|
|
87
|
+
|
|
88
|
+
**Option A: [Name]**
|
|
89
|
+
- Approach: [how it works]
|
|
90
|
+
- Pros: [benefits]
|
|
91
|
+
- Cons: [drawbacks]
|
|
92
|
+
|
|
93
|
+
**Option B: [Name]**
|
|
94
|
+
- Approach: [how it works]
|
|
95
|
+
- Pros: [benefits]
|
|
96
|
+
- Cons: [drawbacks]
|
|
97
|
+
|
|
98
|
+
**Option C: [Name]** (if applicable)
|
|
99
|
+
- Approach: [how it works]
|
|
100
|
+
- Pros: [benefits]
|
|
101
|
+
- Cons: [drawbacks]
|
|
102
|
+
|
|
103
|
+
Which direction feels right?
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Exit Criteria:**
|
|
107
|
+
|
|
108
|
+
- [ ] Presented 2-3 viable approaches
|
|
109
|
+
- [ ] Gave clear recommendation with reasoning
|
|
110
|
+
- [ ] User selected approach (or hybrid)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Phase 4: DESIGN
|
|
115
|
+
|
|
116
|
+
**Iron Law:** PRESENT IN 200-300 WORD SECTIONS. VALIDATE EACH.
|
|
117
|
+
|
|
118
|
+
**Protocol:**
|
|
119
|
+
|
|
120
|
+
1. Present design incrementally (not all at once)
|
|
121
|
+
2. After each section: "Does this look right so far?"
|
|
122
|
+
3. Cover: architecture, components, data flow, error handling
|
|
123
|
+
4. Apply YAGNI ruthlessly - remove anything "just in case"
|
|
124
|
+
5. Go back and clarify when something doesn't fit
|
|
125
|
+
|
|
126
|
+
**Sections (present one at a time):**
|
|
127
|
+
|
|
128
|
+
1. **Overview** - What we're building, high-level approach
|
|
129
|
+
2. **Components** - Key pieces and responsibilities
|
|
130
|
+
3. **Data Flow** - How data moves through system
|
|
131
|
+
4. **Edge Cases** - Error handling, boundaries
|
|
132
|
+
5. **Out of Scope** - What we're explicitly NOT doing
|
|
133
|
+
|
|
134
|
+
**Exit Criteria:**
|
|
135
|
+
|
|
136
|
+
- [ ] Each section validated by user
|
|
137
|
+
- [ ] Design is complete and coherent
|
|
138
|
+
- [ ] YAGNI applied (no speculative features)
|
|
139
|
+
- [ ] Ready to create spec
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Phase 5: SPEC
|
|
144
|
+
|
|
145
|
+
**Purpose:** Convert validated design into structured spec.
|
|
146
|
+
|
|
147
|
+
**Protocol:**
|
|
148
|
+
|
|
149
|
+
1. Determine level (L0/L1/L2) using triage questions
|
|
150
|
+
2. Create spec using appropriate template
|
|
151
|
+
3. Commit the spec
|
|
152
|
+
|
|
153
|
+
**Triage:**
|
|
154
|
+
|
|
155
|
+
| Question | If Yes → |
|
|
156
|
+
| ---------------------------------------- | ---------------------------- |
|
|
157
|
+
| User-facing feature with business value? | **L2** → Feature Spec |
|
|
158
|
+
| Bug, improvement, internal, or refactor? | **L1** → Task Spec |
|
|
159
|
+
| Typo, config, or trivial change? | **L0** → Task Spec (minimal) |
|
|
160
|
+
|
|
161
|
+
**Output Locations:**
|
|
162
|
+
|
|
163
|
+
- L2: `.safeword/planning/specs/feature-[slug].md`
|
|
164
|
+
- L1/L0: `.safeword/planning/specs/task-[slug].md`
|
|
165
|
+
- L2 Test Defs: `.safeword/planning/test-definitions/feature-[slug].md`
|
|
166
|
+
|
|
167
|
+
**Exit Criteria:**
|
|
168
|
+
|
|
169
|
+
- [ ] Spec created in correct location
|
|
170
|
+
- [ ] L2: Test definitions created
|
|
171
|
+
- [ ] Spec committed to git
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Phase 6: HANDOFF
|
|
176
|
+
|
|
177
|
+
**Protocol:**
|
|
178
|
+
|
|
179
|
+
1. Summarize what was created
|
|
180
|
+
2. Ask: "Ready to start implementation with TDD?"
|
|
181
|
+
3. If yes → Invoke enforcing-tdd skill
|
|
182
|
+
|
|
183
|
+
**Exit Criteria:**
|
|
184
|
+
|
|
185
|
+
- [ ] User confirmed spec is complete
|
|
186
|
+
- [ ] Handed off to enforcing-tdd (if continuing)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Key Principles
|
|
191
|
+
|
|
192
|
+
| Principle | Why |
|
|
193
|
+
| ----------------------------- | --------------------------------------- |
|
|
194
|
+
| One question at a time | Prevents overwhelm, gets better answers |
|
|
195
|
+
| Multiple choice preferred | Faster to answer, reduces ambiguity |
|
|
196
|
+
| Alternatives before decisions | Avoids premature commitment |
|
|
197
|
+
| Incremental validation | Catches misunderstandings early |
|
|
198
|
+
| YAGNI ruthlessly | Scope creep kills projects |
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Anti-Patterns
|
|
203
|
+
|
|
204
|
+
| Don't | Do |
|
|
205
|
+
| ------------------------------ | -------------------------------- |
|
|
206
|
+
| Dump full design at once | Present in 200-300 word sections |
|
|
207
|
+
| Ask 5 questions in one message | Ask ONE question |
|
|
208
|
+
| Skip alternatives | Always present 2-3 options |
|
|
209
|
+
| Accept vague requirements | Probe until concrete |
|
|
210
|
+
| Add "nice to have" features | Put them in "Out of Scope" |
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: debugging
|
|
3
3
|
description: Four-phase debugging framework that ensures root cause identification before fixes. Use when encountering bugs, test failures, unexpected behavior, or when previous fix attempts failed. Enforces investigate-first discipline ('debug this', 'fix this error', 'test is failing', 'not working').
|
|
4
4
|
allowed-tools: '*'
|
|
5
5
|
---
|
|
@@ -26,33 +26,6 @@ Answer IN ORDER. Stop at first match:
|
|
|
26
26
|
- "Quick fix" seems obvious (red flag)
|
|
27
27
|
- Already tried 1+ fixes that didn't work
|
|
28
28
|
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## Work Log
|
|
32
|
-
|
|
33
|
-
**Think hard. Keep notes.**
|
|
34
|
-
|
|
35
|
-
Before starting Phase 1, create or open a work log:
|
|
36
|
-
|
|
37
|
-
**Location:** `.safeword/logs/{artifact-type}-{slug}.md`
|
|
38
|
-
|
|
39
|
-
| Working on... | Log file name |
|
|
40
|
-
| --------------------- | ------------------------ |
|
|
41
|
-
| Ticket `001-fix-auth` | `ticket-001-fix-auth.md` |
|
|
42
|
-
| Spec `task-add-cache` | `spec-task-add-cache.md` |
|
|
43
|
-
|
|
44
|
-
**One artifact = one log.** If log exists, append a new session.
|
|
45
|
-
|
|
46
|
-
**Especially important for debugging:**
|
|
47
|
-
|
|
48
|
-
1. **Re-read the log** before each hypothesis
|
|
49
|
-
2. **Log what you tried** and why it didn't work
|
|
50
|
-
3. **Note dead ends** - debugging often revisits same paths
|
|
51
|
-
|
|
52
|
-
**Template:** @./.safeword/templates/work-log-template.md
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
29
|
## The Four Phases
|
|
57
30
|
|
|
58
31
|
Complete each phase before proceeding.
|
|
@@ -220,32 +193,6 @@ If you catch yourself thinking:
|
|
|
220
193
|
|
|
221
194
|
**ALL mean: STOP. Return to Phase 1.**
|
|
222
195
|
|
|
223
|
-
## Finding Test Pollution
|
|
224
|
-
|
|
225
|
-
When tests pass individually but fail together (test isolation problem, tests affect each other, tests leave files behind), use bisection:
|
|
226
|
-
|
|
227
|
-
```bash
|
|
228
|
-
./.safeword/scripts/bisect-test-pollution.sh '.git' '*.test.ts' src
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
See: @./.safeword/scripts/bisect-test-pollution.sh
|
|
232
|
-
|
|
233
|
-
## Debug Logging
|
|
234
|
-
|
|
235
|
-
When adding diagnostic logging:
|
|
236
|
-
|
|
237
|
-
```javascript
|
|
238
|
-
// ❌ BAD
|
|
239
|
-
console.log('here');
|
|
240
|
-
console.log(data);
|
|
241
|
-
|
|
242
|
-
// ✅ GOOD
|
|
243
|
-
console.log('validateUser', { expected: 'admin', actual: user.role });
|
|
244
|
-
console.log('processOrder', JSON.stringify({ input, output }, null, 2));
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
Log **expected vs actual**. Remove after fixing.
|
|
248
|
-
|
|
249
196
|
## Quick Reference
|
|
250
197
|
|
|
251
198
|
| Phase | Key Question | Success Criteria |
|
|
@@ -254,20 +201,3 @@ Log **expected vs actual**. Remove after fixing.
|
|
|
254
201
|
| 2. Pattern | "What's different from working code?" | Identified key differences |
|
|
255
202
|
| 3. Hypothesis | "Is my theory correct?" | Confirmed or formed new theory |
|
|
256
203
|
| 4. Implementation | "Does the fix work?" | Test passes, issue resolved |
|
|
257
|
-
|
|
258
|
-
## Finding Zombie Process Spawners
|
|
259
|
-
|
|
260
|
-
When tests leave processes behind (playwright browsers not cleaned up, port stays in use, zombie node processes, chromium accumulating), use bisection to find the culprit:
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
./.safeword/scripts/bisect-zombie-processes.sh 'chromium' '*.test.ts' tests
|
|
264
|
-
./.safeword/scripts/bisect-zombie-processes.sh 'playwright' '*.spec.ts' e2e
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
See: @./.safeword/scripts/bisect-zombie-processes.sh
|
|
268
|
-
|
|
269
|
-
## Related Resources
|
|
270
|
-
|
|
271
|
-
- Process cleanup guide: @./.safeword/guides/zombie-process-cleanup.md
|
|
272
|
-
- Debug logging style: @./.safeword/guides/code-philosophy.md
|
|
273
|
-
- TDD for fix verification: @./.safeword/guides/testing-guide.md
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: tdd
|
|
3
|
-
description: Use when implementing features, fixing bugs, or
|
|
2
|
+
name: enforcing-tdd
|
|
3
|
+
description: Use when implementing features, fixing bugs, or making code changes. Ensures scope is defined before coding, then enforces RED → GREEN → REFACTOR test discipline. Triggers: 'implement', 'add', 'build', 'create', 'fix', 'change', 'feature', 'bug'.
|
|
4
4
|
allowed-tools: '*'
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@ Answer IN ORDER. Stop at first match:
|
|
|
17
17
|
1. Implementing new feature? → Use this skill
|
|
18
18
|
2. Fixing bug? → Use this skill
|
|
19
19
|
3. Adding enhancement? → Use this skill
|
|
20
|
-
4. Refactoring
|
|
20
|
+
4. Refactoring? → Use this skill
|
|
21
21
|
5. Research/investigation only? → Skip this skill
|
|
22
22
|
|
|
23
23
|
---
|
|
@@ -160,15 +160,15 @@ Claim: "All tests pass" "Tests pass" (no output shown)
|
|
|
160
160
|
|
|
161
161
|
**Red Flags → STOP:**
|
|
162
162
|
|
|
163
|
-
| Flag | Action
|
|
164
|
-
| --------------------------- |
|
|
165
|
-
| "should", "probably" claims | Run command, show output first
|
|
166
|
-
| "Done!" before verification | Run command, show output first
|
|
167
|
-
| "Just in case" code | Delete it
|
|
168
|
-
| Multiple functions | Delete extras
|
|
169
|
-
| Refactoring | Stop - that's Phase 3
|
|
170
|
-
| Test still fails | Debug (→
|
|
171
|
-
| Hardcoded value | Implement real logic (see below)
|
|
163
|
+
| Flag | Action |
|
|
164
|
+
| --------------------------- | ---------------------------------- |
|
|
165
|
+
| "should", "probably" claims | Run command, show output first |
|
|
166
|
+
| "Done!" before verification | Run command, show output first |
|
|
167
|
+
| "Just in case" code | Delete it |
|
|
168
|
+
| Multiple functions | Delete extras |
|
|
169
|
+
| Refactoring | Stop - that's Phase 3 |
|
|
170
|
+
| Test still fails | Debug (→ debugging skill if stuck) |
|
|
171
|
+
| Hardcoded value | Implement real logic (see below) |
|
|
172
172
|
|
|
173
173
|
### Anti-Pattern: Mock Implementations
|
|
174
174
|
|
|
@@ -253,11 +253,11 @@ Phase 0: L0 → create minimal spec → Phase 1: no new test (existing tests cov
|
|
|
253
253
|
|
|
254
254
|
## Integration
|
|
255
255
|
|
|
256
|
-
| Scenario | Handoff
|
|
257
|
-
| ----------------------- |
|
|
258
|
-
| Test fails unexpectedly | →
|
|
259
|
-
| Review needed | → quality-reviewer
|
|
260
|
-
| Scope expanding | → Update spec first
|
|
256
|
+
| Scenario | Handoff |
|
|
257
|
+
| ----------------------- | ------------------- |
|
|
258
|
+
| Test fails unexpectedly | → debugging skill |
|
|
259
|
+
| Review needed | → quality-reviewer |
|
|
260
|
+
| Scope expanding | → Update spec first |
|
|
261
261
|
|
|
262
262
|
---
|
|
263
263
|
|