From 21def5b60858ee11f9366086c3460034be90978a Mon Sep 17 00:00:00 2001 From: Thomas Pinder Date: Sun, 4 Oct 2026 09:33:19 +0000 Subject: [PATCH] ci: add Claude PR review agent A PR comment that mentions @claude-pr-review runs the pr-reviewer agent (.claude/agents/pr-reviewer.md) through anthropics/claude-code-action. Only comments from thomaspinder trigger it, because the run is billed to a personal Claude subscription. Co-Authored-By: Claude Opus 5.5 --- .claude/agents/pr-reviewer.md | 14 +++++++++ .github/workflows/claude-pr-review.yml | 43 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .claude/agents/pr-reviewer.md create mode 100644 .github/workflows/claude-pr-review.yml diff --git a/.claude/agents/pr-reviewer.md b/.claude/agents/pr-reviewer.md new file mode 100644 index 0000000..7c73224 --- /dev/null +++ b/.claude/agents/pr-reviewer.md @@ -0,0 +1,14 @@ +--- +name: pr-reviewer +description: Reviews an Impulso pull request against the PR Review Policy in AGENTS.md and posts the findings on GitHub. Runs when a PR comment mentions @claude-pr-review. +--- + +You review pull requests for Impulso. You do not edit files, commit, or push. + +Read `AGENTS.md` and `.claude/commands/pr-review.md` before you start. Follow the PR Review Policy in `AGENTS.md`, and the procedure, classification rules and output format in `.claude/commands/pr-review.md`, with these changes for GitHub Actions: + +- Get the diff with `gh pr diff `, and the title, description and linked issues with `gh pr view `. Do not use `git diff origin/$BASE_REF...HEAD`; the base branch is not fetched. +- Do not run `gh pr comment`. Put the full review in your tracking comment. +- For each in-scope item on a changed line, also post an inline comment on that line with `mcp__github_inline_comment__create_inline_comment`, and set `confirmed: true`. + +If the comment that asked for the review gives more instructions (for example "focus on the identification code"), follow them within the policy. diff --git a/.github/workflows/claude-pr-review.yml b/.github/workflows/claude-pr-review.yml new file mode 100644 index 0000000..f52e0cf --- /dev/null +++ b/.github/workflows/claude-pr-review.yml @@ -0,0 +1,43 @@ +name: Claude PR review + +# Runs the `pr-reviewer` agent (.claude/agents/pr-reviewer.md) on a pull request +# when a comment mentions `@claude-pr-review`. Text after the mention reaches the +# agent as extra instructions. The action loads `.claude/` from the PR's base +# branch, so agent changes take effect once merged into `main`. + +on: + issue_comment: + types: [created] + +permissions: + contents: read + +jobs: + review: + # Only PR comments that mention the agent, and only from the maintainer: + # the run is billed to a personal Claude subscription. + if: >- + github.event.issue.pull_request && + contains(github.event.comment.body, '@claude-pr-review') && + github.actor == 'thomaspinder' + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + pull-requests: write + issues: write + id-token: write + steps: + - name: Check out + uses: actions/checkout@v7 + with: + fetch-depth: 1 + + - name: Run the reviewer agent + uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + trigger_phrase: "@claude-pr-review" + claude_args: | + --agent pr-reviewer + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr diff:*),Bash(gh pr view:*)"