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,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
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').
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Systematic Debugger
|
|
7
|
+
|
|
8
|
+
Find root cause before fixing. Symptom fixes are failure.
|
|
9
|
+
|
|
10
|
+
**Iron Law:** NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Answer IN ORDER. Stop at first match:
|
|
15
|
+
|
|
16
|
+
1. Bug, error, or test failure? → Use this skill
|
|
17
|
+
2. Unexpected behavior? → Use this skill
|
|
18
|
+
3. Previous fix didn't work? → Use this skill (especially important)
|
|
19
|
+
4. Performance problem? → Use this skill
|
|
20
|
+
5. None of above? → Skip this skill
|
|
21
|
+
|
|
22
|
+
**Use especially when:**
|
|
23
|
+
|
|
24
|
+
- Under time pressure (emergencies make guessing tempting)
|
|
25
|
+
- "Quick fix" seems obvious (red flag)
|
|
26
|
+
- Already tried 1+ fixes that didn't work
|
|
27
|
+
|
|
28
|
+
## The Four Phases
|
|
29
|
+
|
|
30
|
+
Complete each phase before proceeding.
|
|
31
|
+
|
|
32
|
+
### Phase 1: Root Cause Investigation
|
|
33
|
+
|
|
34
|
+
**BEFORE attempting ANY fix:**
|
|
35
|
+
|
|
36
|
+
**1. Read Error Messages Completely**
|
|
37
|
+
|
|
38
|
+
```text
|
|
39
|
+
Don't skip past errors. They often contain the exact solution.
|
|
40
|
+
- Full stack trace (note line numbers, file paths)
|
|
41
|
+
- Error codes and messages
|
|
42
|
+
- Warnings that preceded the error
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**2. Reproduce Consistently**
|
|
46
|
+
|
|
47
|
+
| Can reproduce? | Action |
|
|
48
|
+
| --------------- | ---------------------------------------------------- |
|
|
49
|
+
| Yes, every time | Proceed to step 3 |
|
|
50
|
+
| Sometimes | Gather more data - when does it happen vs not? |
|
|
51
|
+
| Never | Cannot debug what you cannot reproduce - gather logs |
|
|
52
|
+
|
|
53
|
+
**3. Check Recent Changes**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git diff HEAD~5 # Recent code changes
|
|
57
|
+
git log --oneline -10 # Recent commits
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
What changed that could cause this? Dependencies? Config? Environment?
|
|
61
|
+
|
|
62
|
+
**4. Trace Data Flow (Root Cause Tracing)**
|
|
63
|
+
|
|
64
|
+
When error is deep in call stack:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
Symptom: Error at line 50 in utils.js
|
|
68
|
+
↑ Called by handler.js:120
|
|
69
|
+
↑ Called by router.js:45
|
|
70
|
+
↑ Called by app.js:10 ← ROOT CAUSE: bad input here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Technique:**
|
|
74
|
+
|
|
75
|
+
1. Find where error occurs (symptom)
|
|
76
|
+
2. Ask: "What called this with bad data?"
|
|
77
|
+
3. Trace up until you find the SOURCE
|
|
78
|
+
4. Fix at source, not at symptom
|
|
79
|
+
|
|
80
|
+
**5. Multi-Component Systems**
|
|
81
|
+
|
|
82
|
+
When system has multiple layers (API → service → database):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Log at EACH boundary before proposing fixes
|
|
86
|
+
echo "=== Layer 1 (API): request=$REQUEST ==="
|
|
87
|
+
echo "=== Layer 2 (Service): input=$INPUT ==="
|
|
88
|
+
echo "=== Layer 3 (DB): query=$QUERY ==="
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Run once to find WHERE it breaks. Then investigate that layer.
|
|
92
|
+
|
|
93
|
+
### Phase 2: Pattern Analysis
|
|
94
|
+
|
|
95
|
+
**1. Find Working Examples**
|
|
96
|
+
|
|
97
|
+
Locate similar working code in same codebase. What works that's similar?
|
|
98
|
+
|
|
99
|
+
**2. Identify Differences**
|
|
100
|
+
|
|
101
|
+
| Working code | Broken code | Could this matter? |
|
|
102
|
+
| ---------------- | -------------- | ------------------ |
|
|
103
|
+
| Uses async/await | Uses callbacks | Yes - timing |
|
|
104
|
+
| Validates input | No validation | Yes - bad data |
|
|
105
|
+
|
|
106
|
+
List ALL differences. Don't assume "that can't matter."
|
|
107
|
+
|
|
108
|
+
### Phase 3: Hypothesis Testing
|
|
109
|
+
|
|
110
|
+
**1. Form Single Hypothesis**
|
|
111
|
+
|
|
112
|
+
Write it down: "I think X is the root cause because Y"
|
|
113
|
+
|
|
114
|
+
Be specific:
|
|
115
|
+
|
|
116
|
+
- ❌ "Something's wrong with the database"
|
|
117
|
+
- ✅ "Connection pool exhausted because connections aren't released in error path"
|
|
118
|
+
|
|
119
|
+
**2. Test Minimally**
|
|
120
|
+
|
|
121
|
+
| Rule | Why |
|
|
122
|
+
| ------------------------ | ---------------------- |
|
|
123
|
+
| ONE change at a time | Isolate what works |
|
|
124
|
+
| Smallest possible change | Avoid side effects |
|
|
125
|
+
| Don't bundle fixes | Can't tell what helped |
|
|
126
|
+
|
|
127
|
+
**3. Evaluate Result**
|
|
128
|
+
|
|
129
|
+
| Result | Action |
|
|
130
|
+
| --------------- | --------------------------------------- |
|
|
131
|
+
| Fixed | Phase 4 (verify) |
|
|
132
|
+
| Not fixed | NEW hypothesis (return to 3.1) |
|
|
133
|
+
| Partially fixed | Found one issue, continue investigating |
|
|
134
|
+
|
|
135
|
+
### Phase 4: Implementation
|
|
136
|
+
|
|
137
|
+
**1. Create Failing Test**
|
|
138
|
+
|
|
139
|
+
Before fixing, write test that fails due to the bug:
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
it('handles empty input without crashing', () => {
|
|
143
|
+
// This test should FAIL before fix, PASS after
|
|
144
|
+
expect(() => processData('')).not.toThrow();
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**2. Implement Fix**
|
|
149
|
+
|
|
150
|
+
- Address ROOT CAUSE identified in Phase 1
|
|
151
|
+
- ONE change
|
|
152
|
+
- No "while I'm here" improvements
|
|
153
|
+
|
|
154
|
+
**3. Verify**
|
|
155
|
+
|
|
156
|
+
- [ ] New test passes
|
|
157
|
+
- [ ] Existing tests still pass
|
|
158
|
+
- [ ] Issue actually resolved (not just test passing)
|
|
159
|
+
|
|
160
|
+
**4. If Fix Doesn't Work**
|
|
161
|
+
|
|
162
|
+
| Fix attempts | Action |
|
|
163
|
+
| ------------ | ---------------------------------------- |
|
|
164
|
+
| 1-2 | Return to Phase 1 with new information |
|
|
165
|
+
| 3+ | STOP - Question architecture (see below) |
|
|
166
|
+
|
|
167
|
+
**5. After 3+ Failed Fixes: Question Architecture**
|
|
168
|
+
|
|
169
|
+
Pattern indicating architectural problem:
|
|
170
|
+
|
|
171
|
+
- Each fix reveals new coupling/shared state
|
|
172
|
+
- Fixes require "massive refactoring"
|
|
173
|
+
- Each fix creates new symptoms elsewhere
|
|
174
|
+
|
|
175
|
+
**STOP and ask:**
|
|
176
|
+
|
|
177
|
+
- Is this pattern fundamentally sound?
|
|
178
|
+
- Should we refactor vs. continue patching?
|
|
179
|
+
- Discuss with user before more fix attempts
|
|
180
|
+
|
|
181
|
+
## Red Flags - STOP Immediately
|
|
182
|
+
|
|
183
|
+
If you catch yourself thinking:
|
|
184
|
+
|
|
185
|
+
| Thought | Reality |
|
|
186
|
+
| ---------------------------------------------- | --------------------------------- |
|
|
187
|
+
| "Quick fix for now, investigate later" | Investigate NOW or you never will |
|
|
188
|
+
| "Just try changing X" | That's guessing, not debugging |
|
|
189
|
+
| "I'll add multiple fixes and test" | Can't isolate what worked |
|
|
190
|
+
| "I don't fully understand but this might work" | You need to understand first |
|
|
191
|
+
| "One more fix attempt" (after 2+ failures) | 3+ failures = wrong approach |
|
|
192
|
+
|
|
193
|
+
**ALL mean: STOP. Return to Phase 1.**
|
|
194
|
+
|
|
195
|
+
## Quick Reference
|
|
196
|
+
|
|
197
|
+
| Phase | Key Question | Success Criteria |
|
|
198
|
+
| ----------------- | ------------------------------------- | ---------------------------------- |
|
|
199
|
+
| 1. Root Cause | "WHY is this happening?" | Understand cause, not just symptom |
|
|
200
|
+
| 2. Pattern | "What's different from working code?" | Identified key differences |
|
|
201
|
+
| 3. Hypothesis | "Is my theory correct?" | Confirmed or formed new theory |
|
|
202
|
+
| 4. Implementation | "Does the fix work?" | Test passes, issue resolved |
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
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'.
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TDD Enforcer
|
|
7
|
+
|
|
8
|
+
Scope work before coding. Write tests before implementation.
|
|
9
|
+
|
|
10
|
+
**Iron Law:** NO IMPLEMENTATION UNTIL SCOPE IS DEFINED AND TEST FAILS
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
Answer IN ORDER. Stop at first match:
|
|
15
|
+
|
|
16
|
+
1. Implementing new feature? → Use this skill
|
|
17
|
+
2. Fixing bug? → Use this skill
|
|
18
|
+
3. Adding enhancement? → Use this skill
|
|
19
|
+
4. Refactoring? → Use this skill
|
|
20
|
+
5. Research/investigation only? → Skip this skill
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Phase 0: TRIAGE
|
|
25
|
+
|
|
26
|
+
**Purpose:** Determine work level and ensure scope exists.
|
|
27
|
+
|
|
28
|
+
### Step 1: Identify Level
|
|
29
|
+
|
|
30
|
+
Answer IN ORDER. Stop at first match:
|
|
31
|
+
|
|
32
|
+
| Question | If Yes → |
|
|
33
|
+
| ---------------------------------------- | -------------- |
|
|
34
|
+
| User-facing feature with business value? | **L2 Feature** |
|
|
35
|
+
| Bug, improvement, internal, or refactor? | **L1 Task** |
|
|
36
|
+
| Typo, config, or trivial change? | **L0 Micro** |
|
|
37
|
+
|
|
38
|
+
### Step 2: Check/Create Artifacts
|
|
39
|
+
|
|
40
|
+
| Level | Required Artifacts | Test Location |
|
|
41
|
+
| ------ | --------------------------------------------------------------- | ------------------------------- |
|
|
42
|
+
| **L2** | Feature Spec + Test Definitions (+ Design Doc if 3+ components) | `test-definitions/feature-*.md` |
|
|
43
|
+
| **L1** | Task Spec | Inline in spec |
|
|
44
|
+
| **L0** | Task Spec (minimal) | Existing tests |
|
|
45
|
+
|
|
46
|
+
**Locations:**
|
|
47
|
+
|
|
48
|
+
- Specs: `.safeword/planning/specs/`
|
|
49
|
+
- Test definitions: `.safeword/planning/test-definitions/`
|
|
50
|
+
|
|
51
|
+
### Exit Criteria
|
|
52
|
+
|
|
53
|
+
- [ ] Level identified (L0/L1/L2)
|
|
54
|
+
- [ ] Spec exists with "Out of Scope" defined
|
|
55
|
+
- [ ] L2: Test definitions file exists
|
|
56
|
+
- [ ] L1: Test scenarios in spec
|
|
57
|
+
- [ ] L0: Existing test coverage confirmed
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Phase 1: RED
|
|
62
|
+
|
|
63
|
+
**Iron Law:** NO IMPLEMENTATION UNTIL TEST FAILS FOR THE RIGHT REASON
|
|
64
|
+
|
|
65
|
+
**Protocol:**
|
|
66
|
+
|
|
67
|
+
1. Pick ONE test from spec (L1) or test definitions (L2)
|
|
68
|
+
2. Write test code
|
|
69
|
+
3. Run test
|
|
70
|
+
4. Verify: fails because behavior missing (not syntax error)
|
|
71
|
+
5. Commit: `test: [behavior]`
|
|
72
|
+
|
|
73
|
+
**For L0:** No new test needed. Confirm existing tests pass, then proceed to Phase 2.
|
|
74
|
+
|
|
75
|
+
**Exit Criteria:**
|
|
76
|
+
|
|
77
|
+
- [ ] Test written and executed
|
|
78
|
+
- [ ] Test fails for RIGHT reason (behavior missing)
|
|
79
|
+
- [ ] Committed: `test: [behavior]`
|
|
80
|
+
|
|
81
|
+
**Red Flags → STOP:**
|
|
82
|
+
|
|
83
|
+
| Flag | Action |
|
|
84
|
+
| ----------------------- | -------------------------------- |
|
|
85
|
+
| Test passes immediately | Rewrite - you're testing nothing |
|
|
86
|
+
| Syntax error | Fix syntax, not behavior |
|
|
87
|
+
| Wrote implementation | Delete it, return to test |
|
|
88
|
+
| Multiple tests | Pick ONE |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Phase 2: GREEN
|
|
93
|
+
|
|
94
|
+
**Iron Law:** ONLY WRITE CODE THE TEST REQUIRES
|
|
95
|
+
|
|
96
|
+
**Protocol:**
|
|
97
|
+
|
|
98
|
+
1. Write minimal code to pass test
|
|
99
|
+
2. Run test → verify pass
|
|
100
|
+
3. Commit: `feat:` or `fix:`
|
|
101
|
+
|
|
102
|
+
**Exit Criteria:**
|
|
103
|
+
|
|
104
|
+
- [ ] Test passes
|
|
105
|
+
- [ ] No extra code
|
|
106
|
+
- [ ] No hardcoded/mock values
|
|
107
|
+
- [ ] Committed
|
|
108
|
+
|
|
109
|
+
### Verification Gate
|
|
110
|
+
|
|
111
|
+
**Before claiming GREEN:** Evidence before claims, always.
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
✅ CORRECT ❌ WRONG
|
|
115
|
+
───────────────────────────────── ─────────────────────────────────
|
|
116
|
+
Run: npm test "Tests should pass now"
|
|
117
|
+
Output: ✓ 34/34 tests pass "I'm confident this works"
|
|
118
|
+
Claim: "All tests pass" "Tests pass" (no output shown)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**The Rule:** If you haven't run the verification command in this response, you cannot claim it passes.
|
|
122
|
+
|
|
123
|
+
**Red Flags → STOP:**
|
|
124
|
+
|
|
125
|
+
| Flag | Action |
|
|
126
|
+
| --------------------------- | -------------------------------------- |
|
|
127
|
+
| "should", "probably" claims | Run command, show output first |
|
|
128
|
+
| "Done!" before verification | Run command, show output first |
|
|
129
|
+
| "Just in case" code | Delete it |
|
|
130
|
+
| Multiple functions | Delete extras |
|
|
131
|
+
| Refactoring | Stop - that's Phase 3 |
|
|
132
|
+
| Test still fails | Debug (→ debugging skill if stuck) |
|
|
133
|
+
| Hardcoded value | Implement real logic (see below) |
|
|
134
|
+
|
|
135
|
+
### Anti-Pattern: Mock Implementations
|
|
136
|
+
|
|
137
|
+
LLMs sometimes hardcode values to pass tests. This is not TDD.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// ❌ BAD - Hardcoded to pass test
|
|
141
|
+
function calculateDiscount(amount, tier) {
|
|
142
|
+
return 80; // Passes test but isn't real
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ✅ GOOD - Actual logic
|
|
146
|
+
function calculateDiscount(amount, tier) {
|
|
147
|
+
if (tier === 'VIP') return amount * 0.8;
|
|
148
|
+
return amount;
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Fix mocks immediately. The next test cycle will catch them, but they're technical debt.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Phase 3: REFACTOR
|
|
157
|
+
|
|
158
|
+
**Protocol:**
|
|
159
|
+
|
|
160
|
+
1. Tests pass before changes
|
|
161
|
+
2. Improve code (rename, extract, dedupe)
|
|
162
|
+
3. Tests pass after changes
|
|
163
|
+
4. Commit if changed: `refactor: [improvement]`
|
|
164
|
+
|
|
165
|
+
**Exit Criteria:**
|
|
166
|
+
|
|
167
|
+
- [ ] Tests still pass
|
|
168
|
+
- [ ] Code cleaner (or no changes needed)
|
|
169
|
+
- [ ] Committed (if changed)
|
|
170
|
+
|
|
171
|
+
**NOT Allowed:** New behavior, changing assertions, adding tests.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Phase 4: ITERATE
|
|
176
|
+
|
|
177
|
+
```text
|
|
178
|
+
More tests in spec/test-definitions?
|
|
179
|
+
├─ Yes → Return to Phase 1
|
|
180
|
+
└─ No → All "Done When" / AC checked?
|
|
181
|
+
├─ Yes → Complete
|
|
182
|
+
└─ No → Update spec, return to Phase 0
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
For L2: Update test definition status (✅/⏭️/❌/🔴) as tests pass.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Quick Reference
|
|
190
|
+
|
|
191
|
+
| Phase | Key Question | Gate |
|
|
192
|
+
| ----------- | -------------------------------- | ----------------------------- |
|
|
193
|
+
| 0. TRIAGE | What level? Is scope defined? | Spec exists with boundaries |
|
|
194
|
+
| 1. RED | Does test fail for right reason? | Test fails (behavior missing) |
|
|
195
|
+
| 2. GREEN | Does minimal code pass? | Test passes, no extras |
|
|
196
|
+
| 3. REFACTOR | Is code clean? | Tests still pass |
|
|
197
|
+
| 4. ITERATE | More tests? | All done → complete |
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Integration
|
|
202
|
+
|
|
203
|
+
| Scenario | Handoff |
|
|
204
|
+
| ----------------------- | ----------------- |
|
|
205
|
+
| Test fails unexpectedly | → debugging skill |
|
|
206
|
+
| Review needed | → quality-reviewer |
|
|
207
|
+
| Scope expanding | → Update spec first |
|
|
@@ -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
|