Your coding agent needs PR discipline (or it'll ship straight to main)
Your coding agent can write code faster than you can review it. That's the problem.
Most people set up their coding agents like this: give it repository access, point it at an issue, watch it commit directly to main. It feels productive until you realize you have no idea what changed, why, or whether it actually works.
The solution isn't to slow down the agent. It's to give it PR discipline.
Here's the pattern that works:
CODING_WORKFLOW = {
"branch_first": "git checkout -b agent/task-{timestamp}",
"commit_often": "Small, logical commits with clear messages",
"pr_when_done": "Never push to main. Always open a PR.",
"self_review": "Review your own diff before requesting human review"
}The magic happens in the self-review step. Your agent should read its own diff and ask:
- Does this actually solve the stated problem?
- Are there any obvious bugs or edge cases?
- Is the code readable and well-documented?
- Are there any security implications?
Here's how I configure this in practice:
## PR Review Checklist Before opening a PR, review your own changes: 1. Run `git diff main` and read every line 2. Test the happy path and at least one error case 3. Check that your changes match the original requirements 4. Write a PR description that explains WHAT and WHY 5. Tag any areas where you're unsure for human review Never commit directly to main. Never skip the self-review.
The PR description is crucial. Your agent should explain not just what it changed, but why it made those specific choices. This creates an audit trail that future you (or future agents) can follow.
Pro tip: Set up branch protection rules that require PR reviews, even from agents. This forces the discipline at the infrastructure level.
I've seen agents catch their own bugs during self-review that would have made it to production otherwise. The extra 30 seconds of reflection prevents hours of debugging later.
The best part? This pattern scales. Whether you have one coding agent or five, they all follow the same discipline. No more mystery commits. No more "wait, when did this change?" No more rolling back agent changes because you can't figure out what they were trying to do.
Your codebase becomes a conversation between you and your agents, not a black box where code appears and disappears.