/dev:worktree create [branch] | list | cleanup [path] | status | helpfrom dev
Manages git worktrees — creates isolated workspaces with optional Neon DB branching, lists active worktrees, and cleans up. Supports create, list, cleanup, status, and help subcommands.
Ships in dev. Installing the plugin adds it to Claude Code.
<user_request> $ARGUMENTS </user_request>
Parse $ARGUMENTS to determine subcommand: **Usage:** `/dev:worktree create [branch-name]`Create a new worktree following the worktree-lifecycle skill phases 1-5.
Steps:
1. If branch-name not provided, ask user for branch name
2. Use AskUserQuestion to ask for worktree directory (or use .worktrees/ default)
3. Execute Phase 1: Pre-flight Checks
- Verify git repository
- Check branch availability
- Check path availability
4. Execute Phase 2: Directory Selection (use provided or ask)
5. Execute Phase 3: Creation
- Verify .gitignore
- Create worktree with `git worktree add`
- Store original CWD
6. Execute Phase 3.5: Database Branch (if applicable)
- Detect database provider from .env (neon.tech, turso.io, supabase.co)
- If branchable provider detected, ask user if branch involves schema changes
- If yes: create DB branch, get connection string, patch .env, write .db-branch.json
- Follow `${CLAUDE_PLUGIN_ROOT}/skills/backend/db-branching/SKILL.md` (read the
file) for the provider-specific procedure
7. Execute Phase 4: Setup
- Detect stacks (nodejs, rust, golang, python, ruby)
- Install dependencies for each stack
- If Neon branch created: run schema push command against branch
- Run baseline tests
8. Execute Phase 5: Handoff
- Display worktree information
- Show path, branch, stacks, test results
- If Neon branch: show Neon branch ID and isolation status
Output format:
```
Worktree created successfully!
Path: .worktrees/{slug}
Branch: {branch-name}
Stacks: {detected-stacks}
Tests: {passing} passing, {failing} failing
Neon Branch: {branch-id} (from {parent}) | (none)
Database: Isolated | Shared (production)
To work in this worktree:
cd .worktrees/{slug}
To clean up later:
/dev:worktree cleanup .worktrees/{slug}
```
**Usage:** `/dev:worktree list`
Show all active worktrees in this repository.
Steps:
1. Run `git worktree list --porcelain`
2. Parse output to extract:
- Worktree path
- Branch name
- HEAD commit
- Locked status
3. For each worktree, check for `.db-branch.json` to detect Neon branches
4. Format as table:
```
Active Worktrees:
Path Branch Commit Neon Branch
──────────────────────────────────────────────────────────────────────────
/path/to/project main abc1234 production
/path/to/.worktrees/feature feature/auth def5678 br-dark-sky-a8xyz123
/path/to/.worktrees/hotfix hotfix/login ghi9012 (none)
```
If no worktrees besides main:
```
No additional worktrees found.
Only main worktree is active.
Create a worktree with: /dev:worktree create [branch-name]
```
**Usage:** `/dev:worktree cleanup [path]`
Remove a worktree following the worktree-lifecycle skill's Phase 6.
Steps:
1. If path not provided, list available worktrees and ask which to clean up
2. Execute Phase 6 cleanup:
- Return to original CWD if currently in worktree
- Check for uncommitted changes
- If uncommitted changes:
Use AskUserQuestion:
question: "Uncommitted changes found. How to proceed?"
options:
- Commit now
- Stash changes
- Discard changes
- Abort cleanup
- Check for `.db-branch.json` in worktree root
- If database branch exists, follow the cleanup in
`${CLAUDE_PLUGIN_ROOT}/skills/backend/db-branching/SKILL.md`:
- Ask user about schema migration (apply to production / discard / keep)
- If applying: merge code first, then run schema push in main worktree
- Delete database branch via provider-specific method (MCP or CLI)
- Remove worktree with `git worktree remove`
- Optionally delete branch (only if merged)
Safety checks:
- NEVER use `rm -rf` on worktree directories
- ALWAYS use `git worktree remove`
- Check for uncommitted changes before removing
- Warn if branch is not merged
Output format:
```
Worktree removed: .worktrees/{slug}
Branch status: {merged | unmerged}
{if merged}
Branch deleted: {branch-name}
{else}
Branch kept: {branch-name} (not merged to main)
To delete: git branch -D {branch-name}
{end}
```
**Usage:** `/dev:worktree status`
Show current worktree information.
Steps:
1. Get current working directory
2. Run `git worktree list` to find all worktrees
3. Determine which worktree contains current directory
4. Get branch information with `git branch --show-current`
5. Get commit with `git rev-parse --short HEAD`
6. Check for uncommitted changes with `git status --porcelain`
Output format:
```
Current Worktree:
Path: /path/to/current/worktree
Branch: {branch-name}
Commit: {short-sha}
Status: {clean | uncommitted changes}
{if uncommitted}
Modified files: {count}
Untracked files: {count}
{end}
All Worktrees: {total-count}
To see all: /dev:worktree list
```
If not in a worktree:
```
Not in a git worktree.
Current directory is the main working tree.
Create a worktree with: /dev:worktree create [branch-name]
```
**Usage:** `/dev:worktree` or `/dev:worktree help`
Show help message when no arguments provided or "help" requested.
Output:
```
Git Worktree Management
Commands:
create [branch] Create new isolated worktree
list Show all active worktrees
cleanup [path] Remove worktree and optionally delete branch
status Show current worktree information
help Show this help message
Examples:
/dev:worktree create feature/auth-system
/dev:worktree list
/dev:worktree cleanup .worktrees/auth-system
/dev:worktree status
See the worktree-lifecycle skill for detailed documentation.
```
<error_handling> If subcommand not recognized: ``` Unknown subcommand: {subcommand}
Available commands: create, list, cleanup, status, help
Use: /dev:worktree help
```
If git command fails:
```
Error: {error-message}
This may be because:
- Not in a git repository
- Worktree path doesn't exist
- Branch is already checked out elsewhere
- Insufficient permissions
Check git status and try again.
```
</error_handling>
- Be concise and actionable - Show clear success/error messages - Provide next steps after each operation - Use tables for list output - Highlight safety warningsDatabase branching. Read
${CLAUDE_PLUGIN_ROOT}/skills/backend/db-branching/SKILL.md only when the worktree
will change the schema — a migration, a Prisma/Drizzle model edit, or the user naming
Neon, Turso or Supabase. Most worktrees touch no schema, and it was preloaded into all
of them.
What the command file sets; muted values are Claude Code's defaults
git-worktree, workspace-management, database-branching, neon
7-day visitors to each command page
npx claudepluginhub madappgang/magus --plugin dev17 commands in this plugin
/architectArchitecture design and technical planning — complexity-aware with plan mode reasoning and multi-model escalation/auditStructured quality audit — routes to specialist reviewers for code, UI, docs, security, or plugin quality/debugStructured debugging — routes to quick patch (inline), standard debug (skill), or production-grade fix (/dev:fix)/design-systemValidate a project against the design-system guardrails — token-only styling, one component library, variants over call-site restyling. Reports drift by rule, and can fix it or scaffold the guardrails.Other plugins' commands for the same job