Skip to content

ci: add @claude PR comment responder workflow#973

Merged
BigSimmo merged 2 commits into
mainfrom
claude/github-comments-not-solving-2agr0c
Jul 20, 2026
Merged

ci: add @claude PR comment responder workflow#973
BigSimmo merged 2 commits into
mainfrom
claude/github-comments-not-solving-2agr0c

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add .github/workflows/claude.yml: a workflow that runs a Claude Code session (via the official anthropics/claude-code-action) whenever a collaborator mentions @claude on a PR comment or review. Claude reads the triggering comment, works on the PR's current head, pushes a scoped fix to the PR branch, and replies in the thread.
  • Why: today there is no repo-side automation for the Claude path — it depends on a live, subscribed chat session, which stops receiving webhook events once that ephemeral session goes cold (so comments "are seen but not acted on"). A workflow fires on the webhook every time and is not tied to any session's lifetime.
  • The job is gated to non-bot authors mentioning the trigger phrase (so routine comments and Claude's own replies never spin up a runner), requests only the permissions needed to push a fix and reply, and skips gracefully with a warning when ANTHROPIC_API_KEY is unset.
  • Register anthropics/claude-code-action in scripts/github-action-pins.mjs, pinned to the reviewed v1.0.178 commit SHA (af0559e), so the Actions pin check passes. runs-on is ubuntu-24.04 per the repo's pin policy.

Action required before this works: add an ANTHROPIC_API_KEY repository secret (Settings → Secrets and variables → Actions). To use a Claude subscription instead of pay-per-use API billing, generate a token with claude setup-token, store it as CLAUDE_CODE_OAUTH_TOKEN, and swap the action input anthropic_api_keyclaude_code_oauth_token.

Verification

  • npm run verify:pr-local
  • Ran locally: node scripts/check-github-action-pins.mjs (pass), node scripts/check-codex-autofix-workflow.mjs (pass, unaffected), node scripts/check-pr-policy-workflow.mjs (pass), Prettier --check (pass), and a YAML parse of the new workflow (valid; jobs=[claude], triggers=[issue_comment, pull_request_review_comment, pull_request_review]).
  • Verification not run: full npm run verify:pr-local — this is a CI-config-only change (one workflow file + a pin-allowlist entry) with no application source, RAG, or build surface; the relevant Actions-pin and PR-policy gates were run directly instead.
  • npm run verify:ui — not applicable (no UI, routing, styling, or browser behavior changed).

Risk and rollout

  • Risk: Low. Adds a new, self-contained workflow and one allowlist entry; changes no application code. Worst case if misconfigured, the job no-ops (skips when the secret is absent) rather than affecting existing CI.
  • Rollback: Delete .github/workflows/claude.yml and revert the github-action-pins.mjs entry, or remove the ANTHROPIC_API_KEY secret to disable without a code change.
  • Provider or production effects: The workflow calls the Anthropic API at runtime when @claude is used — this is the explicitly requested behavior and is billed to whichever key/token is configured. No effect until the secret is set.

Clinical Governance Preflight

Not applicable — this change is CI configuration only and does not touch ingestion, answer generation, search/ranking, source rendering, document access, privacy, production env, or clinical output.

Notes

  • The action's default trigger phrase is @claude; it acts only for users with write access to the repo (built-in permission check).
  • Scope is intentionally PR comments/reviews. To also respond to @claude on plain issues, add an issues trigger and branch — happy to follow up if wanted.

Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added an automated Claude Code workflow that can respond to qualifying issue and pull request comments.
    • Added safeguards for secure, controlled execution, including permission limits, concurrency handling, timeouts, and optional API key configuration.
  • Chores

    • Added verification for the approved, pinned version of the Claude Code action.

Add .github/workflows/claude.yml, which runs a Claude Code session via the
official anthropics/claude-code-action whenever a collaborator mentions
"@claude" on a PR comment or review. Unlike a subscribed chat session, this
fires on the webhook every time, so it keeps working after the session that
opened the PR has ended.

The job is gated to non-bot authors mentioning the trigger phrase, skips
gracefully when ANTHROPIC_API_KEY is unset, and requests only the permissions
needed to push a scoped fix and reply. The action is pinned to the reviewed
v1.0.178 commit SHA and registered in scripts/github-action-pins.mjs so the
Actions pin check passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0164nBbEeLzQWWZqBn95o3MW
@supabase

supabase Bot commented Jul 20, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@BigSimmo
BigSimmo marked this pull request as ready for review July 20, 2026 08:44
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow that runs Claude for human @claude mentions in pull request discussions, with scoped permissions, concurrency controls, API-key checks, repository checkout, and a pinned action allowlist entry.

Changes

Claude workflow integration

Layer / File(s) Summary
Workflow triggers and permissions
.github/workflows/claude.yml
Defines pull request discussion triggers, human-only @claude filtering, scoped permissions, concurrency, and a 30-minute timeout.
Claude execution and action pin
.github/workflows/claude.yml, scripts/github-action-pins.mjs
Checks for ANTHROPIC_API_KEY, checks out the repository, invokes the pinned Claude action, and allowlists its immutable SHA for version v1.0.178.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Human
  participant GitHub
  participant ClaudeWorkflow
  participant ClaudeCodeAction
  Human->>GitHub: Mention `@claude` in PR discussion
  GitHub->>ClaudeWorkflow: Trigger workflow event
  ClaudeWorkflow->>ClaudeWorkflow: Validate human author and API key
  ClaudeWorkflow->>ClaudeCodeAction: Run pinned action
  ClaudeCodeAction->>GitHub: Update PR branch or discussion
Loading

Possibly related PRs

Suggested labels: github_actions

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Claude PR comment responder workflow.
Description check ✅ Passed The description covers the required summary, verification, risk/rollback, and notes sections with enough detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/github-comments-not-solving-2agr0c

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 20, 2026 08:45
@BigSimmo
BigSimmo merged commit 6cfb7ff into main Jul 20, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the claude/github-comments-not-solving-2agr0c branch July 20, 2026 08:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/claude.yml:
- Around line 27-38: The Claude workflow trigger condition currently allows any
non-bot user to invoke the job. Update the issue_comment,
pull_request_review_comment, and pull_request_review branches in the workflow if
expression to require the corresponding user’s association to be OWNER, MEMBER,
or COLLABORATOR, while preserving the existing `@claude` and event-specific
checks.
- Around line 57-64: Update the Checkout repository step before Run Claude Code
to resolve github.event.issue.pull_request and configure actions/checkout with
the pull request’s repository, head.ref, and head.sha, ensuring Claude runs
against the PR head rather than the issue-comment event ref.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9376f82d-6733-4f4b-8489-eb924ef49efb

📥 Commits

Reviewing files that changed from the base of the PR and between 6d11e53 and 6bbbc5c.

📒 Files selected for processing (2)
  • .github/workflows/claude.yml
  • scripts/github-action-pins.mjs

Comment on lines +27 to +38
if: >
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request != null &&
github.event.comment.user.type != 'Bot' &&
contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' &&
github.event.comment.user.type != 'Bot' &&
contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' &&
github.event.review.user.type != 'Bot' &&
github.event.review.body != null &&
contains(github.event.review.body, '@claude'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the workflow around the referenced lines.
wc -l .github/workflows/claude.yml
cat -n .github/workflows/claude.yml | sed -n '1,220p'

# Look for any authorization / collaborator / association checks in the workflow.
rg -n "association|OWNER|MEMBER|COLLABORATOR|trusted|collaborator|bot|`@claude`|permissions:|contents: write|pull-requests: write|issues: write|anthropic|api key|token" .github/workflows/claude.yml

Repository: BigSimmo/Database

Length of output: 4863


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for any collaborator/association checks or docs around the Claude workflow.
rg -n "claude-code-action|repository association|COLLABORATOR|MEMBER|OWNER|trusted collaborator|`@claude`|ANTHROPIC_API_KEY|claude_code_oauth_token" . -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**'

# Show any workflow/docs files that mention Claude integration.
git ls-files | rg '(^|/)(README|docs?|\.github/workflows/.*claude.*|.*claude.*)\.(md|yml|yaml)$'

Repository: BigSimmo/Database

Length of output: 28335


Require collaborator-only gating before invoking Claude .github/workflows/claude.yml:27-38

The job still accepts any non-bot @claude mention and then runs with write permissions plus ANTHROPIC_API_KEY. Restrict each trigger to trusted repository associations like OWNER, MEMBER, or COLLABORATOR before allowing it to run.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude.yml around lines 27 - 38, The Claude workflow
trigger condition currently allows any non-bot user to invoke the job. Update
the issue_comment, pull_request_review_comment, and pull_request_review branches
in the workflow if expression to require the corresponding user’s association to
be OWNER, MEMBER, or COLLABORATOR, while preserving the existing `@claude` and
event-specific checks.

Comment on lines +57 to +64
- name: Checkout repository
if: ${{ env.ANTHROPIC_API_KEY != '' }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
- name: Run Claude Code
if: ${{ env.ANTHROPIC_API_KEY != '' }}
uses: anthropics/claude-code-action@af0559ee4f514d1ef21826982bed13f7edc3c35e # v1.0.178

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/workflows/claude.yml"

echo "=== file listing ==="
git ls-files "$file"

echo
echo "=== line count ==="
wc -l "$file"

echo
echo "=== relevant excerpt ==="
sed -n '1,220p' "$file"

Repository: BigSimmo/Database

Length of output: 3354


🌐 Web query:

actions/checkout default ref issue_comment github.event.ref default branch documentation claude-code-action current PR head checkout

💡 Result:

The actions/checkout action has specific default behaviors regarding what it checks out depending on the triggering event, and navigating these defaults—particularly for issue_comment events or pull request contexts—often requires explicit configuration [1][2][3]. Default Behavior By default, actions/checkout checks out the reference or SHA that triggered the workflow [1][3]. For events that do not have a specific reference (or when the context is ambiguous), it falls back to the default branch [1][2][3]. Notably, for pull_request events, the default is to checkout the merge commit (refs/pull/PULL_REQUEST_NUMBER/merge), not the individual head branch of the pull request [4][5]. Issue Comment and Pull Request Contexts When a workflow is triggered by an issue_comment event, GitHub does not automatically checkout the pull request branch [6][2]. To checkout the source branch of a pull request from an issue_comment event, you must dynamically determine the PR head reference and pass it to the ref input [6]: 1. Use actions/github-script to retrieve the pull request head ref [6]. 2. Pass that reference to actions/checkout [6]. Example pattern to checkout the PR branch or fallback to default: - uses: actions/github-script@v7 id: pr if: ${{ github.event.issue.pull_request }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.issue.number }); core.setOutput('head_ref', pr.head.ref); - uses: actions/checkout@v4 with: ref: ${{ github.event.issue.pull_request && steps.pr.outputs.head_ref || github.ref }} Claude Code Action Configuration For users of anthropics/claude-code-action, the action expects a repository checkout to exist before it runs [7][8]. Standard practice is to run actions/checkout@v4 before the Claude step [7][8]. If you encounter failures related to branch setup (e.g., when using persist-credentials: false), it is often because the action attempts to fetch origin before configuring its own authentication; in such cases, ensure proper credential persistence or follow the maintainer-recommended workarounds for your specific environment [9].

Citations:


🌐 Web query:

anthropics claude-code-action README current PR head checkout issue_comment actions/checkout default ref

💡 Result:

In GitHub Actions workflows using anthropics/claude-code-action, the interaction between actions/checkout and the action itself is a critical security and functional consideration [1][2]. For workflows triggered by events like issue_comment or pull_request_target, it is recommended to check out the base repository's code at the workspace root by default [1][2]. Because claude-code-action performs actor permission checks and restores project configuration from the base ref, checking out an untrusted head ref (such as github.event.pull_request.head.sha) directly into the workspace root can pose security risks when running with the base repository's secrets [1][2]. To work safely with Pull Request files: 1. Preferred approach: Check out the base ref (the default) at the workspace root [1][2]. yaml - uses: actions/checkout@v6 # No ref specified → defaults to base branch - uses: anthropics/claude-code-action@v1 2. Accessing PR files: If the action needs access to the PR's specific files, check out the base branch at the root, then check out the head ref into a separate subdirectory and provide it to the action via the --add-dir argument [1][2]. yaml - uses: actions/checkout@v6 # Base branch at workspace root - uses: actions/checkout@v6 with: ref: ${{ github.event.pull_request.head.sha }} path: pr-head - uses: anthropics/claude-code-action@v1 with: claude_args: "--add-dir pr-head" Regarding branch selection, the claude-code-action maintains logic to determine the active branch [3]. While it previously defaulted to "main," recent updates ensure it falls back to the repository's default_branch if available [3]. Users can also explicitly specify a branch for operations using the base_branch input parameter if necessary [4].

Citations:


Check out the PR head before running Claude on issue_comment.
actions/checkout will otherwise use the event ref here, which is the base branch for issue comments, so Claude works from the wrong code. Resolve github.event.issue.pull_request and pass the PR’s repository plus head.ref/head.sha into checkout first.

🧰 Tools
🪛 zizmor (1.26.1)

[warning] 57-61: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude.yml around lines 57 - 64, Update the Checkout
repository step before Run Claude Code to resolve
github.event.issue.pull_request and configure actions/checkout with the pull
request’s repository, head.ref, and head.sha, ensuring Claude runs against the
PR head rather than the issue-comment event ref.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/claude.yml:
- Around line 62-68: Update the “Run Claude Code” workflow step and its action
configuration to use the flow that applies fixes directly to the triggering pull
request branch instead of creating a new claude/ branch and returning a separate
PR link. Preserve the existing API-key condition and secret wiring.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 03f7c63d-4735-48b6-9bd3-8d51379e526a

📥 Commits

Reviewing files that changed from the base of the PR and between 6d11e53 and 6bbbc5c.

📒 Files selected for processing (2)
  • .github/workflows/claude.yml
  • scripts/github-action-pins.mjs

Comment on lines +62 to +68
- name: Run Claude Code
if: ${{ env.ANTHROPIC_API_KEY != '' }}
uses: anthropics/claude-code-action@af0559ee4f514d1ef21826982bed13f7edc3c35e # v1.0.178
with:
# The action's default trigger phrase is "@claude"; it reads the
# triggering comment/review and acts on the current PR head.
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== workflow file ==\n'
cat -n .github/workflows/claude.yml | sed -n '1,180p'

printf '\n== references to claude-code-action ==\n'
rg -n "claude-code-action|ANTHROPIC_API_KEY|`@claude`|claude/" .github/workflows . -g '*.yml' -g '*.yaml' -g '*.md' -g '*.txt' || true

Repository: BigSimmo/Database

Length of output: 50374


🏁 Script executed:

#!/bin/bash
set -euo pipefail
cat -n .github/workflows/claude.yml | sed -n '1,180p'

Repository: BigSimmo/Database

Length of output: 3702


🌐 Web query:

anthropics/claude-code-action docs security default @claude creates branch PR-creation link direct update flow

💡 Result:

Claude Code and its associated GitHub Action provide automated workflows for branch management and pull request (PR) creation, supported by specific security configurations [1][2]. Security and Default Behaviors: For the Claude Code Action on GitHub, bot user control is enabled by default for security, meaning bots cannot trigger the action unless explicitly configured via the allowed_bots parameter [3][4]. Caution is advised when using wildcards ('*') for allowed bots, as this can allow external, uninstalled apps to trigger workflows on public repositories [3][4]. Claude Code itself enforces strict read-only permissions by default, requiring explicit user approval for any operations that modify files, execute shell commands, or perform network requests [5][6]. Branch and PR Creation Flow: Claude Code automates the Git lifecycle through natural language instructions [2][7]. Users can request branch creation and PR generation directly within the conversational interface [8][2]. 1. Branch Creation: When asked to create a branch, Claude Code typically handles the naming based on project conventions (e.g., CLAUDE.md) or defaults to patterns like feature/ or fix/ [9][7]. It executes the necessary git checkout commands automatically [2]. 2. PR Creation: Claude uses the GitHub CLI (gh) tool under the hood to manage pull requests [2][7]. A single command like "create a PR" triggers a process where Claude analyzes commits, generates a title and summary, and creates the PR via gh pr create [2][7]. 3. Session Linking: When a PR is created through this flow, the active conversational session is automatically linked to that PR [8][9]. This allows users to resume the session later using the PR number or URL to continue working on feedback or CI results [8][10]. For direct update flows, Claude Code performs background checks for updates on startup, with native installations updating automatically by default [11][12]. Users can configure release channels or disable these updates depending on their installation method (e.g., Homebrew/WinGet vs. native) [11][12].

Citations:


🌐 Web query:

site:github.com/anthropics/claude-code-action/docs/security.md "@claude" branch PR current PR head anthropic_api_key claude_code_oauth_token

💡 Result:

Key points from security.md:

  • If you use pull_request_target or workflow_run, don’t check out the PR head into the workspace root before claude-code-action; if you do, Claude runs on that untrusted checkout. Use the base branch at the root, or check out the PR head into a subdirectory and pass it via --add-dir. The doc specifically references github.event.pull_request.head.sha and github.event.workflow_run.head_sha. [1]
  • Never hardcode anthropic_api_key or claude_code_oauth_token in workflow files; store them in GitHub Secrets instead. [1]
  • In the default @claude flow, Claude does not auto-create PRs; it commits to a new branch and gives you a PR link to open manually. [1]

If you want, I can extract the exact YAML-safe pattern from that doc.


Update .github/workflows/claude.yml:62-68 to match the actual flow. The default @claude path creates a new claude/ branch and returns a PR link, so this does not push fixes to the triggering PR branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/claude.yml around lines 62 - 68, Update the “Run Claude
Code” workflow step and its action configuration to use the flow that applies
fixes directly to the triggering pull request branch instead of creating a new
claude/ branch and returning a separate PR link. Preserve the existing API-key
condition and secret wiring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants