From b8083942a60d437daae64b0e8278903e9df02f00 Mon Sep 17 00:00:00 2001 From: etrobert-bot Date: Tue, 30 Jun 2026 14:34:27 +0200 Subject: [PATCH] ci: respond to PR comments via claude-code-action on the Max plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a workflow that runs anthropics/claude-code-action@v1 on every human comment/review on a PR (issue_comment, pull_request_review_comment, pull_request_review) — no @claude mention required. Claude reads the comment in context and either pushes a fix to the PR branch or replies, following the repo's Conventional Comments convention. It never merges. Authenticated with CLAUDE_CODE_OAUTH_TOKEN so usage draws from the Claude Max subscription rather than API credits. Loop-guarded two ways: the job `if` skips bot senders, and exclude_comments_by_actor ignores Claude's own replies. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/claude-pr-comment.yml | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/claude-pr-comment.yml diff --git a/.github/workflows/claude-pr-comment.yml b/.github/workflows/claude-pr-comment.yml new file mode 100644 index 00000000..d5bf965b --- /dev/null +++ b/.github/workflows/claude-pr-comment.yml @@ -0,0 +1,67 @@ +--- +name: Claude PR comment handler + +# Respond to every human comment/review on a PR — no @claude mention needed. +# Runs on the Max subscription via CLAUDE_CODE_OAUTH_TOKEN (not API credits). +"on": + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + pull_request_review: + types: [submitted] + +# One run per PR; newer comments supersede an in-flight run. +concurrency: + group: + claude-pr-comment-${{ github.event.issue.number || + github.event.pull_request.number }} + cancel-in-progress: false + +permissions: + contents: write + pull-requests: write + issues: write + id-token: write + +jobs: + respond: + # Only on PR-attached comments, with a non-empty body, and never from a bot + # (the loop guard: Claude's own replies are bot comments, so they can't + # re-trigger this workflow). + if: > + github.event.sender.type != 'Bot' && ( + (github.event_name == 'issue_comment' && github.event.issue.pull_request + != null) + || github.event_name == 'pull_request_review_comment' + || (github.event_name == 'pull_request_review' && + github.event.review.body != '') + ) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - uses: anthropics/claude-code-action@v1 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + # Belt-and-suspenders loop guard alongside the sender.type check above. + exclude_comments_by_actor: "etrobert-bot,github-actions[bot],claude[bot]" + prompt: | + A human just left a comment or review on this pull request. Read it + in the full context of the PR diff and the conversation so far, then + handle it: + + - If it requests a change, or makes a suggestion you agree with, + implement it and push a commit to this PR's branch. + - If it asks a question, answer it as a reply. + - If it is purely informational (e.g. "thanks", "lgtm"), a brief + acknowledgement is enough — don't manufacture work. + + Follow this repo's Conventional Comments convention (issue, + question, suggestion, nitpick). Always reply on the thread so the + author knows the comment was handled. Do NOT merge — a human reviews + and merges. + claude_args: | + --max-turns 20