Recommended patterns
- Use branch-per-run for non-trivial agent tasks.
- Treat
mainas promoted, reviewed state. - Scope API keys to the minimum required permissions.
- Add metadata in commit messages so runs are traceable.
Operational practices
- Track commit and merge latency in your critical paths.
- Enforce repository naming conventions and limits.
- Keep human review workflows for high-impact changes.
Repo-per-project
Use a separate repository for each project or similar concept in your application. This keeps history focused, reduces noisy diffs, and lets you apply permissions and retention policies per project. Use this when projects are logically independent and typically reviewed/deployed separately. Some examples of how to decide what’s a repo and what isn’t:- n8n-style workflows: each workflow is a separate repo
- app builder: each user app is a separate repo
- coding agents: each user codebase is a separate repo
- VMs & infra: each user volume is a separate repo
Checkpoint-per-prompt
Create a checkpoint after each user prompt. This gives you a clean timeline of intent, makes undo/redo straightforward, and lets you restore the repository to a known good state if a later step goes wrong. Recommended for:- conversational coding agents,
- iterative content generation,
- any workflow where users expect “undo last prompt” behavior.
Branch-per-session
Create one branch per user session/chat/run instead of mixing multiple sessions on one branch. Each session can evolve independently, and you can merge or discard without affecting parallel work. Recommended naming:session/<session-id> or proposal/<feature-name>-<run-id>.
Short-lived branches
Keep branches temporary. Merge approved work quickly and delete abandoned branches. Short-lived branches reduce drift frommain, lower conflict rates, and make reviews easier because diffs stay small.
Good rule of thumb: if a branch has been idle for a while, either refresh it from main or close it.
Approvals (branch + diff endpoint)
Use a proposal branch for all non-trivial changes, then show users a diff before merge:- Agent writes to a proposal branch.
- Use structured diff endpoint to compare the changes to main.
- Render the diff in your UI in a way that makes sense for your app.
- On user approval, merge proposal into
main. - On reject, keep the branch for iteration or discard it.

