Add Claude Code GitHub Workflow#8
Merged
flatfinderai-cyber merged 4 commits intomainfrom Jan 20, 2026
Merged
Conversation
Reviewer's GuideAdds two GitHub Actions workflows to integrate Claude Code into the repository: one that automatically reviews pull requests and comments using the Claude Code action, and another that triggers Claude in response to @claude mentions and certain issue/PR review events. Sequence diagram for automatic Claude Code PR review workflowsequenceDiagram
actor Developer
participant GitHub
participant Workflow_Claude_Code_Review
participant Claude_Code_Action
participant Anthropic_API
participant GitHub_CLI_gh
Developer->>GitHub: Open or update pull_request
GitHub-->>Workflow_Claude_Code_Review: Trigger pull_request opened or synchronize event
Workflow_Claude_Code_Review->>Workflow_Claude_Code_Review: Evaluate optional author and path filters
Workflow_Claude_Code_Review->>GitHub: Checkout repository (actions_checkout)
Workflow_Claude_Code_Review->>Claude_Code_Action: Invoke anthropics_claude-code-action with claude_code_oauth_token, prompt, claude_args
Claude_Code_Action->>Anthropic_API: Send review request with PR context and tools configuration
Anthropic_API-->>Claude_Code_Action: Return review analysis and suggestions
Claude_Code_Action->>GitHub_CLI_gh: Execute Bash gh pr view and gh pr diff
GitHub_CLI_gh->>GitHub: Fetch PR details and diff
Claude_Code_Action->>GitHub_CLI_gh: Execute Bash gh pr comment with review text
GitHub_CLI_gh->>GitHub: Post review comment on pull_request
GitHub-->>Developer: Display Claude review comment on PR
Sequence diagram for @claude mention interaction workflowsequenceDiagram
actor User
participant GitHub
participant Workflow_Claude_Code
participant Claude_Code_Action
participant Anthropic_API
participant GitHub_CLI_gh
User->>GitHub: Create issue, PR review, or comment containing @claude
GitHub-->>Workflow_Claude_Code: Trigger issue_comment, pull_request_review_comment, pull_request_review, or issues event
Workflow_Claude_Code->>Workflow_Claude_Code: Check event body or title for @claude mention
alt Contains_mention
Workflow_Claude_Code->>GitHub: Checkout repository (actions_checkout)
Workflow_Claude_Code->>Claude_Code_Action: Invoke anthropics_claude-code-action with claude_code_oauth_token and additional_permissions actions_read
Claude_Code_Action->>GitHub: Read PR or issue context, files, diffs, CI results
Claude_Code_Action->>Anthropic_API: Send task request based on user instructions or custom prompt
Anthropic_API-->>Claude_Code_Action: Return task plan and outputs
Claude_Code_Action->>GitHub_CLI_gh: Optionally run Bash gh commands according to allowed tools
GitHub_CLI_gh->>GitHub: Apply changes, comments, branches, or commits
GitHub-->>User: Show Claude responses and repository updates
else No_mention
Workflow_Claude_Code->>Workflow_Claude_Code: Job skipped
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
claude-code-review.yml, the job only grantspull-requests: read, butgh pr commentwill need write access to post a review comment; consider bumpingpull-requeststowriteso the review step can succeed. - Similarly, in
claude.ymlthe defaultcontents,pull-requests, andissuespermissions are set toread, which may prevent Claude from creating PR comments or other write actions later; if you intend to allow that behavior, update these towritewhere appropriate.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `claude-code-review.yml`, the job only grants `pull-requests: read`, but `gh pr comment` will need write access to post a review comment; consider bumping `pull-requests` to `write` so the review step can succeed.
- Similarly, in `claude.yml` the default `contents`, `pull-requests`, and `issues` permissions are set to `read`, which may prevent Claude from creating PR comments or other write actions later; if you intend to allow that behavior, update these to `write` where appropriate.
## Individual Comments
### Comment 1
<location> `.github/workflows/claude-code-review.yml:22-25` </location>
<code_context>
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
+
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: read
+ issues: read
+ id-token: write
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Permissions likely too restrictive for posting PR comments via `gh pr comment`.
This workflow only grants `pull-requests: read` and `issues: read`, but the instructions rely on `gh pr comment` to post review feedback. Commenting on PRs requires `issues: write` and/or `pull-requests: write`, so with the current permissions the job will likely fail when trying to post. Suggest updating to:
```yaml
actions:
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
```
so the review comments can actually be created.
</issue_to_address>
### Comment 2
<location> `.github/workflows/claude.yml:21-26` </location>
<code_context>
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
+
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: read
</code_context>
<issue_to_address>
**issue (bug_risk):** Workflow permissions may prevent Claude from posting replies on issues/PRs.
Since this workflow needs to post comments/reviews in response to `@claude` mentions, it requires write access, not just read. Please update the job permissions to include at least:
```yaml
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
actions: read
```
so it can successfully create issue/PR comments and PR reviews.
</issue_to_address>Your trial expires on January 30, 2026. Please upgrade to continue using Sourcery ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Installing Claude Code GitHub App
This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.
What is Claude Code?
Claude Code is an AI coding agent that can help with:
How it works
Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.
Important Notes
Security
There's more information in the Claude Code action repo.
After merging this PR, let's try mentioning @claude in a comment on any PR to get started!
Summary by Sourcery
Add GitHub Actions workflows to integrate Claude Code for automated PR reviews and on-demand assistance via @claude mentions in issues and PRs.
CI: