Skip to content

olgeni/ccswitch

Β 
Β 

Repository files navigation

πŸ”€ ccswitch

Built by Kyle Redelinghuys

A friendly CLI tool for managing multiple git worktrees, perfect for juggling different features, experiments, or Claude Code sessions without the context-switching headaches.

🎯 What is this?

ccswitch helps you create and manage git worktrees with a clean, intuitive interface. Each worktree gets its own directory, letting you work on multiple features simultaneously without stashing changes or switching branches in place.

✨ Features

  • πŸš€ Quick Session Creation - Describe what you're working on, get a branch and worktree instantly
  • πŸ“‹ Interactive Session List - See all your active work sessions with a clean TUI
  • 🧹 Smart Cleanup - Remove worktrees and optionally delete branches when done
  • πŸ—‘οΈ Bulk Cleanup - Remove ALL worktrees at once with cleanup --all (perfect for spring cleaning!)
  • 🐚 Shell Integration - Automatically cd into new worktrees (no copy-pasting paths!)
  • 🎨 Pretty Output - Color-coded messages and clean formatting

πŸ“¦ Installation

Using Make

# Clone the repo
git clone https://github.com/ksred/ccswitch.git
cd ccswitch

# Build and install
make install

# Add shell integration to your .bashrc or .zshrc
cat bash.txt >> ~/.bashrc  # or ~/.zshrc
source ~/.bashrc           # or ~/.zshrc

Manual Installation

# Build the binary
go build -o ccswitch .

# Move to your PATH
sudo mv ccswitch /usr/local/bin/

# Add the shell wrapper
source bash.txt

πŸš€ Usage

Create a New Work Session

ccswitch
# πŸš€ What are you working on? Fix authentication bug
# βœ“ Created session: feature/fix-authentication-bug
#   Branch: feature/fix-authentication-bug
#   Path: /home/user/project/../fix-authentication-bug
# 
# Automatically switches to the new directory!

List Active Sessions

ccswitch list
# Shows an interactive list of all your worktrees
# Use arrow keys to navigate, Enter to select, q to quit

Switch Between Sessions

ccswitch switch
# Interactive selection of session to switch to

ccswitch switch fix-auth-bug
# Direct switch to a specific session
# Automatically changes to the session directory!

Clean Up When Done

ccswitch cleanup
# Select a session interactively, or:

ccswitch cleanup fix-authentication-bug
# Delete branch feature/fix-authentication-bug? (y/N): y
# βœ“ Removed session and branch: fix-authentication-bug

# Bulk cleanup - remove ALL worktrees at once!
ccswitch cleanup --all
# ⚠️  You are about to remove the following worktrees:
#   β€’ feature-1 (feature/feature-1)
#   β€’ feature-2 (feature/feature-2)
#   β€’ bugfix-1 (feature/bugfix-1)
# Press Enter to continue or Ctrl+C to cancel...
# Delete associated branches as well? (y/N): y
# βœ“ Successfully removed: feature-1
# βœ“ Successfully removed: feature-2
# βœ“ Successfully removed: bugfix-1
# βœ… All 3 worktrees removed successfully!
# βœ“ Switched to main branch

πŸ› οΈ Development

Quick Start

# Run directly
make run

# Run tests
make test

# See all commands
make help

Testing

# Unit tests only (fast, no git required)
make test-unit

# All tests including integration
make test

# Run tests in Docker (clean environment)
make test-docker

# Generate coverage report
make coverage

Project Structure

ccswitch/
β”œβ”€β”€ main.go              # Main application code
β”œβ”€β”€ bash.txt             # Shell integration wrapper
β”œβ”€β”€ Makefile            # Build automation
β”œβ”€β”€ *_test.go           # Test files
β”œβ”€β”€ Dockerfile.test     # Docker test environment
└── README.md           # You are here! πŸ‘‹

πŸ€” How It Works

  1. Session Creation: Converts your description into a branch name (e.g., "Fix login bug" β†’ feature/fix-login-bug)
  2. Centralized Storage: Creates worktrees in ~/.ccswitch/worktrees/repo-name/session-name - your projects stay clean!
  3. Automatic Navigation: The bash wrapper captures the output and cds you into the new directory
  4. Session Tracking: Lists all worktrees except the main one as active sessions

Directory Structure

~/.ccswitch/                      # All ccswitch data in your home directory
└── worktrees/                    # Centralized worktree storage
    β”œβ”€β”€ my-project/               # Organized by repository name
    β”‚   β”œβ”€β”€ fix-login-bug/        # Individual sessions
    β”‚   β”œβ”€β”€ add-new-feature/
    β”‚   └── refactor-ui/
    └── another-project/
        β”œβ”€β”€ update-deps/
        └── new-feature/

# Your project directories remain completely clean!
/Users/you/projects/
β”œβ”€β”€ my-project/                   # Just your main repository
└── another-project/              # No clutter!

πŸ”§ Requirements

  • Go 1.21 or higher (for building)
  • Git 2.20 or higher (for worktree support)
  • Bash or Zsh (for shell integration)

πŸ’‘ Tips

  • Use descriptive session names - they become your branch names!
  • Regular cleanup keeps your workspace tidy
  • Each worktree is independent - perfect for testing different approaches
  • The tool respects your current branch when creating new sessions

πŸ› Troubleshooting

"Failed to create worktree"

  • Check if the branch already exists: git branch -a
  • Ensure you're in a git repository
  • Verify you have write permissions in the parent directory

Shell integration not working

  • Make sure you've sourced the bash wrapper
  • Check that ccswitch is in your PATH
  • Try using the full path: /usr/local/bin/ccswitch

πŸ“ License

MIT License - feel free to use this in your projects!

🀝 Contributing

Found a bug? Have an idea? Feel free to open an issue or submit a PR!


Made with ❀️ for developers who juggle multiple features at once

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 77.6%
  • Shell 15.3%
  • Makefile 6.8%
  • Dockerfile 0.3%