Workflow

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.

by NightMe team 6 min read

One branch, one worktree, one agent, one PR. Run three of them in parallel — the rest of your main stays clean.

/gtw (Git Team Workflow) is NightMe's opinionated take on "AI opened a PR." It's a single short-lived loop that:

  1. Cuts a fresh git worktree off your just-up-to-date main.
  2. Runs shell hooks to set up the worktree (think npm install, go mod download).
  3. Hands the worktree to a one-shot agent session.
  4. Lets you /gtw close to 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:

  1. Runs git fetch origin <base> and git worktree add ../<repo>-<branch> -b <branch> <base>.
  2. Triggers gtw.hooks.before (configurable in ~/.nightme/gtw.yml) — typically ./scripts/worktree-setup.sh, which runs npm ci, go mod download, etc.
  3. Switches the chat's CWD to the new worktree (only for this chat — others are unaffected).
  4. 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:

  1. Runs git status to confirm the worktree is committable (no uncommitted changes, no merge markers).
  2. Runs gtw.hooks.after — typically a formatter and a test suite. Failures halt the close and tell you why.
  3. Optionally pushes: pass --push to push the branch, or --push --pr to additionally run gh pr create with 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 — /gtw is short-lived by design. For multi-day refactors, drop /gtw, set up a normal chat, and use /share with a second chat for steering. See Run agents in parallel.
  • Hot patches to a running service — /gtw doesn't reload your service after pushing. That's still your job.

What's next