AI Agents for Code Review, Remediation, and Approval: A Practical Workflow

    A reliable AI-assisted delivery workflow separates code review, remediation, and approval rather than giving one agent unrestricted control. This article explains risk-based review depth, bounded repair tasks, auditable approval rules, and a seven-step rollout from a pilot repository to branch protection, along with metrics and common failure modes.

    Why Separate Review, Remediation, and Approval?

    AI coding tools can generate patches quickly, but delivery bottlenecks usually appear after the first draft: Is the logic consistent? Do the tests pass? Have conflicts been resolved? Does the change meet team rules? Who is authorized to merge it?

    If a single unconstrained automated process writes code, modifies it, and approves the merge, a mistaken judgment can affect not just one commit but the main branch.

    A safer approach divides these responsibilities among three roles that provide checks and balances:

    • Code review: Read-only analysis of logic, security risks, edge cases, and deviations from requirements. The reviewer annotates issues on the pull request without changing the repository.
    • Remediation: Authorized code changes, test execution, and conflict resolution, with an explanation of what changed and how to undo it. By default, this role cannot approve or merge its own work.
    • Rule-based approval: Evaluation against predefined team rules to determine which routine, low-risk changes may proceed and which require human review. This role checks established gates rather than inventing criteria on the fly.

    Each role has a bounded permission set and produces or consumes explicit evidence. Review produces findings, remediation produces reversible changes and a change report, and approval consumes rules and evidence without expanding the scope of the change.

    Match Review Depth to Risk

    The same model should not apply the same level of scrutiny to every change. Use three review levels based on the affected area:

    1. Quick review: Suitable for copy changes, configuration toggles, and small dependency version updates. Focus on whether the diff stays within scope and whether unrelated files were changed accidentally.
    2. Standard review: Suitable for routine features. Cover the main execution path, error branches, input validation, and the relationship between the change and existing tests.
    3. Deep review: Suitable for authentication and authorization, payments, data migrations, permission models, and public library interfaces. In addition to functional correctness, check for injection, unauthorized access, sensitive data exposure, concurrency issues, and rollback compatibility.

    Review findings should be structured rather than expressed as a general assessment. At minimum, include the location, triggering conditions, impact, severity, suggested fix, and whether the issue blocks merging. Mark uncertain findings as “Requires human verification” instead of presenting assumptions as facts.

    An illustrative review finding might look like this:

    1. [Blocking] Order status update does not verify caller authorization
    2. Location: service/order/update
    3. Condition: A caller with only a read-only token can mark an order as paid
    4. Impact: Payment completion can be falsified
    5. Recommendation: Check write permissions and allowed state-machine transitions

    Remediation Must Be Explainable and Reversible

    The remediation role can handle failing tests, merge conflicts, and review feedback. However, its constraints must be part of the task definition, not added after something goes wrong.

    A minimum remediation workflow is:

    1. Inspect the project structure and relevant tests. List the planned changes and affected files, and wait for confirmation before high-risk steps.
    2. Modify only files covered by the plan. Do not delete existing business data, change paths outside the repository, or deploy directly to production.
    3. Run relevant tests and static checks. Check for logic errors, security risks, and edge cases.
    4. Provide a change report that includes modified files, test results, unresolved issues, and rollback instructions.

    Rollback instructions must say more than “the changes can be reverted.” Specify the commit to restore, whether data migrations or configuration toggles are involved, and which checks must run again after rollback.

    Even if the remediation agent makes all tests pass, that result is not permission to merge. Approval must remain with a human or an independent rule-based approval role.

    The following task constraints can be reused:

    1. Implement one small feature change in the current project.
    2. Step 1: Inspect the project structure and list the change plan and affected files.
    3. Step 2: Wait for confirmation before making changes.
    4. Step 3: Run relevant tests and check for logic errors, security risks, and edge cases.
    5. Step 4: Provide a change report covering modified files, test results, unresolved issues, and rollback instructions.
    6. Do not delete existing data, modify files outside the project, or deploy directly to production.
    7. Any high-risk operation requires human confirmation.

    Approval Executes Rules, Not Model Discretion

    Automated approval requires rules that exist before the model evaluates a change and that humans can inspect. Store these rules in version-controlled files in the repository and review them alongside code, rather than leaving them scattered across chat histories.

    Changes suitable for automated approval typically have a small scope, avoid sensitive directories, pass tests and style checks, and introduce neither new external dependencies nor expanded permissions.

    Changes that require human review include:

    • Identity and permissions
    • Payments and billing
    • Data deletion and migration
    • Secrets and configuration
    • Breaking changes to public interfaces
    • Major dependency upgrades
    • Unresolved review findings

    Approval should produce only three outcomes: approve, reject with the unmet rule entries, or refer to a human. Avoid unauditable explanations such as “looks fine.” Every decision must be traceable to rule identifiers and supporting evidence, including diff scope, check results, and review status.

    An observation period is especially important. Run automated approval alongside human review first, recording decisions without making the approval check a branch-protection requirement. After comparing results for a period of time, make the check mandatory only if false approvals and false rejections are within acceptable limits.

    When the rules change, return to observation mode to avoid mixing old and new standards.

    Seven Steps from Pilot to Branch Protection

    This rollout assumes the organization already has code hosting, pull requests, and branch protection, with repository administrators who can install integrations and adjust permissions. There is no need to cover every repository at the outset.

    1. Enable the relevant capabilities. Have an organization owner enable AI-assisted delivery capabilities in the organization settings, where supported, and confirm who can enable or disable review, remediation, and approval.
    2. Connect a pilot repository with least-privilege access. Connect the code-hosting account and install an integration limited to the pilot repository. Review needs access to diffs and comments; remediation needs permission to push to feature branches; approval needs only permission to write check statuses.
    3. Start with review only. Choose a noncritical repository with tests and enable code review first.
    4. Validate finding quality. Open a test pull request containing an intentional edge-case issue. Confirm that the reviewer identifies a specific location rather than offering generic advice.
    5. Enable manually triggered remediation. Verify that the agent can make changes, produce a change report, and provide usable rollback instructions. Also confirm that it cannot merge its own work.
    6. Introduce approval in observation mode. Commit the team’s approval rules to the repository. Let the system record and compare decisions without blocking merges.
    7. Evaluate results before enforcing the gate. Compare automated and human decisions, including agreement rates, missed issues, and false blocks. Once results are stable, add the approval check to branch protection. Continue requiring human review for sensitive paths.

    Metrics and Common Failure Modes

    After rollout, do not measure success solely by faster merges. Track:

    • The proportion of review findings confirmed as valid
    • The first-pass success rate of remediation
    • The rollback rate after automated approval
    • The proportion of changes referred to humans
    • Average waiting time

    If delivery speeds up but rollbacks also increase, the gates may have become too permissive. Increase deep-review coverage or tighten automated approval conditions.

    Common failure modes include:

    • Prompts that allow the model to skip confirmation
    • Integration tokens with excessive permissions
    • Rules so vague that almost any change can pass
    • Remediation commits containing unrelated refactoring, making rollback difficult
    • Review and approval sharing the same context, effectively allowing the agent to approve its own claim that its findings have been fixed

    Mitigations include permission isolation, version-controlled rules, mandatory change reports, and a human veto for sensitive changes.

    AI agents are well suited to repetitive delivery work that can be checked and reversed. Quality standards, risk tolerance, and final accountability still belong to the team. Separating review, remediation, and approval—and observing results before enforcing branch protection—helps automation reduce waiting time without bypassing controls.