/ tools / EnterWorktreeTool / prompt.ts
prompt.ts
 1  export function getEnterWorktreeToolPrompt(): string {
 2    return `Use this tool ONLY when the user explicitly asks to work in a worktree. This tool creates an isolated git worktree and switches the current session into it.
 3  
 4  ## When to Use
 5  
 6  - The user explicitly says "worktree" (e.g., "start a worktree", "work in a worktree", "create a worktree", "use a worktree")
 7  
 8  ## When NOT to Use
 9  
10  - The user asks to create a branch, switch branches, or work on a different branch — use git commands instead
11  - The user asks to fix a bug or work on a feature — use normal git workflow unless they specifically mention worktrees
12  - Never use this tool unless the user explicitly mentions "worktree"
13  
14  ## Requirements
15  
16  - Must be in a git repository, OR have WorktreeCreate/WorktreeRemove hooks configured in settings.json
17  - Must not already be in a worktree
18  
19  ## Behavior
20  
21  - In a git repository: creates a new git worktree inside \`.claude/worktrees/\` with a new branch based on HEAD
22  - Outside a git repository: delegates to WorktreeCreate/WorktreeRemove hooks for VCS-agnostic isolation
23  - Switches the session's working directory to the new worktree
24  - Use ExitWorktree to leave the worktree mid-session (keep or remove). On session exit, if still in the worktree, the user will be prompted to keep or remove it
25  
26  ## Parameters
27  
28  - \`name\` (optional): A name for the worktree. If not provided, a random name is generated.
29  `
30  }