Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

README.md

65 lines3.7 KB

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

  1. A machine GitHub user with write access on this repo.
  2. A PAT for that user, stored as repo secret AI_REVIEW_TOKEN. The PAT needs repo so it can approve waiting Actions runs.
  3. An xAI key, stored as repo secret XAI_API_KEY.
  4. Set AI_REVIEW_MACHINE_USER in the workflow to that user's login (default tanstack-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_request opened, 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_dispatch with a PR number.
  • Manual: a login in .github/maintainers.json comments /ai-review on the PR.
  • Manual: a login in .github/maintainers.json adds the ai-review label. 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.

LabelMeaning
ai-rejectedNot useful, or it does not fix the claimed bug.
ai-needs-workListed fixes are not on the branch (no push, or maintainer edits off).
ai-readyThe bot thinks a maintainer can merge after they Approve.
secureHost 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_TOKEN or XAI_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.