A lightweight pattern for spawning secondary Claude Code sessions using tmux, enabling parallel work across projects without context collision.
When working from a "mission control" directory (like ~/work/src/ with 100+ projects), you often need to:
- Dispatch deep work to a specific project while continuing meta-level coordination
- Run parallel investigations that would pollute a single session's context
- Isolate risky refactors where you might abandon the branch
- Review someone's PR without disrupting your current work
The key insight: a single Claude session has one context. Spawning secondary sessions gives each task its own isolated context and working directory.
Launch Claude in any directory without creating a new branch:
# From mission control, spawn a session in a specific project
tmx-claude -d ~/work/src/myapp "Fix the flaky test in user_spec.rb"
# Spawn and immediately attach to it
tmx-claude -a -d ~/work/src/billing "Review the invoice calculation"
# With custom window name
tmx-claude -n "auth-fix" -d ~/work/src/auth "Debug the OAuth callback"What happens:
- Creates a new tmux window (or session if not in tmux)
- Changes to the specified directory
- Launches
claudewith your prompt - Returns you to your original window (unless
-a)
Good for:
- Quick tasks in the main branch
- Read-only investigations
- Tasks that don't need branch isolation
Create a git worktree with a new branch and launch Claude in it:
# Create worktree + branch, launch Claude
tmx-worktree -b feature-auth "Implement OAuth login flow"
# Explicit project (when not in that directory)
tmx-worktree -p ~/work/src/myapp -b fix-123 "Fix the race condition in #123"
# Branch from non-main branch
tmx-worktree -b hotfix -f release-2.0 "Patch the security vuln"What happens:
- Creates
~/work/src/<project>-<branch>/ - Creates a new git branch from main (or specified base)
- Spawns a tmux window in the worktree
- Launches Claude with your prompt
Good for:
- Multi-session features
- Risky refactors you might abandon
- Parallel work on unrelated features
- Reviewing/testing branches while keeping your work intact
Remove worktrees with safety checks:
# Remove a specific worktree (checks for uncommitted/unpushed work)
worktree-clean myapp-feature
# Also delete the branch
worktree-clean -d myapp-feature
# Preview what would be cleaned
worktree-clean --merged -n
# Clean all merged worktrees across projects
worktree-clean --mergedSafety checks:
- Uncommitted changes (blocks)
- Unpushed commits (blocks)
- Unmerged branch (warns but doesn't block)
# You're triaging issues in ~/work/src/
# Found something that needs deep work in myapp
tmx-claude -d myapp "bd ready && bd show beads-abc123"
# Continue your triage - the child session handles myapp# Need to understand how three apps handle auth differently
tmx-claude -d app-a "How does authentication work? Show me the flow."
tmx-claude -d app-b "How does authentication work? Show me the flow."
tmx-claude -d app-c "How does authentication work? Show me the flow."
# Three parallel sessions, each with full project context# Starting a feature that might take multiple sessions
tmx-worktree -p myapp -b feature-new-dashboard "Implement the analytics dashboard"
# Work happens across multiple days in ~/work/src/myapp-feature-new-dashboard/
# When merged, clean up
worktree-clean -d myapp-feature-new-dashboard# Someone asks you to review their PR
# You're mid-task in the main repo
# Option A: Quick review in main branch
tmx-claude -d myapp "Review PR #456 - git fetch && git diff origin/main..origin/feature-x"
# Option B: Full checkout for testing
git -C myapp fetch origin pull/456/head:pr-456
tmx-worktree -p myapp -b pr-456-review "Review and test PR #456"When dispatching work tracked in a parent directory's beads database, the child session won't find issues by ID alone (it looks in its own .beads/). Include the path:
# Instead of telling the child: "bd update beads-abc --status in_progress"
# Tell it to use the parent's database:
tmx-claude -d myapp "bd -C ~/work/src update src-abc --status in_progress && implement the feature"| Situation | Tool |
|---|---|
| Quick fix, same branch | tmx-claude -d project "prompt" |
| Deep work, needs isolation | tmx-worktree -b branch "prompt" |
| Read-only investigation | tmx-claude -d project "prompt" |
| Might abandon the work | tmx-worktree (easy cleanup) |
| Already in project's worktree | Just use current session |
| Single-session task | Just use current session |
Both tools use the same underlying pattern:
- Create tmux window/session with
-c DIRfor working directory - Use
tmux send-keysto startclaudewith the prompt - Return focus to original window (unless
-aattach flag)
Worktrees live at ~/work/src/<project>-<branch>/ by convention, making them easy to find and clean up.
The tools gracefully handle both "inside tmux" (creates window) and "outside tmux" (creates session) scenarios.