A bash tool for safely running AI agents in isolated git worktrees. Create separate workspaces for each task, issue, or PR review - keeping your main branch pristine.

work/coral-apex-beamIMPORTANT: While git worktrees safely isolate branches and working directories, git itself is not designed for concurrent operations. Running multiple git commands simultaneously across different worktrees can cause repository corruption.
Safe - Worktrees prevent these problems:
Unsafe - Concurrent git commands can corrupt your repository:
# Running git operations in parallel across worktrees
cd worktree1 && git commit -m "change" &
cd worktree2 && git rebase main &
cd worktree3 && git push &
Git shares critical data across all worktrees:
.git/objects/ - Object database.git/refs/ - References.git/config - Configuration.git/hooks/ - HooksRunning concurrent git commands can corrupt this shared data, even though each worktree has its own branch and working directory.
Run git operations sequentially:
cd worktree1 && git commit -m "change"
cd worktree2 && git commit -m "change"
cd worktree3 && git rebase main
When using AI agents:
For more information:
brew install gum jq
For GitHub:
brew install gh
gh auth login
For GitLab:
brew install glab
glab auth login
For JIRA:
brew install ankitpokhrel/jira-cli/jira-cli
jira init
For Linear:
brew install schpet/tap/linear
# Or via Deno: deno install -A --reload -f -g -n linear jsr:@schpet/linear-cli
# Then set your API key:
export LINEAR_API_KEY=your_key_here # Get from https://linear.app/settings/account/security
For AI agents (choose one):
brew install claude or npm install -g @anthropic-ai/claude-codenpm install -g @openai/codex-cliAdd to your ~/.zshrc:
source /path/to/auto-worktree/aw.sh
This provides both the full auto-worktree command and a convenient aw shorthand alias that is worktree-aware:
aw automatically uses your local changesaw uses the globally-installed versionaw is just shorter to typeUse either the full auto-worktree command or the shorter aw alias:
aw # Interactive menu
aw new # Create new worktree
aw issue [id] # Work on an issue (GitHub #123, GitLab #456, JIRA PROJ-123, or Linear TEAM-123)
aw pr [num] # Review a GitHub PR or GitLab MR
aw list # List existing worktrees
aw settings # Configure per-repo settings
aw doctor # Run repository diagnostics (check for lock files, etc.)
aw help # Show help
Note: aw and auto-worktree work identically. All examples below use aw for brevity.
aw new
Enter a branch name or leave blank for a random name like work/mint-code-flux.
The first time you run aw issue, you'll be prompted to choose between GitHub, GitLab, JIRA, or Linear for this repository. This preference is stored in git config.
GitHub Issues:
aw issue # Select from open issues
aw issue 42 # Work on issue #42 directly
Creates a branch like work/42-fix-login-bug and launches your AI agent.
GitLab Issues:
aw issue # Select from open GitLab issues
aw issue 42 # Work on issue #42 directly
Creates a branch like work/42-fix-login-bug and launches your AI agent.
JIRA Issues:
aw issue # Select from open JIRA issues
aw issue PROJ-123 # Work on JIRA-123 directly
Creates a branch like work/PROJ-123-implement-feature and launches your AI agent.
Linear Issues:
aw issue # Select from open Linear issues
aw issue TEAM-123 # Work on Linear issue TEAM-123 directly
Creates a branch like work/TEAM-123-implement-feature and launches your AI agent.
aw pr # Select from open PRs
aw pr 123 # Review PR #123 directly
Checks out the PR in a new worktree and shows the diff stats.
aw list
Shows all worktrees with:
Issue provider settings are stored per-repository using git config. Use the
interactive Settings menu (or aw settings) to view and update project-specific
preferences.
# View current configuration
git config --get auto-worktree.issue-provider # github, gitlab, jira, or linear
# Manual configuration for JIRA
git config auto-worktree.issue-provider jira
git config auto-worktree.jira-server https://your-company.atlassian.net
git config auto-worktree.jira-project PROJ # Optional: default project filter
# Manual configuration for GitLab
git config auto-worktree.issue-provider gitlab
git config auto-worktree.gitlab-server https://gitlab.example.com # Optional: for self-hosted
git config auto-worktree.gitlab-project group/project # Optional: default project filter
# Manual configuration for Linear
git config auto-worktree.issue-provider linear
git config auto-worktree.linear-team TEAM # Optional: default team filter
# Manual configuration for AI and auto-select
git config auto-worktree.ai-tool claude # claude, codex, gemini, jules, skip
git config auto-worktree.issue-autoselect true # true/false
git config auto-worktree.pr-autoselect true # true/false
Different repositories can use different issue providers and AI tool configurations.
~/worktrees/<repo-name>/--dangerously-skip-permissions for uninterrupted worklist to clean up merged worktrees and branches# Start work on a GitHub issue
cd my-project
aw issue 42
# AI agent opens in ~/worktrees/my-project/work-42-add-feature/
# Make changes, commit, push, create PR
# Later, check for cleanup
aw list
# Shows "[merged #42]" indicator, prompts to clean up
# First time setup
cd my-work-project
aw issue
# Choose "JIRA" from the menu
# Enter JIRA server URL and project key
# Start work on a JIRA ticket
aw issue PROJ-456
# AI agent opens in ~/worktrees/my-work-project/work-PROJ-456-add-auth/
# Make changes, commit, push
# Later, when JIRA ticket is marked as Done
aw list
# Shows "[resolved PROJ-456]" indicator, prompts to clean up
# First time setup
cd my-product-project
aw issue
# Choose "Linear Issues" from the menu
# Optionally enter default team key
# Start work on a Linear issue
aw issue TEAM-789
# AI agent opens in ~/worktrees/my-product-project/work-TEAM-789-add-feature/
# Make changes, commit, push
# Later, when Linear issue is marked as Done
aw list
# Shows "[completed TEAM-789]" indicator, prompts to clean up
The tool includes full zsh completion for both aw and auto-worktree:
aw <TAB> # Shows: new, issue, pr, list, settings, help
aw issue <TAB> # Shows open issues from GitHub
aw pr <TAB> # Shows open PRs from GitHub
This project uses ShellCheck to validate shell scripts and catch common bugs, portability issues, and code quality problems.
To validate all shell scripts in the repository:
ci/validate.sh
This will check all .sh files and report any issues found.
Install the pre-commit hook to automatically validate shell scripts before each commit:
ci/install_pre_commit_hook.sh
The hook will run ShellCheck on staged .sh files and prevent commits if issues are found. To bypass the hook for a single commit (not recommended):
git commit --no-verify
To uninstall the hook:
rm .git/hooks/pre-commit
ShellCheck validation runs automatically on all pull requests via GitHub Actions. PRs must pass validation before they can be merged.
The .shellcheckrc file configures which checks are enabled. Currently, many warnings are disabled to allow gradual improvement. As issues are fixed, warnings will be progressively enabled.
macOS:
brew install shellcheck
Ubuntu/Debian:
sudo apt-get install shellcheck
Other platforms: See ShellCheck installation instructions
When using auto-worktree with AI agents like Claude Code, background git operations can sometimes leave stale lock files that interfere with worktree operations.
fatal: Unable to create '.git/index.lock': File exists.
Another git process seems to be running in this repository...
1. Run the doctor command:
aw doctor --check-locks
This will detect and report any stale lock files. To automatically remove them:
aw doctor --check-locks --remove-locks
2. Automatic detection:
Auto-worktree now includes:
3. Manual cleanup:
If needed, you can manually remove all lock files:
find .git -name '*.lock' -type f -delete
The lock file handling is designed to work seamlessly with AI agents:
For more information, see Issue #175.
MIT
116 commits
Hacker News (1)
Shell
100.0%
A bash tool for safely running AI agents in isolated git worktrees. Create separate workspaces for each task, issue, or PR review - keeping your main branch pristine.

work/coral-apex-beamIMPORTANT: While git worktrees safely isolate branches and working directories, git itself is not designed for concurrent operations. Running multiple git commands simultaneously across different worktrees can cause repository corruption.
Safe - Worktrees prevent these problems:
Unsafe - Concurrent git commands can corrupt your repository:
# Running git operations in parallel across worktrees
cd worktree1 && git commit -m "change" &
cd worktree2 && git rebase main &
cd worktree3 && git push &
Git shares critical data across all worktrees:
.git/objects/ - Object database.git/refs/ - References.git/config - Configuration.git/hooks/ - HooksRunning concurrent git commands can corrupt this shared data, even though each worktree has its own branch and working directory.
Run git operations sequentially:
cd worktree1 && git commit -m "change"
cd worktree2 && git commit -m "change"
cd worktree3 && git rebase main
When using AI agents:
For more information:
brew install gum jq
For GitHub:
brew install gh
gh auth login
For GitLab:
brew install glab
glab auth login
For JIRA:
brew install ankitpokhrel/jira-cli/jira-cli
jira init
For Linear:
brew install schpet/tap/linear
# Or via Deno: deno install -A --reload -f -g -n linear jsr:@schpet/linear-cli
# Then set your API key:
export LINEAR_API_KEY=your_key_here # Get from https://linear.app/settings/account/security
For AI agents (choose one):
brew install claude or npm install -g @anthropic-ai/claude-codenpm install -g @openai/codex-cliAdd to your ~/.zshrc:
source /path/to/auto-worktree/aw.sh
This provides both the full auto-worktree command and a convenient aw shorthand alias that is worktree-aware:
aw automatically uses your local changesaw uses the globally-installed versionaw is just shorter to typeUse either the full auto-worktree command or the shorter aw alias:
aw # Interactive menu
aw new # Create new worktree
aw issue [id] # Work on an issue (GitHub #123, GitLab #456, JIRA PROJ-123, or Linear TEAM-123)
aw pr [num] # Review a GitHub PR or GitLab MR
aw list # List existing worktrees
aw settings # Configure per-repo settings
aw doctor # Run repository diagnostics (check for lock files, etc.)
aw help # Show help
Note: aw and auto-worktree work identically. All examples below use aw for brevity.
aw new
Enter a branch name or leave blank for a random name like work/mint-code-flux.
The first time you run aw issue, you'll be prompted to choose between GitHub, GitLab, JIRA, or Linear for this repository. This preference is stored in git config.
GitHub Issues:
aw issue # Select from open issues
aw issue 42 # Work on issue #42 directly
Creates a branch like work/42-fix-login-bug and launches your AI agent.
GitLab Issues:
aw issue # Select from open GitLab issues
aw issue 42 # Work on issue #42 directly
Creates a branch like work/42-fix-login-bug and launches your AI agent.
JIRA Issues:
aw issue # Select from open JIRA issues
aw issue PROJ-123 # Work on JIRA-123 directly
Creates a branch like work/PROJ-123-implement-feature and launches your AI agent.
Linear Issues:
aw issue # Select from open Linear issues
aw issue TEAM-123 # Work on Linear issue TEAM-123 directly
Creates a branch like work/TEAM-123-implement-feature and launches your AI agent.
aw pr # Select from open PRs
aw pr 123 # Review PR #123 directly
Checks out the PR in a new worktree and shows the diff stats.
aw list
Shows all worktrees with:
Issue provider settings are stored per-repository using git config. Use the
interactive Settings menu (or aw settings) to view and update project-specific
preferences.
# View current configuration
git config --get auto-worktree.issue-provider # github, gitlab, jira, or linear
# Manual configuration for JIRA
git config auto-worktree.issue-provider jira
git config auto-worktree.jira-server https://your-company.atlassian.net
git config auto-worktree.jira-project PROJ # Optional: default project filter
# Manual configuration for GitLab
git config auto-worktree.issue-provider gitlab
git config auto-worktree.gitlab-server https://gitlab.example.com # Optional: for self-hosted
git config auto-worktree.gitlab-project group/project # Optional: default project filter
# Manual configuration for Linear
git config auto-worktree.issue-provider linear
git config auto-worktree.linear-team TEAM # Optional: default team filter
# Manual configuration for AI and auto-select
git config auto-worktree.ai-tool claude # claude, codex, gemini, jules, skip
git config auto-worktree.issue-autoselect true # true/false
git config auto-worktree.pr-autoselect true # true/false
Different repositories can use different issue providers and AI tool configurations.
~/worktrees/<repo-name>/--dangerously-skip-permissions for uninterrupted worklist to clean up merged worktrees and branches# Start work on a GitHub issue
cd my-project
aw issue 42
# AI agent opens in ~/worktrees/my-project/work-42-add-feature/
# Make changes, commit, push, create PR
# Later, check for cleanup
aw list
# Shows "[merged #42]" indicator, prompts to clean up
# First time setup
cd my-work-project
aw issue
# Choose "JIRA" from the menu
# Enter JIRA server URL and project key
# Start work on a JIRA ticket
aw issue PROJ-456
# AI agent opens in ~/worktrees/my-work-project/work-PROJ-456-add-auth/
# Make changes, commit, push
# Later, when JIRA ticket is marked as Done
aw list
# Shows "[resolved PROJ-456]" indicator, prompts to clean up
# First time setup
cd my-product-project
aw issue
# Choose "Linear Issues" from the menu
# Optionally enter default team key
# Start work on a Linear issue
aw issue TEAM-789
# AI agent opens in ~/worktrees/my-product-project/work-TEAM-789-add-feature/
# Make changes, commit, push
# Later, when Linear issue is marked as Done
aw list
# Shows "[completed TEAM-789]" indicator, prompts to clean up
The tool includes full zsh completion for both aw and auto-worktree:
aw <TAB> # Shows: new, issue, pr, list, settings, help
aw issue <TAB> # Shows open issues from GitHub
aw pr <TAB> # Shows open PRs from GitHub
This project uses ShellCheck to validate shell scripts and catch common bugs, portability issues, and code quality problems.
To validate all shell scripts in the repository:
ci/validate.sh
This will check all .sh files and report any issues found.
Install the pre-commit hook to automatically validate shell scripts before each commit:
ci/install_pre_commit_hook.sh
The hook will run ShellCheck on staged .sh files and prevent commits if issues are found. To bypass the hook for a single commit (not recommended):
git commit --no-verify
To uninstall the hook:
rm .git/hooks/pre-commit
ShellCheck validation runs automatically on all pull requests via GitHub Actions. PRs must pass validation before they can be merged.
The .shellcheckrc file configures which checks are enabled. Currently, many warnings are disabled to allow gradual improvement. As issues are fixed, warnings will be progressively enabled.
macOS:
brew install shellcheck
Ubuntu/Debian:
sudo apt-get install shellcheck
Other platforms: See ShellCheck installation instructions
When using auto-worktree with AI agents like Claude Code, background git operations can sometimes leave stale lock files that interfere with worktree operations.
fatal: Unable to create '.git/index.lock': File exists.
Another git process seems to be running in this repository...
1. Run the doctor command:
aw doctor --check-locks
This will detect and report any stale lock files. To automatically remove them:
aw doctor --check-locks --remove-locks
2. Automatic detection:
Auto-worktree now includes:
3. Manual cleanup:
If needed, you can manually remove all lock files:
find .git -name '*.lock' -type f -delete
The lock file handling is designed to work seamlessly with AI agents:
For more information, see Issue #175.
MIT
Hacker News (1)
116 commits
Shell
100.0%