Customizable git worktree manager
Project description
autowt: git worktree manager
autowt manages git worktrees with automatic terminal switching and cleanup. Each branch gets its own working directory, letting you switch between features without stashing changes or losing context.
Why worktrees? Why autowt?
Why worktrees: Multitask without switching branches, great for long-running agents like Claude Code
Why autowt:
- Worktrees don't get initialized with untracked files; this is annoying.
.envis common, as is the need to install dependencies withuv syncornpm install. - It takes a lot of typing to set up a worktree and cd into it
Core use case is running multiple Claude Code instances on different problems and submitting independent PRs. I can call autowt feature1 --after-init='claude "add a pony and submit a PR"' and it opens a new tab in my terminal with Claude off to the races.
Quick Start
Create or switch to a worktree for any branch:
autowt feature-branch
If the branch exists as a worktree, autowt switches to it. Otherwise, it creates a new worktree and opens it in a new terminal tab.
Core Workflow
Creating worktrees: When you run autowt branch-name, it fetches the latest branches, creates a worktree at ../reponame-worktrees/branch-name, and switches to it. New branches are created from the latest main branch. Branch names with slashes like steve/bugfix become steve-bugfix in the filesystem.
Terminal integration: On macOS with iTerm2, autowt uses AppleScript to switch between existing terminal sessions or create new ones. It tracks session IDs to find the right tab when switching back to a worktree.
Integration: autowt is designed to work alongside existing development tools and workflows without modifying your git repository's hooks or configuration.
Listing and Navigation
autowt ls
Shows your primary clone, current location, and all worktrees:
Primary clone: ~/dev/myproject
You are in: feature-branch
Branches:
feature-auth ~/dev/myproject-worktrees/feature-auth 💻
steve/bugfix ~/dev/myproject-worktrees/steve-bugfix
refactor-core ~/dev/myproject-worktrees/refactor-core 💻
Use 'autowt <branch>' to switch to a worktree or create a new one.
The 💻 icon indicates branches with active terminal sessions.
Cleanup
autowt cleanup
Analyzes your worktrees and categorizes them:
- Without remotes: Branches that don't track a remote branch
- Identical to main: Branches pointing to the same commit as main/master
- Merged: Branches that have been merged into main/master
By default, cleanup removes all categories. Use --mode to be selective:
autowt cleanup --mode all # All categories (default)
autowt cleanup --mode merged # Only merged and identical branches
autowt cleanup --mode remoteless # Only branches without remotes
autowt cleanup --mode interactive # Choose individually with TUI
Use --dry-run to see what would be removed without actually removing:
autowt cleanup --dry-run
Before removing worktrees, autowt finds running processes in those directories and terminates them with SIGINT, followed by SIGKILL after 10 seconds if needed.
Terminal Modes
Control how autowt opens terminals:
autowt branch-name --terminal=tab # Switch to existing session or new tab (default)
autowt branch-name --terminal=window # Switch to existing session or new window
autowt branch-name --terminal=inplace # Change directory directly in current terminal
autowt branch-name --terminal=echo # Output commands for manual evaluation
Smart terminal switching: When using tab or window modes, autowt first checks if the worktree already has a terminal session. If it does, it prompts whether to switch to the existing session or create a new one. Use --yes to automatically switch to existing sessions without prompting.
Inplace mode uses osascript (macOS) to execute directory changes directly in your current terminal session, providing seamless switching without opening new tabs or windows.
Echo mode outputs shell commands that can be evaluated manually or through shell functions:
eval "$(autowt branch-name --terminal=echo)"
Shell Integration for Echo Mode
Get shell-specific integration instructions:
autowt shellconfig # Auto-detect current shell
autowt shellconfig --shell bash # Get bash instructions
autowt shellconfig --shell zsh # Get zsh instructions
autowt shellconfig --shell fish # Get fish instructions
autowt shellconfig --shell tcsh # Get tcsh instructions
autowt shellconfig --shell nu # Get nushell instructions
autowt shellconfig --shell oil # Get oil shell instructions
autowt shellconfig --shell elvish # Get elvish instructions
Or manually add these functions:
# bash - add to ~/.bashrc
autowt_cd() { eval "$(autowt "$@" --terminal=echo)"; }
# zsh - add to ~/.zshrc
autowt_cd() { eval "$(autowt "$@" --terminal=echo)"; }
# fish - add to ~/.config/fish/config.fish
function autowt_cd
eval (autowt $argv --terminal=echo)
end
Then use: autowt_cd branch-name
Note: The shellconfig command supports bash, zsh, fish, tcsh/csh, nushell, oil shell, and elvish. For unsupported shells, it provides comprehensive fallback instructions covering common shell families.
Configure the default behavior:
autowt config
This opens an interactive TUI to set your preferred terminal mode.
Init Scripts
Run custom commands when switching to a worktree:
autowt branch-name --init "npm install && npm run dev"
The init script runs after changing to the worktree directory.
Project Configuration
Create an autowt.toml or .autowt.toml file in your project root to set a default init script:
init = "npm install && npm run dev"
This eliminates the need to pass --init every time. The command-line --init flag still overrides the config file setting.
State Management
autowt stores its state in platform-appropriate directories:
- macOS:
~/Library/Application Support/autowt/ - Linux:
~/.local/share/autowt/(or$XDG_DATA_HOME/autowt/) - Windows:
~/.autowt/
The state includes worktree locations, current branch tracking, and terminal session mappings for seamless switching.
Command Reference
autowt- List all worktrees (same asautowt ls)autowt [branch]- Create or switch to worktree for any branch nameautowt switch <branch>- Explicitly switch to a branch (useful when branch name conflicts with commands)autowt ls- List all worktrees and current locationautowt cleanup- Remove merged, identical, or remoteless worktreesautowt config- Configure terminal behavior using interactive TUIautowt shellconfig- Show shell integration instructions for your current shell (use--shellto override detection)
All commands support -h for help, -y/--yes for auto-confirmation, and --debug for verbose logging.
Installation
pip install autowt
For development:
git clone https://github.com/your-username/autowt
cd autowt
uv sync
Requirements
- Python 3.10+
- git with worktree support
- iTerm2 on macOS for best terminal integration (falls back to generic methods on other platforms)
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 autowt-0.1.0.tar.gz.
File metadata
- Download URL: autowt-0.1.0.tar.gz
- Upload date:
- Size: 109.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
456fa93f12035665bd812effb0dd2a58849b2b0f2f5f4040b3c4f018918fb005
|
|
| MD5 |
730db93f25cddf7dbe232c9c2fcd87c7
|
|
| BLAKE2b-256 |
41e419e0ee780286dba4ad132f38e59206b58a096a614ff03c5dd99727841f99
|
Provenance
The following attestation bundles were made for autowt-0.1.0.tar.gz:
Publisher:
pypi.yml on irskep/autowt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autowt-0.1.0.tar.gz -
Subject digest:
456fa93f12035665bd812effb0dd2a58849b2b0f2f5f4040b3c4f018918fb005 - Sigstore transparency entry: 289737580
- Sigstore integration time:
-
Permalink:
irskep/autowt@c4bc99c4037be56e7fb6260a907eea4c3889fcb7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/irskep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@c4bc99c4037be56e7fb6260a907eea4c3889fcb7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file autowt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: autowt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86cb5494f5fc4def240bc5f1f80ee06d604e922d88dfe529c414145c24bc114a
|
|
| MD5 |
d0db173d78493a6fff2f8f7d5607d926
|
|
| BLAKE2b-256 |
b0af0e614553c849b4b7bc490a0bd3fc6e134f2ecb782f695b99a5a9909524fc
|
Provenance
The following attestation bundles were made for autowt-0.1.0-py3-none-any.whl:
Publisher:
pypi.yml on irskep/autowt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autowt-0.1.0-py3-none-any.whl -
Subject digest:
86cb5494f5fc4def240bc5f1f80ee06d604e922d88dfe529c414145c24bc114a - Sigstore transparency entry: 289737613
- Sigstore integration time:
-
Permalink:
irskep/autowt@c4bc99c4037be56e7fb6260a907eea4c3889fcb7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/irskep
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@c4bc99c4037be56e7fb6260a907eea4c3889fcb7 -
Trigger Event:
push
-
Statement type: