gwt creates a git worktree, clones submodules at their latest branch HEAD,
then launches your coding agent — all in one command. No agent config needed:
it auto-detects what's on your machine.
gwt my-feature # worktree + auto-detected agent (pi > codex > …)
gwt -w claude fix-bug # worktree + specific agent
gwt --no-agent scratch # worktree only
git worktree add is great, but git submodule update --init afterwards
breaks when the pinned SHA was garbage-collected or force-pushed.
gwt clones each submodule directly from its branch HEAD — never stale.
And since you're going to open a coding session anyway, it launches the agent
too. Just gwt fix-login and you're coding.
Zero sudo. Clone and add two lines to your shell rc.
git clone https://github.com/4ier/gwt.git ~/code/gwtThen in ~/.zshrc (or ~/.bashrc):
export PATH="$HOME/code/gwt:$PATH" # gwt, gwt-doctor on PATH
source ~/code/gwt/init.sh # gwt() wrapper functionOptional:
export GWT_WITH=pi # override auto-detect
export GWT_SUB_BRANCH=develop # default submodule branchgwt picks your agent in this order:
| Priority | Source | Example |
|---|---|---|
1. -w flag |
Explicit | gwt -w codex feat |
2. GWT_WITH env |
Persistent default | export GWT_WITH=claude |
| 3. Auto-detect | First on PATH | pi → codex → claude → gemini → agent → … |
| 4. Fallback | No agent found | Plain worktree, prints path |
Aliases work anywhere in the chain because the wrapper uses eval exec:
alias claude-a='claude --dangerously-skip-permissions'
gwt -w claude-a fix # alias expands fine# Default: worktree + auto-detect agent
gwt my-feature # → creates worktree, launches pi (if installed)
# Pick an agent
gwt -w claude fix-bug # → worktree + claude
gwt -w codex experiment # → worktree + codex
# Worktree only
gwt --no-agent scratch # → prints path, no agent launched
# Custom base branch
gwt -b develop hotfix # → from develop, not main
# Sync before work
gwt --sync my-feature # → pull latest, update submodule pointers, then agent
# Preview
gwt --dry-run testgwt (shell function) → gwt.sh (bash subprocess) → git worktree + submodules
│ │
└─ resolve agent └─ porcelain output (stdout = path)
eval exec $agent
gwt.sh— the engine. Creates worktree, handles submodules. stdout = path.init.sh— the wrapper.sourceit to get thegwt()function. Agent resolution, theneval exec.doctor.sh— self-check. Shows what agents are available and which onegwtwill pick.
| Scenario | Behaviour |
|---|---|
Plain repo (no .gitmodules) |
Simple git worktree add |
| Repo with submodules | Worktree + each submodule cloned from branch HEAD |
| Branch fallback per submodule | .gitmodules annotation → main → remote HEAD |
gwt-doctorChecks: bash, zsh, git, worktree support, PATH, agent auto-detection, SSH.
- Default agent-first.
gwt fix-logindoes everything — you're coding immediately. - Zero config. No agent installed? Detects it and falls back to plain worktree.
- Pure engine.
gwt.shdoes one job: create a worktree. One output: a path. - Thin wrapper.
init.shis ~40 lines. Agent resolution,cd,eval exec. - No sudo. Add the repo directory to
$PATH. - No project coupling. Reads
.gitmodules— works with any git repo. - Cross-platform. bash 3.2+ / zsh 5+. macOS, Linux.
gwt = git worktree. Three letters, says exactly what it does.
Originally named ame (anemone / 海葵, from Finding Nemo) because each worktree is a safe place to grow code.
MIT