Skip to main content
Automate code review for every Pull Request. Cline runs in GitHub Actions, reads the pull request, and posts a review with its analysis and suggestions.

The Workflow

The workflow has two jobs, so that the job that runs Cline can’t change your repository or the pull request:
  1. review gets a read-only token. It checks out your base branch, installs Cline CLI, configures authentication (e.g., Anthropic, OpenAI), and asks Cline to read the pull request with GitHub CLI (gh) and write its review to a file.
  2. post gets permission to write pull requests, but doesn’t check out code or run Cline. It posts the file as a review comment.

Prerequisites

  • GitHub repository with Actions enabled.
  • AI Provider API Key (e.g., Anthropic, OpenRouter) added as a repository secret (e.g., ANTHROPIC_API_KEY).
  • GitHub Token (automatically provided by Actions as GITHUB_TOKEN).

Setup

1. Create the Workflow File

Create a file named .github/workflows/cline-pr-review.yml in your repository:

2. Configure Secrets

  1. Go to your repository settings -> Secrets and variables -> Actions.
  2. Add a New repository secret.
  3. Name: ANTHROPIC_API_KEY (or match the key used in your workflow).
  4. Value: Your actual API key.

Key Components Explained

Permissions

The workflow starts with no permissions, and each job asks only for what it needs:
  • review can read the code, pull requests, issues, checks and workflow runs, but can’t change anything. Cline runs in this job and reads text that the pull request’s author wrote, so the job gets no write access.
  • post can write pull requests, so that it can post the review. It doesn’t check out code or run Cline. It always posts a comment, so nothing Cline writes can approve the pull request.
A pull_request run uses the workflow file from the pull request, so anyone who can push a branch to your repository can edit these permissions. They guard against text in a pull request that tries to make Cline do something else.

Authentication

The auth command configures Cline in the CI environment without interactive prompts. It needs both --apikey and --modelid. You can switch providers (e.g., openai-native, openrouter) by changing the flags.

Autonomous Mode (--auto-approve true)

The --auto-approve true flag tells Cline to run autonomously, executing approved tools without waiting for interactive confirmation. Prompt runs start in Act mode by default, so CI/CD workflows can perform the requested work immediately.

What the Review Job Can Still Do

With --auto-approve true, Cline can run any shell command in the review job; the CLI has no allow or deny list for shell commands. Text in a pull request could persuade Cline to do something other than review it, or change what its review says. The read-only token stops Cline from changing your repository, but the job can still read your code and your provider API key, and it can reach the internet. Use a provider key with a spending limit, and don’t give the review job any other secrets. Cline runs the hooks and plugins it finds in the workspace’s .cline/ and .clinerules/ folders. The job checks out the base branch, so those folders come from your branch, and a pull request can’t add to them or change them. Cline reads the pull request’s changes with gh pr diff.

Pull Requests from Forks

GitHub doesn’t pass your secrets to workflows run for pull requests from forks or from Dependabot, so the review job couldn’t sign in to your provider. The workflow skips those pull requests. Don’t switch to pull_request_target to review them automatically: that trigger runs with your secrets and a token that can write. To review a pull request from a fork, read it first, then run the workflow from the Actions tab and enter the pull request’s number. The run checks out the branch you choose, not the pull request. It still has your provider key, and it can write to that branch’s Actions caches, which your other workflows restore.

Customizing the Reviewer

The prompt passed to Cline in the review step is fully customizable. You can modify it to:
  • Enforce specific style guides.
  • Focus on security vs. performance.
  • Ask for specific types of feedback (e.g., “Roast my code” vs. “Be gentle”).
To post inline comments too, have Cline write them to a JSON file in the review job, and post them from the post job with the pull request reviews API. Set the review’s event to COMMENT in the post job instead of reading it from Cline’s file, so that nothing Cline writes can approve the pull request.