Overview

When an agent writes code, the mental context you would normally have does not exist. Git fills that gap - it records what changed, lets you see it, and lets you undo it. The core principles are the same for everyone. The workflow is not.

Choose your guide

The three rules that apply to everyone

Save state before sessions
Commit your current state before any agent session starts. If the session produces bad output, you have a clean return point.
Review what changed
After the agent works, look at the diff before accepting anything. Look for files you did not expect to change, deleted content, and new dependencies.
Commit in small pieces
One agent session should not be one giant commit. Break it by logical unit so you can revert precisely if something breaks later.