Agent skill
switch-feature
Commit or stash current work, then switch to another existing worktree. Use when switching between features or stories, ensures changes are saved before switching.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/switch-feature
SKILL.md
/switch-feature - Commit and Switch to Another Worktree
Description
Commits or stashes current work, then helps you switch to another existing worktree.
Usage
/switch-feature
What It Does
Step 1: Check Git Status
git status --porcelain
Step 2: Handle Uncommitted Changes
If there are uncommitted changes:
Ask user:
⚠️ You have uncommitted changes. What would you like to do?
1. Commit changes
2. Stash changes
3. Discard changes (dangerous!)
4. Cancel
Option 1: Commit Changes
# Show current changes
git status
# Ask for commit message
git add -A
git commit -m "{user_message}"
git push origin HEAD
Option 2: Stash Changes
# Stash with message
git stash push -m "{user_message}"
Option 3: Discard Changes
# Warn and confirm
git reset --hard HEAD
git clean -fd
Option 4: Cancel
❌ Operation cancelled.
Step 3: List Available Worktrees
git worktree list
Display to user:
Available worktrees:
1. /Users/user/project (main) [main branch]
2. /Users/user/project/tree/feature/gallery-123 [feature/gallery-123]
3. /Users/user/project/tree/bug/main-app-456 [bug/main-app-456]
4. /Users/user/project/tree/feature/auth-567 [feature/auth-567]
Which worktree would you like to switch to? (1-4)
Step 4: Provide Switch Instructions
After user selects worktree #2:
✅ To switch to feature/gallery-123:
cd tree/feature/gallery-123
Or use this command to switch and open in new terminal:
cd tree/feature/gallery-123 && exec $SHELL
Your current changes have been committed/stashed safely.
Benefits
✅ Safe Switching - Never lose uncommitted work ✅ Quick Navigation - See all worktrees at a glance ✅ Clean Transitions - Proper commit/stash before switching ✅ Simple - One command to handle everything
Notes
- This is a slash command (one-shot operation)
- It doesn't actually change your terminal's directory (can't do that)
- Instead, it provides the
cdcommand for you to run - Your changes are safely committed or stashed before switching
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?