You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(plugin): create intent worktree before discovery to avoid artifacts on main
Move worktree creation from Phase 6 to Phase 2.25 so discovery.md and
all subsequent files are written directly on the intent branch. This
prevents untracked .ai-dlc/{slug}/ artifacts from being left on main
during elaboration. Also updates Phase 0 "Start fresh" cleanup to
properly remove worktrees and intent branches.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: plugin/skills/elaborate/SKILL.md
+60-44Lines changed: 60 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,9 +149,22 @@ If the user invoked this with a slug argument:
149
149
150
150
If no slug provided, or the intent doesn't exist, proceed to Phase 1.
151
151
152
-
**Start fresh cleanup:** When the user chooses "Start fresh", delete the entire `.ai-dlc/{slug}/` directory. This includes any `discovery.md` that may have been created in a prior elaboration attempt:
152
+
**Start fresh cleanup:** When the user chooses "Start fresh", remove the intent worktree and its branch (if they exist from a prior elaboration attempt), then clean up any leftover `.ai-dlc/{slug}/` directory:
Before beginning technical exploration, initialize the discovery scratchpad. This file persists elaboration findings to disk so they survive context compaction and are available to builders later.
210
+
Before beginning technical exploration, create the intent worktree and initialize the discovery scratchpad inside it. Creating the worktree early ensures **no artifacts are left on `main`** — all files from this point forward are written on the intent branch.
198
211
199
212
```bash
200
213
# Derive intent slug from the user's description (same slug used throughout elaboration)
**Tell the user the worktree location** so they know where to find it.
233
+
234
+
Now initialize the discovery scratchpad. This file persists elaboration findings to disk so they survive context compaction and are available to builders later.
235
+
236
+
```bash
202
237
DISCOVERY_DIR=".ai-dlc/${INTENT_SLUG}"
203
238
DISCOVERY_FILE="${DISCOVERY_DIR}/discovery.md"
204
239
205
-
# Create directory (may already exist from Phase 0)
206
240
mkdir -p "$DISCOVERY_DIR"
207
241
208
242
# Initialize discovery.md with frontmatter header
@@ -221,7 +255,15 @@ Builders: read section headers for an overview, then dive into specific sections
221
255
DISCOVERY_EOF
222
256
```
223
257
224
-
This file lives in the main repo's working directory (not in a worktree — the worktree doesn't exist yet). It will be copied into the intent worktree in Phase 6.
258
+
This file is written directly in the intent worktree on the `ai-dlc/{intent-slug}/main` branch. No artifacts touch `main`.
259
+
260
+
This ensures:
261
+
- Main working directory stays on `main` for other work
262
+
- All discovery findings are written directly on the intent branch
263
+
- All subsequent `han keep` operations use the intent branch's storage
264
+
- Multiple intents can run in parallel in separate worktrees
265
+
- Clean separation between main and AI-DLC orchestration state
266
+
- Subagents spawn from the intent worktree, not the original repo
225
267
226
268
---
227
269
@@ -842,53 +884,27 @@ Map selections to the `announcements` array in intent.md frontmatter:
842
884
843
885
## Phase 6: Write AI-DLC Artifacts
844
886
845
-
Create the intent branch and worktree, then write files in `.ai-dlc/{intent-slug}/`:
887
+
Write intent and unit files in `.ai-dlc/{intent-slug}/` (already in the intent worktree since Phase 2.25):
846
888
847
-
### 1. Create intent branch and worktree
889
+
### 1. Verify intent worktree
848
890
849
-
**CRITICAL: The intent MUST run in an isolated worktree, not the main working directory. Create this BEFORE writing any artifacts so all files are committed to the intent branch.**
891
+
The intent worktree was already created in **Phase 2.25** (before discovery began), so all files — including `discovery.md` — are already on the intent branch. Verify we're in the right place:
0 commit comments