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-code: # Two gates, both required. # # The mention gate is what a person types. The association gate is who they # are: OWNER, MEMBER or COLLABORATOR on this repository. Every trigger here # -- opening an issue, commenting on one, reviewing a pull request -- is # available to any GitHub account, and this job runs with contents, # pull-requests and issues write plus id-token. Without the second gate the # only thing standing between an arbitrary account and a write-scoped token # is whatever the action decides to check on its own. That is the action's # policy, not ours, and it can change under us; this is ours. # # author_association lives in a different place per event, hence the four # branches rather than one shared expression. if: | (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.review.author_association)) || (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)) runs-on: ubuntu-latest # Long agent runs are expected; this caps a hung one rather than holding the # runner for GitHub's six-hour default. timeout-minutes: 30 permissions: contents: write pull-requests: write issues: write id-token: write actions: read steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 1
- name: Run Claude Code id: claude uses: anthropics/claude-code-action@756cc22e19660d20e8cc9496b4f242475a7f7790 # v1.0.235 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} claude_args: "--model claude-opus-5"Shared (cross-cutting)·Reusable workflow·on: issue_comment, pull_request_review_comment, issues, pull_request_review
Claude Agent
Claude Code
.github/workflows/claude-agent.yml