Skip to content

Conversation

@ozzy2438
Copy link
Owner

@ozzy2438 ozzy2438 commented Jul 7, 2025

🤖 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 documentation.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

Summary by Sourcery

Set up GitHub Actions workflows for Claude Code integration to automate AI-driven pull request reviews and handle @claude mentions for in-context assistance.

CI:

  • Add a workflow to run automated Claude Code reviews on pull_request events.
  • Add a workflow to invoke Claude Code on @claude mentions in issues, comments, and PR reviews.

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 7, 2025

Reviewer's Guide

This PR introduces two new GitHub Actions workflows to integrate the Claude Code AI assistant: one for automated pull-request reviews (triggered on PR events) and one for ad-hoc Claude runs via @claude mentions in comments or issues.

Sequence diagram for @claude mention workflow

sequenceDiagram
  actor User
  participant GitHub as GitHub
  participant Actions as GitHub Actions Runner
  participant Claude as Claude Code Action
  participant Anthropic as Anthropic API

  User->>GitHub: Comment with @claude on PR/issue
  GitHub->>Actions: Trigger claude.yml workflow
  Actions->>Claude: Run Claude Code Action
  Claude->>Anthropic: Send context and request
  Anthropic-->>Claude: Return response
  Claude->>GitHub: Post comment/commit/branch
  GitHub-->>User: Show Claude's response
Loading

Sequence diagram for automated Claude Code Review workflow

sequenceDiagram
  participant GitHub as GitHub
  participant Actions as GitHub Actions Runner
  participant Claude as Claude Code Review Action
  participant Anthropic as Anthropic API

  GitHub->>Actions: PR opened/synchronized
  Actions->>Claude: Run Claude Code Review Action
  Claude->>Anthropic: Send PR context for review
  Anthropic-->>Claude: Return review feedback
  Claude->>GitHub: Post review feedback as comment
Loading

File-Level Changes

Change Details Files
Added PR-triggered Claude Code review workflow
  • Created a new workflow file that runs on pull_request opened/synchronize events
  • Configured job permissions (contents, pull-requests, issues, id-token)
  • Set up checkout step and invoked anthropics/claude-code-action with API key
  • Included a direct_prompt for automated code review feedback
  • Left optional commented sections for model selection, author filtering, tool allowances, and skip conditions
.github/workflows/claude-code-review.yml
Added comment/issue-triggered Claude Code workflow
  • Created a new workflow file that triggers on issue_comment, pull_request_review_comment, pull_request_review, and issues events
  • Added conditional to run only when '@claude' is mentioned in comments or titles
  • Configured job permissions and checkout step
  • Invoked anthropics/claude-code-action with API key
  • Provided optional commented settings for custom trigger phrases, tools, instructions, and environment variables
.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

@claude
Copy link

claude bot commented Jul 7, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

Copy link

@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 @ozzy2438 - I've reviewed your changes - here's some feedback:

  • Add explicit conditions to skip running the workflow on comments or PR updates made by the Claude bot itself to prevent infinite recursive triggers.
  • Consider narrowing your trigger scopes (e.g. by file path or specific branches) so the workflow only runs on relevant changes and reduces unnecessary runs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add explicit conditions to skip running the workflow on comments or PR updates made by the Claude bot itself to prevent infinite recursive triggers.
- Consider narrowing your trigger scopes (e.g. by file path or specific branches) so the workflow only runs on relevant changes and reduces unnecessary runs.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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