Gemini CLI Gemini CLI

Build an Autonomous GitHub PR Review Agent with Gemini CLI

Create a self‑running agent that analyses pull requests, generates detailed code reviews, and opens review comments on GitHub automatically.

Takes
Text Code
Produces
Text Code Json
What you'll produce
Input
Create an autonomous agent that reviews pull requests for security vulnerabilities, code style, and performance issues, then posts a detailed markdown summary to a new branch and opens a PR.
Output
The agent created a branch `review-123`, added `REVIEW.md` with 45 issue entries, committed the file, pushed the branch, and opened a pull request titled "Automated PR Review – #123" containing the full analysis.

The Workflow

9 steps · click a step number to mark it done

Open Gemini CLI and have it ready before you start

Install Gemini CLI by running `npx @google/gemini-cli@latest` in your terminal

Create a `gemini.md` guardrail file in your home directory (e.g., `~/.mini/gemini.md`) that defines the agent’s role as an expert code reviewer

Set environment variables `GITHUB_TOKEN` and `OPENAI_API_KEY` with your personal access token and API key

Run `gemini init` and follow the prompts to link the agent to your target GitHub repository and branch

Enter a detailed prompt asking Gemini to generate a PR review agent that: • scans changed files • flags bugs, security issues, and style violations • writes a markdown summary • creates a new branch, commits the summary, and opens a pull request

Approve the autogenerated plan when Gemini displays it, then let the CLI execute the plan

After the run finishes, open the created pull request on GitHub and verify that the review comments and summary file were added

Ozero Ozero

Securely grant the agent GitHub access via Ozero OAuth flow

Run the agent again; Ozero will open a consent screen, you approve, and the agent receives a short‑lived token to comment on future PRs without storing secrets

Did this workflow help?
Also uses
Ozero Ozero
🔍 Looking for AI tools? Try searching!