Skip to main content

· iWork Technologies Team · AI Governance

The Human-Gated Agentic CI/CD SDLC: Directing Claude Code & OpenAI Codex Without AI Tech Debt

A stage-by-stage blueprint for directing Claude Code and OpenAI Codex across the SDLC, with a human gate at every step that keeps AI tech debt out of your codebase.

A stage-by-stage blueprint for directing Claude Code and OpenAI Codex across the SDLC, with a human gate at every step that keeps AI tech debt out of your codebase.

Most of the debate about AI coding agents is about the pull request: who reviews it, which checks it must pass, whether the agent can merge it. That matters, and we have written about governing Claude Code and Codex in CI and how senior review prevents AI tech debt.

But by the time an agent opens a PR, most of the important decisions are already made. What the ticket asked for, how the agent chose to solve it, which files it touched and which tests it wrote were all decided upstream. A reviewer who first sees the work at the PR is reviewing a finished building, not a plan.

This post is the blueprint we use across the whole software delivery lifecycle (SDLC) when senior engineers direct Claude Code and OpenAI Codex on client codebases. It names each stage, who does the work, and the human gate that has to be passed before the work moves on.

The model in one table

Agents do the volume. People make the decisions that are expensive to reverse.

Stage Who does the work Gate before the next stage Who signs off
1. Intake Senior engineer, with the client Ticket is agent-ready Senior engineer
2. Plan Agent proposes, in the repository Plan approved before any code Senior engineer
3. Build Agent, in an isolated branch Local checks pass Agent (automated)
4. Pull request Agent opens it, CI runs Required checks pass CI (automated)
5. Review Senior engineer Line-by-line approval Senior engineer
6. Release Pipeline, behind flags or a preview Release check Named owner
7. Learn Whole pod Lessons written back into the repo Tech lead

Two of the seven gates are automated. Five need a person. That ratio is the point: the gates that need judgment stay with people, and the ones a machine can enforce are enforced by machines, every time.

1. Intake: make the ticket agent-ready

Agents are literal. A vague ticket produces confident code for the wrong problem, and the debt starts there.

A ticket is agent-ready when it has:

  • One outcome, small enough to review in one sitting. If the diff will run past a few hundred lines, split the ticket.
  • Acceptance criteria a test can check, written as behaviour, not implementation.
  • The boundaries: which modules are in scope, and which must not change.
  • Known constraints: performance budgets, compatibility promises, data that must not be touched.

An illustrative example:

PROJ-1234: Skip zero-quantity lines in the invoice export

Outcome: Exported invoice totals ignore lines with quantity 0.

Acceptance criteria:
- An invoice with only zero-quantity lines exports a total of 0.00.
- A mixed invoice totals only the non-zero lines.
- The CSV column order does not change.

In scope: src/billing/export/
Out of scope: invoice creation, tax calculation, the public API.

The gate: a senior engineer reads the ticket and asks, “Could two competent engineers build different things from this?” If yes, it is not ready.

2. Plan: approve the approach before any code exists

This is the gate most teams skip, and it is the cheapest one to run.

Before writing code, the agent reads the ticket and the codebase and proposes a plan: which files it will change, which existing helpers it will reuse, what it will test and what it is unsure about. Claude Code has a plan mode built for this, and Codex can be asked for a plan before it edits anything. Either way, the output is a short list a senior engineer can read in two minutes.

What the reviewer looks for at this stage:

  • Reuse. Is the agent about to write a helper that already exists? This is the most common source of duplication, and it is far easier to stop here than to unpick in review.
  • Blast radius. Does the plan touch files outside the ticket’s scope?
  • New dependencies. Any new package is a supply-chain and maintenance decision. It needs a reason.
  • Test intent. Do the planned tests check the acceptance criteria, or only that the code runs?

Rejecting a plan costs minutes. Rejecting a finished PR costs the time to build it, review it and build it again.

3. Build: isolate the agent, then let it work

Once the plan is approved, the agent builds. The controls here are about containment, so a mistake stays small:

  • A dedicated branch per ticket, named so it is easy to find later, for example agent/PROJ-1234-skip-zero-lines.
  • An isolated working copy. A separate git worktree or a sandboxed cloud task, so parallel agents never edit the same files.
  • No production credentials in the environment the agent runs in. It works against test data and local services.
  • Project instructions in the repository. Claude Code reads CLAUDE.md; Codex reads AGENTS.md. These files hold the project’s conventions, commands and limits, and because they are versioned, any change to them goes through review like code.

An agent should also run the project’s own checks before it calls the work done: lint, type checks and the test suite. That is the third gate, and it is automated. Nothing goes to a PR that the agent has not already seen pass locally.

4. Pull request: CI is the second reviewer

The agent opens the PR. It cannot merge it. Branch protection makes that a rule rather than a habit, and CI runs the checks a machine can run: tests, lint, static analysis, dependency review, secret scanning and a provenance label that marks the work as agent-authored.

We cover the exact branch protection settings and an illustrative GitHub Actions workflow in governing Claude Code and Codex in CI/CD. The short version: if any path exists from an agent to main that skips a named human approver, close it.

5. Review: a senior engineer reads every line

CI proves the code passes the checks. It cannot prove the checks are the right ones, or that the change does what the ticket meant.

The senior review compares three things: the ticket, the approved plan and the diff. If the diff wandered from the plan, that is the first question. Then the reviewer reads for the patterns agents tend to produce: duplicated helpers, drifting conventions, shallow tests and errors that are caught and silently ignored. Our full checklist is in how senior review prevents AI-generated tech debt.

Two rules keep this gate honest:

  • Approvals reset when new commits arrive. An approval covers the code that actually merges, not an earlier version.
  • Review time is budgeted, not squeezed. If agents produce PRs faster than seniors can review them, the answer is fewer agent tasks in flight, not lighter review.

6. Release: ship small and keep a way back

Merged is not the same as live. Agent-built changes go out the same way any change should, with a way to undo them:

  • A preview or staging deploy for every PR, so the reviewer can see the change working, not just read it.
  • Feature flags for anything user-facing, so a change can be turned off without a redeploy.
  • Small batches. One ticket, one PR, one release unit. Large merges hide which change caused a problem.
  • A named owner for each release who checks it once it is live.

7. Learn: write the lesson back into the repository

Every time a reviewer rejects a plan or a PR for the same reason twice, that reason belongs in the repository, not in someone’s head.

  • A convention the agent keeps missing goes into CLAUDE.md or AGENTS.md.
  • A bug that escaped becomes a regression test.
  • A risky pattern becomes a lint rule or a static analysis check.

This is how the system improves. Each gate catches fewer problems over time because the earlier stages stop producing them.

Where AI tech debt enters, and which gate catches it

Source of debt Where it starts Gate that should catch it
Building the wrong thing Vague ticket 1. Intake
Duplicated helpers Agent did not look for existing code 2. Plan
Unneeded dependencies Agent reached for a package 2. Plan, then 4. CI
Pattern drift Conventions not written down 3. Build (instructions file), 5. Review
Shallow tests Tests check that code runs, not behaviour 2. Plan, then 5. Review
Leaked secrets Credentials in the agent’s environment 3. Build, then 4. CI
Risky releases Large batches, no rollback 6. Release

If a problem keeps reaching review, look one or two rows up. The fix is usually an earlier gate, not a harder review.

What to measure

You cannot run this model on instinct. A few measures tell you whether the gates are working:

  • Plan rejection rate. High at first is healthy. It should fall as the instructions files improve.
  • Review rework rate. How often a PR goes back for changes. Falling over time means earlier gates are doing their job.
  • Time to first review. If PRs wait, reviewers are the bottleneck and agent work in flight should be reduced.
  • Change failure rate and time to restore, two of the DORA delivery metrics. Agents should not make either worse.
  • Reverted agent PRs. Each one deserves a short note on which gate missed it.

Common ways this goes wrong

  • Review only at the PR. Seniors spend their time unpicking approaches they would have rejected in a two-minute plan review.
  • Agents with an engineer’s personal token. The audit trail disappears and the agent inherits access it does not need.
  • Instructions files nobody maintains. The same review comment appears every week.
  • Too much work in flight. Agents can open more PRs than people can review. Review queues grow, and review quality drops first.

Where to start

Pick one repository and one stream of work. Add the plan gate first: before any agent writes code, a senior engineer approves a written plan. It needs no new tooling, and it usually removes the largest share of review rework within a couple of weeks. Then check the CI controls and the instructions files against this blueprint.

If you would like a senior engineer to walk through your setup with you, book a 30-minute AI readiness audit. You will talk to an engineer, not a salesperson, and we will map where agents could work in your SDLC and which gates you need first.

Need more shipped work from your team?

AI Velocity Pods put four senior engineers and a tech lead, directing AI coding agents, inside your codebase. Start with a free 30-minute AI Readiness Audit with a senior engineer.

Related Posts

View All Posts »

Before you go: the free guide

The Ultimate Guide to Agentic Product Development, as an instant PDF download.

No spam. See our Privacy Policy.