Start Claude Code on a branch in its own worktree
When an agent works on a task, it should use its own branch and leave the files you’re editing alone. git worktrees do that: they let you have more than one checkout of the same repository.
Every branch and every pull request in gitto has Open in Claude Code in its menu. It starts a Claude Code session on that branch:
- in the worktree that already has the branch checked out, which can be the repository itself;
- otherwise in a new worktree next to the repository, called
{repo}-{branch}. gitto creates it for you.
For a pull request, the worktree starts from the pull request’s head, so the agent works on the code you are reviewing. This also works for repositories over SSH. The worktree is then on the server.
Save your prompts as commands
You probably write some prompts over and over, for example “fix the review comments” or “update the changelog”. You can save them as custom commands of type Claude Code. They appear in the menu of every branch and pull request and in Quick Launch, and you can give them a shortcut.
gitto replaces these variables in the prompt:
| Variable | Value |
|---|---|
$BRANCH |
The branch. |
$BASE |
The pull request’s base branch, or the default branch. |
$PR |
The pull request’s number, like #12. |
$TITLE |
The pull request’s title. |
$REPO |
The path of the repository. |
The prompt is typed in but not sent, so you can add to it before the agent starts.
Rebase with Claude
Rebasing a branch with many conflicts is slow work, and the commits on both sides explain what each change was for. That makes it a good task for an agent. gitto comes with this command:
Rebase `$BRANCH` onto the latest `$BASE` from the
remote and resolve the merge conflicts, keeping the
intent of both sides. Run the tests, then push with
--force-with-lease.
There is also Rebase on Parent Branch, which is a script. It stashes your changes, updates the branch the current
one was created from, and rebases on it. If the rebase stops on conflicts and Claude Code is installed, it runs
claude -p to resolve them and the rebase continues. Without Claude Code, you resolve the conflicts in gitto, block
by block.
Both are normal custom commands. You can read the prompt and the script in the settings, change them or delete them.
See the agent session behind a commit
If you use Entire, the agent sessions are saved in the repository next to the commits they made. gitto shows them:
- A commit made by an agent has a Session tab with the conversation: the prompt, what the agent did and what it answered.
- A bar shows how many of the committed lines the agent wrote and how many you wrote.
- The Sessions view lists all sessions in the repository by day, with the commits of each one. Click a session to go to its commits.
This helps during a review. When a change looks strange, the prompt often explains it.
Review the agent’s pull request
When the agent pushes a pull request, you can review it in gitto. You see all files on one page, comments under the lines, suggestions and the Merge card. If something needs fixing, use Open in Claude Code on the pull request to start a new session on it.
Questions
How does gitto start Claude Code?
It opens the Code tab of the Claude desktop app in the right folder. Your prompt is typed in but not sent, so you can read it and change it first.
Why a worktree?
A worktree is a second checkout of the same repository. The agent works on its branch there, and your own checkout stays untouched. gitto uses the worktree that already has the branch checked out, or creates a new one next to the repository.
Does it work on a repository over SSH?
Yes. gitto creates the worktree on the server and starts Claude Code there. See repositories over SSH.
What is Entire?
Entire is a command line tool that saves agent sessions in the repository, next to the commits they made. If a repository has them, gitto shows them.
Do I need Claude Code to use gitto?
No. gitto works as a git client without it. The Claude Code commands are there if you want them, and you can delete them.