@flavor-code/superharness 1.0.0
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/HARNESS.md +56 -0
- package/flavor-plugin.json +25 -0
- package/index.js +238 -0
- package/package.json +23 -0
- package/scripts/ralph-lib.ps1 +297 -0
- package/scripts/ralph-lib.sh +366 -0
- package/skills/brainstorm/SKILL.md +179 -0
- package/skills/brainstorm/scripts/layout.js +76 -0
- package/skills/brainstorm/scripts/mindmap.html +249 -0
- package/skills/brainstorm/scripts/server.cjs +208 -0
- package/skills/brainstorm/scripts/start-server.ps1 +57 -0
- package/skills/brainstorm/scripts/stop-server.ps1 +17 -0
- package/skills/finishing-a-development-branch/SKILL.md +112 -0
- package/skills/go/SKILL.md +169 -0
- package/skills/light/SKILL.md +85 -0
- package/skills/requesting-code-review/SKILL.md +103 -0
- package/skills/requesting-code-review/code-reviewer.md +168 -0
- package/skills/subagent-driven-development/SKILL.md +125 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/using-git-worktrees/SKILL.md +91 -0
- package/skills/verification-before-completion/SKILL.md +139 -0
- package/skills/writing-plans/SKILL.md +138 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Testing Anti-Patterns
|
|
2
|
+
|
|
3
|
+
**Load this reference when:** writing or changing tests, adding mocks, or tempted to add test-only methods to production code.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
|
|
8
|
+
|
|
9
|
+
**Core principle:** Test what the code does, not what the mocks do.
|
|
10
|
+
|
|
11
|
+
**Following strict TDD prevents these anti-patterns.**
|
|
12
|
+
|
|
13
|
+
## The Iron Laws
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
1. NEVER test mock behavior
|
|
17
|
+
2. NEVER add test-only methods to production classes
|
|
18
|
+
3. NEVER mock without understanding dependencies
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Anti-Pattern 1: Testing Mock Behavior
|
|
22
|
+
|
|
23
|
+
**The violation:**
|
|
24
|
+
```typescript
|
|
25
|
+
// ❌ BAD: Testing that the mock exists
|
|
26
|
+
test('renders sidebar', () => {
|
|
27
|
+
render(<Page />);
|
|
28
|
+
expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Why this is wrong:**
|
|
33
|
+
- You're verifying the mock works, not that the component works
|
|
34
|
+
- Test passes when mock is present, fails when it's not
|
|
35
|
+
- Tells you nothing about real behavior
|
|
36
|
+
|
|
37
|
+
**your human partner's correction:** "Are we testing the behavior of a mock?"
|
|
38
|
+
|
|
39
|
+
**The fix:**
|
|
40
|
+
```typescript
|
|
41
|
+
// ✅ GOOD: Test real component or don't mock it
|
|
42
|
+
test('renders sidebar', () => {
|
|
43
|
+
render(<Page />); // Don't mock sidebar
|
|
44
|
+
expect(screen.getByRole('navigation')).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// OR if sidebar must be mocked for isolation:
|
|
48
|
+
// Don't assert on the mock - test Page's behavior with sidebar present
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Gate Function
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
BEFORE asserting on any mock element:
|
|
55
|
+
Ask: "Am I testing real component behavior or just mock existence?"
|
|
56
|
+
|
|
57
|
+
IF testing mock existence:
|
|
58
|
+
STOP - Delete the assertion or unmock the component
|
|
59
|
+
|
|
60
|
+
Test real behavior instead
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Anti-Pattern 2: Test-Only Methods in Production
|
|
64
|
+
|
|
65
|
+
**The violation:**
|
|
66
|
+
```typescript
|
|
67
|
+
// ❌ BAD: destroy() only used in tests
|
|
68
|
+
class Session {
|
|
69
|
+
async destroy() { // Looks like production API!
|
|
70
|
+
await this._workspaceManager?.destroyWorkspace(this.id);
|
|
71
|
+
// ... cleanup
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// In tests
|
|
76
|
+
afterEach(() => session.destroy());
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Why this is wrong:**
|
|
80
|
+
- Production class polluted with test-only code
|
|
81
|
+
- Dangerous if accidentally called in production
|
|
82
|
+
- Violates YAGNI and separation of concerns
|
|
83
|
+
- Confuses object lifecycle with entity lifecycle
|
|
84
|
+
|
|
85
|
+
**The fix:**
|
|
86
|
+
```typescript
|
|
87
|
+
// ✅ GOOD: Test utilities handle test cleanup
|
|
88
|
+
// Session has no destroy() - it's stateless in production
|
|
89
|
+
|
|
90
|
+
// In test-utils/
|
|
91
|
+
export async function cleanupSession(session: Session) {
|
|
92
|
+
const workspace = session.getWorkspaceInfo();
|
|
93
|
+
if (workspace) {
|
|
94
|
+
await workspaceManager.destroyWorkspace(workspace.id);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// In tests
|
|
99
|
+
afterEach(() => cleanupSession(session));
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Gate Function
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
BEFORE adding any method to production class:
|
|
106
|
+
Ask: "Is this only used by tests?"
|
|
107
|
+
|
|
108
|
+
IF yes:
|
|
109
|
+
STOP - Don't add it
|
|
110
|
+
Put it in test utilities instead
|
|
111
|
+
|
|
112
|
+
Ask: "Does this class own this resource's lifecycle?"
|
|
113
|
+
|
|
114
|
+
IF no:
|
|
115
|
+
STOP - Wrong class for this method
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Anti-Pattern 3: Mocking Without Understanding
|
|
119
|
+
|
|
120
|
+
**The violation:**
|
|
121
|
+
```typescript
|
|
122
|
+
// ❌ BAD: Mock breaks test logic
|
|
123
|
+
test('detects duplicate server', () => {
|
|
124
|
+
// Mock prevents config write that test depends on!
|
|
125
|
+
vi.mock('ToolCatalog', () => ({
|
|
126
|
+
discoverAndCacheTools: vi.fn().mockResolvedValue(undefined)
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
await addServer(config);
|
|
130
|
+
await addServer(config); // Should throw - but won't!
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Why this is wrong:**
|
|
135
|
+
- Mocked method had side effect test depended on (writing config)
|
|
136
|
+
- Over-mocking to "be safe" breaks actual behavior
|
|
137
|
+
- Test passes for wrong reason or fails mysteriously
|
|
138
|
+
|
|
139
|
+
**The fix:**
|
|
140
|
+
```typescript
|
|
141
|
+
// ✅ GOOD: Mock at correct level
|
|
142
|
+
test('detects duplicate server', () => {
|
|
143
|
+
// Mock the slow part, preserve behavior test needs
|
|
144
|
+
vi.mock('MCPServerManager'); // Just mock slow server startup
|
|
145
|
+
|
|
146
|
+
await addServer(config); // Config written
|
|
147
|
+
await addServer(config); // Duplicate detected ✓
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Gate Function
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
BEFORE mocking any method:
|
|
155
|
+
STOP - Don't mock yet
|
|
156
|
+
|
|
157
|
+
1. Ask: "What side effects does the real method have?"
|
|
158
|
+
2. Ask: "Does this test depend on any of those side effects?"
|
|
159
|
+
3. Ask: "Do I fully understand what this test needs?"
|
|
160
|
+
|
|
161
|
+
IF depends on side effects:
|
|
162
|
+
Mock at lower level (the actual slow/external operation)
|
|
163
|
+
OR use test doubles that preserve necessary behavior
|
|
164
|
+
NOT the high-level method the test depends on
|
|
165
|
+
|
|
166
|
+
IF unsure what test depends on:
|
|
167
|
+
Run test with real implementation FIRST
|
|
168
|
+
Observe what actually needs to happen
|
|
169
|
+
THEN add minimal mocking at the right level
|
|
170
|
+
|
|
171
|
+
Red flags:
|
|
172
|
+
- "I'll mock this to be safe"
|
|
173
|
+
- "This might be slow, better mock it"
|
|
174
|
+
- Mocking without understanding the dependency chain
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Anti-Pattern 4: Incomplete Mocks
|
|
178
|
+
|
|
179
|
+
**The violation:**
|
|
180
|
+
```typescript
|
|
181
|
+
// ❌ BAD: Partial mock - only fields you think you need
|
|
182
|
+
const mockResponse = {
|
|
183
|
+
status: 'success',
|
|
184
|
+
data: { userId: '123', name: 'Alice' }
|
|
185
|
+
// Missing: metadata that downstream code uses
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Later: breaks when code accesses response.metadata.requestId
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Why this is wrong:**
|
|
192
|
+
- **Partial mocks hide structural assumptions** - You only mocked fields you know about
|
|
193
|
+
- **Downstream code may depend on fields you didn't include** - Silent failures
|
|
194
|
+
- **Tests pass but integration fails** - Mock incomplete, real API complete
|
|
195
|
+
- **False confidence** - Test proves nothing about real behavior
|
|
196
|
+
|
|
197
|
+
**The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
|
|
198
|
+
|
|
199
|
+
**The fix:**
|
|
200
|
+
```typescript
|
|
201
|
+
// ✅ GOOD: Mirror real API completeness
|
|
202
|
+
const mockResponse = {
|
|
203
|
+
status: 'success',
|
|
204
|
+
data: { userId: '123', name: 'Alice' },
|
|
205
|
+
metadata: { requestId: 'req-789', timestamp: 1234567890 }
|
|
206
|
+
// All fields real API returns
|
|
207
|
+
};
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Gate Function
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
BEFORE creating mock responses:
|
|
214
|
+
Check: "What fields does the real API response contain?"
|
|
215
|
+
|
|
216
|
+
Actions:
|
|
217
|
+
1. Examine actual API response from docs/examples
|
|
218
|
+
2. Include ALL fields system might consume downstream
|
|
219
|
+
3. Verify mock matches real response schema completely
|
|
220
|
+
|
|
221
|
+
Critical:
|
|
222
|
+
If you're creating a mock, you must understand the ENTIRE structure
|
|
223
|
+
Partial mocks fail silently when code depends on omitted fields
|
|
224
|
+
|
|
225
|
+
If uncertain: Include all documented fields
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Anti-Pattern 5: Integration Tests as Afterthought
|
|
229
|
+
|
|
230
|
+
**The violation:**
|
|
231
|
+
```
|
|
232
|
+
✅ Implementation complete
|
|
233
|
+
❌ No tests written
|
|
234
|
+
"Ready for testing"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Why this is wrong:**
|
|
238
|
+
- Testing is part of implementation, not optional follow-up
|
|
239
|
+
- TDD would have caught this
|
|
240
|
+
- Can't claim complete without tests
|
|
241
|
+
|
|
242
|
+
**The fix:**
|
|
243
|
+
```
|
|
244
|
+
TDD cycle:
|
|
245
|
+
1. Write failing test
|
|
246
|
+
2. Implement to pass
|
|
247
|
+
3. Refactor
|
|
248
|
+
4. THEN claim complete
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## When Mocks Become Too Complex
|
|
252
|
+
|
|
253
|
+
**Warning signs:**
|
|
254
|
+
- Mock setup longer than test logic
|
|
255
|
+
- Mocking everything to make test pass
|
|
256
|
+
- Mocks missing methods real components have
|
|
257
|
+
- Test breaks when mock changes
|
|
258
|
+
|
|
259
|
+
**your human partner's question:** "Do we need to be using a mock here?"
|
|
260
|
+
|
|
261
|
+
**Consider:** Integration tests with real components often simpler than complex mocks
|
|
262
|
+
|
|
263
|
+
## TDD Prevents These Anti-Patterns
|
|
264
|
+
|
|
265
|
+
**Why TDD helps:**
|
|
266
|
+
1. **Write test first** → Forces you to think about what you're actually testing
|
|
267
|
+
2. **Watch it fail** → Confirms test tests real behavior, not mocks
|
|
268
|
+
3. **Minimal implementation** → No test-only methods creep in
|
|
269
|
+
4. **Real dependencies** → You see what the test actually needs before mocking
|
|
270
|
+
|
|
271
|
+
**If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
|
|
272
|
+
|
|
273
|
+
## Quick Reference
|
|
274
|
+
|
|
275
|
+
| Anti-Pattern | Fix |
|
|
276
|
+
|--------------|-----|
|
|
277
|
+
| Assert on mock elements | Test real component or unmock it |
|
|
278
|
+
| Test-only methods in production | Move to test utilities |
|
|
279
|
+
| Mock without understanding | Understand dependencies first, mock minimally |
|
|
280
|
+
| Incomplete mocks | Mirror real API completely |
|
|
281
|
+
| Tests as afterthought | TDD - tests first |
|
|
282
|
+
| Over-complex mocks | Consider integration tests |
|
|
283
|
+
|
|
284
|
+
## Red Flags
|
|
285
|
+
|
|
286
|
+
- Assertion checks for `*-mock` test IDs
|
|
287
|
+
- Methods only called in test files
|
|
288
|
+
- Mock setup is >50% of test
|
|
289
|
+
- Test fails when you remove mock
|
|
290
|
+
- Can't explain why mock is needed
|
|
291
|
+
- Mocking "just to be safe"
|
|
292
|
+
|
|
293
|
+
## The Bottom Line
|
|
294
|
+
|
|
295
|
+
**Mocks are tools to isolate, not things to test.**
|
|
296
|
+
|
|
297
|
+
If TDD reveals you're testing mock behavior, you've gone wrong.
|
|
298
|
+
|
|
299
|
+
Fix: Test real behavior or question why you're mocking at all.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-git-worktrees
|
|
3
|
+
description: Use when starting feature work that needs isolation from the current workspace, or before executing an implementation plan - ensures an isolated workspace exists, preferring native worktree tools then git, and degrades to working in place when there is no git repo
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Git Worktrees
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Make engineering work happen in an isolated, disposable workspace so a run that
|
|
11
|
+
goes wrong can be thrown away cleanly. Prefer a native worktree tool; fall back
|
|
12
|
+
to a manual `git worktree`; degrade to working in place when the project is not
|
|
13
|
+
a git repo.
|
|
14
|
+
|
|
15
|
+
**Announce at start:** "Setting up an isolated workspace (using-git-worktrees)."
|
|
16
|
+
|
|
17
|
+
**superharness default:** `go` invokes this for autonomous, auto-committing runs,
|
|
18
|
+
so in a git project **create a worktree by default** — do not stop to ask for
|
|
19
|
+
consent. Honor an explicit user instruction to work in place if one was given.
|
|
20
|
+
|
|
21
|
+
## Step 0 — Detect existing isolation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
GIT_DIR=$(cd "$(git rev-parse --git-dir 2>/dev/null)" 2>/dev/null && pwd -P)
|
|
25
|
+
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir 2>/dev/null)" 2>/dev/null && pwd -P)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- If `git rev-parse` fails (**not a git repo**): announce "No git repo here —
|
|
29
|
+
working in place." Skip to Step 3.
|
|
30
|
+
- If `GIT_DIR` != `GIT_COMMON`: you may already be in a linked worktree. Guard
|
|
31
|
+
against submodules first:
|
|
32
|
+
```bash
|
|
33
|
+
git rev-parse --show-superproject-working-tree 2>/dev/null
|
|
34
|
+
```
|
|
35
|
+
If that prints a path you are in a submodule — treat it as a normal repo.
|
|
36
|
+
Otherwise you are already isolated: report the path/branch and skip to Step 3.
|
|
37
|
+
|
|
38
|
+
## Step 1 — Create the isolated workspace
|
|
39
|
+
|
|
40
|
+
### 1a. Native worktree tool (preferred)
|
|
41
|
+
|
|
42
|
+
If a native worktree tool is available (a tool named like `EnterWorktree`, a
|
|
43
|
+
`/worktree` command, or a `--worktree` flag), use it and skip to Step 3. Native
|
|
44
|
+
tools place the directory, create the branch, and clean up for you. Using raw
|
|
45
|
+
`git worktree add` when a native tool exists creates state the harness can't see.
|
|
46
|
+
|
|
47
|
+
### 1b. Git worktree fallback
|
|
48
|
+
|
|
49
|
+
Only if no native tool is available:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
branch="superharness/<short-task-slug>"
|
|
53
|
+
# Ensure the worktree directory is ignored before creating it:
|
|
54
|
+
git check-ignore -q .worktrees || { printf '\n.worktrees/\n' >> .gitignore; git add .gitignore && git commit -m "chore: ignore .worktrees"; }
|
|
55
|
+
git worktree add ".worktrees/$branch" -b "$branch"
|
|
56
|
+
cd ".worktrees/$branch"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**If `git worktree add` fails** (permission/sandbox denial): announce the
|
|
60
|
+
failure and **work in place** on the current branch, then continue to Step 3.
|
|
61
|
+
|
|
62
|
+
## Step 3 — Project setup
|
|
63
|
+
|
|
64
|
+
Auto-detect and run setup for whatever the project uses, e.g.:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
[ -f package.json ] && npm install
|
|
68
|
+
[ -f requirements.txt ] && pip install -r requirements.txt
|
|
69
|
+
[ -f Cargo.toml ] && cargo build
|
|
70
|
+
[ -f go.mod ] && go mod download
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Step 4 — Verify a clean baseline
|
|
74
|
+
|
|
75
|
+
Run the project's test command. If it passes, report ready. If it fails, report
|
|
76
|
+
the failures and ask whether to proceed or investigate — you must be able to tell
|
|
77
|
+
new breakage from pre-existing breakage.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Workspace ready at <path> (worktree | in place)
|
|
81
|
+
Baseline: <N> tests passing, 0 failing
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Red Flags
|
|
85
|
+
|
|
86
|
+
| Thought | Reality |
|
|
87
|
+
|---------|---------|
|
|
88
|
+
| "I'll `git worktree add` even though EnterWorktree exists" | Use the native tool. Raw git creates phantom state. |
|
|
89
|
+
| "No git, so I'm stuck" | No. Announce and work in place — never block. |
|
|
90
|
+
| "I'll just commit inside the worktree dir" | Verify `.worktrees` is gitignored first. |
|
|
91
|
+
| "Baseline tests fail, I'll start anyway" | Report and ask. You can't attribute breakage later. |
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: verification-before-completion
|
|
3
|
+
description: Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Verification Before Completion
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Claiming work is complete without verification is dishonesty, not efficiency.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Evidence before claims, always.
|
|
13
|
+
|
|
14
|
+
**Violating the letter of this rule is violating the spirit of this rule.**
|
|
15
|
+
|
|
16
|
+
## The Iron Law
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If you haven't run the verification command in this message, you cannot claim it passes.
|
|
23
|
+
|
|
24
|
+
## The Gate Function
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
BEFORE claiming any status or expressing satisfaction:
|
|
28
|
+
|
|
29
|
+
1. IDENTIFY: What command proves this claim?
|
|
30
|
+
2. RUN: Execute the FULL command (fresh, complete)
|
|
31
|
+
3. READ: Full output, check exit code, count failures
|
|
32
|
+
4. VERIFY: Does output confirm the claim?
|
|
33
|
+
- If NO: State actual status with evidence
|
|
34
|
+
- If YES: State claim WITH evidence
|
|
35
|
+
5. ONLY THEN: Make the claim
|
|
36
|
+
|
|
37
|
+
Skip any step = lying, not verifying
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Common Failures
|
|
41
|
+
|
|
42
|
+
| Claim | Requires | Not Sufficient |
|
|
43
|
+
|-------|----------|----------------|
|
|
44
|
+
| Tests pass | Test command output: 0 failures | Previous run, "should pass" |
|
|
45
|
+
| Linter clean | Linter output: 0 errors | Partial check, extrapolation |
|
|
46
|
+
| Build succeeds | Build command: exit 0 | Linter passing, logs look good |
|
|
47
|
+
| Bug fixed | Test original symptom: passes | Code changed, assumed fixed |
|
|
48
|
+
| Regression test works | Red-green cycle verified | Test passes once |
|
|
49
|
+
| Agent completed | VCS diff shows changes | Agent reports "success" |
|
|
50
|
+
| Requirements met | Line-by-line checklist | Tests passing |
|
|
51
|
+
|
|
52
|
+
## Red Flags - STOP
|
|
53
|
+
|
|
54
|
+
- Using "should", "probably", "seems to"
|
|
55
|
+
- Expressing satisfaction before verification ("Great!", "Perfect!", "Done!", etc.)
|
|
56
|
+
- About to commit/push/PR without verification
|
|
57
|
+
- Trusting agent success reports
|
|
58
|
+
- Relying on partial verification
|
|
59
|
+
- Thinking "just this once"
|
|
60
|
+
- Tired and wanting work over
|
|
61
|
+
- **ANY wording implying success without having run verification**
|
|
62
|
+
|
|
63
|
+
## Rationalization Prevention
|
|
64
|
+
|
|
65
|
+
| Excuse | Reality |
|
|
66
|
+
|--------|---------|
|
|
67
|
+
| "Should work now" | RUN the verification |
|
|
68
|
+
| "I'm confident" | Confidence ≠ evidence |
|
|
69
|
+
| "Just this once" | No exceptions |
|
|
70
|
+
| "Linter passed" | Linter ≠ compiler |
|
|
71
|
+
| "Agent said success" | Verify independently |
|
|
72
|
+
| "I'm tired" | Exhaustion ≠ excuse |
|
|
73
|
+
| "Partial check is enough" | Partial proves nothing |
|
|
74
|
+
| "Different words so rule doesn't apply" | Spirit over letter |
|
|
75
|
+
|
|
76
|
+
## Key Patterns
|
|
77
|
+
|
|
78
|
+
**Tests:**
|
|
79
|
+
```
|
|
80
|
+
✅ [Run test command] [See: 34/34 pass] "All tests pass"
|
|
81
|
+
❌ "Should pass now" / "Looks correct"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Regression tests (TDD Red-Green):**
|
|
85
|
+
```
|
|
86
|
+
✅ Write → Run (pass) → Revert fix → Run (MUST FAIL) → Restore → Run (pass)
|
|
87
|
+
❌ "I've written a regression test" (without red-green verification)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Build:**
|
|
91
|
+
```
|
|
92
|
+
✅ [Run build] [See: exit 0] "Build passes"
|
|
93
|
+
❌ "Linter passed" (linter doesn't check compilation)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Requirements:**
|
|
97
|
+
```
|
|
98
|
+
✅ Re-read plan → Create checklist → Verify each → Report gaps or completion
|
|
99
|
+
❌ "Tests pass, phase complete"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Agent delegation:**
|
|
103
|
+
```
|
|
104
|
+
✅ Agent reports success → Check VCS diff → Verify changes → Report actual state
|
|
105
|
+
❌ Trust agent report
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Why This Matters
|
|
109
|
+
|
|
110
|
+
From 24 failure memories:
|
|
111
|
+
- your human partner said "I don't believe you" - trust broken
|
|
112
|
+
- Undefined functions shipped - would crash
|
|
113
|
+
- Missing requirements shipped - incomplete features
|
|
114
|
+
- Time wasted on false completion → redirect → rework
|
|
115
|
+
- Violates: "Honesty is a core value. If you lie, you'll be replaced."
|
|
116
|
+
|
|
117
|
+
## When To Apply
|
|
118
|
+
|
|
119
|
+
**ALWAYS before:**
|
|
120
|
+
- ANY variation of success/completion claims
|
|
121
|
+
- ANY expression of satisfaction
|
|
122
|
+
- ANY positive statement about work state
|
|
123
|
+
- Committing, PR creation, task completion
|
|
124
|
+
- Moving to next task
|
|
125
|
+
- Delegating to agents
|
|
126
|
+
|
|
127
|
+
**Rule applies to:**
|
|
128
|
+
- Exact phrases
|
|
129
|
+
- Paraphrases and synonyms
|
|
130
|
+
- Implications of success
|
|
131
|
+
- ANY communication suggesting completion/correctness
|
|
132
|
+
|
|
133
|
+
## The Bottom Line
|
|
134
|
+
|
|
135
|
+
**No shortcuts for verification.**
|
|
136
|
+
|
|
137
|
+
Run the command. Read the output. THEN claim the result.
|
|
138
|
+
|
|
139
|
+
This is non-negotiable.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: writing-plans
|
|
3
|
+
description: Use when you have a spec or requirements for a multi-step task, before touching code
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Writing Plans
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Write comprehensive implementation plans assuming the engineer has zero context for our codebase and questionable taste. Document everything they need to know: which files to touch for each task, code, testing, docs they might need to check, how to test it. Give them the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits.
|
|
11
|
+
|
|
12
|
+
Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well.
|
|
13
|
+
|
|
14
|
+
**Announce at start:** "I'm using the writing-plans skill to create the implementation plan."
|
|
15
|
+
|
|
16
|
+
**Save plans to:** `<state-root>/superharness/plans/YYYY-MM-DD-<feature-name>.md` (create the folder if missing). `<state-root>` follows the host: `.claude` under Claude Code, `.flavor` under flavor-code.
|
|
17
|
+
- (User preferences for plan location override this default)
|
|
18
|
+
|
|
19
|
+
## Scope Check
|
|
20
|
+
|
|
21
|
+
If the spec covers multiple independent subsystems, it should have been broken into sub-project specs during brainstorming. If it wasn't, suggest breaking this into separate plans — one per subsystem. Each plan should produce working, testable software on its own.
|
|
22
|
+
|
|
23
|
+
## File Structure
|
|
24
|
+
|
|
25
|
+
Before defining tasks, map out which files will be created or modified and what each one is responsible for. This is where decomposition decisions get locked in.
|
|
26
|
+
|
|
27
|
+
- Design units with clear boundaries and well-defined interfaces. Each file should have one clear responsibility.
|
|
28
|
+
- You reason best about code you can hold in context at once, and your edits are more reliable when files are focused. Prefer smaller, focused files over large ones that do too much.
|
|
29
|
+
- Files that change together should live together. Split by responsibility, not by technical layer.
|
|
30
|
+
- In existing codebases, follow established patterns. If the codebase uses large files, don't unilaterally restructure - but if a file you're modifying has grown unwieldy, including a split in the plan is reasonable.
|
|
31
|
+
|
|
32
|
+
This structure informs the task decomposition. Each task should produce self-contained changes that make sense independently.
|
|
33
|
+
|
|
34
|
+
## Bite-Sized Task Granularity
|
|
35
|
+
|
|
36
|
+
**Each step is one action (2-5 minutes):**
|
|
37
|
+
- "Write the failing test" - step
|
|
38
|
+
- "Run it to make sure it fails" - step
|
|
39
|
+
- "Implement the minimal code to make the test pass" - step
|
|
40
|
+
- "Run the tests and make sure they pass" - step
|
|
41
|
+
- "Commit" - step
|
|
42
|
+
|
|
43
|
+
## Plan Document Header
|
|
44
|
+
|
|
45
|
+
**Every plan MUST start with this header:**
|
|
46
|
+
|
|
47
|
+
```markdown
|
|
48
|
+
# [Feature Name] Implementation Plan
|
|
49
|
+
|
|
50
|
+
> **For agentic workers:** Execute this plan task-by-task under the superharness:go workflow, Phase 2 (strict TDD per task). Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
51
|
+
|
|
52
|
+
**Goal:** [One sentence describing what this builds]
|
|
53
|
+
|
|
54
|
+
**Architecture:** [2-3 sentences about approach]
|
|
55
|
+
|
|
56
|
+
**Tech Stack:** [Key technologies/libraries]
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Task Structure
|
|
62
|
+
|
|
63
|
+
````markdown
|
|
64
|
+
### Task N: [Component Name]
|
|
65
|
+
|
|
66
|
+
**Files:**
|
|
67
|
+
- Create: `exact/path/to/file.py`
|
|
68
|
+
- Modify: `exact/path/to/existing.py:123-145`
|
|
69
|
+
- Test: `tests/exact/path/to/test.py`
|
|
70
|
+
|
|
71
|
+
- [ ] **Step 1: Write the failing test**
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
def test_specific_behavior():
|
|
75
|
+
result = function(input)
|
|
76
|
+
assert result == expected
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- [ ] **Step 2: Run test to verify it fails**
|
|
80
|
+
|
|
81
|
+
Run: `pytest tests/path/test.py::test_name -v`
|
|
82
|
+
Expected: FAIL with "function not defined"
|
|
83
|
+
|
|
84
|
+
- [ ] **Step 3: Write minimal implementation**
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
def function(input):
|
|
88
|
+
return expected
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- [ ] **Step 4: Run test to verify it passes**
|
|
92
|
+
|
|
93
|
+
Run: `pytest tests/path/test.py::test_name -v`
|
|
94
|
+
Expected: PASS
|
|
95
|
+
|
|
96
|
+
- [ ] **Step 5: Commit**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git add tests/path/test.py src/path/file.py
|
|
100
|
+
git commit -m "feat: add specific feature"
|
|
101
|
+
```
|
|
102
|
+
````
|
|
103
|
+
|
|
104
|
+
## No Placeholders
|
|
105
|
+
|
|
106
|
+
Every step must contain the actual content an engineer needs. These are **plan failures** — never write them:
|
|
107
|
+
- "TBD", "TODO", "implement later", "fill in details"
|
|
108
|
+
- "Add appropriate error handling" / "add validation" / "handle edge cases"
|
|
109
|
+
- "Write tests for the above" (without actual test code)
|
|
110
|
+
- "Similar to Task N" (repeat the code — the engineer may be reading tasks out of order)
|
|
111
|
+
- Steps that describe what to do without showing how (code blocks required for code steps)
|
|
112
|
+
- References to types, functions, or methods not defined in any task
|
|
113
|
+
|
|
114
|
+
## Remember
|
|
115
|
+
- Exact file paths always
|
|
116
|
+
- Complete code in every step — if a step changes code, show the code
|
|
117
|
+
- Exact commands with expected output
|
|
118
|
+
- DRY, YAGNI, TDD, frequent commits
|
|
119
|
+
|
|
120
|
+
## Self-Review
|
|
121
|
+
|
|
122
|
+
After writing the complete plan, look at the spec with fresh eyes and check the plan against it. This is a checklist you run yourself — not a subagent dispatch.
|
|
123
|
+
|
|
124
|
+
**1. Spec coverage:** Skim each section/requirement in the spec. Can you point to a task that implements it? List any gaps.
|
|
125
|
+
|
|
126
|
+
**2. Placeholder scan:** Search your plan for red flags — any of the patterns from the "No Placeholders" section above. Fix them.
|
|
127
|
+
|
|
128
|
+
**3. Type consistency:** Do the types, method signatures, and property names you used in later tasks match what you defined in earlier tasks? A function called `clearLayers()` in Task 3 but `clearFullLayers()` in Task 7 is a bug.
|
|
129
|
+
|
|
130
|
+
If you find issues, fix them inline. No need to re-review — just fix and move on. If you find a spec requirement with no task, add the task.
|
|
131
|
+
|
|
132
|
+
## Execution Handoff
|
|
133
|
+
|
|
134
|
+
After saving the plan, announce: "Plan complete and saved to `<state-root>/superharness/plans/<filename>.md`."
|
|
135
|
+
|
|
136
|
+
Then continue with the superharness:go workflow, Phase 2: execute the plan task-by-task
|
|
137
|
+
in this session, one TodoWrite/Task item per plan task, strict TDD on every task, and
|
|
138
|
+
review checkpoints per Phase 4.
|