agent-scripts/ai-review
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
Grok PR review bot#
A GitHub Action that reviews open pull requests with TanStack AI (chat() + grokBuildText('grok-4.6')). It comments, sets one ai-* label, and can push listed polish commits.
The first lines of every bot comment say the comment is automated. It is not a maintainer review. The bot never GitHub-approves a review and never merges.
What you need#
- A machine GitHub user with write access on this repo.
- A PAT for that user, stored as repo secret
AI_REVIEW_TOKEN. The PAT needsreposo it can approve waiting Actions runs. - An xAI key, stored as repo secret
XAI_API_KEY. - Set
AI_REVIEW_MACHINE_USERin the workflow to that user's login (defaulttanstack-ai-bot).
Until both secrets exist, the job fails with missing AI_REVIEW_TOKEN or XAI_API_KEY. It does not comment as github-actions[bot].
How a run starts#
- Auto:
pull_requestopened, synchronize, or ready_for_review, when the PR is not a draft. - Auto does not start when the PR author is AlemTuzlak, tombeckenham, or jherr.
- Keep those logins in sync with
.github/maintainers.json. GitHub then shows a skipped check, not a cancelled check. - Manual: Actions
workflow_dispatchwith a PR number. - Manual: a login in
.github/maintainers.jsoncomments/ai-reviewon the PR. - Manual: a login in
.github/maintainers.jsonadds theai-reviewlabel. Remove it and add it again to run a second time.
Auto also skips drafts, bot PRs, roster-maintainer PRs, the machine user's own head commit, and a head SHA this bot already reviewed. Manual still runs on those. The bot never executes PR code.
A first-time fork PR does not run auto review until a maintainer comments /ai-review or adds the ai-review label. After a clean ai-ready scan, the bot approves the waiting Test checks.
Labels#
A roster maintainer adds the ai-review label to start a manual run. The bot does not remove that label. The bot does not auto-approve workflows when the PR changes a workflow file.
The bot sets exactly one of these verdict labels. It removes the other two. It never touches ready-to-merge.
When the verdict is ai-ready and a host scan finds no malware, the bot adds secure. Then it approves waiting first-time-contributor workflow runs. A maintainer can Approve and merge without clicking Approve and run workflows first.
| Label | Meaning |
|---|---|
ai-rejected | Not useful, or it does not fix the claimed bug. |
ai-needs-work | Listed fixes are not on the branch (no push, or maintainer edits off). |
ai-ready | The bot thinks a maintainer can merge after they Approve. |
secure | Host scan found no malware. The bot approved waiting workflow runs. |
Local run#
pnpm test:ai-review
A full agent run needs AI_REVIEW_TOKEN, XAI_API_KEY, GITHUB_EVENT_NAME, GITHUB_EVENT_PATH, GITHUB_REPOSITORY, and AI_REVIEW_WORKTREE pointing at a checkout of the PR head. Do not run pnpm install in that worktree.
Failed run#
Open the AI review workflow log. The job prints text, reasoning, tool input/output, and the verdict. It does not print raw chunks.
Common causes:
- Missing
AI_REVIEW_TOKENorXAI_API_KEY - Fork with maintainer edits off (comment is posted, label is
ai-needs-work, no push) chat()did not return a valid verdict object- Workspace setup failed to install the Grok CLI
Layout#
Code lives in agent-scripts/ai-review/, not under scripts/. The maintainer sweep stays in scripts/maintainer/ and does not review diffs.