Skip to content

Commit 07b8841

Browse files
jwaldripclaude
andcommitted
fix(plugin): enforce gitignore for .ai-dlc/worktrees before worktree creation
Split worktree setup into two explicit steps with a guard to prevent creating worktrees without gitignoring the directory first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a7219c8 commit 07b8841

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

plugin/skills/elaborate/SKILL.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,36 @@ Continue asking until you can articulate back to the user, in your own words, ex
215215

216216
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.
217217

218+
**CRITICAL — Step 1: Gitignore worktrees directory (MUST run before creating any worktree)**
219+
220+
You MUST ensure `.ai-dlc/worktrees/` is in `.gitignore` BEFORE creating the worktree. Run this as a **separate Bash command** first:
221+
218222
```bash
219-
# Derive intent slug from the user's description (same slug used throughout elaboration)
220-
INTENT_SLUG="{intent-slug}"
221223
PROJECT_ROOT=$(git rev-parse --show-toplevel)
222-
INTENT_BRANCH="ai-dlc/${INTENT_SLUG}/main"
223-
INTENT_WORKTREE="${PROJECT_ROOT}/.ai-dlc/worktrees/${INTENT_SLUG}"
224-
225-
# Ensure worktrees directory exists and is gitignored (on main, before creating worktree)
226224
mkdir -p "${PROJECT_ROOT}/.ai-dlc/worktrees"
227225
if ! grep -q '\.ai-dlc/worktrees/' "${PROJECT_ROOT}/.gitignore" 2>/dev/null; then
228226
echo '.ai-dlc/worktrees/' >> "${PROJECT_ROOT}/.gitignore"
229227
git add "${PROJECT_ROOT}/.gitignore"
230228
git commit -m "chore: gitignore .ai-dlc/worktrees"
231229
fi
230+
```
231+
232+
**Step 2: Create the intent worktree**
233+
234+
Only after confirming the gitignore entry exists:
235+
236+
```bash
237+
INTENT_SLUG="{intent-slug}"
238+
PROJECT_ROOT=$(git rev-parse --show-toplevel)
239+
INTENT_BRANCH="ai-dlc/${INTENT_SLUG}/main"
240+
INTENT_WORKTREE="${PROJECT_ROOT}/.ai-dlc/worktrees/${INTENT_SLUG}"
241+
242+
# Guard: abort if worktrees dir is not gitignored
243+
if ! grep -q '\.ai-dlc/worktrees/' "${PROJECT_ROOT}/.gitignore" 2>/dev/null; then
244+
echo "ERROR: .ai-dlc/worktrees/ is not in .gitignore. Run Step 1 first." >&2
245+
exit 1
246+
fi
232247

233-
# Create the intent worktree on its own branch
234248
git worktree add -B "$INTENT_BRANCH" "$INTENT_WORKTREE"
235249
cd "$INTENT_WORKTREE"
236250
```

0 commit comments

Comments
 (0)