-
Notifications
You must be signed in to change notification settings - Fork 38
Add Claude Code GitHub Workflow #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Claude Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # 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 | ||
|
|
||
| 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 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| 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 }}' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The code-review plugin for anthropics/claude-code-action is a Claude Code slash command plugin that provides automated PR code review using multiple specialized agents. To use it in claude-code-action GitHub workflows, specify the plugin via the plugins input or invoke it directly in the prompt: - uses: anthropics/claude-code-action@v1 with: plugins: "code-review@claude-code-plugins" prompt: "/code-review --comment" Alternatively, use a custom prompt that calls the command: prompt: | REPO: ${{ github.repository }} PR NUMBER: ${{ github.event.pull_request.number }} /code-review --comment The core prompt syntax is defined in the plugin's command file at https://github.com/anthropics/claude-code/blob/main/plugins/code-review/commands/code-review.md. It starts with a YAML frontmatter block: --- allowed-tools: Bash(gh pr view:), Bash(gh pr diff:), mcpgithub_inline_commentcreate_inline_comment description: Code review a pull request --- Followed by detailed Markdown instructions for multi-agent review workflow (check PR status, gather CLAUDE.md files, summarize changes, parallel audits for compliance/bugs/history, confidence scoring >=80, output summary or post comments with precise GitHub links using full SHA). For GitHub Actions integration, the PR Citations:
Update prompt syntax to use the correct code-review command format. The prompt uses or simplify to: 🤖 Prompt for AI Agents |
||
| # 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| name: Claude Code | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created] | ||
| pull_request_review_comment: | ||
| types: [created] | ||
| issues: | ||
| types: [opened, assigned] | ||
| 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'))) | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check the claude-code-action documentation for required permissions
# Search for permission requirements in the action's README
gh api repos/anthropics/claude-code-action/readme --jq '.content' | base64 -d | rg -i -C5 'permission'Repository: Xtendify/Simple-Calendar Length of output: 120 🏁 Script executed: cat -n .github/workflows/claude.ymlRepository: Xtendify/Simple-Calendar Length of output: 2295 🏁 Script executed: # Search for any local documentation about claude permissions
fd -type f -name "*.md" | xargs rg -i "claude.*permission|permission.*claude" -B2 -A2
# Also check for any comments or documentation about the action
rg "claude-code-action" --type mdRepository: Xtendify/Simple-Calendar Length of output: 238 🏁 Script executed: # Search for any local documentation about claude permissions
fd . -type f -name "*.md" | xargs rg -i "claude.*permission|permission.*claude" -B2 -A2
# Also search for any README or docs mentioning claude-code-action
rg "claude-code-action" -t mdRepository: Xtendify/Simple-Calendar Length of output: 238 🏁 Script executed: # Search for README or docs files that mention claude
find . -name "*.md" -type f | head -20
# Search for claude in documentation
rg "claude" --glob="*.md" -B2 -A2Repository: Xtendify/Simple-Calendar Length of output: 109 🏁 Script executed: cat -n ./CLAUDE.mdRepository: Xtendify/Simple-Calendar Length of output: 2875 🌐 Web query:
💡 Result: The Anthropic Claude Code Action (anthropics/claude-code-action) requires specific permissions in GitHub workflows and optionally a GitHub App installation to enable Claude to interact with repositories (e.g., reading/writing files, issues, PRs). Workflow Permissions (in .github/workflows YAML): - contents: write (to read/modify repository files) - pull-requests: write (to create/update PRs) - issues: write (to respond to issues) - Optionally: id-token: write (for OIDC with cloud providers like Bedrock/Vertex), actions: read (for viewing workflow results) Example from official docs: permissions: contents: write pull-requests: write issues: write id-token: write GitHub App Permissions (https://github.com/apps/claude): - Contents: Read & write - Issues: Read & write - Pull requests: Read & write Additional action inputs: - additional_permissions: e.g., "actions: read" - allowed_bots: restrict bot triggers (default: none) - allowed_non_write_users: risky, allows non-write users (use cautiously) Security best practices: - Use least-privilege permissions in workflows. - Store ANTHROPIC_API_KEY as repo secret. - Review Claude's changes before merging. - For public repos, restrict to trusted triggers. These enable Claude to respond to Citations:
Missing write permissions — Claude cannot respond to The action requires write permissions to respond to comments and create/update files. Update to: Per official Anthropic documentation, 🤖 Prompt for AI Agents |
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code | ||
| id: claude | ||
| uses: anthropics/claude-code-action@v1 | ||
| 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:*)' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing
actions: readpermission for CI result access.The
claude.ymlworkflow grantsactions: readpermission to allow Claude to access CI results on PRs (line 26 in that file). This workflow should include the same permission since it also performs PR analysis and would benefit from CI context.📝 Proposed fix
permissions: contents: read pull-requests: read issues: read id-token: write + actions: read📝 Committable suggestion
🤖 Prompt for AI Agents
🧩 Analysis chain
🏁 Script executed:
Repository: Xtendify/Simple-Calendar
Length of output: 173
🏁 Script executed:
Repository: Xtendify/Simple-Calendar
Length of output: 1800
🌐 Web query:
anthropics claude-code-action permissions requirements pull-requests write💡 Result:
Anthropic's claude-code-action is a GitHub Action that integrates Claude Code into GitHub workflows for PRs and issues, enabling code analysis, changes, and PR creation via
@claudementions or prompts. Permissions requirements: - GitHub App (official Claude app at https://github.com/apps/claude): Requests read & write access to Contents (modify files), Issues (respond), Pull Requests (create/update PRs). [3,6,11,12,15,16] - Workflow YAML permissions: Minimum contents: read/write (for read-only reviews, contents: read and pull-requests: write suffice), pull-requests: write, issues: write. Explicitly set to prevent privilege escalation. [6,8,9,12] - Secrets: ANTHROPIC_API_KEY (or CLAUDE_CODE_OAUTH_TOKEN) stored in repo secrets. Never hardcode. [2,3,6] - Claude Code tool permissions: Configurable via claude_args like --allowedTools for Read/Edit/Bash in headless mode; uses bypassPermissions or similar for automation. Review outputs for security. [1,2,4,55,56] For write operations like creating PRs/commits: Requires contents: write in workflow and GitHub App. Use branch protection requiring human approval. allowed_non_write_users is risky for non-write users. [2,12,56] Security: Workflow permissions lock GITHUB_TOKEN scope; fork PRs get read-only/no secrets. Prompt injection risks from untrusted comments sanitized but review raw input. [12,56]Citations:
Change
pull-requestspermission fromreadtowrite.The code review action requires write permissions to post review comments and annotations on pull requests. The current
pull-requests: readpermission is insufficient; it must be changed topull-requests: write.Corrected permissions block
🤖 Prompt for AI Agents