Shipping with Guardrails
Every agent-written change gets reviewed before it merges. Every deploy passes gates. Every alert opens a specific page. Here's the discipline that makes autonomy safe.
5 min read
I run a team of AI agents that ship real code. They write patches, open PRs, and merge to production. That's only safe because every change gets reviewed, every deploy passes gates, and every failure has a name.
Here's the discipline that makes autonomy work.
The first rule: a closed loop#
Agents open pull requests. The system reviews them, and once the checks and balances pass, it merges them. That's the contract.
The agent writes the patch, runs lint and tests, and opens the PR. Then the loop takes over. The code reviews itself. The gates run. If they pass, the system merges. I don't sit on every diff. I design the loop and the checks.
That loop is part of what I call the rock tumbler strategy. Work keeps cycling through the checks until it's polished, the way a tumbler runs stones through coarser, then finer, grit. A change that can't pass doesn't ship. A change that does pass doesn't wait on me.
Deterministic gates before review#
Before a PR can merge, the change has already passed deterministic checks:
- Lint. Code formatting, unused imports, naming conventions. If lint fails, the agent fixes it or the task escalates.
- Typecheck. TypeScript errors, missing types, any-escapes. If typecheck fails, the agent fixes it or the task escalates.
- Tests. Unit tests, integration tests, browser journeys. If tests fail, the agent fixes them or the task escalates.
- Secret scan. API keys, passwords, tokens. If the scan finds a secret, the change is blocked and the task escalates immediately.
Those checks are deterministic. They either pass or they fail. There's no judgment, no "close enough," no "we'll fix it later." If a check fails, the change doesn't proceed.
That's what makes review fast. By the time the reviewer looks at the change, the mechanical gates have already passed. It doesn't have to check for lint errors or missing types. It reviews the logic and the design.
Review takes under two minutes, or it's too complex#
If a change can't be reviewed in under two minutes, it's too complex. That's the threshold.
A two-minute review covers:
- Scan the diff. What changed, and why?
- Check the files. Does the change touch auth, billing, or migrations? If yes, escalate.
- Read the logic. Does the code do what it says it does?
- Look at the tests. Do they cover the new behavior?
That's enough time to catch most bugs, most bad designs, and most wrong assumptions. It's not enough time to review a 500-line PR that touches 15 files. That kind of PR gets closed with a note: "break this into smaller changes."
The two-minute rule enforces scope discipline. Agents learn that large changes don't merge. They learn to keep PRs small, focused, and easy to review. That's good for review speed, and it's good for rollback safety.
The worm guard#
Every deploy passes a final gate: the worm guard. It's a check that runs before anything ships to production. The name is deliberate. It's looking for the kind of change that could spread through the system and break everything.
The worm guard checks:
- Blast radius. How many files does the change touch? If it's more than 10, escalate.
- High-risk areas. Does the change touch auth, billing, database migrations, or the deploy pipeline itself? If yes, escalate.
- Dependency changes. Does the change add, remove, or upgrade a dependency? If yes, flag it for review.
- Config changes. Does the change modify environment variables, feature flags, or secrets? If yes, escalate.
The worm guard doesn't prevent those changes. It just makes sure they're reviewed with extra care. A change that touches auth and upgrades three dependencies might be fine, but it's not a change that should slip through late on a Friday without that extra pass.
Escalation is a feature#
When an agent can't finish a task, it escalates. That's not a failure. That's the design.
Escalation happens when:
- The agent retries a fix three times and still can't pass the checks.
- The change touches auth, billing, or migrations.
- The blast radius is too large.
- The task depends on a decision the agent can't make.
When a task escalates, it parks with evidence: what the agent tried, what failed, and where it got stuck. I read the evidence, make a decision, and either finish the task myself or queue it back to the agent with more guidance.
The escalation rate is a signal. If too many tasks escalate, the agent needs better instructions or the tasks are too complex. If too few tasks escalate, the gates might be too loose. I keep it around 10-15%. That feels right.
Every alert opens a specific page#
The 70x7 Android app has push notifications. When a deploy finishes, when a task needs attention, when an agent parks a task, the phone buzzes. That's not the useful part. The useful part is what happens when you tap the notification.
Tap it, and it opens the specific page you need. Not the home screen. Not the notifications list. The deploy that just finished. The task that needs attention. The parked task with the evidence attached.
That discipline matters because alerts without actions are noise. If I have to tap the notification, open the app, navigate to the right page, find the item, and then act, I'm not going to do it. If tapping the notification takes me straight to the page, I will.
That's not a technical problem. It's a design problem. Every alert has to know which page to open. That means every alert has to carry enough context to generate the right URL. That takes more work up front, but it makes the alerts useful.
The takeaway#
Autonomy isn't about letting agents do whatever they want. It's about giving them a job, a contract, and a stop condition. The agents open PRs. The code reviews itself, and the system merges once the checks pass. The gates are deterministic. Review is fast. Escalation is a feature. Alerts open specific pages.
That discipline is what makes autonomy safe. Without it, agents are a risk. With it, they're a team.
Related
- Engineering
Fail Closed, Capture Before You Act
Two rules sit at the center of a governance runtime I've been building: when in doubt, the answer is no, and the record is written before anything happens. Here's what they mean in practice, and why they matter more as agents start taking real actions.
Architecture · Security · Agents7 min read
- Engineering
The Art of the Rock Tumbler: Polishing Loops for Code and Agents
A rock tumbler doesn't make a stone smooth in one pass. It uses coarse grit, then finer grit, then polish, and checks between stages. That's how I build agent loops in Starship: bounded retries, deterministic gates, and lessons that are only allowed to hurt once.
Agents · AI · Architecture · Delivery7 min read
- Engineering
The Agent Loop That Ships Its Own Code
How Starship's coding agents go from a planned task to a merged pull request without a human driving each step, and the gates, retries and postmortems that make that safe to leave running.
AI · Agents · Architecture · Delivery6 min read