Skip to content

Add Claude Code GitHub Workflow#22

Merged
shyndman merged 2 commits intomainfrom
add-claude-github-actions-1765355962707
Dec 10, 2025
Merged

Add Claude Code GitHub Workflow#22
shyndman merged 2 commits intomainfrom
add-claude-github-actions-1765355962707

Conversation

@shyndman
Copy link
Copy Markdown
Owner

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

Copilot AI review requested due to automatic review settings December 10, 2025 08:39
@shyndman shyndman merged commit 2f214cc into main Dec 10, 2025
4 checks passed
@shyndman shyndman deleted the add-claude-github-actions-1765355962707 branch December 10, 2025 08:40
@claude
Copy link
Copy Markdown

claude bot commented Dec 10, 2025

Code Review: Claude Code GitHub Workflow Integration

Summary

This PR adds two GitHub Actions workflows to integrate Claude Code into the repository. Overall, the implementation is solid and well-structured, with good security practices. I have identified several areas for improvement and consideration.


✅ Strengths

  1. Security-First Approach: Proper use of GitHub secrets for API tokens and appropriate permission scoping
  2. Clear Documentation: The PR description provides excellent context about what Claude Code does and how to use it
  3. Flexible Design: Smart use of commented-out conditional logic for future customization
  4. Consistent with Repository Standards: Follows the existing workflow patterns (checkout@v4, similar structure to pre-commit.yml)

🔍 Issues & Recommendations

🔴 High Priority

1. Missing Write Permissions for Claude Code Actions

File: .github/workflows/claude.yml (lines 20-25)
Issue: The workflow only grants read permissions, but Claude needs write access to create comments, branches, and commits as described in the PR description.

Current:

permissions:
  contents: read
  pull-requests: read
  issues: read

Recommended:

permissions:
  contents: write        # Required for creating branches/commits
  pull-requests: write   # Required for creating/updating PR comments
  issues: write          # Required for issue comments
  id-token: write
  actions: read

Impact: Without these permissions, Claude cannot perform the actions described in the PR (creating comments, branches, commits).


2. Incomplete Condition Logic for PR Reviews

File: .github/workflows/claude.yml:17-19
Issue: The condition checks for @claude mentions in pull_request_review events, but the logic may not handle all edge cases correctly.

Current logic:

  • pull_request_review_comment events → should work ✅
  • pull_request_review events → checks github.event.review.body but this should be verified ⚠️

Recommendation: Test the workflow with actual PR review events to ensure the condition works correctly.


🟡 Medium Priority

3. Missing Rate Limiting Protection

Both files
Issue: No protection against rapid-fire mentions or accidental infinite loops.

Recommendation: Consider adding concurrency control to prevent multiple concurrent runs and wasted API credits.


4. Overly Broad Trigger on Issues

File: .github/workflows/claude.yml:9
Issue: The workflow triggers on issues: [opened, assigned] checking for @claude in title/body.

Issue: The assigned trigger does not check assignment context—it triggers regardless of who is assigned.

Recommendation: Either:

  1. Remove assigned if not needed
  2. Add a condition to check who is assigned if you want Claude assigned to issues

5. Fetch Depth Limitation

Both files
Issue: fetch-depth: 1 limits git history to the latest commit, which may limit Claude ability to understand context for complex changes.

Recommendation: Consider fetch-depth: 0 or a higher value (e.g., 50) for better context, especially for:

  • Code reviews spanning multiple commits
  • Understanding change history
  • Analyzing refactoring patterns

Trade-off: Slightly slower checkout vs. better code understanding.


6. Auto-Review Workflow May Be Too Aggressive

File: .github/workflows/claude-code-review.yml
Issue: The workflow triggers automatically on ALL PRs (opened, synchronize) without any filtering.

Concerns:

  1. API Cost: Every PR update triggers a review (could be expensive for active repos)
  2. Noise: May create too many automated comments
  3. Author Experience: Could feel like micromanagement for experienced contributors

Recommendation:

  • Start with the commented-out filters (new contributors, specific authors)
  • Consider adding a label-based trigger
  • Or require an explicit @claude review mention in a comment instead

🟢 Low Priority / Suggestions

7. Additional Allowed Tools for Better Reviews

File: .github/workflows/claude-code-review.yml:56
Suggestion: Consider adding shellcheck and shfmt to allowed tools to match pre-commit hooks and provide more accurate reviews.


8. Missing Documentation Updates

Files: README.md and AGENTS.md
Issue: The documentation does not mention the new Claude Code integration.

Recommendation: Add a section to README.md explaining:

  • How to use @claude mentions
  • What Claude can help with
  • Link to workflow files for customization
  • Examples of good requests

🔒 Security Assessment

✅ Good Security Practices:

  1. API token stored as GitHub secret (not hardcoded)
  2. Permissions explicitly scoped (principle of least privilege)
  3. id-token: write for OIDC authentication
  4. No exposure of sensitive data in logs

⚠️ Considerations:

  1. Trust Boundary: Claude has access to entire repository content—ensure CLAUDE_CODE_OAUTH_TOKEN is properly secured
  2. PR Author Permissions: Current setup allows any contributor to trigger Claude (intentional per PR description, but worth noting)
  3. Secret Exposure: Ensure CI logs do not accidentally expose the OAuth token (GitHub should handle this automatically)

🧪 Test Coverage

Issue: No tests for the workflows themselves.

Recommendation:

  1. Test the workflows in a fork or feature branch before merging
  2. Verify @claude mentions work as expected in various contexts (issue comments, PR comments, PR review comments, issue/PR bodies)
  3. Confirm auto-review triggers correctly on PR open/update

📋 Pre-Merge Checklist

Before merging, please verify:

  • CLAUDE_CODE_OAUTH_TOKEN secret is configured in repository settings
  • Write permissions are added to claude.yml workflow (HIGH PRIORITY)
  • Decide on auto-review strategy (all PRs vs. filtered)
  • Consider rate limiting/concurrency controls
  • Update README.md with usage instructions
  • Test @claude mention workflow after merge

🎯 Suggested Implementation Plan

  1. Immediate (before merge):

    • Fix permissions in claude.yml (high priority)
    • Decide on auto-review filtering strategy
    • Test workflows in a safe environment
  2. Short-term (first week after merge):

    • Monitor API usage and adjust triggers
    • Add concurrency controls if needed
    • Update documentation
  3. Long-term (first month):

    • Gather team feedback on review quality
    • Fine-tune allowed tools and permissions
    • Consider expanding to more tools (test runners, linters)

💡 Overall Recommendation

Approval Status: ✅ Approve with changes

The workflows are well-designed and follow good practices. The main blocker is the missing write permissions in claude.yml. I recommend:

  1. Fix the permissions issue (REQUIRED)
  2. Add concurrency controls (strongly recommended)
  3. Consider filtering the auto-review workflow (recommended)
  4. Test thoroughly before merging (REQUIRED)

Once these are addressed, this will be a valuable addition to the repository development workflow!


Review performed by Claude Code Review workflow 🤖

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds GitHub Actions workflows to integrate Claude Code, an AI coding agent, into the repository. The integration enables both on-demand assistance through @claude mentions and automatic PR reviews.

  • Adds claude.yml workflow that responds to @claude mentions in comments on issues and pull requests
  • Adds claude-code-review.yml workflow that automatically runs Claude Code reviews on new and updated pull requests
  • Configures appropriate OAuth token authentication and tool restrictions for security

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/claude.yml Workflow triggered by @claude mentions in comments; enables on-demand AI assistance for bug fixes, documentation, and feature implementation
.github/workflows/claude-code-review.yml Workflow that automatically reviews pull requests with Claude; provides feedback on code quality, security, and best practices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +24
contents: read
pull-requests: read
issues: read
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The workflow is missing write permissions that Claude Code needs to create branches and commits. According to the PR description, Claude should be able to "create comments, branches, and commits."

Add the following permissions:

contents: write
pull-requests: write
issues: write
Suggested change
contents: read
pull-requests: read
issues: read
contents: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +25
contents: read
pull-requests: read
issues: read
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The workflow is missing write permissions that Claude Code needs to create comments and commits. According to the PR description, Claude should be able to "create comments, branches, and commits."

Add the following permissions:

contents: write
pull-requests: write
issues: write
Suggested change
contents: read
pull-requests: read
issues: read
contents: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
- Security concerns
- Test coverage

Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The prompt references CLAUDE.md for style and conventions, but this file doesn't exist in the repository. Consider either:

  1. Creating a CLAUDE.md file with style guidelines, or
  2. Updating the reference to use the existing AGENTS.md file which contains project documentation and conventions.
Suggested change
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
Use the repository's AGENTS.md for guidance on style and conventions. Be constructive and helpful in your feedback.

Copilot uses AI. Check for mistakes.
# 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:*)'

Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Remove the extra blank line at the end of the file. This is inconsistent with the repository's style (see .github/workflows/pre-commit.yml).

Suggested change

Copilot uses AI. Check for mistakes.
# 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 issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Remove the extra blank lines at the end of the file. This is inconsistent with the repository's style (see .github/workflows/pre-commit.yml).

Suggested change

Copilot uses AI. Check for mistakes.
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