-
Notifications
You must be signed in to change notification settings - Fork 0
Add Claude Code GitHub Workflow #1
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,78 @@ | ||||||||||||||||||||||||||||||||||||||
| name: Claude Code Review | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||
| types: [opened, synchronize] | ||||||||||||||||||||||||||||||||||||||
| # 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 | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+21
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. 🛠️ Refactor suggestion Gate runs on forked PRs or document that forks won’t be auto-reviewed. Secrets aren’t available to forked PRs on Apply this diff to only run for same-repo PRs: claude-review:
- # Optional: Filter by PR author
+ # Run only for PRs originating from this repository (secrets are unavailable to forks)
+ if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
+ # Optional: Filter by PR authorIf you intend to support forks, I can propose a safe 📝 Committable suggestion
Suggested change
🧰 Tools🪛 YAMLlint (1.37.1)[error] 20-20: trailing spaces (trailing-spaces) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||||||||||||||
| issues: read | ||||||||||||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
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. 🛠️ Refactor suggestion Action cannot comment with read-only permissions; remove unnecessary id-token. The job likely needs to create or update PR comments. With Apply this diff: permissions:
- contents: read
- pull-requests: read
- issues: read
- id-token: write
+ contents: read
+ pull-requests: write
+ issues: write
+ # id-token not required; remove to reduce privilege📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| 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@beta | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+39
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. 💡 Verification agent 🧩 Analysis chainConfirm secret name and required inputs match the action’s docs. The input is If the action accepts 🌐 Web query: 💡 Result: The required input name for the secret/token in anthropics/claude-code-action is api_key, and the secret itself should be set as ANTHROPIC_API_KEY in your GitHub repository or organization secrets[10][4]. The value expected is your raw Anthropic API key, typically beginning with Input/Secret Name:
There is no reference in any documentation or SDK code to a secret named Required OAuth Scopes:
Summary Table
Relevant documentation supports only Citations:
Update Claude Code Action Input and Secret Name The Please update your workflow snippet as follows: - name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@beta
with:
- claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
+ api_key: ${{ secrets.ANTHROPIC_API_KEY }}• Rename your repository (or organization) secret from Let me know if you need further assistance in adjusting scopes or permissions. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) | ||||||||||||||||||||||||||||||||||||||
| # model: "claude-opus-4-1-20250805" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Direct prompt for automated review (no @claude mention needed) | ||||||||||||||||||||||||||||||||||||||
| direct_prompt: | | ||||||||||||||||||||||||||||||||||||||
| Please review this pull request and provide feedback on: | ||||||||||||||||||||||||||||||||||||||
| - Code quality and best practices | ||||||||||||||||||||||||||||||||||||||
| - Potential bugs or issues | ||||||||||||||||||||||||||||||||||||||
| - Performance considerations | ||||||||||||||||||||||||||||||||||||||
| - Security concerns | ||||||||||||||||||||||||||||||||||||||
| - Test coverage | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Be constructive and helpful in your feedback. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR | ||||||||||||||||||||||||||||||||||||||
| # use_sticky_comment: true | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Optional: Customize review based on file types | ||||||||||||||||||||||||||||||||||||||
| # direct_prompt: | | ||||||||||||||||||||||||||||||||||||||
| # Review this PR focusing on: | ||||||||||||||||||||||||||||||||||||||
| # - For TypeScript files: Type safety and proper interface usage | ||||||||||||||||||||||||||||||||||||||
| # - For API endpoints: Security, input validation, and error handling | ||||||||||||||||||||||||||||||||||||||
| # - For React components: Performance, accessibility, and best practices | ||||||||||||||||||||||||||||||||||||||
| # - For tests: Coverage, edge cases, and test quality | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Optional: Different prompts for different authors | ||||||||||||||||||||||||||||||||||||||
| # direct_prompt: | | ||||||||||||||||||||||||||||||||||||||
| # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && | ||||||||||||||||||||||||||||||||||||||
| # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || | ||||||||||||||||||||||||||||||||||||||
| # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Optional: Add specific tools for running tests or linting | ||||||||||||||||||||||||||||||||||||||
| # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Optional: Skip review for certain conditions | ||||||||||||||||||||||||||||||||||||||
| # if: | | ||||||||||||||||||||||||||||||||||||||
| # !contains(github.event.pull_request.title, '[skip-review]') && | ||||||||||||||||||||||||||||||||||||||
| # !contains(github.event.pull_request.title, '[WIP]') | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+20
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. Anyone can currently trigger runs by typing @claude; enforce “writers only.” The PR description says only users with write access can trigger this workflow, but the condition doesn’t enforce that. Add association checks and guard against null bodies. Apply this diff: - 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')))
+ if: |
+ (
+ github.event_name == 'issue_comment' &&
+ (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') &&
+ github.event.comment.body != '' &&
+ contains(github.event.comment.body, '@claude')
+ ) ||
+ (
+ github.event_name == 'pull_request_review_comment' &&
+ (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') &&
+ github.event.comment.body != '' &&
+ contains(github.event.comment.body, '@claude')
+ ) ||
+ (
+ github.event_name == 'pull_request_review' &&
+ (github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'COLLABORATOR') &&
+ github.event.review.body != '' &&
+ contains(github.event.review.body, '@claude')
+ ) ||
+ (
+ github.event_name == 'issues' &&
+ (github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'COLLABORATOR') &&
+ (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))
+ )📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issues: read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| actions: read # Required for Claude to read CI results on PRs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+21
to
+27
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. 🛠️ Refactor suggestion Grant minimal write permissions for comments; remove id-token. To post replies or status back, the job needs Apply this diff: permissions:
- contents: read
- pull-requests: read
- issues: read
- id-token: write
- actions: read # Required for Claude to read CI results on PRs
+ contents: read
+ pull-requests: write
+ issues: write
+ actions: read # Required for Claude to read CI results on PRs
+ # id-token not required; remove to reduce privilege📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch-depth: 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Run Claude Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: claude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: anthropics/claude-code-action@beta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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. 💡 Verification agent 🧩 Analysis chainFix YAML lint nits: trailing spaces and the extra blank line. Remove trailing spaces on the noted lines and the extra blank line at the end. You can verify locally with: Also applies to: 45-45, 48-48, 51-51, 54-54, 60-60, 64-65 🏁 Script executed: #!/bin/bash
yamllint .github/workflows/claude.yml || trueLength of output: 1267 Address all yamllint violations in .github/workflows/claude.yml When running • Line 1: warning – missing document start ( Please:
You can re-verify locally with: yamllint .github/workflows/claude.yml || true🧰 Tools🪛 YAMLlint (1.37.1)[error] 42-42: trailing spaces (trailing-spaces) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # model: "claude-opus-4-1-20250805" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Customize the trigger phrase (default: @claude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # trigger_phrase: "/claude" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Trigger when specific user is assigned to an issue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # assignee_trigger: "claude-bot" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Allow Claude to run specific commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Add custom instructions for Claude to customize its behavior for your project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # custom_instructions: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Follow our coding standards | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure all new code has tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use TypeScript for new files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Optional: Custom environment variables for Claude | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # claude_env: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # NODE_ENV: test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
💡 Verification agent
🧩 Analysis chain
Fix YAML lint nits: trailing spaces and extra blank line.
There are trailing spaces on several lines and an extra blank line at the end. Clean them up to keep CI lint quiet.
You can auto-fix with:
-# (remove trailing spaces on the noted lines and drop the extra blank line at EOF)Or run:
yamllint .github/workflows/claude-code-review.ymllocally and apply its suggestions.Also applies to: 27-27, 51-51, 56-56, 64-64, 67-67, 70-70, 73-73, 78-79
🏁 Script executed:
Length of output: 1327
Fix YAML lint errors in
.github/workflows/claude-code-review.ymlThe workflow file currently fails
yamllintwith multiple errors. Please address the following to keep CI green:• Add the document start marker
---at top of file• Replace non-boolean values with
true/false[false, true]• Remove trailing spaces
• Ensure lines do not exceed 80 characters
• Remove the extra blank line at end of file
You can locally verify and auto-fix many of these with:
…then trim trailing spaces, wrap or shorten long lines, add
---at the top, and replace any non-boolean values accordingly.🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 20-20: trailing spaces
(trailing-spaces)
🤖 Prompt for AI Agents