Menü schliessen
Created: November 25th 2025
Last updated: November 25th 2025
Categories: Artificial intelligence (AI),  IT Knowledge
Author: Ian Walser

Automating Your Code Reviews with a Custom Claude Agent Command

Tags:  Claude Code

Introduction

If you're new to AI agents and want to streamline your development workflow, this guide will walk you through a simple but powerful setup: an automated code-review loop using a custom Claude agent command. This loop connects two specialized agents—a reviewer and a developer—that work together until your code is production-ready.

A colleague of mine already wrote a blog post about the AI agent basics. So if you're completely new to AI agents, it's definitely worth it to check that out first to get a basic understanding of how AI agents work. You can find the blog post here.

What This Review Process Does

The command /codereview-startreviewprocess launches a full automated review cycle between two Claude agents:

  • @codereview-reviewer (using the Opus model): Reviews only the files that changed and checks them against a strict ruleset.
  • @codereview-developer (using the Sonnet model): Applies atomic fixes, resolves rule failures, and validates syntax.

The reviewer and developer alternate in a loop until the reviewer is satisfied and returns REVIEW_COMPLETE.

How the Loop Works

The process follows a simple flow:

Start → Reviewer → Developer → Reviewer → (repeat until approved) → Complete

Built-In Safety Controls

  • Approval-based termination: Loop stops when all rules pass.
  • 8 iteration hard limit: Prevents runaway loops and escalates to human review.
  • 200,000 token budget: Ensures in-depth reviews for large files or whole branches.

Setting It Up

This system works entirely through a single command that you can run from your agent workspace or team chat.

Option 1: Review Uncommitted Changes

This is the quickest way to run the review loop:

/codereview-startreviewprocess

This will analyze your working tree using git diff HEAD, including any changed documentation.

Option 2: Review the Last Commit

If no uncommitted changes exist, the process automatically falls back to:

git show HEAD

No additional configuration required—the same command handles it.

Option 3: Review the Entire Branch

If you're comparing your branch against main or master, and there are no local changes, the loop analyzes everything using:

git diff main..HEAD
// OR
git diff master..HEAD

How to Monitor the Loop

As the agents work, you’ll see updates like:

  • HANDOFF: @codereview-reviewer [Iteration X/8] — loop progress
  • REVIEW_COMPLETE — all rules passed
  • Human review request — if iteration 8 is exceeded

Best Practices for Smooth Reviews

  1. Run on small batches: Keep changes focused for clearer results.
  2. Use uncommitted changes: Fastest cycle time and best accuracy.
  3. Let it loop: The agents manage the handoff automatically.
  4. Enjoy the safety net: A backup branch is created before any fixes.

After Approval

After the agent returns REVIEW_COMPLETE it will automatically run tests for you and push the changes to the repository with git push. This behaviour can be customized or removed below the ## Post-Approval section:

git push

All agent and command configuration files can be found here. They are uploaded as standard text files so the file format would have to be changed to .md to use them:

Feel free to experiment with the existing configuration, tweak it to your liking and maybe even leave a comment to help out other developers who are just getting started working with agents.