Stage 5: Deploy
AI in the PR review loop, hooks as approval gates, and CI/CD with tiered autonomy.
From reading every line to governing as the agent acts
Review used to depend on how many people were free to read. Now every PR gets the same review passes, and approvals are enforced in the moment.
Humans review every line
Governance lives in review cycles, often applied inconsistently. A PR waits for a reviewer to read all of it.
Layers of agentic review
Human review is reserved for regulated and critical code. Governance is enforced as the AI acts, with hooks as approval gates.
AI in the PR review loop
Claude both gives and receives reviews. Engineers focus on behavior: judging intent and risk.
Review capacity is planned around human output. A PR waits for a reviewer to read all of it, quality varies with reviewer load, and the author chases while the backlog grows.
All PRs get an identical set of review passes, with findings ranked by severity. Human attention moves up a level: does the change do what the plan intended, and is the risk acceptable?
Prerequisites
- An updated CLAUDE.md from Stage 3.
- Skills, if review passes should enforce written policies.
- Defined subagents.
Infrastructure
- A repo with the Claude integration installed: the managed Code Review service (enabled by an Owner of the Claude organization), or
claude-code-actionin your own CI. - Where needed, model calls through Amazon Bedrock, Google Cloud's Vertex AI, or Microsoft Foundry.
- Branch protection that requires a code owner's approval is worthwhile.
- Start with the managed Code Review service. Use
claude-code-actionin your own CI when you need pipeline control or want calls routed through your own cloud agreement. - Tech lead writes the review policy as REVIEW.md at the repo root, split into passes: bugs and logical errors, security and vulnerabilities, and compliance against spec.md, plan.md and design principles. It also says what counts as Important versus a Nit, and what to skip.
- Tech lead sets the human threshold. Findings do not approve or block a PR on their own. Branch protection still requires a code owner's approval. A platform engineer who wants to gate merges on findings can read the severity counts the check run publishes.
- When a reviewer or author tags
@claudeon a comment, Claude addresses it and pushes the fix. For PRs Claude opened, let it "babysit" the PR with a custom slash command that sweeps unresolved comments and failing checks until the PR is green and waiting only on the code owner. - Feed findings back into CLAUDE.md. When a review flags the same mistake twice, the correction goes into CLAUDE.md in that review.
- Monthly, the tech lead tunes the setup: rate the findings and cap Nit volume in REVIEW.md. Exclude generated paths and anything CI already enforces.
Separation of duties
The agent that wrote the code has no way to approve it.
One policy for every PR
REVIEW.md applies to all PRs.
Where it is logged
Findings, fixes, ratings and approvals sit in PR history. The PR is the audit record.
Who approves
A human, through branch protection, informed by the findings. Code owners approve every PR.
Open question from the course: which code is "regulated and critical", and so still reviewed by hand, is not defined precisely. The tech lead sets that threshold for your organization.
Watch a PR move through review
The insurer status panel PR. Click a stage, or use Play.
- Policy: REVIEW.mdPR
- Logic, edge cases, regressionsPR
- Injection, auth, PII in logsPR
- Matches spec and planPR
- Nits capped at 5PR
- Code owner approvesPR
claims-api/tests/test_status.py:8Bugs: no test covers a paid claim with no expected date.claims-api/routes/status.py:31Security: the error path logs the whole claims-core response, which includes the policy holder's name.portal/src/claims/StatusPanel.tsx:22Compliance: the panel fetches on every render, but plan.md says it must cache. Only the compliance pass finds this, because it reads the committed plan.Hooks as approval gates
A hook is a script that runs before Claude acts. It can allow, ask or block. The release gate is the clearest case.
Governance lives in review cycles, applied by people, often inconsistently.
Governance is enforced as the AI acts. In Stage 3, hooks allowed or blocked with no human. A hook can also ask, pausing until the person running the session confirms. When the approver is someone else, such as a release manager, the hook looks for their recorded approval and blocks until it exists.
Hooks run wherever Claude acts. They can block edits to migrations and infra without a change ticket (Stage 3), and stop the agent editing test files during a fix (Stage 4).
Prerequisites
None.
Infrastructure
A written list of the approvals your change process requires.
- Engineering leadership, with change management and compliance, lists the human approval gates that must survive: change management sign-off, release authorization, edits to protected paths.
- Platform engineer expresses each gate as a hook, a script that runs before Claude acts and can allow, ask or block.
- Team hooks go in .claude/settings.json in Git. Non-negotiable hooks go in managed settings, owned by the platform or IT admin, where engineers cannot switch them off.
- A block must explain itself. The reason and the route to approval appear in Claude's output.
What is enforced
"Hooks are the approval gates." The condition is checked every time, for everyone.
Where it is logged
Allow and block decisions are logged with a timestamp.
Who approves
The gate defines what counts as approval: an approved change ticket, or the release manager's sign-off.
What it relies on
The agent has no way to write to the records the gate reads.
Watch a release meet the gate
The insurer portal ships to dev, staging and production. Each environment has its own deploy tools, and a hook checks every release call.
Calls release
Release to dev.
Dev
Released.
Managed settings for a regulated enterprise
The platform team deploys these through device management or the admin console. Engineers cannot edit or override them. The course calls this a starting point to customize.
Team hooks live here. With "managed hooks only" switched on, project hooks do not run, so the approval gate goes in the outer layer.
CI/CD integration and deployment
Run Claude Code non-interactively in the pipeline, sandbox it, expose deployment through MCP, and "rehearse the rollback paths before the agent ever needs them".
Pipelines run deterministic scripts. Anything that needs judgment waits for a human: triaging a flaky test, writing the changelog, diagnosing a broken build. Deployment and rollback are runbooks followed under pressure.
Claude runs non-interactively in the pipeline for judgment steps, in a sandbox with scoped credentials. Deployment tooling is exposed through MCP, so the workflow that wrote and tested the change can also ship and roll it back, inside gates the organization defines per environment.
Prerequisites
AI in the PR review loop and hooks as approval gates. The gates must exist before automation speeds anything through them.
Infrastructure
- A CI platform with
claude-code-action, or any runner that can callclaude -p. - Model access through the API, Bedrock, Foundry or Vertex where traffic must stay on your cloud agreement.
- MCP servers for the deployment targets.
- A sandbox profile for agent jobs, with no standing production credentials.
Platform engineer adds capability in this order. The animation below walks through it.
- Start with read-only judgment steps through
claude -p: triage a failed build, summarize a flaky test, draft the changelog. - Add write steps behind existing gates: fix lint, update generated docs, address review comments through
@claude. Everything the agent writes arrives as a PR through branch protection. The agent has no route to push to main. - Sandbox execution: containers under a network policy, short-lived scoped tokens, no production credentials by default.
- Expose deployment through MCP. Deploy, status and rollback become tools scoped per environment, an allowlist instead of a shell script with credentials.
- Tier autonomy by environment. Dev deploys freely. In production the agent prepares the release and the release manager authorizes it, enforced by a hook. Staging sits in the middle.
- Make rollback the most rehearsed path in the pipeline: a single command the agent can run, exercised regularly in staging. The Stage 6 loop calls it when a band is breached.
The rule
"The agent may act up to the production gate and cannot pass it."
Branch protection
Everything the agent writes becomes a PR.
Production deploy hook
Blocks release until a named release manager authorizes it. Each non-interactive run acts under the agent's own identity, so logs separate agent actions from the triggering engineer's.
Permission tiers
One set per environment. If managed settings allow only managed hooks or servers, the gate and the servers must be in the managed files.
Watch autonomy grow in order
Each step stands on the one before it. Click a step, or use Play.
Read-only judgment steps
A step that runs only if the build failed. Claude reads the log, names the likely cause, says whether it looks flaky or real, and writes a three-line summary for the PR thread. It cannot change anything.
Write steps behind existing gates
Fix lint, update generated docs, address review comments. Everything the agent writes arrives as a PR. The agent has no route to push to main.
Deployment through MCP
Agent jobs run in a sandbox with short-lived scoped tokens and no standing production credentials. There is one MCP server per environment, because an allow rule names the server and tool, not the arguments. That is how an allowlist tells staging from production.
| Tool | Input | Returns |
|---|---|---|
release | The version. In production, also a ticket. | The release ID once the rollout finishes. |
status | None. | Waits until five minutes after the last release, then reports each endpoint's 5xx rate. |
rollback | None. | The version that is live again. |
Autonomy tiered by environment
| Environment | On the allowlist | What happens to release | Who approves |
|---|---|---|---|
| Dev | release, status, rollback | The hook allows. | Nobody. |
| Staging | release, status, rollback | The hook asks, or allows from the pipeline on main. | The engineer, or the approved merge. |
| Production | status, rollback | Denied unless the hook allows. | Release manager, through a change ticket. |
In production, release is off the allowlist, so the hook's allow is the only way through. Production fails closed: if the hook fails to run, the release is denied. Rollback stays allowed because it is a runbook approved in advance.
Rollback is the most rehearsed path
One command the agent can run, exercised regularly in staging. In the example staging job, the agent releases the commit, checks status, and rolls back if any endpoint's 5xx rate is over 1%. The Stage 6 loop calls the same command when a control band is breached.
What Deploy hands on
A merged PR
It passed the review passes and carries a code owner's approval. PR history is the audit record.
merged PR
The pipeline runs
A merge to main starts CI/CD. Staging is allowed from the pipeline on main, because the approved merge is the approval. Production waits at the gate.
A release in production
It reached production through the gate, with a rehearsed rollback ready and every gate decision logged.
release + rollback
Agents watch the live release
Production hands over to Stage 6: Maintain. When a control band is breached, that loop can call rollback.
Key takeaways
- Every PR gets the same review passes, written once in REVIEW.md. Humans spend their time on intent and risk.
- Findings do not approve or block on their own. A code owner still approves, and the tech lead sets the human threshold.
- Approval gates are hooks. The agent may act up to the production gate and cannot pass it.
- Grow autonomy in order: read-only steps, write steps behind gates, deployment through MCP, then tiers by environment.
- Rehearse rollback in staging before the agent ever needs it.
Based on Anthropic's The AI-native SDLC playbook course (Claude Academy). Summarized by Bitovi to guide client transitions.