Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
Comment on lines +3 to +5

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files:\n'
git ls-files '.github/workflows/claude-code-review.yml' || true

printf '\nLine-numbered contents:\n'
cat -n .github/workflows/claude-code-review.yml

printf '\nWorkflow outline (if supported):\n'
ast-grep outline .github/workflows/claude-code-review.yml 2>/dev/null || true

Repository: ophi-dev/antlr-rust-runtime

Length of output: 2068


Cancel stale reviews per pull request. Add a workflow-level concurrency group with cancel-in-progress: true so newer synchronize runs replace older Claude review runs and avoid stale duplicate comments.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 3-3: truthy value should be one of [false, true]

(truthy)

🪛 zizmor (1.26.1)

[warning] 3-11: insufficient job-level concurrency limits (concurrency-limits): workflow is missing concurrency setting

(concurrency-limits)

🤖 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-code-review.yml around lines 3 - 5, Add a
workflow-level concurrency configuration alongside the pull_request trigger,
using a pull-request-specific group and enabling cancel-in-progress so newer
synchronize runs cancel older Claude review runs. Keep the existing trigger
types unchanged.

Source: Linters/SAST tools

# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
Comment on lines +22 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Files ==\n'
git ls-files '.github/workflows/claude-code-review.yml' '.github/workflows/claude.yml' || true

printf '\n== claude-code-review.yml ==\n'
cat -n .github/workflows/claude-code-review.yml

printf '\n== claude.yml ==\n'
cat -n .github/workflows/claude.yml

printf '\n== Search for workflow/action usage ==\n'
rg -n "pull-requests:|issues:|actions:|anthropic|claude|checkout@" .github/workflows .github -g '*.yml' -g '*.yaml' || true

Repository: ophi-dev/antlr-rust-runtime

Length of output: 12325


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "hello"

Repository: ophi-dev/antlr-rust-runtime

Length of output: 171


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1,220p' .github/workflows/claude-code-review.yml
printf '\n---\n'
sed -n '1,220p' .github/workflows/claude.yml

Repository: ophi-dev/antlr-rust-runtime

Length of output: 3489


🌐 Web query:

anthropics/claude-code-action workflow permissions pull-requests issues write GITHUB_TOKEN OAuth token comments documentation

💡 Result:

To use the anthropics/claude-code-action, you must configure specific GitHub workflow permissions and authentication to enable the action to interact with your repository. Required Workflow Permissions In your GitHub Actions workflow YAML file, you must explicitly define the following permissions to allow the action to read and write to your repository [1][2]: permissions: contents: write pull-requests: write issues: write id-token: write # Required for OIDC authentication to the Claude GitHub App If you need Claude to access workflow runs, job logs, or test results, you must also add actions: read to these permissions [2][3]. Authentication and OAuth Tokens The claude-code-action typically uses the Claude GitHub App [1][4]. The action uses OpenID Connect (OIDC) to exchange an identity token for an app token, which is why id-token: write is mandatory [2][5]. If you choose not to use the official GitHub App or need to override the default behavior, you can provide your own github_token (such as a Personal Access Token or a custom app token) as an input to the action [2][3]. Note that if you use a custom token, you must ensure it has the necessary contents, pull-requests, and issues write permissions to perform its tasks [1][4]. Security Considerations * Repository Write Access: As a security measure, only users with write access to the repository can trigger the action by default [2][4]. * Bot Triggers: By default, other bots cannot trigger the action. If you need to enable this, you must use the allowed_bots parameter [4]. * Least Privilege: Always specify permissions explicitly in your workflow rather than relying on default settings, and use GitHub Secrets for any sensitive tokens [2]. * Fine-Grained Permissions: For more advanced control within the Claude Code tool itself (not just the GitHub Action), you can manage tool-level permissions using the /permissions command in the Claude Code CLI [6][7].

Citations:


Grant the Claude workflows the write scopes they require.

  • .github/workflows/claude-code-review.yml: anthropics/claude-code-action needs contents: write, pull-requests: write, issues: write, and id-token: write; the current read-only scopes will block review/comment creation.
  • .github/workflows/claude.yml: apply the same write scopes; keep actions: read only for CI-result access.
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 24-24: permissions without explanatory comments (undocumented-permissions): needs an explanatory comment

(undocumented-permissions)

📍 Affects 2 files
  • .github/workflows/claude-code-review.yml#L22-L26 (this comment)
  • .github/workflows/claude.yml#L21-L26
🤖 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-code-review.yml around lines 22 - 26, Update the
permissions for the workflow at .github/workflows/claude-code-review.yml, lines
22-26, to grant contents, pull-requests, and issues write access while retaining
id-token write. Apply the same write scopes in .github/workflows/claude.yml,
lines 21-26, and preserve actions read there for CI-result access.


Comment on lines +21 to +27
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
Comment on lines +29 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## Workflow files\n'
git ls-files .github/workflows/claude-code-review.yml .github/workflows/claude.yml

printf '\n## Relevant lines\n'
for f in .github/workflows/claude-code-review.yml .github/workflows/claude.yml; do
  echo "---- $f ----"
  cat -n "$f" | sed -n '1,120p'
done

printf '\n## Search for other action pins in workflows\n'
rg -n 'uses:\s*[^@]+@' .github/workflows -g '*.yml' -g '*.yaml'

Repository: ophi-dev/antlr-rust-runtime

Length of output: 7088


Pin these workflow actions to immutable SHAs.
Both Claude jobs still reference mutable tags in privileged contexts:

  • .github/workflows/claude-code-review.yml: actions/checkout@v4, anthropics/claude-code-action@v1
  • .github/workflows/claude.yml: actions/checkout@v4, anthropics/claude-code-action@v1
🧰 Tools
🪛 zizmor (1.26.1)

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

(artipacked)


[error] 30-30: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 36-36: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

📍 Affects 2 files
  • .github/workflows/claude-code-review.yml#L29-L36 (this comment)
  • .github/workflows/claude.yml#L28-L35
🤖 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-code-review.yml around lines 29 - 36, Pin the
actions/checkout and anthropics/claude-code-action references to immutable
commit SHAs in both .github/workflows/claude-code-review.yml lines 29-36 and
.github/workflows/claude.yml lines 28-35, replacing the mutable v4 and v1 tags
while preserving the existing action configuration.

Source: Linters/SAST tools

with:
Comment on lines +34 to +37
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip forked PRs before reading Claude secrets

For pull_request runs opened from forks, GitHub does not pass repository secrets other than GITHUB_TOKEN, so secrets.CLAUDE_CODE_OAUTH_TOKEN is empty and this action has no Claude authentication to use. Because the workflow has no fork guard, external contributor PRs will get a failed Claude Code Review check instead of a skipped review; add an if that excludes forked heads or switch to a carefully scoped pull_request_target pattern.

Useful? React with 👍 / 👎.

plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
plugins: 'code-review@claude-code-plugins'
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
Comment on lines +36 to +41

Copy link
Copy Markdown

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

echo "== workflow =="
sed -n '1,120p' .github/workflows/claude-code-review.yml

echo
echo "== repo references =="
rg -n --hidden --glob '!**/.git/**' --glob '!**/node_modules/**' "code-review|claude_args|--comment|plugin_marketplaces|plugins:" .github/workflows . || true

Repository: ophi-dev/antlr-rust-runtime

Length of output: 2890


🏁 Script executed:

#!/bin/bash
set -euo pipefail

wc -l .github/workflows/claude-code-review.yml
printf '\n'
cat -n .github/workflows/claude-code-review.yml | sed -n '1,120p'

Repository: ophi-dev/antlr-rust-runtime

Length of output: 1951


🌐 Web query:

Anthropic claude-code code-review README --comment claude_args inline-comment GitHub CLI tools

💡 Result:

Claude Code provides a dedicated /code-review command designed to analyze diffs for correctness bugs, style issues, and efficiency improvements [1][2][3]. When using this command, the --comment flag is specifically used to post findings as inline comments directly on a GitHub Pull Request [1][2]. Usage and Integration: - Local Execution: The /code-review command is run within a Claude Code terminal session [1][3]. It automatically detects the open GitHub pull request associated with your current branch, provided the GitHub CLI (gh) is installed [2]. - Command Syntax: To run a review and post findings as inline comments, use: /code-review --comment [2][4] - Modifiers: You can specify effort levels (e.g., /code-review high --comment) to control the depth of the analysis [2][3]. - Alternative (GitHub App/Actions): For team-wide automation, you can use the managed Claude GitHub App (via Anthropic's organization settings) to trigger reviews on PR events (creation, push, or manual comment), or use the anthropics/claude-code-action in self-hosted GitHub Actions workflows to achieve similar inline feedback [1][3]. The --comment flag effectively bridges the local CLI environment with GitHub's code review interface, allowing for seamless integration into development workflows without leaving the terminal [2][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,120p' .github/workflows/claude.yml

Repository: ophi-dev/antlr-rust-runtime

Length of output: 2051


Run /code-review in comment mode
Add --comment to the prompt and pass the GitHub CLI/inline-comment tools through claude_args; otherwise this step only prints to the terminal instead of posting PR review comments.

🧰 Tools
🪛 zizmor (1.26.1)

[error] 36-36: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 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-code-review.yml around lines 36 - 41, Update the
Claude Code action configuration to append --comment to the prompt and configure
claude_args to pass the GitHub CLI and inline-comment tools, ensuring the
code-review command posts review comments on the pull request instead of only
printing output.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add --comment to publish review results

With this prompt, the automatic pull_request workflow invokes the code-review plugin without --comment; the upstream command instructions say the plugin stops after printing the terminal summary when that flag is absent, so each PR review can consume a Claude run and finish without posting any PR summary or inline comments. Add --comment to the slash command so the workflow actually publishes review feedback.

Useful? React with 👍 / 👎.

# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options

50 changes: 50 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
Comment on lines +8 to +9
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
Comment on lines +15 to +19
Comment on lines +8 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

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

Repository: ophi-dev/antlr-rust-runtime

Length of output: 2462


Remove the assigned issue trigger.
issues.assigned re-runs this workflow whenever the issue still contains @claude, so unrelated reassignment can invoke Claude again. Keep it only if assignment is meant to trigger Claude and is gated to the configured assignee.

🧰 Tools
🪛 zizmor (1.26.1)

[info] 14-14: workflow or action definition without a name (anonymous-definition): this job

(anonymous-definition)

🤖 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 8 - 19, Remove assigned from the
issues.types list in the workflow trigger, leaving only opened so unrelated
issue reassignment cannot rerun the claude job. Do not change the existing job
conditions or other event triggers.

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
Comment on lines +21 to +26
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
Comment on lines +29 to +35
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr *)'

Loading