Skip to content

Add Claude Code GitHub Workflow#8

Merged
flatfinderai-cyber merged 4 commits intomainfrom
add-claude-github-actions-1768697301516
Jan 20, 2026
Merged

Add Claude Code GitHub Workflow#8
flatfinderai-cyber merged 4 commits intomainfrom
add-claude-github-actions-1768697301516

Conversation

@flatfinderai-cyber
Copy link
Copy Markdown
Owner

@flatfinderai-cyber flatfinderai-cyber commented Jan 18, 2026

🤖 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:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

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

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

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:

  • Introduce a claude-code-review workflow that runs on pull request open/sync events to generate automated code review feedback using the Claude Code action.
  • Add a claude workflow that triggers Claude Code when @claude is mentioned in issue or PR comments, reviews, or newly opened/assigned issues, with scoped permissions and optional CI insights.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Jan 18, 2026

Reviewer's Guide

Adds 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 workflow

sequenceDiagram
  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
Loading

Sequence diagram for @claude mention interaction workflow

sequenceDiagram
  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
Loading

File-Level Changes

Change Details Files
Introduce an automated Claude-powered code review workflow for pull requests.
  • Create a Claude Code Review workflow triggered on pull_request events of types opened and synchronize
  • Configure a claude-review job running on ubuntu-latest with read permissions for contents, pull-requests, and issues, plus id-token write
  • Check out the repository with shallow clone (fetch-depth: 1) before running the review
  • Invoke anthropics/claude-code-action@v1 with the repository and PR number in a structured prompt asking for review of quality, bugs, performance, security, and tests
  • Instruct Claude to use gh pr comment via its Bash tool to post the review back to the PR
  • Restrict Claude’s allowed tools via claude_args to selected gh commands for issues and PRs
.github/workflows/claude-code-review.yml
Add a general-purpose Claude Code workflow that responds to @claude mentions and selected issue/PR review events.
  • Create a Claude Code workflow reacting to issue_comment, pull_request_review_comment, issues, and pull_request_review events
  • Gate the claude job with a compound if condition that checks for @claude in comment bodies, review bodies, issue bodies, or issue titles depending on event type
  • Run the job on ubuntu-latest with read permissions on contents, pull-requests, issues, actions, and id-token write
  • Check out the repository with shallow clone (fetch-depth: 1) before invoking Claude
  • Invoke anthropics/claude-code-action@v1 with the OAuth token secret and grant additional actions: read permissions so Claude can read CI results
  • Document optional configuration knobs like custom prompt and claude_args for future tuning
.github/workflows/claude.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • 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.
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.

@flatfinderai-cyber flatfinderai-cyber merged commit cf56849 into main Jan 20, 2026
2 checks passed
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.

1 participant