Git Branch Hygiene for Multi-Agent Teams
When multiple agents push frequently, branch hygiene matters more than speed. Clear branch conventions prevent accidental merges and review confusion.
Step 1: Enforce branch naming contracts
^codex/[a-z0-9-]+$
Step 2: Block direct pushes to protected main
git config receive.denyCurrentBranch updateInstead
# plus server-side protected branch policy
Step 3: Require branch cleanup after merge
git branch --merged main | rg '^\s*codex/' | xargs -r git branch -d
Common pitfall
Long-lived agent branches with mixed unrelated changes. Reviewers lose context and risk increases.
What to check
- Every PR maps to one focused branch intent.
- Merged branches are removed quickly.
- Branch policy violations are blocked automatically.