playbook · play
CI/CD with agents
Continuous integration and deployment is vital for even the smallest project, but my default go-to (PR-centric) flow is looking dated. The new flow is one process for every project: agents build, prove and cross-review every change, the risk of a change sets the gate, people approve intent and accept outcomes, and recovery rolls forward.
- maturity
- evolving
- tools
- 0
- updated
Historically I've followed the conventional pull request (PR)-driven flow: a person reads every diff before it merges. When agents write most of the code, that person becomes the bottleneck, and their attention goes where it adds least: the line-by-line check that a reviewer from another model family already does well.
So there's one flow for every project, whatever its size. Agents build, prove and cross-review every change. Risk decides whether a person is needed before production. People approve the intent before risky work starts and accept the outcome once it ships. Between my own projects, team projects at my current school and customer work, only two things differ: who the accountable person is, and how the platform enforces the gate.
NB. Much of what's written online about this is about US-centric SOC 2 requirements. That's not a thing for us, so this play focuses solely on leading practice rather than box-ticking. Where a control would also satisfy an auditor, we note that.
the flow
- Intent. Work starts from a brief: what changes, why, and how we'll know it works. For high and critical work, the accountable person approves the brief before an agent builds it, including what could go wrong and how it would be undone.
- Build and prove. An agent makes the change and proves it works end to end.
- Cross-review. A model from another family reviews anything above low risk. Every finding is fixed, or dismissed with a reason.
- Land on
main. Checks pass, and the commit deploys to staging. - Gate. The pipeline sorts what changed into risk tiers. Low and medium changes go to production automatically. High and critical changes wait for the accountable person, who reads the evidence and findings, tries the change on staging and releases the exact commit.
- Accept. Whoever owns the behaviour tries it on staging, or behind a flag in production with their own users. "Done" means safely landed in production and working.
- Sample. Once a month, someone skims what went out automatically, ideally with a fresh cross-family review, plus every hand release.
Nobody waits in a review queue for low and medium changes, and nobody reads diffs except on critical paths.
the core for every project
- Every commit runs the same checks locally and in CI: install from the lockfile, generate types, typecheck, lint, format and tests. Nothing deploys unless they pass.
mainis always releasable. Every greenmaincommit deploys to staging, with smoke checks against staging's real address, including its access controls.- Production is a promotion of a commit that already passed staging. The deploy message records the commit SHA, so anyone, including the pipeline, can ask which commit production runs.
- The gate depends on what changed, not who changed it. The pipeline compares production's commit with the candidate and sorts the changed paths into risk tiers.
- An agent never reviews its own work alone. Review comes in layers (below).
- Data moves forward. Schema changes use expand and contract. Migrating down is pretty much always a bad idea. Unless it's a catastrophe, in which case we're talking disaster recovery, a change is undone with a new forward migration.
- New behaviour that might need switching off ships behind a flag, using one pattern: OpenFeature in code, Cloudflare Flagship as the provider.
- Agents never hold production credentials. Only the pipeline deploys. Agents push, ask, watch and report. They never approve, merge or release their own high and critical changes, and never change critical paths alone.
- The loop closes after deploy. Route checks run in the pipeline, and the agent that made the change confirms it is live and working, or says it is held or broken.
- Everything is recorded: the commit trailer links the Amp thread, the deploy message holds the SHA, the run summary says what was promoted or held and why, and review findings are recorded against the SHA, each fixed or dismissed with a reason.
review comes in layers
Layer | Who | What they get | What they produce |
|---|---|---|---|
1. Author proof | The agent that made the change | Its own diff | Checks run, screenshots or logs, and end-to-end evidence that it works |
2. Cross-family review | A model from another family than the author, such as GPT-6.2 Sol reviewing Claude's work or the reverse | The diff and the intent, but not the author's conclusion | Findings, each later marked fixed or dismissed with a reason |
3. Accountable person | The person who answers for the change (see below) | The brief before; layer 1's evidence and layer 2's findings after | Approval of the brief and release of the exact commit for high and critical changes; a monthly sample of the rest |
Models from one family tend to miss the same things, which is why layer 2 uses another family. Treat it as a strong tool, like static analysis, not as the approver of record. Ways to run it:
- In Amp: a review thread on another model, such as GPT-6.2 Sol for a change Opus or Sonnet wrote, given the diff since production.
- In GitHub: Copilot code review requested automatically by a ruleset, or a review workflow built with GitHub Agentic Workflows (generally available since October 2026), which can choose the engine and model per workflow.
A reviewer that reads untrusted text, such as pull request descriptions from outside contributors or issue bodies, must not also hold write or deploy rights. That's Meta's "Rule of Two": at most two of untrusted input, sensitive access and the ability to change things.
risk tiers determine the path to prod
The path list lives in the repository, next to the pipeline that enforces it. Changing the list, the pipeline or the rulesets is itself critical.
Tier | Typical paths in a Workers app | Review needed | Gate to production |
|---|---|---|---|
Low | Content, copy, styles, docs, tests | Author proof | Automatic after staging |
Medium | Ordinary application code | Author proof and cross-family review | Automatic after staging |
High | Auth and access, sessions, secrets and bindings, migrations and anything that runs them (including CMS or ORM upgrades), Durable Object classes, email and payments, dependencies and lockfile | Every layer; the accountable person approved the brief | The accountable person releases the exact commit |
Critical | CI configuration, code owners, rulesets, the path list, deploy tokens, access policies | Every layer, and a person reads the diff | A person releases it; agents never change these alone |
who's accountable is a lookup, not a mode
Where the work is | Accountable for the code | Accountable for the behaviour |
|---|---|---|
My own projects, such as this site and Portona | Me | Me |
A team project at my current school | The code owner for the area that changed | The product owner for the area |
Work delivered for a customer | The delivering team's code owner | The customer |
A code owner owns an area and its high and critical changes. They don't review every line. A customer accepts behaviour, on staging or behind a flag in production with their own users. They don't approve code or individual releases.
A second person is needed only where separation of duties is a real requirement, such as payments, bulk access to student data or access control. Those paths are critical, so someone other than the person who approved the brief releases them.
the gate is the same everywhere; only its enforcement differs
Setup | Branch flow | How high and critical changes are held |
|---|---|---|
Personal repository on GitHub Free or Pro | Agents push to | The pipeline holds production at staging, and later pushes stay held until the owner runs the release by hand. No paid plan needed. This guards against mistakes, not against a determined owner. |
GitHub Team | Short-lived branches; the pull request carries the evidence and the findings, and a merge queue lands it | A ruleset on |
GitHub Enterprise (which we have at my current school) | As Team | As Team, plus a deployment environment with required reviewers, self-review prevented and admin bypass off, for high and critical releases. |
Required reviewers on deployment environments only work in private repositories on GitHub Enterprise. On Free, Pro and Team, the enforceable gate is the merge or the pipeline hold.
extras when the work is for a customer
These are contract add-ons, not a different flow:
- release windows for high-risk changes, if the customer wants them
- release notes generated from the commits and review findings
- migration rehearsal on a recent anonymised copy of production data
- provenance attestations for what the pipeline deploys
- agreed recovery time and data-loss targets, with a restore drill at least each quarter, recorded
- Workers gradual deployments, where traffic is enough to judge errors per version and there's no shared page cache
migrations: expand, migrate, contract, and undo by moving forward
Rollback is hard in most of these apps because of migrations, so the playbook doesn't rely on it. A deployed migration stays applied when code rolls back, and some tools (D1, for example) have no down migrations anyway.
- Expand: add tables and nullable columns, or new Durable Object classes. Old code keeps working. This is its own release.
- Migrate: ship code that writes both shapes and reads the new one, behind a flag when the switch is risky. Backfill in batches.
- Contract: remove the old shape in a later release, after a soak at least as long as you'd want to roll back. This is a high-risk change in its own right.
Rules that go with it:
- One migration per release, separate from behaviour changes. Staging gets it first.
- Write the reversing migration before applying the risky one, as a new forward migration, and test both on staging. Undoing a change is then a normal roll-forward release.
- A code rollback is only safe when no migration has run since the target version.
- Record a D1 Time Travel bookmark before production migrates. Restoring is the last resort. It is destructive, overwrites writes made since the bookmark, and covers 7 days on Workers Free and 30 on Paid. EmDash's backup guide recommends the same.
- CMS and framework upgrades are migrations. EmDash applies D1 migrations on the first request after an upgrade, so treat its upgrades as high risk.
- Durable Object migrations are permanent. Add classes freely; delete or rename only through an approved migration. Code can't roll back across one.
feature flags: OpenFeature in code, Flagship as the provider
Write flag checks against OpenFeature, the CNCF standard interface, and use Cloudflare Flagship as the provider on Workers. Flagship evaluates flags through a Workers binding with no network round trip, supports targeting rules and percentage rollouts, keeps an audit history, and changes take effect in seconds without a deploy. Because the code talks to OpenFeature, swapping providers is a one-line change.
- Caveat: Flagship has been in public beta since 26 May 2026, with pricing still not announced. For customer projects, agree on it with the customer. If they need something else, keep OpenFeature and change the provider.
- Defaults: every flag's default is the safe, old behaviour, and the code must work when evaluation fails.
- Lifecycle: each flag has an owner and a removal issue when it's created. Agents add flags, open the removal issue and remove the flag once it's fully on. Flags older than a quarter show up in the monthly sample.
- Flags and acceptance: a flag is how the owner of the behaviour accepts a feature in production, with their own users, before everyone gets it.
- Flags and migrations: flag the "read the new shape" switch in step 2 of expand and contract, so turning it off is the fastest recovery.
- Flags and page caches: a page cached by path serves one variation to everyone. Keep per-user flags out of cached pages, or vary the cache key.
- Small sites: for a site with no per-user features yet, a kill switch can be a configuration variable. It's slower, because changing it needs a deploy. Adopt Flagship when the first real flag is needed.
recovery: use the cheapest step that's safe
The agent proposes; the accountable person decides, or on-call where a team runs one.
Step | Time | Safe when | Who decides |
|---|---|---|---|
Turn the flag off | Seconds | The change is behind a flag | The accountable person or on-call; an agent may flip a pre-approved kill switch |
Roll forward with a fix | Minutes | Always; this is the default | The normal flow, held at staging if the fix is high risk |
Roll the Worker back to an earlier version | Seconds | No migration, Durable Object migration or binding change since that version | The accountable person or on-call, then a fix rolls forward |
Release a reversing migration | Minutes | It was written and tested on staging beforehand | A high-risk release |
Restore D1 with Time Travel | Minutes, and data written since is lost | Data is corrupted and nothing else works | The accountable person, after exporting rows written since; on customer work, the customer is told |
After any production deploy, the pipeline runs route checks. The agent that made the change then reads errors and logs for a set time, such as 15 minutes, and either reports the change as working or proposes a recovery step. Emergency changes, such as a hand deploy or a bypass, get a review afterwards, within a week.
how this site runs it
I'm the accountable person for everything here. Every push to main is checked and deployed to staging. When staging passes, the pipeline looks at what changed since production. Ordinary changes, such as content, styles and page code, go straight to production. A change to anything on the site's high-risk list, such as its configuration, dependencies, worker entry point or contact and email code, waits at staging until I release it by hand, and that release records who released it and what went out.
Not adopted yet: Flagship (no flags needed today), recording a D1 bookmark in the pipeline before CMS upgrades, and an automated post-deploy watch.
sources/reading
- GitHub: deployments and environments and managing environments (plan limits on private repositories), Copilot code review in rulesets, GitHub Agentic Workflows GA, merge queue, artifact attestations.
- Cloudflare: Flagship and its announcement, D1 Time Travel, gradual deployments, rollbacks.
- EmDash: backups and recovery.
- Amp and agentic practice: "That's not SOC 2 compliant", The Amp Way, Sonar: agentic pipelines (risk tiers, Rule of Two), AWS: gated review pipeline for AI coding agents.