IBRAVRA Media Network
engineering • 13 min read

AI Code Review & Automated PR QA: Setting Up LLM GitHub Actions with Security Linting

Build an automated AI pull request review bot using GitHub Actions, Gemini 1.5/2.0 Pro, AST parsing, and Semgrep security scanning.

By Enow A. Jovial • Published 2026-08-31

Peer code reviews represent one of the most critical quality gates in modern software development—yet senior engineering teams spend 15% to 25% of their weekly capacity checking basic syntax consistency, reviewing boilerplate regressions, and catching common security anti-patterns (such as unsanitized SQL queries or exposed API secrets).

Deploying an AI-driven Pull Request reviewer via GitHub Actions and Gemini Pro provides instantaneous, context-aware architectural feedback, catches CVE regressions, and reduces PR merge turnaround times by over 50%.

```

+-----------------------------------------------------------------------------+

| AI PULL REQUEST QA & REVIEW PIPELINE |

| |

| [ Developer Opens Pull Request (Event: `pull_request.opened`) ] |

| | |

| v |

| [ GitHub Action Runner Step 1: Static Analysis & Git Diff Parsing ] |

| - Run Semgrep & ESLint for Deterministic Security Analysis |

| - Parse `git diff` (Filter out lockfiles, generated assets & vendor files) |

| | |

| v |

| [ GitHub Action Runner Step 2: Gemini 2.0 Contextual Intelligence ] |

| - Inject Git Diff + Repository Architectural Guidelines (`AGENTS.md`) |

| - Prompt Gemini to review for edge-case errors, race conditions, memory leaks|

| | |

| v |

| [ GitHub Action Runner Step 3: Inline PR Review Comments ] |

| - Post line-specific inline annotations & markdown summary on GitHub PR |

+-----------------------------------------------------------------------------+

```

Production GitHub Actions Workflow Configuration

Below is a complete, production-ready GitHub Actions workflow file (`.github/workflows/ai-code-review.yml`) deploying Gemini-powered PR reviews:

```yaml

name: AI Pull Request Reviewer

on:

pull_request:

types: [opened, synchronize]

paths-ignore:

- '/package-lock.json'

- '/dist/'

- '/*.min.js'

jobs:

ai-review:

runs-on: ubuntu-latest

permissions:

contents: read

pull-requests: write

steps:

- name: Checkout Code

uses: actions/checkout@v4

with:

fetch-depth: 0

- name: Setup Node.js Environment

uses: actions/setup-node@v4

with:

node-version: 22

- name: Run Deterministic Security Scan (Semgrep)

run: |

npx semgrep --config auto --json -o semgrep-results.json || true

- name: Execute Gemini PR Code Analysis

env:

GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

PR_NUMBER: ${{ github.event.pull_request.number }}

run: |

npx tsx scripts/ai-pr-reviewer.ts

```

Core Architecture Review Guidelines for LLMs

To prevent developer "alert fatigue," the AI review prompt must strictly forbid nitpicking trivial styling choices (handled by Prettier/ESLint) and focus entirely on high-severity logical risks:

1. Concurrency & Race Conditions: Check for unsynchronized shared states, improper async/await error handling, and unhandled promise rejections.

2. Database Query Efficiency & N+1 Problems: Flag unindexed SQL joins, missing pagination parameters, or unmemoized full-table scans.

3. Security Vulnerabilities (OWASP Top 10): Detect unescaped user inputs passed to raw database queries, SSRF vulnerabilities, and hardcoded API tokens.

4. Performance & Memory Leaks: Identify uncleaned event listeners, large memory retained in closures, and unbounded array growth.

Actionable Code Review Automation Checklist

[x] Add Exclusions for Generated Assets: Exclude lockfiles, compiled assets, and test snapshots from AI token budgets.

[x] Store Repository Architecture Rules in Markdown: Place coding standards in `AGENTS.md` or `CONTRIBUTING.md` for automated system prompt injection.

[x] Integrate Inline Annotation APIs: Use GitHub's `POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews` endpoint to post comments on specific line numbers.

[x] Set Fail-Safe Severity Gates: Block merges only when high-severity security vulnerabilities or critical logical bugs are detected.

For modern full-stack development patterns, explore our comparison of WordPress vs. Headless React & Next.js and learn how to deploy Autonomous AI Agents in Production.

To evaluate generative accuracy and reduce hallucinations, see RAG Evaluation Frameworks & Ragas Metrics.

IBRAVRA Media Network
Loading decision engine & verified intelligence...

The Decision Engine for Modern Founders and Scaleups

Ibravra is an authoritative digital resource hub for solo founders, operators, and cross-border businesses. We provide actionable guides, free interactive financial tools, software reviews and comparisons, and business launch kits.