Building ccswitch: Managing Multiple Claude Code Sessions Without the Chaos

Building ccswitch: Managing Multiple Claude Code Sessions Without the Chaos

I've been using Claude Code extensively for development work, and whilst it's incredibly powerful, I kept running into the same frustrating workflow problem. You can only have one branch checked out at a time, which becomes a real productivity killer when you're trying to run multiple AI-assisted development sessions simultaneously.

The breaking point came when I was working on a project where I'd ask Claude Code to add new API routes, then immediately want to start another session to annotate all existing API routes with Swagger documentation. The problem? Both tasks would inevitably touch the same files, creating conflicts and contamination between what should have been separate workflows. I'd either have to wait for one task to complete entirely before starting the next, or risk having different AI agents make changes to the same files and lines - which failed more often than not.

This is where git worktrees became the obvious solution. Claude Code itself recommended this approach when I asked about managing multiple concurrent sessions. The concept is brilliant: each worktree gets its own directory and can have a different branch checked out, letting you work on multiple features simultaneously without any context contamination.

The Problem with Raw Git Worktrees

Using git worktrees manually works, but it's a mission to get right every time. The commands are verbose, you need to remember where you put each worktree, and switching between them involves copying and pasting directory paths. When Claude Code can take anywhere from a few minutes to an hour depending on the breadth of the task, this friction adds up quickly.

I wanted to be able to start multiple Claude Code sessions and have them work in complete isolation. One might be refactoring authentication logic whilst another adds database migrations. Running these in parallel makes you incredibly efficient, but only if you can manage the workflow properly.

Building ccswitch

The first working version took me about 3 hours to put together. Nothing fancy - just a Go CLI that could create worktrees with sensible branch names and list active sessions. But getting it to somewhere genuinely useful took closer to 10 hours, mainly spent on handling edge cases and making the user experience smooth.

The key insight was centralising storage. Instead of cluttering your project directory with worktree folders, ccswitch creates them in ~/.ccswitch/worktrees/repo-name/session-name. Your main project stays clean, and all the parallel work happens in a predictable location.

Here's how it works in practice:

ccswitch
# 🚀 What are you working on? Add swagger documentation
# ✓ Created session: feature/add-swagger-documentation
#   Branch: feature/add-swagger-documentation
#   Path: ~/.ccswitch/worktrees/my-project/add-swagger-documentation

The tool automatically cds you into the new directory - no copy-pasting paths. Start your Claude Code session there, and it operates in complete isolation from your other work.

Technical Implementation

The Go implementation handles the worktree creation, branch naming (converting descriptions like "Add swagger documentation" into feature/add-swagger-documentation), and cleanup. The shell integration wrapper captures the output and changes your working directory automatically.

I particularly focused on the cleanup workflow. When a Claude Code session finishes, you want to be able to remove the worktree and optionally delete the branch without hassle:

ccswitch cleanup add-swagger-documentation
# Delete branch feature/add-swagger-documentation? (y/N): y
# ✓ Removed session and branch: add-swagger-documentation

The interactive session listing shows all your active work, making it easy to switch between different Claude Code tasks or see what's currently running.

Real-World Impact

The difference in my workflow has been substantial. I can now confidently run multiple Claude Code instances without worrying about conflicts. One session might be working on API improvements whilst another handles documentation updates, and a third refactors the authentication system. Each operates in its own branch and directory, then I can review and merge them as separate PRs.

The main challenge now is actually remembering what each session is working on when you have several running simultaneously. That's led me to build another tool (to be released soon) that tracks session statistics - token usage, estimated costs, files changed, and task descriptions. This gives you per-session, per-project, and overall visibility into your AI-assisted development work.

Looking Forward

Building ccswitch solved an immediate workflow problem, but it's also highlighted how much the development process changes when you can effectively parallelise AI assistance. Instead of waiting for one task to complete before starting another, you can keep multiple sessions active and switch between them as needed.

The tool handles the boring parts - worktree management, directory switching, cleanup - so you can focus on the actual development work. It's open source on GitHub if you're dealing with similar workflow challenges.

The combination of AI-assisted development and proper tooling to manage it feels like a glimpse into how software development workflows will continue to evolve. When automating git commits using AI and tools like ccswitch, the entire development process becomes more fluid and efficient.

Having multiple AI agents working on different aspects of your codebase simultaneously, each in their own isolated environment, then bringing those changes together through normal PR processes - that's a workflow that simply wasn't possible a few years ago. Now it's becoming essential for staying productive with AI development tools.


Need help with your business?

Enjoyed this post? I offer consulting services to help businesses like yours tackle AI, tech strategy, and more. Learn more about how I can support you.

Subscribe

Get new posts directly to your inbox
You've successfully subscribed to Kyle Redelinghuys
Great! Next, complete checkout to get full access to all premium content.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.