You have two devs on vacation, a critical feature branch piling up, and nobody available for yet another nit-pick review. "Ship fast, fix later" is tempting—until Friday night deploys teach you otherwise. In this guide I’ll show the exact OpenClaw code review automation setup for small teams that saves me ~45 minutes per pull request without letting bugs slip through.
Why Automate Code Review When You Don't Have Bandwidth
Code review does three different jobs:
- Enforce syntax and style so the codebase stays consistent.
- Catch obvious security / performance issues before they reach staging.
- Transfer knowledge between humans.
Only the last one requires a human every time. The first two can be scripted. When your team is 2-10 people, the biggest bottleneck is folks being busy (or asleep in a different time zone). Automating the boring parts means you’re only paging a developer when it really matters.
OpenClaw already knows how to run a shell, talk to GitHub’s API, and reason about text files. In practice that gives you:
- Instant feedback when a pull request (PR) is opened or updated.
- Inline suggestions that can be batch-applied with one click.
- Security red-flags based on rules you define (I’m using Semgrep).
- An explicit “human override” path so the bot doesn’t block shipping.
What OpenClaw Can (and Cannot) Do in a PR Review
Before wiring anything up, be clear about trade-offs:
- Great at repetitive patterns. Formatting, unused variables, simple refactors.
- Surprisingly good at explaining code. The GPT-4-turbo backend summarizes functions in plain English—handy for junior devs.
- Bad at architectural judgment. Don’t let it approve a migration strategy or API contract on its own.
- Sometimes noisy. If you feed the model the entire diff plus 15 plugins, expect comments like “Consider improving naming” on every line.
Keep that mental model as we design the workflow: automated recommendations, human decisions.
Baseline Setup: Wiring GitHub, OpenClaw, and Composio
1. Install the OpenClaw daemon locally or on ClawCloud
You can self-host if you already have a CI box, but most small teams I’ve worked with just spin up a free ClawCloud agent:
# one-time sign-up
$ curl -s https://claw.cloud/install.sh | bash
# name your agent, choose region, you’re live in 60 seconds
If you prefer on-prem:
$ nvm install 22
$ npm install -g openclaw@latest # currently 1.8.2
$ claw daemon & # keepalive process
2. Generate a GitHub App token
Create a private GitHub App with pull_request and contents read/write scopes. Note the App ID, installation ID, and a PEM private key.
Inside your agent settings (UI or ~/.claw/config.json):
{
"tools": {
"github": {
"appId": "123456",
"installationId": "987654",
"privateKeyPath": "~/.ssh/gh-app.pem"
}
}
}
3. Enable the GitHub → OpenClaw trigger
OpenClaw ships a built-in webhook listener. Point your GitHub App to https://<your-agent>.claw.cloud/github/webhook and subscribe to:
- pull_request (opened, synchronize, reopened)
- issue_comment (created)
4. Add Composio integrations
For style checks we’ll call ESLint and Prettier; for security we’ll call Semgrep. Composio already has these wrappers:
$ claw tool:add eslint@8.56.0
$ claw tool:add semgrep@1.67.0
This means the agent can do eslint --fix or semgrep --config=p/ci inside the checkout directory without manual installation on the runner.
Adding Linters and Static Analysis Into the Agent
You’ll need two pieces:
- A GitHub Action (or any CI job) that fetches the diff and sends it to OpenClaw.
- An OpenClaw task that decides which linters to run and how to post comments back.
1. The GitHub Action
Add .github/workflows/claw-review.yml:
name: "OpenClaw PR Review"
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Notify OpenClaw
env:
CLAW_ENDPOINT: ${{ secrets.CLAW_ENDPOINT }}
CLAW_TOKEN: ${{ secrets.CLAW_TOKEN }}
run: |
curl -X POST $CLAW_ENDPOINT/review \
-H "Authorization: Bearer $CLAW_TOKEN" \
-d '{ "pr": "${{ github.event.pull_request.html_url }}" }'
Tip: Instead of checking out the repo twice (CI and agent), pass GITHUB_SHA and let OpenClaw use GitHub’s REST API to pull the diff. Saves minutes on every run.
2. The OpenClaw Task
Create tasks/review.mjs in your agent repo:
import { exec } from 'node:child_process';
import { comment, approve, requestChanges } from '@claw/github';
export default async function review(pr) {
await comment(pr, `👋 Automated review in progress…`);
// 1. Run ESLint + Prettier fix in dry-run mode
let lint = await exec('eslint **/*.js --format json');
if (lint.stdout) {
const issues = JSON.parse(lint.stdout);
for (const file of issues) {
for (const msg of file.messages) {
await comment(pr, `${file.filePath}:${msg.line} – ${msg.message}`);
}
}
}
// 2. Run Semgrep for security patterns
let sec = await exec('semgrep ci --json');
if (sec.stdout) {
const findings = JSON.parse(sec.stdout);
for (const f of findings.results) {
await comment(pr, `⚠️ ${f.path}:${f.start.line} – ${f.extra.message}`);
}
}
// 3. Ask the LLM for high-level feedback (diff limited to 400 lines)
const diff = await pr.diff({ maxLines: 400 });
const ai = await claw.llm.chat({
system: `You are a senior engineer. Point out logic issues, missing tests, and unclear naming. Be concise.`,
user: diff
});
await comment(pr, ai.content);
// 4. Decide status: if only nits, auto-approve
if (lint.exitCode === 0 && sec.exitCode === 0) {
await approve(pr, `LGTM (automated)`);
} else {
await requestChanges(pr, `Please address the comments above.`);
}
}
Restart the daemon so it picks up the new task:
$ claw daemon --reload
Writing the Review Prompt: Context Windows Matter
The biggest lever for signal-to-noise is the prompt. I wasted days feeding the entire repo to GPT-4. It cost money and produced paragraphs like “Consider improving modularity.” Not helpful.
My current recipe:
- If the diff is < 400 lines, pass the whole thing.
- Else include only modified functions plus the file header comment.
- Truncate historical conversation beyond the last 4 messages.
- Add a system instruction: “If you’re not sure, say you’re not sure.”
In practice this drops OpenAI spend from ~$0.25 to $0.06 per PR and reduces generic comments by ~70% (measured across 57 PRs last month).
Human Override Workflow: Labels, Slash Commands, Auto-Dismiss
No matter how well you tune, the bot will misfire. Here’s the escape hatch:
- Skip per label. If a PR has
skip-botlabel, the action exits early. You can add it via GitHub’s UI or a/skip-botcomment. - Override decisions. Maintainers can comment
/approveor/reject, and the agent updates the PR review status accordingly. - Auto-dismiss stale comments. When a new commit resolves an issue (file diff no longer contains the offending line), the daemon calls
POST /pulls/:number/reviews/:id/dismissalsso your conversation stays clean.
Implementation snippet:
import { onIssueComment } from '@claw/github';
onIssueComment(async (comment, pr) => {
if (comment.body === '/approve') {
await pr.approve('Manual override');
}
if (comment.body === '/skip-bot') {
await pr.label('skip-bot');
}
});
Tuning the Signal-to-Noise Ratio
Metrics I track:
- Comments per 100 lines of diff. Aim for < 5. Anything above that is spam.
- False-positive rate. Percentage of bot comments deleted by humans. Keep it under 10%.
- Merge delay. Time from PR opened to merged. The goal is no worse than before automation.
Levers to pull:
- Switch ESLint to
--quietmode so only errors, not warnings, are emitted. - Add
semgrep.ignorepatterns (i.e.,tests/**) to skip noisy folders. - Set
LLM_temperature = 0.2. Higher temps generate creative prose, which is not what you want in reviews. - Cap LLM responses:
max_tokens = 300.
Real-World Numbers
After two weeks:
- Bot auto-approved 38% of PRs (mostly typo fixes & doc updates).
- Average human review comments dropped from 9.1 → 3.4.
- CI time + bot action added 1m12s per PR. Acceptable trade-off.
When to Skip AI and Call a Human
The heuristic I give teammates:
- If the PR touches more than 3 modules, mark
/needs-human. - If the change deletes more lines than it adds (big refactor), skip the bot.
- If the PR introduces an external dependency (new package.json entry), skip.
- If the author is a junior dev, don’t skip—AI explanations help them learn.
You can codify rule #3 by grepping the diff for "dependencies" in package.json and aborting the task. The others are social conventions.
The Practical Next Step
Clone openclaw-recipes, copy claw-review.yml and tasks/review.mjs, then open a tiny PR in your own repo. Measure how many comments feel useful vs. distracting. Tweak the prompt and linter settings before rolling it out team-wide. Ten lines of config can save you hours—just remember the bot is a junior reviewer, not a senior architect.