Back to Blog
·4 min read

How I use AI to review my own pull requests

My self-review workflow using Claude to catch bugs and improve code quality before my teammates even see it.

AI Dev
ai
code-review
workflow
claude

How I use AI to review my own pull requests

I've been using Claude to review my own pull requests for the past six months, and it's fundamentally changed how I ship code. Instead of pushing commits and hoping my teammates catch issues, I now catch most problems myself before anyone else sees them.

The key insight: AI is perfect for the tedious parts of code review that humans often miss when they're tired or rushing.

My Pre-Submit Workflow

Before I create any pull request, I run my code through this process:

Step 1: Generate the diff

# Get all changes in the current branch
git diff main...HEAD > current_changes.diff

Step 2: Ask Claude to review

I paste the diff into Claude with this prompt:

Review this code diff for:
1. Logic errors and potential bugs
2. Performance issues 
3. Security vulnerabilities
4. Code style inconsistencies
5. Missing error handling
6. Unclear variable names or comments

Focus on issues that would cause production problems or confuse other developers.

Step 3: Iterate based on feedback

Claude typically finds 2-3 real issues per review. I fix them, generate a new diff, and sometimes run it through again for complex changes.

What Claude Catches That I Miss

Off-by-one errors -- Claude consistently spots array boundary issues and loop conditions that I gloss over:

// I wrote this
for (let i = 0; i <= items.length; i++) {
  processItem(items[i]); // Will crash on last iteration
}
 
// Claude flagged: "This loop will exceed array bounds"
for (let i = 0; i < items.length; i++) {
  processItem(items[i]);
}

Async/await gotchas -- It catches Promise handling issues that would cause subtle bugs:

// My original code
async function processUsers(users: User[]) {
  users.forEach(async (user) => {
    await updateUser(user); // These won't wait for each other
  });
  console.log("All users processed"); // Lies!
}
 
// Claude's suggestion
async function processUsers(users: User[]) {
  await Promise.all(users.map(user => updateUser(user)));
  console.log("All users processed");
}

SQL injection risks -- Even in TypeScript with ORMs, Claude spots dangerous patterns:

// My hasty code
const query = `SELECT * FROM users WHERE name = '${userName}'`;
 
// Claude flagged this immediately
const query = `SELECT * FROM users WHERE name = $1`;
const result = await db.query(query, [userName]);

The Questions I Ask

I've refined my prompts over time. These questions get the best results:

  • "What would break this code in production?"
  • "Are there any race conditions or concurrency issues?"
  • "What happens if this API call fails?"
  • "Is this code readable to someone unfamiliar with the codebase?"

The specific, scenario-based questions work better than generic "review this code" requests.

What It Does not Replace

Claude is not perfect. It cannot:

  • Understand business logic context -- It does not know if your algorithm matches the product requirements
  • Catch integration issues -- It cannot see how your code interacts with other services
  • Review architecture decisions -- It does not have opinions on whether you should use a factory pattern here
  • Test user experience -- It cannot tell you if a UI change feels clunky

This is why I still value human code reviews. My teammates review for product fit, architecture, and user impact. Claude handles the mechanical stuff.

The Time Investment

The whole process adds about 5-10 minutes to each pull request. But it saves much more time than that:

  • Fewer review cycles -- My PRs get approved faster because there are fewer basic issues
  • Less debugging -- I catch bugs before they hit staging
  • Better learning -- Claude explains why something is problematic, so I write better code next time

My Results

Since starting this workflow:

  • My PRs spend 40% less time in review
  • I have not had a production bug caused by the types of issues Claude typically catches
  • My teammates spend their review time on higher-level feedback instead of nitpicking syntax

The best part? My team has started adopting this workflow too. We catch more issues earlier, and our code reviews focus on what matters: the product and architecture decisions that AI cannot make for us.

Claude will not replace your teammates, but it's an incredible first pass that makes everyone's job easier.