Documentation

Build a Multi-Model Code Review Bot

Automated code reviews using Claude + GPT-4 in parallel. Catches bugs, security issues, and suggests improvements on every PR.

Automated code reviews using Claude + GPT-4 in parallel. Catches bugs, security issues, and suggests improvements on every PR.

What You'll Build

A GitHub Action that runs parallel code reviews with Claude Opus (architecture) and GPT-4 (security), then posts combined feedback as PR comments.

Why This Is Powerful

  • Parallel AI reviews = faster + better
  • Catches issues human reviewers miss
  • Automated on every PR
  • Free up senior engineers

Prerequisites

  • GitHub repository
  • SkillBoss account
  • GitHub Actions knowledge

Architecture

Input: Git diff from PR Skills: anthropic/claude-opus-4, openai/gpt-4o Output: PR comments with review feedback


Step 1: Create GitHub Action

Set up automated workflow trigger:

# .github/workflows/ai-review.yml
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Get PR diff
        id: diff
        run: |
          git fetch origin ${{ github.base_ref }}
          git diff origin/${{ github.base_ref }}...HEAD > pr.diff

      - name: Run AI Review
        env:
          SKILLBOSS_API_KEY: ${{ secrets.SKILLBOSS_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: node review.js

Step 2: Parallel Review Logic

Run Claude and GPT-4 reviews in parallel:

// review.js
import { OpenAI } from 'openai'
import { readFileSync } from 'fs'

const client = new OpenAI({
  baseURL: 'https://api.skillboss.co/v1',
  apiKey: process.env.SKILLBOSS_API_KEY,
})

async function parallelReview(diff) {
  const [claudeReview, gptReview] = await Promise.all([
    // Claude: Architecture & design review
    client.chat.completions.create({
      model: 'anthropic/claude-opus-4',
      messages: [{
        role: 'system',
        content: 'Review code architecture, design patterns, and maintainability. Focus on high-level structure.'
      }, {
        role: 'user',
        content: `Review this code:\n${diff}`
      }],
    }),

    // GPT-4: Security & bug review
    client.chat.completions.create({
      model: 'openai/gpt-4o',
      messages: [{
        role: 'system',
        content: 'Review for security vulnerabilities, bugs, edge cases, and OWASP top 10 issues.'
      }, {
        role: 'user',
        content: `Review this code:\n${diff}`
      }],
    }),
  ])

  return {
    architecture: claudeReview.choices[0].message.content,
    security: gptReview.choices[0].message.content,
  }
}

Step 3: Post Review to PR

Add AI feedback as PR comments:

import { Octokit } from '@octokit/rest'

async function postReview(reviews) {
  const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN })

  const comment = `## πŸ€– AI Code Review

### πŸ—οΈ Architecture (Claude Opus)
${reviews.architecture}

### πŸ”’ Security & Bugs (GPT-4)
${reviews.security}

---
*Powered by [SkillBoss](https://skillboss.co)*
`

  await octokit.issues.createComment({
    owner: process.env.GITHUB_REPOSITORY.split('/')[0],
    repo: process.env.GITHUB_REPOSITORY.split('/')[1],
    issue_number: process.env.PR_NUMBER,
    body: comment,
  })
}

Step 4: Run Complete Review

Execute the full review pipeline:

async function main() {
  const diff = readFileSync('pr.diff', 'utf-8')

  console.log('πŸ” Running parallel AI review...')
  const reviews = await parallelReview(diff)

  console.log('πŸ’¬ Posting to PR...')
  await postReview(reviews)

  console.log('βœ… Review complete!')
}

main()

Related Tutorials