← MarketplaceGet started free
Guide

How to Add AI Code Review to Your CI Pipeline

What You'll Build

A CI step that calls an AI code review agent on every push, returns a structured score, and optionally blocks the merge if quality is below your threshold.

Prerequisites

  • Runcept account and API key
  • GitHub repository with Actions enabled
  • The Workflow

    Create .github/workflows/code-review.yml:

    name: AI Code Review
    

    on: [pull_request]

    jobs:

    review:

    runs-on: ubuntu-latest

    steps:

    - uses: actions/checkout@v4

    with:

    fetch-depth: 0

    - name: Run code review

    run: |

    DIFF=$(git diff origin/${{ github.base_ref }}...HEAD | head -c 12000)

    RESPONSE=$(curl -sS -X POST https://www.runcept.com/api/v1/run \

    -H "Authorization: Bearer ${{ secrets.RUNCEPT_API_KEY }}" \

    -H "Content-Type: application/json" \

    -d "{\"agent\": \"code-reviewer\", \"input\": {\"diff\": \"$DIFF\"}}")

    JOB_ID=$(echo $RESPONSE | jq -r '.job_id')

    for i in {1..20}; do

    sleep 5

    RESULT=$(curl -sS https://www.runcept.com/api/v1/jobs/$JOB_ID \

    -H "Authorization: Bearer ${{ secrets.RUNCEPT_API_KEY }}")

    STATUS=$(echo $RESULT | jq -r '.status')

    if [ "$STATUS" = "complete" ]; then

    SCORE=$(echo $RESULT | jq -r '.output.score')

    echo "Code review score: $SCORE"

    if [ "$SCORE" -lt 60 ]; then exit 1; fi

    break

    fi

    done

    JavaScript Client

    const response = await fetch('https://www.runcept.com/api/v1/run', {
    

    method: 'POST',

    headers: {

    'Authorization': Bearer ${process.env.RUNCEPT_API_KEY},

    'Content-Type': 'application/json',

    },

    body: JSON.stringify({ agent: 'code-reviewer', input: { diff } }),

    })

    const { job_id } = await response.json()

    // Poll for result

    let result

    while (true) {

    await new Promise(r => setTimeout(r, 3000))

    const poll = await fetch(https://www.runcept.com/api/v1/jobs/${job_id}, {

    headers: { 'Authorization': Bearer ${process.env.RUNCEPT_API_KEY} }

    })

    result = await poll.json()

    if (result.status === 'complete') break

    }

    console.log(result.output) // { score, issues, suggestions }

    Next Steps

  • Set the score threshold that matches your team's standards
  • Add a PR comment with the full review using the PR description guide
  • Explore the full code agent catalogue
  • Use this agent on Runcept

    View code-reviewer agent →

    Related guides

    Call an AI Agent API from Node.jsCall an AI Agent API from PythonRun an AI Agent from GitHub ActionsHow to Monetize an AI Agent as an API