Git - Teams
Branching protocol, PRs, and keeping shared history protected.
Overview
In a team, agent-generated code that reaches main without review is a shared risk. The protocol is strict because the consequences are shared. Every rule here exists because the cost of getting it wrong falls on more than one person.
Not sure which guide is right for you? See all three profiles.
The branch rule - not optional
Never let the agent modify main directly. Every agent session starts on a branch:
git checkout -b agent/feature-name The naming convention matters. agent/ as a prefix makes it immediately clear in the commit history and PR list what came from an agent session versus human work. Your team can filter, review, and track it.
Before the session
Commit your current state before the agent starts working. This gives you a clean rollback point and a clear before/after boundary in the history:
git add -A
git commit -m "checkpoint: before agent session" Reviewing the diff
After the agent works, review before staging anything:
git diff Committing and pushing
Commit by logical unit, not by session. One PR should tell one coherent story:
git add src/lib/components/NewComponent.svelte
git commit -m "add NewComponent"
git add src/lib/components/index.ts
git commit -m "export NewComponent from barrel"
git push origin agent/feature-name
# open PR from here The team protocol
agent/ prefix so it is visible in history.Recovery patterns
git reset --soft HEAD~1git reset --hard HEAD~1git checkout HEAD~1 -- path/to/file.tsgit stash
git stash pop # restore
git stash drop # discard