branch
Use when the user runs /branch [target] [strategy] to switch to a target branch, safely handling uncommitted work first.
Файлы1
Открыть в GitHubSKILL.mdskills/branch/SKILL.md
GitHubSwitch Branch
Switches to a target branch, handling uncommitted changes before checkout.
Arguments
/branch [target] [strategy]
target: branch name to switch to. If omitted, ask the user.strategy:temporstash. Defaults totempif not provided.temp— stage all changes and create a commit with message"temp"before switchingstash— stash all changes before switching
Workflow
1. Parse arguments
- Extract
targetandstrategyfrom arguments. - If
strategyis not provided or not one oftemp/stash, default totemp.
2. Resolve target branch
If target was provided, use it directly.
If not provided, ask via AskUserQuestion:
devdemorelease- Other (user types a custom branch name)
3. Check working tree
git status --porcelain
If output is empty, the tree is clean — skip to step 5.
4. Handle uncommitted changes
If strategy is temp:
git add -A
git commit -m "temp"
If strategy is stash:
git stash push -m "auto-stash before switching to TARGET_BRANCH"
5. Switch branch
git checkout TARGET_BRANCH
git pull
If checkout fails (branch doesn't exist locally or remotely), tell the user and stop.
Rules
- Never discard changes — always commit or stash before switching
- Default strategy is
tempwhen not specified - Always
git pullafter checkout