| description | allowed-tools |
|---|---|
Create a new git worktree for focused work on a task |
Read, Glob, Bash, Task |
Create a new git worktree from the latest main branch for focused, isolated work.
Required argument: A brief description of the work (e.g., "investigate prod auth flow")
Description provided: $ARGUMENTS
If no description was provided (empty or blank $ARGUMENTS), respond with:
Usage: /new-worktree <description of work>
Examples:
/new-worktree fix authentication bug
/new-worktree add export feature
/new-worktree investigate slow queries
Then stop.
- Get current datetime:
date +%Y%m%d-%H%M - Extract 2-4 keywords from description, lowercase, hyphenated
- Get repo name:
basename $(git rev-parse --show-toplevel) - Create:
- Branch:
feat/sess-{YYYYMMDD-HHMM}-{keywords}(e.g.,feat/sess-20260102-1152-fix-auth-bug) - Worktree folder:
../{repo}-{keywords}(e.g.,../myproject-fix-auth-bug)
- Branch:
# Fetch latest from origin
git fetch origin main
# Create new worktree with branch based on origin/main
git worktree add -b {branch-name} {worktree-path} origin/mainReport success with:
- Branch name created
- Worktree path
- Command to cd into it
Tell the user:
## Worktree Created
**Branch:** feat/sess-YYYYMMDD-HHMM-keywords
**Location:** /path/to/worktree
To start working:
cd {worktree-path}
Or open in a new terminal/editor.
## Suggested Workflow
1. `/plan <feature>` - Create implementation plan
2. `/implement` - Implement from plan
3. `/test` - Run tests
4. `/docs-review` - Check docs before PR
5. `/coderabbit` - Run CodeRabbit CLI locally, fix issues
6. `/pr` - Create PR (auto-ignores CodeRabbit bot)
7. `/worktree-cleanup` - Clean up after merge
Read key documentation if it exists:
CLAUDE.md(project instructions)docs/README.md(current status)docs/CONTEXT.md(background)docs/LESSONS-LEARNED.md(recent lessons)
If no docs exist, that's fine - just note it.
Provide:
- Worktree created: path and branch
- Project context: Key points from docs (if available)
- Recent activity: Notable recent changes (from docs or git log)
End with: "Ready for your task. What would you like to work on?"
Then output the rename command as the final line:
**Rename session:** /rename {keywords}