From c066a2d5bfbfd309a19949107ef8df1e5d1d60c2 Mon Sep 17 00:00:00 2001 From: AkhileshNegi Date: Sat, 5 Sep 2026 19:09:15 +0530 Subject: [PATCH] ci: add Claude Code GitHub Action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two jobs in one workflow: - `claude` — responds to @claude mentions in issues, PR comments and reviews. - `review` — auto-reviews a PR when the `ready-for-review` label is added, reusing the repo's own checklist in .claude/commands/pr-review.md so the bot review and the local /pr-review pass apply the same conventions. Requires an ANTHROPIC_API_KEY repository secret and the Claude GitHub App installed on the org. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/claude.yml | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/claude.yml diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 000000000..767bd561e --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,74 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + pull_request_review: + types: [submitted] + issues: + types: [opened, assigned] + pull_request: + types: [labeled] + +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 + permissions: + contents: write + pull-requests: write + issues: write + id-token: write + actions: read # lets Claude read CI results on PRs + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 1 + + - uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + + review: + if: github.event_name == 'pull_request' && github.event.label.name == 'ready-for-review' + runs-on: ubuntu-latest + concurrency: + group: claude-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + permissions: + contents: read + pull-requests: write + id-token: write + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 1 + + - uses: anthropics/claude-code-action@v1 + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + track_progress: true + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.pull_request.number }} + + Review this PR against the repository's own review checklist. + + 1. Read `.claude/commands/pr-review.md` and follow it from the "What to check" + section onward, together with "How to write the comments" and "Output format". + 2. Skip its "Gather the diff" section — that one assumes a local clone. Use + `gh pr diff` for the diff and `gh pr view` for the description and commits. + 3. Read the full files at non-trivial change sites before judging them, and + check `docs/wiki/INDEX.md` for the touched module before claiming that a + helper, service, or entity does not already exist. + + Post specific findings as inline comments citing path:line, and the summary as + a single top-level comment. Review only — do not modify files. + claude_args: | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"