controlling the path from commit to merge
A single approval workflow for all code changes treats a generated CRUD form the same as a change to payment processing. A risk based approval workflow for AI-generated code differentiates by system area, requires mandatory reviewers for critical paths, and anchors automated gates in the CI pipeline instead of relying on good intentions.
Table of Contents
- 1. Why AI-generated code needs its own approval workflow
- 2. Defining risk tiers: not all code is equally critical
- 3. The approval workflow step by step
- 4. Mandatory reviewers for critical areas
- 5. Automated gates in the CI pipeline
- 6. Audit trail: ensuring traceability
- 7. Roles and responsibilities in the approval workflow
- 8. Handling exceptions and urgent cases
- 9. Approval workflows compared: manual, semi-automated, fully automated
- 10. Summary
- 11. FAQ
1. Why AI-generated code needs its own approval workflow
Claude Code can design a complete feature, write a migration, or carry out a complex refactoring step in minutes. That very speed becomes a problem when the existing approval workflow for code changes is not built for it. A classic pull request review that works for manually written code, because the scope of the change keeps pace with the author's thinking speed, falls behind when suddenly five hundred lines of generated code land in a single commit.
A dedicated approval workflow for AI-generated code is not extra bureaucracy, it is an adaptation to a changed risk profile. While a human developer usually changes a limited section of the system they are familiar with, an AI assistant can propose changes across module boundaries that look plausible at first glance but create side effects in areas the prompt never had in view. The approval workflow must therefore explicitly check which system areas are affected, not just whether the code looks functionally correct.
Another reason for a dedicated approval workflow is the tendency of language models to produce confidently worded but subtly wrong code. Unlike human mistakes, which are often recognizable by unusual style or hesitance, AI-generated code usually looks stylistically flawless even when it contains a subtle security hole or an edge case bug. Reviewers who rely on gut feeling therefore systematically underestimate the risk in AI-generated code.
2. Defining risk tiers: not all code is equally critical
The core of a working approval workflow is dividing the codebase into risk tiers that apply regardless of whether the code comes from humans or from Claude Code, but that are applied more strictly to AI-generated code. A proven breakdown distinguishes three tiers: tier 1 covers uncritical areas such as styling, text snippets and internal tools without access to production data. Tier 2 covers business logic with moderate risk, such as product catalog features or reporting. Tier 3 covers critical paths such as authentication, payment processing, permission checks and anything with direct access to personal data.
These risk tiers determine how strict the approval workflow is for a given change. For tier 1, a single reviewer can be enough, sometimes even an automated review by a second AI model as an additional check. For tier 3, at least two human reviewers with demonstrable expertise in the respective area are mandatory, regardless of how trivial the change appears. This differentiation prevents the approval workflow from either slowing down the whole team with unnecessary bureaucracy or handling critical areas too loosely.
Mapping code to risk tiers should be anchored in the repository structure itself, for example through directory paths or tags in the CI configuration, instead of being discussed anew with every pull request. A directory like src/payment/ is then automatically treated as tier 3, regardless of who submitted the change.
# risk-tiers.yaml — maps repository paths to review requirements
tiers:
tier_1_low:
paths:
- "src/styles/**"
- "src/i18n/**"
- "tools/internal/**"
required_approvals: 1
ai_pre_review_allowed: true
tier_2_moderate:
paths:
- "src/catalog/**"
- "src/reporting/**"
required_approvals: 2
ai_pre_review_allowed: true
tier_3_critical:
paths:
- "src/auth/**"
- "src/payment/**"
- "src/permissions/**"
required_approvals: 2
required_reviewer_groups: ["security-team", "senior-backend"]
ai_pre_review_allowed: false # human-only first pass on tier 3
3. The approval workflow step by step
A complete approval workflow for AI-generated code does not start at the pull request, it starts at the commit itself. The first step is disclosure: every commit substantially created with Claude Code receives a note that stays visible later during review. The second step is a self check by the developer who submitted the generated change, using a short checklist that asks, for example, whether edge cases were tested and whether the change matches existing architectural decisions.
The third step in the approval workflow is the automated gate in the CI pipeline: linting, type checking, unit tests, and for critical areas, static security analysis, all run before any human review. Only after that comes the fourth step, the actual review by the reviewers required for the given risk tier. The fifth and final step is the merge itself, which for tier 3 is typically also tied to a deployment approval, so the change reaches production in a controlled way rather than immediately.
It is important that this approval workflow is not perceived as rigid bureaucracy. Most steps can be integrated into existing tools like GitHub or GitLab, so the additional manual effort for the developer stays small while the control the team gains is substantial.
## Pull Request Checklist — AI-assisted changes
- [ ] This PR was substantially generated with Claude Code (tag: Assisted-by)
- [ ] I reviewed the diff line by line, not just the generated summary
- [ ] Edge cases (empty input, null, concurrent access) were tested manually
- [ ] No hardcoded secrets or customer data are present in the diff
- [ ] The change matches existing architectural patterns in this module
- [ ] Risk tier of touched paths: ______ (see risk-tiers.yaml)
- [ ] Required reviewer group for this tier has been requested
4. Mandatory reviewers for critical areas
A general reviewer is not enough for tier 3 areas. The approval workflow should define mandatory reviewers who have demonstrated expertise in the respective area, for example the security team for authentication code or an experienced backend developer for payment processing logic. This mapping can be implemented technically through CODEOWNERS files, natively supported by GitHub and GitLab, which automatically enter the correct reviewers as a required field in the pull request.
A common mistake when building an approval workflow is defining mandatory reviewers by name instead of by role. If the only person allowed to review payment logic is on vacation, the entire merge process gets blocked. Role based groups with at least two qualified people per critical area avoid this single point of failure and keep the approval workflow functional even during absences.
For tier 3 changes, it is additionally worth applying a four eyes principle with separated responsibilities: one reviewer checks functional correctness, a second explicitly checks security aspects. This separation prevents a single reviewer from having to cover both aspects at once and neglecting one of them.
# CODEOWNERS — maps critical paths to mandatory reviewer groups
# GitHub and GitLab both parse this file automatically
/src/auth/ @security-team @senior-backend
/src/payment/ @security-team @payments-guild
/src/permissions/ @security-team
# Tier 2 — one qualified reviewer from the domain team
/src/catalog/ @catalog-team
/src/reporting/ @data-team
# Tier 1 — any team member may approve
/src/styles/ @frontend-team
5. Automated gates in the CI pipeline
Human reviewers are slow, inconsistent and get fatigued through repetition. A robust approval workflow therefore shifts as much verification work as possible into automated gates before any human is even involved. For AI-generated code, three additional gates are especially valuable: an analysis for known hallucination patterns such as invented API methods or nonexistent packages, a diff comparison against the task description formulated in the prompt, and a security analysis using static analysis tools that catch typical AI mistakes such as missing input validation.
An approval workflow with well configured gates automatically blocks a merge when critical criteria are not met, instead of relying on the attention of the human reviewer. This significantly relieves the mandatory reviewers from section 4, because they can focus on architectural and domain questions instead of checking every line for trivial mistakes.
It is important to calibrate the gates regularly. Rules that are too strict produce many false positives and undermine acceptance of the approval workflow in the team, rules that are too loose let through exactly the mistakes the process is supposed to prevent. An iterative approach, where gate rules are sharpened after every incident that actually occurs, has proven itself in practice.
# .github/workflows/ai-code-gate.yml — additional gates for AI-assisted PRs
name: AI Code Gate
on: [pull_request]
jobs:
hallucination-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify referenced packages actually exist
run: ./scripts/verify-imports-exist.sh
diff-prompt-match:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compare diff scope against linked task description
run: ./scripts/check-diff-matches-scope.sh --pr "${{ github.event.pull_request.number }}"
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Static security analysis (tier 2 and tier 3 paths only)
run: ./scripts/run-security-scan.sh --tiers=2,3
6. Audit trail: ensuring traceability
An approval workflow without an audit trail cannot be reviewed after the fact. For every change it should be traceable who initiated it, whether and how much AI assistance was involved, which reviewers participated, which automated gates were passed, and when the merge happened. This information is not only relevant for compliance purposes, but also for debugging when a bug shows up months later in a component that was generated back then.
Most of this data already exists in git history, pull request metadata and CI logs, but as part of the approval workflow it needs to be centrally consolidated so it can be quickly analyzed in a real incident. A simple script that periodically exports commit trailers, review metadata and CI results into a searchable database is entirely sufficient for most mid sized teams and does not need to be a complex compliance tool.
An often overlooked aspect of the audit trail is the retention period. An approval workflow should explicitly define how long this traceability data is kept, aligned with the regulatory requirements of the relevant market, and who has access to it if needed.
7. Roles and responsibilities in the approval workflow
An approval workflow needs clearly assigned roles, otherwise responsibility blurs between developer, reviewer and tooling. The developer who creates a change with Claude Code stays functionally responsible for the submitted change, regardless of how much of it the AI contributed. This clarification matters because some teams otherwise tend to delegate responsibility to the tool, which does not work legally or practically.
The mandatory reviewers from section 4 carry responsibility for the functional and security review, while a person overall responsible for the approval workflow, usually an engineering lead or platform team representative, maintains the risk tiers, CODEOWNERS mappings and gate configurations. This role should also be responsible for regularly checking whether the process is actually being followed in practice or whether workarounds have emerged.
Larger organizations additionally benefit from a higher level function that observes trends across multiple teams, for example whether certain teams systematically bypass tier 3 reviews, or whether certain types of AI-generated code are flagged in review more often than average. This aggregated view helps improve the approval workflow organization wide instead of letting every team gather experience in isolation.
8. Handling exceptions and urgent cases
Every approval workflow needs a defined exception path for real emergencies, for example a critical production outage requiring an immediate hotfix. Without this path, the regular process gets bypassed in practice, usually informally and undocumented, which undermines the goal of the whole framework. A clean exception path instead explicitly defines who may authorize an urgent approval, typically an incident commander or a senior engineer on call, and which follow up steps must mandatorily happen.
The most important follow up step is a mandatory post hoc review within twenty four to forty eight hours after the hotfix, in which the full approval workflow is applied retroactively, including the reviewers that would normally have been required. If this post review finds a problem, a follow up fix must go through the same process as any regular change, not be treated as an urgent case again.
It matters to keep the exception path restrictive and to regularly review how often it is actually used. An approval workflow where a quarter of all changes go through the emergency path does not have an emergency problem, it has a structural problem with the speed of the regular process, which needs to be solved rather than papered over with exceptions.
9. Approval workflows compared: manual, semi-automated, fully automated
The maturity of an approval workflow for AI-generated code can roughly be divided into three stages, which teams should implement to different degrees depending on size and risk tolerance.
| Feature | Manual | Semi-automated | Fully automated |
|---|---|---|---|
| AI code disclosure | Voluntary, by convention | Git hook suggestion | Enforced automatically, merge blocked without tag |
| Risk tier mapping | In the reviewer's head | Documented in wiki | CODEOWNERS and CI configuration |
| CI gates | Standard tests only | Additional security checks | Hallucination check, diff-prompt match |
| Audit trail | Plain git history | Exported reports | Central, searchable database |
| Suitable for | Small teams, low risk | Growing teams | Regulated, large organizations |
No team has to reach the fully automated stage immediately. What matters is that the approval workflow grows with rising use of Claude Code and growing team size, instead of staying rigidly at the initial stage while the volume of generated code, and with it the risk, keeps increasing.
Mironsoft
CI/CD pipelines, code review processes and Magento/Hyvä development
Does your team need a resilient approval workflow for AI code?
We design risk tiers, CODEOWNERS mappings and automated CI gates for your pipeline, so AI-generated code from Claude Code reaches production in a controlled, traceable way.
Risk tier design
Defining repository structure, CODEOWNERS and reviewer groups
CI gate implementation
Security checks, hallucination checks and automated blockers
Audit trail setup
Central traceability across commits, reviews and deployments
10. Summary
A workable approval workflow for AI-generated code begins with a clear risk tier breakdown that defines which system areas require which level of scrutiny. Mandatory reviewers, defined by role rather than by name, secure critical paths such as authentication and payment processing. Automated CI gates relieve human reviewers from trivial checks and catch typical language model mistake patterns early. A central audit trail makes every decision traceable after the fact.
The approval workflow must include a clearly defined but restrictive exception path for real emergencies, otherwise the regular process gets bypassed under time pressure. Teams that expand this process step by step, from purely manual conventions to fully automated gates, gain control over AI-generated code without losing the speed that makes Claude Code attractive in the first place.
Approval Workflows for AI-Generated Code — The Essentials at a Glance
Risk tiers
Three tiers anchored in repository paths, instead of case by case decisions on every pull request.
Mandatory reviewers
Role based via CODEOWNERS, with at least two qualified people per critical area.
CI gates
Hallucination check and security analysis before any human review, calibrated regularly.
Exception path
Restrictive, with a mandatory post review within 24 to 48 hours after every hotfix.