Commit 14d1fc4
Prevent agents from escaping worktree via prompt constraint
Root cause found via agent logs: Claude Code agents cd out of their
worktree into the main repo when they encounter errors (e.g., npm test
fails in worktree). This abandons the worktree, and subsequent git
operations in the main repo context can destroy worktree metadata.
Fix: append worktree constraint to agent prompt instructing it to stay
in the current directory and not run git worktree/init/thinktank commands.
Evidence from agent-1 logs:
cd C:/Users/silon/Documents/repos/thinktank && npm run lint
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 975c7c6 commit 14d1fc4
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | | - | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
0 commit comments