Skip to content

Commit 664d827

Browse files
committed
fixed do worktree use error
1 parent 7cc7f50 commit 664d827

1 file changed

Lines changed: 59 additions & 30 deletions

File tree

skills/do/SKILL.md

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,17 @@ An orchestrator for systematic feature development. Invoke agents via `codeagent
1010

1111
## Loop Initialization (REQUIRED)
1212

13-
When triggered via `/do <task>`, follow these steps:
14-
15-
### Step 1: Ask about worktree mode
16-
17-
Use AskUserQuestion to ask:
18-
19-
```
20-
Develop in a separate worktree? (Isolates changes from main branch)
21-
- Yes (Recommended for larger changes)
22-
- No (Work directly in current directory)
23-
```
24-
25-
### Step 2: Initialize task directory
13+
When triggered via `/do <task>`, initialize the task directory immediately without asking about worktree:
2614

2715
```bash
28-
# If worktree mode selected:
29-
python3 ".claude/skills/do/scripts/setup-do.py" --worktree "<task description>"
30-
31-
# If no worktree:
3216
python3 ".claude/skills/do/scripts/setup-do.py" "<task description>"
3317
```
3418

3519
This creates a task directory under `.claude/do-tasks/` with:
3620
- `task.md`: Single file containing YAML frontmatter (metadata) + Markdown body (requirements/context)
3721

22+
**Worktree decision is deferred until Phase 4 (Implement).** Phases 1-3 are read-only and do not require worktree isolation.
23+
3824
## Task Directory Management
3925

4026
Use `task.py` to manage task state:
@@ -52,15 +38,23 @@ python3 ".claude/skills/do/scripts/task.py" list
5238

5339
## Worktree Mode
5440

55-
When worktree mode is enabled in task.json, ALL `codeagent-wrapper` calls that modify code MUST include `--worktree`:
41+
The worktree is created **only when needed** (right before Phase 4: Implement). If the user chooses worktree mode:
42+
43+
1. Run setup with `--worktree` flag to create the worktree:
44+
```bash
45+
python3 ".claude/skills/do/scripts/setup-do.py" --worktree "<task description>"
46+
```
47+
48+
2. Use the `DO_WORKTREE_DIR` environment variable to direct `codeagent-wrapper` develop agent into the worktree. **Do NOT pass `--worktree` to subsequent calls** — that creates a new worktree each time.
5649

5750
```bash
58-
codeagent-wrapper --worktree --agent develop - . <<'EOF'
51+
# Save the worktree path from setup output, then prefix all develop calls:
52+
DO_WORKTREE_DIR=<worktree_dir> codeagent-wrapper --agent develop - . <<'EOF'
5953
...
6054
EOF
6155
```
6256

63-
Read-only agents (code-explorer, code-architect, code-reviewer) do NOT need `--worktree`.
57+
Read-only agents (code-explorer, code-architect, code-reviewer) do NOT need `DO_WORKTREE_DIR`.
6458

6559
## Hard Constraints
6660

@@ -69,7 +63,7 @@ Read-only agents (code-explorer, code-architect, code-reviewer) do NOT need `--w
6963
3. **Update phase after each phase.** Use `task.py update-phase <N>`.
7064
4. **Expect long-running `codeagent-wrapper` calls.** High-reasoning modes can take a long time.
7165
5. **Timeouts are not an escape hatch.** If a call times out, retry with narrower scope.
72-
6. **Respect worktree setting.** If enabled, always pass `--worktree` to develop agent calls.
66+
6. **Defer worktree decision until Phase 4.** Only ask about worktree mode right before implementation. If enabled, prefix develop agent calls with `DO_WORKTREE_DIR=<path>`. Never pass `--worktree` after initialization.
7367

7468
## Agents
7569

@@ -78,7 +72,7 @@ Read-only agents (code-explorer, code-architect, code-reviewer) do NOT need `--w
7872
| `code-explorer` | Trace code, map architecture, find patterns | No (read-only) |
7973
| `code-architect` | Design approaches, file plans, build sequences | No (read-only) |
8074
| `code-reviewer` | Review for bugs, simplicity, conventions | No (read-only) |
81-
| `develop` | Implement code, run tests | **Yes** (if worktree enabled) |
75+
| `develop` | Implement code, run tests | **Yes** — use `DO_WORKTREE_DIR` env prefix |
8276

8377
## Issue Severity Definitions
8478

@@ -175,12 +169,39 @@ EOF
175169

176170
**Goal:** Build feature and review in one phase.
177171

178-
1. Invoke `develop` to implement. For full-stack projects, split into backend/frontend tasks with per-task `skills:` injection. Use `--parallel` when tasks can be split; use single agent when the change is small or single-domain.
172+
**Step 1: Decide on worktree mode (ONLY NOW)**
179173

180-
**Single-domain example** (add `--worktree` if enabled):
174+
Use AskUserQuestion to ask:
175+
176+
```
177+
Develop in a separate worktree? (Isolates changes from main branch)
178+
- Yes (Recommended for larger changes)
179+
- No (Work directly in current directory)
180+
```
181+
182+
If user chooses worktree:
183+
```bash
184+
python3 ".claude/skills/do/scripts/setup-do.py" --worktree "<task description>"
185+
# Save the worktree path from output for DO_WORKTREE_DIR
186+
```
187+
188+
**Step 2: Invoke develop agent**
189+
190+
For full-stack projects, split into backend/frontend tasks with per-task `skills:` injection. Use `--parallel` when tasks can be split; use single agent when the change is small or single-domain.
191+
192+
**Single-domain example** (prefix with `DO_WORKTREE_DIR` if worktree enabled):
181193

182194
```bash
183-
codeagent-wrapper --worktree --agent develop --skills golang-base-practices - . <<'EOF'
195+
# With worktree:
196+
DO_WORKTREE_DIR=<worktree_dir> codeagent-wrapper --agent develop --skills golang-base-practices - . <<'EOF'
197+
Implement with minimal change set following the Phase 3 blueprint.
198+
- Follow Phase 1 patterns
199+
- Add/adjust tests per Phase 3 plan
200+
- Run narrowest relevant tests
201+
EOF
202+
203+
# Without worktree:
204+
codeagent-wrapper --agent develop --skills golang-base-practices - . <<'EOF'
184205
Implement with minimal change set following the Phase 3 blueprint.
185206
- Follow Phase 1 patterns
186207
- Add/adjust tests per Phase 3 plan
@@ -191,7 +212,8 @@ EOF
191212
**Full-stack parallel example** (adapt task IDs, skills, and content based on Phase 3 design):
192213

193214
```bash
194-
codeagent-wrapper --worktree --parallel <<'EOF'
215+
# With worktree:
216+
DO_WORKTREE_DIR=<worktree_dir> codeagent-wrapper --parallel <<'EOF'
195217
---TASK---
196218
id: p4_backend
197219
agent: develop
@@ -213,11 +235,17 @@ Implement frontend changes following Phase 3 blueprint.
213235
- Follow Phase 1 patterns
214236
- Add/adjust tests per Phase 3 plan
215237
EOF
238+
239+
# Without worktree: remove DO_WORKTREE_DIR prefix
216240
```
217241

218242
Note: Choose which skills to inject based on Phase 3 design output. Only inject skills relevant to each task's domain.
219243

220-
2. Run parallel reviews:
244+
**Step 3: Review**
245+
246+
**Step 3: Review**
247+
248+
Run parallel reviews:
221249

222250
```bash
223251
codeagent-wrapper --parallel <<'EOF'
@@ -239,9 +267,10 @@ Classify each issue as BLOCKING or MINOR.
239267
EOF
240268
```
241269

242-
3. Handle review results:
243-
- **MINOR issues only** → Auto-fix via `develop`, no user interaction
244-
- **BLOCKING issues** → Use AskUserQuestion: "Fix now / Proceed as-is"
270+
**Step 4: Handle review results**
271+
272+
- **MINOR issues only** → Auto-fix via `develop`, no user interaction
273+
- **BLOCKING issues** → Use AskUserQuestion: "Fix now / Proceed as-is"
245274

246275
### Phase 5: Complete (No Interaction)
247276

0 commit comments

Comments
 (0)