Add your description here
Project description
workstack
Effortless git worktree management for parallel development.
Create, switch, and manage multiple worktrees from a centralized location with automatic environment setup.
Installation
# With uv (recommended)
uv tool install workstack
# From source
uv tool install git+https://github.com/schrockn/workstack.git
Quick Start
# Initialize in your repo
cd /path/to/your/repo
workstack init
source ~/.zshrc # or ~/.bashrc
# Create and switch to a worktree
workstack create user-auth
workstack switch user-auth
# Switch back and clean up
workstack switch root
workstack rm user-auth
Overview
workstack solves the pain of managing multiple git worktrees for parallel agenetic coding sessions.
Key features:
- Centralized worktrees in
~/worktrees/<repo>/<feature>/ - Automatic environment setup (
.env, virtual environments, activation scripts) - Simple CLI:
create,switch,rm,ls - Plan-based development workflow
- Optional Graphite integration for stacked diffs
Core Commands
Creating Worktrees
# New feature branch
workstack create feature-x # Creates worktree 'feature-x' with branch 'feature-x'
workstack create fix --branch hotfix/bug # Creates worktree 'fix' with branch 'hotfix/bug'
# From existing branch
workstack create --from-branch feature/login # Creates worktree from existing branch 'feature/login'
workstack create login --from-branch feature/login # Creates worktree 'login' from branch 'feature/login'
# Move current work
workstack create --from-current-branch # Move current branch to new worktree
# From a plan file
workstack create --plan Add_Auth.md # Creates worktree, moves plan to .PLAN.md
Managing Worktrees
workstack switch NAME # Switch between worktrees (or 'root' for repo root)
workstack list # List all worktrees (alias: ls)
workstack list --stacks # List with graphite stacks and PR status
workstack tree # Show tree of worktrees with dependencies
workstack rename OLD NEW # Rename a worktree
workstack rm NAME # Remove worktree
workstack gc # Find safe-to-delete worktrees (merged PRs)
workstack sync # Sync with Graphite, show cleanup candidates
workstack sync -f # Sync and auto-remove merged workstacks
Example output:
$ workstack list
root [master]
feature-a [feature-a]
feature-b [work/feature-b]
$ workstack list --stacks
root [master]
◉ master
feature-a [feature-a]
◯ master
◉ feature-a ✅ #123
feature-b [work/feature-b]
◯ master
◉ work/feature-b 🚧 #456
PR Status Indicators:
- ✅ Checks passing
- ❌ Checks failing
- 🟣 Merged
- 🚧 Draft
- ⭕ Closed
- ◯ Open (no checks)
Note: The repository root is displayed as root and can be accessed with workstack switch root.
Visualizing Worktrees
workstack tree # Show tree of worktrees with dependencies
Example output:
$ workstack tree
main [@root]
├─ feature-a [@feature-a]
│ └─ feature-a-2 [@feature-a-2]
└─ feature-b [@feature-b]
The tree command shows:
- Only branches with active worktrees (not all branches)
- Dependency relationships from Graphite stacks
- Current worktree highlighted in bright green
- Worktree names in brackets
[@name]
Note: Requires Graphite to be enabled.
Configuration
workstack init # Initialize in repository
workstack init --shell # Set up shell integration (completion + auto-activation)
workstack init --list-presets # List available config presets
workstack init --repo # Initialize repo config only (skip global)
workstack config list # Show all configuration
workstack config get KEY # Get config value
workstack config set KEY VALUE # Set config value
workstack completion bash/zsh/fish # Generate shell completion script
Configuration Files
Global (~/.workstack/config.toml):
workstacks_root = "/Users/you/worktrees"
use_graphite = true # Auto-detected if gt CLI installed
show_pr_info = true # Display PR status in list --stacks (requires gh CLI)
Per-Repository (~/worktrees/<repo>/config.toml):
[env]
# Template variables: {worktree_path}, {repo_root}, {name}
DATABASE_URL = "postgresql://localhost/{name}_db"
[post_create]
shell = "bash"
commands = [
"uv venv",
"uv pip install -e .",
]
Common Workflows
Parallel Feature Development
workstack create feature-a
workstack switch feature-a
# ... work on feature A ...
workstack create feature-b
workstack switch feature-b
# ... work on feature B ...
workstack switch feature-a # Instantly back to feature A
Plan-Based Development
workstack promotes an opinionated workflow that separates planning from implementation:
Core principles:
- Plan in main/master - Keep your main branch "read-only" for planning. Since planning doesn't modify code, you can create multiple plans in parallel without worktrees.
- Execute in worktrees - All code changes happen in dedicated worktrees, keeping work isolated and switchable.
- Plans as artifacts - Each plan is a markdown file that travels with its worktree.
Workflow:
# 1. Stay in root repo for planning
workstack switch root
# 2. Create your plan and save it to disk (e.g. Add_User_Auth.md)
# 3. Create worktree from plan
workstack create --plan Add_User_Auth.md
# This automatically:
# - Creates worktree named 'add-user-auth'
# - Moves Add_User_Auth.md to worktree as .PLAN.md
# - .PLAN.md is already in .gitignore (added by workstack init)
# 4. Switch and execute
workstack switch add-user-auth
# Your plan is now at .PLAN.md for reference during implementation
Why this works:
- Plans don't clutter PR reviews (
.PLAN.mdin.gitignore) - Each worktree has its own plan context
- Clean separation between thinking and doing
- Workflow guides user to start implementation with clean context with just the .PLAN.md.
This workflow emerged from experience - checking in planning documents created noise in reviews and maintenance overhead without clear benefits.
Moving Current Work
# Started work on main by accident?
workstack create --from-current-branch
# Creates worktree with current branch, switches you back to root
Syncing and Cleanup
After merging PRs, sync your local branches and clean up:
workstack sync
# This will:
# 1. Switch to root (avoiding git conflicts)
# 2. Run gt sync to update branch tracking
# 3. Identify merged/closed PR workstacks
# 4. Prompt for confirmation before removing them
# 5. Switch back to your original worktree
# Or use -f to skip confirmation:
workstack sync -f
Options:
workstack sync # Sync and show cleanup candidates
workstack sync -f # Force gt sync and auto-remove merged workstacks
workstack sync --dry-run # Preview without executing
Requires Graphite CLI (gt) and GitHub CLI (gh) installed.
Command Reference
create Options
| Option | Description |
|---|---|
--branch BRANCH |
Specify branch name (default: NAME) |
--ref REF |
Base ref (default: current HEAD) |
--plan FILE |
Create from plan file |
--from-current-branch |
Move current branch to worktree |
--from-branch BRANCH |
Create from existing branch |
--no-post |
Skip post-create commands |
list / ls Options
| Option | Description |
|---|---|
-s, --stacks |
Show graphite stacks and PR status |
remove / rm Options
| Option | Description |
|---|---|
-f, --force |
Do not prompt for confirmation |
-s, --delete-stack |
Delete all branches in Graphite stack |
--dry-run |
Show what would be done without executing |
rename Options
| Option | Description |
|---|---|
--dry-run |
Show what would be done without executing |
sync Options
| Option | Description |
|---|---|
-f, --force |
Force gt sync and auto-remove merged workstacks |
--dry-run |
Show what would be done without executing |
init Options
| Option | Description |
|---|---|
--force |
Overwrite existing repo config |
--preset NAME |
Config template (auto/generic/dagster/etc) |
--list-presets |
List available presets and exit |
--repo |
Initialize repo config only (skip global) |
--shell |
Set up shell integration only |
Environment Variables
Always exported when switching:
WORKTREE_PATH- Absolute path to current worktreeREPO_ROOT- Absolute path to repository rootWORKTREE_NAME- Name of current worktree
Advanced Features
Graphite Integration
If Graphite CLI is installed, workstack automatically uses gt create for proper stack tracking.
brew install withgraphite/tap/graphite
workstack init # Auto-detects gt
Disable in ~/.workstack/config.toml: use_graphite = false
Repository Presets
Dagster:
[env]
DAGSTER_GIT_REPO_DIR = "{worktree_path}"
[post_create]
commands = ["uv venv", "uv run make dev_install"]
Garbage Collection
Find and clean up merged/closed PR branches:
workstack gc
# Output:
# feature-x [work/feature-x] - merged (PR #123)
# → workstack rm feature-x
Requires GitHub CLI (gh) installed and authenticated.
FAQ
Q: How is this different from git worktree?
A: Adds centralized management, automatic environment setup, and seamless switching.
Q: Does it work with non-Python projects?
A: Yes! Configure post_create commands for any stack.
Q: What if I don't use Graphite?
A: Works perfectly with standard git commands.
Documentation
For Developers
Core documentation for contributors:
- CLAUDE.md - Coding standards and conventions (required reading)
- tests/CLAUDE.md - Testing patterns and practices
For AI Assistants
Comprehensive, agent-optimized documentation is available in the .agent/ directory:
- Architecture - System design, patterns, and component relationships
- Feature Index - Complete feature catalog with implementation locations
- Glossary - Terminology and concept definitions
- Module Map - Module structure and exports
- Coding Patterns - Detailed implementation patterns with examples
- Exception Handling - Complete exception handling guide
See .agent/README.md for more details.
Links
License
MIT - Nick Schrock (@schrockn)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file workstack-0.1.7.tar.gz.
File metadata
- Download URL: workstack-0.1.7.tar.gz
- Upload date:
- Size: 128.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b35e0cb6aaf840be9eb197efff5e15e6621f1feb9e3943b2d1310bf87ba7e66
|
|
| MD5 |
83640f4547be85649d8445e64b0d5114
|
|
| BLAKE2b-256 |
e9843ae2c7b982c58fc61aca5bcb04d3730fdc107f06a2cac47c366e412d4065
|
File details
Details for the file workstack-0.1.7-py3-none-any.whl.
File metadata
- Download URL: workstack-0.1.7-py3-none-any.whl
- Upload date:
- Size: 57.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
182de4a718fbfcb958c82d35f40441b2a017999d73da5137f34ab9c251d8d349
|
|
| MD5 |
647e7025db645a52484238edb121a648
|
|
| BLAKE2b-256 |
6204cfe013131a1b0f69b61f944e38b4be3d11fc158e9461e7175b31cbc5997d
|