The Workflow
The workflow has two jobs, so that the job that runs Cline can’t change your repository or the pull request:reviewgets 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.postgets 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
- Go to your repository settings -> Secrets and variables -> Actions.
- Add a New repository secret.
- Name:
ANTHROPIC_API_KEY(or match the key used in your workflow). - Value: Your actual API key.
Key Components Explained
Permissions
reviewcan 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.postcan 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.
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
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)
--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 topull_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”).
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.