Start work in a copy
Work on Agents never happens on main. Each task gets a copy of the repo, a git worktree on a branch of its own off GitHub’s main, with its own node_modules. agents-git makes the copy and tracks it in a ledger, so several people and agents can work at once without touching each other’s files. This page is for anyone who changes the repo, by hand or through an agent.
Before you start
Section titled “Before you start”- Check out the repo, with
.envand.env.testin the main checkout. The README’s “Set up a working copy” section writes both. - Put
~/.local/node/binfirst onPATH. - Install the
ghcommand.agents-git statusandfinishask GitHub through it. - Have Docker running if you will run checks. Run the checks explains why.
Make a copy
Section titled “Make a copy”-
From the main checkout, run:
Terminal window node daemon/agents-git/main.ts start <name> --note "<what you work on>"A name is 1 to 63 lowercase letters, digits and dashes, and cannot be
mainorHEAD. It becomes the branch, the folder and the ledger entry. -
Wait for
npm ci. The command fetches GitHub’smainfirst, then makes the copy in<repo>-worktrees/<name>, beside the repo. It prints the path. -
Change into the copy and link the main checkout’s two env files into it. Git ignores both, so
startdoes not carry them, and the checks andagentsctlread them from the copy.Terminal window ln -s <main checkout>/.env .envln -s <main checkout>/.env.test .env.test -
Make every edit and commit in the copy.
start refuses, and changes nothing, when the ledger already has the name, the branch exists, the folder exists, or the main checkout has uncommitted files. If npm ci fails, it takes the copy back and you can run it again with the same name.
Install the guard and the hooks
Section titled “Install the guard and the hooks”Run these once on a machine.
node daemon/agents-git/main.ts guard installnode daemon/agents-git/main.ts hooks installguard install writes git’s reference-transaction hook into the repo’s shared .git, so it covers every copy and every tool that runs git. The hook refuses to move main to anything but origin/main, and refuses to make a stash entry. It also installs a post-commit hook that warns when a commit leaves the branch over the size cap, and a prepare-commit-msg hook that adds a Session: <id> trailer to a commit a Claude Code session makes with -m or -F. guard status says whether the hooks are there.
hooks install adds three hooks to Claude Code’s settings in ~/.claude/settings.json and Codex’s in ~/.codex/hooks.json. They run the scripts in the main checkout. Codex runs a hook only once you trust it in /hooks.
- The session-start hook runs
agents-git statusas a session starts in a copy. - The before-tool hook refuses
git stash, a push tomain,gh pr merge,git add -A,git add --all,git add ., a baresleep, and any command it crashes reading, and says what to run instead. Name the paths you stage, withgit add <paths>. - The stop hook runs
agents-git finishas each turn ends, when the copy is clean and ahead oforigin/main.
agents-git sweep finishes every copy that is clean, ahead of origin/main, and idle for 15 minutes. It is meant to run every 5 minutes under launchd on the developer’s Mac, through ops/com.agents.sweeper.plist.
Check where you stand
Section titled “Check where you stand”Run agents-git status from the copy. It prints the branch against origin/main, the size against the line cap, the branch’s pull request and its checks, every open pull request, and the next command to run. agents-git size prints the size alone, from what the machine last fetched, with no network.
Start a session nobody types into
Section titled “Start a session nobody types into”node daemon/agents-git/main.ts session <name> --note "<text>" --job "<text>" --done "<check>"This runs start, then a Claude session in the copy inside a herdr pane, with the playbook plugin loaded. How a session loads the playbooks explains the first message. The command prints how to attach, take over, and wait for the session to go idle.
Keep track of your copies
Section titled “Keep track of your copies”agents-git listshows every worktree, tracked or not, and where the ledger and git disagree.agents-git adopt <path> [--name <name>] [--note <text>]tracks a worktree that exists, without changing it.agents-git save <name>keeps a copy’s uncommitted work in a ref and leaves the copy as it is.agents-git sync <name>brings localmaininto the branch, by a rebase, or by a merge once the branch is submitted.agents-git done <name>previews what it would remove. Add--yesto save the last commit, remove the copy, and delete the branch oncemainhas it. It refuses when an ignored path would be lost, and--backup <path>copies one to~/.agents-app/backupsfirst.agents-git prunerunsdonefor each copy that is merged and clean, or whose folder is gone. It previews until you add--yes.