Agents are powerful git collaborators — and powerful git hazards. A solid Claude Code git workflow keeps changes reviewable, reversible, and CI-friendly.
Start on a branch
Never run open-ended tasks on main. Create feature/short-description, push early, and let CI catch regressions while you iterate locally.
Scope prompts to the branch goal
Tie each session to one ticket: "Add rate limiting to POST /api/orders" beats "improve backend." Link acceptance criteria and files likely involved.
Review diffs like a human PR
- Read every hunk — agents miss business rules.
- Watch for drive-by refactors unrelated to the ticket.
- Run tests locally even if the agent claims success.
Commit hygiene
Prefer small commits with clear messages. Squash before merge if your team standardizes history. Attach test output in PR descriptions when changes are risky.
Working with remotes
Pull/rebase before long agent runs to avoid massive conflicts. For submodules or LFS repos, mention constraints in AGENTS.md.
Rollback plan
Tag known-good commits before experimental agent sessions. git reset --hard is cheaper than manual file surgery.
New to the tool? Begin with install guide and a toy repo before touching production services.
Ready to install Claude Code? Start on our download page, then use the official installer.
Open download page Official download