@tianhai/pi-workflow-kit 0.5.1 → 0.6.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/README.md +44 -494
- package/docs/developer-usage-guide.md +41 -401
- package/docs/oversight-model.md +13 -34
- package/docs/workflow-phases.md +32 -46
- package/extensions/workflow-guard.ts +67 -0
- package/package.json +3 -7
- package/skills/brainstorming/SKILL.md +16 -59
- package/skills/executing-tasks/SKILL.md +26 -227
- package/skills/finalizing/SKILL.md +33 -0
- package/skills/writing-plans/SKILL.md +23 -132
- package/ROADMAP.md +0 -16
- package/agents/code-reviewer.md +0 -18
- package/agents/config.ts +0 -5
- package/agents/implementer.md +0 -26
- package/agents/spec-reviewer.md +0 -13
- package/agents/worker.md +0 -17
- package/docs/plans/completed/2026-04-09-cleanup-legacy-state-and-enforce-think-phases-design.md +0 -56
- package/docs/plans/completed/2026-04-09-cleanup-legacy-state-and-enforce-think-phases-implementation.md +0 -196
- package/docs/plans/completed/2026-04-09-workflow-next-autocomplete-design.md +0 -185
- package/docs/plans/completed/2026-04-09-workflow-next-autocomplete-implementation.md +0 -334
- package/docs/plans/completed/2026-04-09-workflow-next-handoff-state-design.md +0 -251
- package/docs/plans/completed/2026-04-09-workflow-next-handoff-state-implementation.md +0 -253
- package/extensions/constants.ts +0 -15
- package/extensions/lib/logging.ts +0 -138
- package/extensions/plan-tracker.ts +0 -502
- package/extensions/subagent/agents.ts +0 -144
- package/extensions/subagent/concurrency.ts +0 -52
- package/extensions/subagent/env.ts +0 -47
- package/extensions/subagent/index.ts +0 -1181
- package/extensions/subagent/lifecycle.ts +0 -25
- package/extensions/subagent/timeout.ts +0 -13
- package/extensions/workflow-monitor/debug-monitor.ts +0 -98
- package/extensions/workflow-monitor/git.ts +0 -31
- package/extensions/workflow-monitor/heuristics.ts +0 -58
- package/extensions/workflow-monitor/investigation.ts +0 -52
- package/extensions/workflow-monitor/reference-tool.ts +0 -42
- package/extensions/workflow-monitor/skip-confirmation.ts +0 -19
- package/extensions/workflow-monitor/tdd-monitor.ts +0 -137
- package/extensions/workflow-monitor/test-runner.ts +0 -37
- package/extensions/workflow-monitor/verification-monitor.ts +0 -61
- package/extensions/workflow-monitor/warnings.ts +0 -81
- package/extensions/workflow-monitor/workflow-handler.ts +0 -358
- package/extensions/workflow-monitor/workflow-next-completions.ts +0 -68
- package/extensions/workflow-monitor/workflow-next-state.ts +0 -112
- package/extensions/workflow-monitor/workflow-tracker.ts +0 -253
- package/extensions/workflow-monitor/workflow-transitions.ts +0 -55
- package/extensions/workflow-monitor.ts +0 -872
- package/skills/dispatching-parallel-agents/SKILL.md +0 -194
- package/skills/receiving-code-review/SKILL.md +0 -196
- package/skills/systematic-debugging/SKILL.md +0 -170
- package/skills/systematic-debugging/condition-based-waiting-example.ts +0 -158
- package/skills/systematic-debugging/condition-based-waiting.md +0 -115
- package/skills/systematic-debugging/defense-in-depth.md +0 -122
- package/skills/systematic-debugging/find-polluter.sh +0 -63
- package/skills/systematic-debugging/reference/rationalizations.md +0 -61
- package/skills/systematic-debugging/root-cause-tracing.md +0 -169
- package/skills/test-driven-development/SKILL.md +0 -266
- package/skills/test-driven-development/reference/examples.md +0 -101
- package/skills/test-driven-development/reference/rationalizations.md +0 -67
- package/skills/test-driven-development/reference/when-stuck.md +0 -33
- package/skills/test-driven-development/testing-anti-patterns.md +0 -299
- package/skills/using-git-worktrees/SKILL.md +0 -231
|
@@ -1,299 +0,0 @@
|
|
|
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.
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: using-git-worktrees
|
|
3
|
-
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
> **Related skills:** Set up after `/skill:brainstorming`. Execute with `/skill:executing-tasks`. Clean up with `/skill:executing-tasks`.
|
|
7
|
-
|
|
8
|
-
# Using Git Worktrees
|
|
9
|
-
|
|
10
|
-
## Overview
|
|
11
|
-
|
|
12
|
-
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
|
|
13
|
-
|
|
14
|
-
**Core principle:** Systematic directory selection + safety verification = reliable isolation.
|
|
15
|
-
|
|
16
|
-
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
|
|
17
|
-
|
|
18
|
-
## Directory Selection Process
|
|
19
|
-
|
|
20
|
-
Follow this priority order:
|
|
21
|
-
|
|
22
|
-
### 1. Check Existing Directories
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
# Check in priority order
|
|
26
|
-
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
|
27
|
-
ls -d worktrees 2>/dev/null # Alternative
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**If found:** Use that directory. If both exist, `.worktrees` wins.
|
|
31
|
-
|
|
32
|
-
### 2. Check Project Configuration
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
grep -i "worktree.*director" README.md .pi/settings.json AGENTS.md 2>/dev/null
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**If preference specified:** Use it without asking.
|
|
39
|
-
|
|
40
|
-
### 3. Ask User
|
|
41
|
-
|
|
42
|
-
If no directory exists and no project configuration preference:
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
No worktree directory found. Where should I create worktrees?
|
|
46
|
-
|
|
47
|
-
1. .worktrees/ (project-local, hidden)
|
|
48
|
-
2. ~/worktrees/<project-name>/ (global location)
|
|
49
|
-
|
|
50
|
-
Which would you prefer?
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Safety Verification
|
|
54
|
-
|
|
55
|
-
### For Project-Local Directories (.worktrees or worktrees)
|
|
56
|
-
|
|
57
|
-
**MUST verify directory is ignored before creating worktree:**
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# Check if directory is ignored (respects local, global, and system gitignore)
|
|
61
|
-
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**If NOT ignored:**
|
|
65
|
-
|
|
66
|
-
Fix broken things immediately:
|
|
67
|
-
1. Add appropriate line to .gitignore
|
|
68
|
-
2. Commit the change
|
|
69
|
-
3. Proceed with worktree creation
|
|
70
|
-
|
|
71
|
-
**Why critical:** Prevents accidentally committing worktree contents to repository.
|
|
72
|
-
|
|
73
|
-
### For Global Directory (~/worktrees)
|
|
74
|
-
|
|
75
|
-
No .gitignore verification needed - outside project entirely.
|
|
76
|
-
|
|
77
|
-
## Creation Steps
|
|
78
|
-
|
|
79
|
-
### 1. Detect Project Name
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
project=$(basename "$(git rev-parse --show-toplevel)")
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### 2. Create Worktree
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# Determine full path
|
|
89
|
-
case $LOCATION in
|
|
90
|
-
.worktrees|worktrees)
|
|
91
|
-
path="$LOCATION/$BRANCH_NAME"
|
|
92
|
-
;;
|
|
93
|
-
~/worktrees/*)
|
|
94
|
-
path="~/worktrees/$project/$BRANCH_NAME"
|
|
95
|
-
;;
|
|
96
|
-
esac
|
|
97
|
-
|
|
98
|
-
# Create worktree with new branch
|
|
99
|
-
git worktree add "$path" -b "$BRANCH_NAME"
|
|
100
|
-
cd "$path"
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### 3. Run Project Setup
|
|
104
|
-
|
|
105
|
-
Auto-detect and run appropriate setup:
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
# Node.js
|
|
109
|
-
if [ -f package.json ]; then npm install; fi
|
|
110
|
-
|
|
111
|
-
# Rust
|
|
112
|
-
if [ -f Cargo.toml ]; then cargo build; fi
|
|
113
|
-
|
|
114
|
-
# Python
|
|
115
|
-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
116
|
-
if [ -f pyproject.toml ]; then poetry install; fi
|
|
117
|
-
|
|
118
|
-
# Go
|
|
119
|
-
if [ -f go.mod ]; then go mod download; fi
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### 4. Verify Clean Baseline
|
|
123
|
-
|
|
124
|
-
Run tests to ensure worktree starts clean:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
# Examples - use project-appropriate command
|
|
128
|
-
npm test
|
|
129
|
-
cargo test
|
|
130
|
-
pytest
|
|
131
|
-
go test ./...
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**If tests fail:** Report failures, ask whether to proceed or investigate.
|
|
135
|
-
|
|
136
|
-
**If tests pass:** Report ready.
|
|
137
|
-
|
|
138
|
-
### 5. Report Location
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
Worktree ready at <full-path>
|
|
142
|
-
Tests passing (<N> tests, 0 failures)
|
|
143
|
-
Ready to implement <feature-name>
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Keeping a Worktree Current
|
|
147
|
-
|
|
148
|
-
For longer-running work, the base branch may advance. If upstream changes cause test failures or you need new code from main:
|
|
149
|
-
|
|
150
|
-
```bash
|
|
151
|
-
git fetch origin
|
|
152
|
-
git rebase origin/main # or git merge origin/main
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Re-run tests after rebasing. Prefer rebase for clean history unless the branch is shared.
|
|
156
|
-
|
|
157
|
-
## Quick Reference
|
|
158
|
-
|
|
159
|
-
| Situation | Action |
|
|
160
|
-
|-----------|--------|
|
|
161
|
-
| `.worktrees/` exists | Use it (verify ignored) |
|
|
162
|
-
| `worktrees/` exists | Use it (verify ignored) |
|
|
163
|
-
| Both exist | Use `.worktrees/` |
|
|
164
|
-
| Neither exists | Check project config → Ask user |
|
|
165
|
-
| Directory not ignored | Add to .gitignore + commit |
|
|
166
|
-
| Tests fail during baseline | Report failures + ask |
|
|
167
|
-
| No package.json/Cargo.toml | Skip dependency install |
|
|
168
|
-
|
|
169
|
-
## Common Mistakes
|
|
170
|
-
|
|
171
|
-
### Skipping ignore verification
|
|
172
|
-
|
|
173
|
-
- **Problem:** Worktree contents get tracked, pollute git status
|
|
174
|
-
- **Fix:** Always use `git check-ignore` before creating project-local worktree
|
|
175
|
-
|
|
176
|
-
### Assuming directory location
|
|
177
|
-
|
|
178
|
-
- **Problem:** Creates inconsistency, violates project conventions
|
|
179
|
-
- **Fix:** Follow priority: existing > project config > ask
|
|
180
|
-
|
|
181
|
-
### Proceeding with failing tests
|
|
182
|
-
|
|
183
|
-
- **Problem:** Can't distinguish new bugs from pre-existing issues
|
|
184
|
-
- **Fix:** Report failures, get explicit permission to proceed
|
|
185
|
-
|
|
186
|
-
### Hardcoding setup commands
|
|
187
|
-
|
|
188
|
-
- **Problem:** Breaks on projects using different tools
|
|
189
|
-
- **Fix:** Auto-detect from project files (package.json, etc.)
|
|
190
|
-
|
|
191
|
-
## Example Workflow
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
You: I'm using the using-git-worktrees skill to set up an isolated workspace.
|
|
195
|
-
|
|
196
|
-
[Check .worktrees/ - exists]
|
|
197
|
-
[Verify ignored - git check-ignore confirms .worktrees/ is ignored]
|
|
198
|
-
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
|
|
199
|
-
[Run npm install]
|
|
200
|
-
[Run npm test - 47 passing]
|
|
201
|
-
|
|
202
|
-
Worktree ready at /home/user/myproject/.worktrees/auth
|
|
203
|
-
Tests passing (47 tests, 0 failures)
|
|
204
|
-
Ready to implement auth feature
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Red Flags
|
|
208
|
-
|
|
209
|
-
**Never:**
|
|
210
|
-
- Create worktree without verifying it's ignored (project-local)
|
|
211
|
-
- Skip baseline test verification
|
|
212
|
-
- Proceed with failing tests without asking
|
|
213
|
-
- Assume directory location when ambiguous
|
|
214
|
-
|
|
215
|
-
**Always:**
|
|
216
|
-
- Follow directory priority: existing > project config > ask
|
|
217
|
-
- Verify directory is ignored for project-local
|
|
218
|
-
- Auto-detect and run project setup
|
|
219
|
-
- Verify clean test baseline
|
|
220
|
-
|
|
221
|
-
## Integration
|
|
222
|
-
|
|
223
|
-
**Called by:**
|
|
224
|
-
- **`/skill:brainstorming`** - When design is approved and implementation follows
|
|
225
|
-
- **`/skill:executing-tasks`** - Execute tasks in isolated workspace
|
|
226
|
-
- Any skill needing isolated workspace
|
|
227
|
-
|
|
228
|
-
**Note:** For small changes, branching in the current directory is acceptable with human approval. Worktrees are the default for larger work.
|
|
229
|
-
|
|
230
|
-
**Pairs with:**
|
|
231
|
-
- **`/skill:executing-tasks`** - REQUIRED for cleanup after work complete
|