Use `/gtw` for one-shot fixes
One branch, one worktree, one agent, one PR. Run three of them in parallel — the rest of your `main` stays clean.
One branch, one worktree, one agent, one PR. Run three of them in parallel — the rest of your
mainstays clean.
/gtw (Git Team Workflow) is NightMe's opinionated take on "AI opened a PR." It's a single short-lived loop that:
- Cuts a fresh
git worktreeoff your just-up-to-datemain. - Runs shell hooks to set up the worktree (think
npm install,go mod download). - Hands the worktree to a one-shot agent session.
- Lets you
/gtw closeto push the branch and open a PR when you're happy.
The point: parallel agents that don't collide on shared state. Each /gtw is fully isolated by the filesystem and by git, so you can run three at once and ship them one by one.
TL;DR
/gtw fix -n fix/parser-nom
Refactor src/parser.rs to use nom. Add tests.
(… agent runs, you /diff from your phone …)
/gtw push
The agent's edits land on fix/parser-nom in a worktree off main. /gtw push opens a PR. Your main chat never knew any of this was happening.
Anatomy of a /gtw fix
/gtw fix -n <branch> [--agent claude] [--base main]
| Flag | Default | Notes |
|---|---|---|
-n <branch> |
required | New branch name. Convention is fix/<slug>, feat/<slug>, or whatever your team uses. |
--agent <name> |
inherited from chat | Override the chat's current agent for this worktree only. |
--base <ref> |
main (or whatever your chat's gtw.base says) |
The ref to branch off. Pass a release branch if you're patching a release line. |
Behind the scenes NightMe:
- Runs
git fetch origin <base>andgit worktree add ../<repo>-<branch> -b <branch> <base>. - Triggers
gtw.hooks.before(configurable in~/.nightme/gtw.yml) — typically./scripts/worktree-setup.sh, which runsnpm ci,go mod download, etc. - Switches the chat's CWD to the new worktree (only for this chat — others are unaffected).
- Hands the next message to the agent as a one-shot task with an isolated history.
The chat card, mid-/gtw
Once the worktree is up, the bot's status card updates to:
CWD: ../nightme-fix-parser-nom
Git: branch=fix/parser-nom · clean
Agent: claude · /gtw fix · 3k tokens
The "Git · clean" comes from the freshly-created worktree. As the agent edits files, the card flips to "Git · dirty" and the diff count climbs. You'll glance at the card and know exactly when the agent's worth interrupting.
Closing a /gtw
/gtw close
This:
- Runs
git statusto confirm the worktree is committable (no uncommitted changes, no merge markers). - Runs
gtw.hooks.after— typically a formatter and a test suite. Failures halt the close and tell you why. - Optionally pushes: pass
--pushto push the branch, or--push --prto additionally rungh pr createwith a templated body.
If you don't want to push yet, omit --push and you'll be left on the worktree with the branch ready locally. You can /gtw close --push --pr later from the same chat.
Running three /gtw in parallel
Open three chats. In each:
/cwd ~/code/ntme-driver
/gtw fix -n fix/parser-nom → chat 1
/gtw fix -n fix/config-crlf → chat 2
/gtw fix -n feat/cli-flags → chat 3
Each chat now has its own worktree (../ntme-driver-fix-parser-nom, etc.). Each runs its own Claude Code process. Each edit lives on its own branch. /cwd in chat 1 doesn't move chat 2.
When all three are done, review the diffs (/diff per chat) and close them one by one. Each /gtw close --push --pr opens a separate PR — no merge conflicts between them because none of them touch the same files.
When /gtw is the wrong tool
- Quick typo fixes — a one-line commit doesn't need a worktree. Just do it in the chat's normal CWD.
- Long-running migrations —
/gtwis short-lived by design. For multi-day refactors, drop/gtw, set up a normal chat, and use/sharewith a second chat for steering. See Run agents in parallel. - Hot patches to a running service —
/gtwdoesn't reload your service after pushing. That's still your job.
What's next
- Write your first
/gtwconfig — wire upnpm ciand a linter so every worktree starts clean. - Install NightMe on Windows —
/gtwis fully supported; just confirmghis onPATH.