@@ -26,6 +26,25 @@ Uncommitted changes: `git status --short`
2626
2727<execution_steps>
2828<step_0>
29+ <description >Ask user for setup mode</description >
30+ <prompt >
31+ <message>How would you like to set up the worktree?</message>
32+ <options>
33+ <option value="quick">
34+ <label>Quick</label>
35+ <description>Just create the worktree (skip deps, settings, IDE)</description>
36+ </option>
37+ <option value="full">
38+ <label>Full setup</label>
39+ <description>Install dependencies, copy settings, open in IDE</description>
40+ </option>
41+ </options>
42+ </prompt >
43+ <set_variable>$SETUP_MODE = user selection ("quick" or "full")</set_variable>
44+ <purpose >Allow quick worktree creation when user just needs the branch</purpose >
45+ </step_0>
46+
47+ <step_0b>
2948 <description >Detect git hosting provider and available tools (only needed if argument is an issue URL)</description >
3049 <condition >Only run this step if first argument looks like a git hosting URL</condition >
3150<detect_provider>
@@ -49,10 +68,11 @@ Uncommitted changes: `git status --short`
4968</select_tool>
5069
5170 <purpose >Detect git hosting provider and select appropriate tool for issue lookup</purpose >
52- </step_0 >
71+ </step_0b >
5372
5473 <step_1>
5574 <description >Detect current IDE environment</description >
75+ <condition >Only if $SETUP_MODE is "full"</condition >
5676 <detection_methods>
5777 <method_1>
5878 <tool >mcp__ ide__ getDiagnostics</tool >
@@ -136,11 +156,29 @@ Uncommitted changes: `git status --short`
136156 </step_2_5>
137157
138158 <step_3>
139- <description >Add all files and stash uncommitted changes if any exist</description >
140- <condition >If output is not empty (has uncommitted changes)</condition >
141- <command >git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</command >
142- <purpose >Preserve work in progress before switching worktrees</purpose >
143- <note >Remember stash was created for later restoration</note >
159+ <description >Handle uncommitted changes if any exist</description >
160+ <condition >If git status --short output is not empty (has uncommitted changes)</condition >
161+ <prompt >
162+ <message >You have uncommitted changes. Move them to the new branch?</message >
163+ <options >
164+ <option value =" yes " >
165+ <label >Yes</label >
166+ <description >Stash changes and apply them in the new worktree</description >
167+ </option >
168+ <option value =" no " >
169+ <label >No</label >
170+ <description >Leave changes in current branch</description >
171+ </option >
172+ </options >
173+ </prompt >
174+ <if_yes>
175+ <command >git add -A && git stash push -m "Worktree switch: Moving changes to ${branch_name}"</command >
176+ <set_variable>$STASH_CREATED = true</set_variable>
177+ </if_yes>
178+ <if_no>
179+ <set_variable>$STASH_CREATED = false</set_variable>
180+ </if_no>
181+ <purpose >Let user decide whether to move work in progress to new branch</purpose >
144182 </step_3>
145183
146184 <step_4>
@@ -184,8 +222,32 @@ Uncommitted changes: `git status --short`
184222 </option_b_existing_branch>
185223 </step_7>
186224
225+ <step_7b>
226+ <description >Set up remote tracking for new branch</description >
227+ <condition >Only if new branch was created (option_a from step_7)</condition >
228+ <working_directory>${parent_path}/${branch_name}</working_directory>
229+ <command >cd ${parent_path}/${branch_name} && git push -u origin ${branch_name}</command >
230+ <purpose >Establish remote tracking so git status shows ahead/behind and git push/pull work without specifying remote</purpose >
231+ <note >This creates the remote branch and sets upstream tracking in one step</note >
232+ </step_7b>
233+
234+ <step_7c>
235+ <description >Quick mode completion</description >
236+ <condition >Only if $SETUP_MODE is "quick"</condition >
237+ <message >Worktree created at: ${parent_path}/${branch_name}</message >
238+ <suggested_next_steps>
239+ <intro >You can now:</intro >
240+ <suggestion priority =" 1 " >Open in VS Code: ` code ${parent_path}/${branch_name} ` </suggestion >
241+ <suggestion priority =" 2 " >Open in Cursor: ` cursor ${parent_path}/${branch_name} ` </suggestion >
242+ <suggestion priority =" 3 " >Navigate to it: ` cd ${parent_path}/${branch_name} ` </suggestion >
243+ <suggestion priority =" 4 " >Install dependencies: ` cd ${parent_path}/${branch_name} && pnpm install ` </suggestion >
244+ </suggested_next_steps>
245+ <action >STOP here - do not continue to remaining steps</action >
246+ </step_7c>
247+
187248 <step_8>
188249 <description >Copy Claude settings to new worktree</description >
250+ <condition >Only if $SETUP_MODE is "full"</condition >
189251 <source >.claude/settings.local.json</source >
190252 <destination >${parent_path}/${branch_name}/.claude/settings.local.json</destination >
191253 <command >cp -r .claude/settings.local.json ${parent_path}/${branch_name}/.claude/settings.local.json</command >
@@ -194,21 +256,22 @@ Uncommitted changes: `git status --short`
194256
195257 <step_9>
196258 <description >Copy .env.local files to new worktree</description >
259+ <condition >Only if $SETUP_MODE is "full"</condition >
197260 <search_command>find . -name ".env.local" -type f</search_command>
198261 <copy_logic>For each .env.local file found, copy to corresponding location in new worktree</copy_logic>
199262 <common_locations>
200263 - app/.env.local
201264 - packages/* /.env.local
202265 - (any other .env.local files found)
203266 </common_locations>
204- <copy_command>find . -name ".env.local" -type f -exec sh -c 'mkdir -p "$(dirname "${parent_path}/${branch_name}/$1")" && cp "$1" "${parent_path}/${branch_name}/$1"' _ {} \; </copy_command>
267+ <copy_command>find . -name ".env.local" -type f -exec sh -c 'mkdir -p "$(dirname "${parent_path}/${branch_name}/$1")" && cp "$1" "${parent_path}/${branch_name}/$1"'_ {} \; </copy_command>
205268 <purpose >Preserve local environment configurations for development</purpose >
206269 <note >Only copies files that exist; ignores missing ones</note >
207270 </step_9>
208271
209272 <step_10>
210273 <description >Create IDE-specific configuration (conditional)</description >
211- <condition >Only if supports_tasks is true (VS Code variants)</condition >
274+ <condition >Only if $SETUP_MODE is "full" AND supports_tasks is true (VS Code variants)</condition >
212275 <vs_code_tasks>
213276 <create_directory>mkdir -p ${parent_path}/${branch_name}/.vscode</create_directory>
214277 <create_file_command>cat > ${parent_path}/${branch_name}/.vscode/tasks.json << 'EOF'
@@ -240,14 +303,15 @@ EOF</create_file_command>
240303
241304 <step_11>
242305 <description >Install dependencies in new worktree</description >
306+ <condition >Only if $SETUP_MODE is "full"</condition >
243307 <working_directory>${parent_path}/${branch_name}</working_directory>
244308 <command >cd ${parent_path}/${branch_name} && pnpm install</command >
245309 <purpose >Ensure all node_modules are installed for the new worktree</purpose >
246310 </step_11>
247311
248312 <step_12>
249313 <description >Apply stashed changes to new worktree (if stash was created)</description >
250- <condition >Only if stash was created in step_3 </condition >
314+ <condition >Only if $SETUP_MODE is "full" AND $STASH_CREATED is true </condition >
251315 <working_directory>${parent_path}/${branch_name}</working_directory>
252316 <command >cd ${parent_path}/${branch_name} && git stash pop</command >
253317 <purpose >Restore uncommitted work-in-progress to the new worktree branch</purpose >
@@ -256,6 +320,7 @@ EOF</create_file_command>
256320
257321 <step_13>
258322 <description >Open detected IDE in new worktree</description >
323+ <condition >Only if $SETUP_MODE is "full"</condition >
259324 <command >${ide_command} ${parent_path}/${branch_name}</command >
260325 <ide_specific_behavior>
261326 <vs_code_variants>Opens folder in VS Code/Insiders/Cursor with tasks.json auto-starting Claude</vs_code_variants>
@@ -269,7 +334,8 @@ EOF</create_file_command>
269334
270335<important_notes>
271336
272- - Automatically detects and uses your current IDE (VS Code, VS Code Insiders, Cursor, Zed, etc.)
337+ - Offers Quick or Full setup mode - Quick just creates the worktree, Full does everything
338+ - Automatically detects and uses your current IDE (VS Code, VS Code Insiders, Cursor, Zed, etc.) in Full mode
273339- Creates VS Code-specific tasks.json only for VS Code variants (auto-starts Claude on folder open)
274340- Branch names with slashes (feat/, fix/, etc.) are fully supported
275341- The worktree directory path will match the full branch name including slashes
@@ -279,6 +345,7 @@ EOF</create_file_command>
279345- Uncommitted changes are automatically stashed and moved to the new worktree
280346- Your work-in-progress seamlessly transfers to the new branch
281347- IDE detection fallback: checks available editors and uses priority order
348+ - New branches are automatically pushed with ` -u ` to set up remote tracking
282349
283350Limitations:
284351
0 commit comments