From 56d85e94ec27c003140f82a3e3bd623c17679a37 Mon Sep 17 00:00:00 2001 From: DJ Date: Sun, 5 Apr 2026 21:04:01 -0700 Subject: [PATCH 1/5] feat: split Claude workflow into interactive + issue automation jobs Aligns with the org standard in petry-projects/.github. The claude-issue job runs in automation mode with tools to create PRs, self-review, check CI, and tag code owners when ready. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/claude.yml | 55 +++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 2ebf06da..91a59405 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -1,3 +1,6 @@ +# AI-assisted code review via Claude Code Action on PRs. +# Issue automation: implement, open PR, self-review, check CI, notify maintainer. +# Standard: https://github.com/petry-projects/.github/blob/main/standards/ci-standards.md#4-claude-code-claudeyml name: Claude Code on: @@ -14,6 +17,7 @@ on: permissions: {} jobs: + # Interactive mode: PR reviews and @claude mentions claude: if: >- (github.event_name == 'pull_request' && @@ -23,17 +27,16 @@ jobs: 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 == 'issues' && github.event.action == 'labeled' && - github.event.label.name == 'claude') + contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) runs-on: ubuntu-latest timeout-minutes: 60 permissions: - # write required for issue-triggered branch creation contents: write id-token: write pull-requests: write issues: write + actions: read + checks: read steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -41,7 +44,51 @@ jobs: fetch-depth: 1 - name: Run Claude Code if: github.event_name != 'pull_request' || github.event.pull_request.user.login != 'dependabot[bot]' + uses: anthropics/claude-code-action@6e2bd52842c65e914eba5c8badd17560bd26b5de # v1.0.89 + with: + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + additional_permissions: | + actions: read + checks: read + + # Automation mode: issue-triggered work — implement, open PR, review, and notify + claude-issue: + if: >- + github.event_name == 'issues' && github.event.action == 'labeled' && + github.event.label.name == 'claude' + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: write + id-token: write + pull-requests: write + issues: write + actions: read + checks: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 1 + - name: Run Claude Code uses: anthropics/claude-code-action@6e2bd52842c65e914eba5c8badd17560bd26b5de # v1.0.89 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} label_trigger: "claude" + track_progress: "true" + additional_permissions: | + actions: read + checks: read + claude_args: | + --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh run view:*),Bash(gh run watch:*),Bash(cat:*),Edit,Write" + prompt: | + Implement a fix for issue #${{ github.event.issue.number }}. + + After implementing: + 1. Create a pull request with a clear title and description. Include "Closes #${{ github.event.issue.number }}" in the PR body. + 2. Self-review your own PR — look for bugs, style issues, missed edge cases, and test gaps. If you find problems, push fixes. + 3. Review all comments and review threads on the PR. For each one: + - If you can address the feedback, make the fix, push, and mark the conversation as resolved. + - If the comment requires human judgment, leave a reply explaining what you need. + 4. Check CI status. If CI fails, read the logs, fix the issues, and push again. Repeat until CI passes. + 5. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. From 1c0ee95750b9400fc888cac3dde3d4401a269987 Mon Sep 17 00:00:00 2001 From: DJ Date: Mon, 6 Apr 2026 00:13:41 -0700 Subject: [PATCH 2/5] fix: add concurrency guard and missing allowedTools to claude-issue job Address CodeRabbit review feedback: - Add concurrency block keyed on issue number to prevent duplicate automation runs when the 'claude' label is re-applied - Add Bash(gh pr comment:*), Bash(gh pr review:*), and Bash(gh api:*) to allowedTools so the automation can post comments, submit reviews, and resolve review threads as described in the prompt Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/claude.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 91a59405..6ac7aea2 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -58,6 +58,9 @@ jobs: github.event.label.name == 'claude' runs-on: ubuntu-latest timeout-minutes: 60 + concurrency: + group: claude-issue-${{ github.event.issue.number }} + cancel-in-progress: true permissions: contents: write id-token: write @@ -80,7 +83,7 @@ jobs: actions: read checks: read claude_args: | - --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh run view:*),Bash(gh run watch:*),Bash(cat:*),Edit,Write" + --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr comment:*),Bash(gh pr review:*),Bash(gh run view:*),Bash(gh run watch:*),Bash(gh api:*),Bash(cat:*),Edit,Write" prompt: | Implement a fix for issue #${{ github.event.issue.number }}. From 220e0a4ee4a83c80d6b9009ffb2286d269ee2d99 Mon Sep 17 00:00:00 2001 From: DJ Date: Mon, 6 Apr 2026 04:15:02 -0700 Subject: [PATCH 3/5] fix: add merge conflict handling guidance to automation prompt Adds step 5 to the issue automation prompt instructing Claude to rebase or merge the base branch when merge conflicts are detected. Addresses CodeRabbit review feedback on PR #56. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/claude.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 6ac7aea2..22477d9d 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -94,4 +94,5 @@ jobs: - If you can address the feedback, make the fix, push, and mark the conversation as resolved. - If the comment requires human judgment, leave a reply explaining what you need. 4. Check CI status. If CI fails, read the logs, fix the issues, and push again. Repeat until CI passes. - 5. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. + 5. If the PR has merge conflicts with the base branch, rebase or merge the base branch to resolve them. + 6. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. From c9585a5097b4dc7a96317397f69bff26c262b1e9 Mon Sep 17 00:00:00 2001 From: DJ Date: Mon, 6 Apr 2026 04:46:03 -0700 Subject: [PATCH 4/5] fix: add concurrency guard and comment tools to claude-issue job - Add concurrency group keyed on issue number to prevent duplicate runs - Add gh pr comment and gh issue comment to allowedTools for review replies, thread resolution, and code owner tagging - Remove Bash(cat:*) since the Read tool already covers file reads Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/claude.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 22477d9d..c26c538f 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -56,11 +56,11 @@ jobs: if: >- github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'claude' - runs-on: ubuntu-latest - timeout-minutes: 60 concurrency: group: claude-issue-${{ github.event.issue.number }} cancel-in-progress: true + runs-on: ubuntu-latest + timeout-minutes: 60 permissions: contents: write id-token: write @@ -83,7 +83,7 @@ jobs: actions: read checks: read claude_args: | - --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr comment:*),Bash(gh pr review:*),Bash(gh run view:*),Bash(gh run watch:*),Bash(gh api:*),Bash(cat:*),Edit,Write" + --allowedTools "Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr comment:*),Bash(gh issue comment:*),Bash(gh run view:*),Bash(gh run watch:*),Edit,Write" prompt: | Implement a fix for issue #${{ github.event.issue.number }}. @@ -94,5 +94,4 @@ jobs: - If you can address the feedback, make the fix, push, and mark the conversation as resolved. - If the comment requires human judgment, leave a reply explaining what you need. 4. Check CI status. If CI fails, read the logs, fix the issues, and push again. Repeat until CI passes. - 5. If the PR has merge conflicts with the base branch, rebase or merge the base branch to resolve them. - 6. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. + 5. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. From 64b79015dbfcb9e79bbc60d3c03d61c387de6a42 Mon Sep 17 00:00:00 2001 From: DJ Date: Mon, 6 Apr 2026 04:47:33 -0700 Subject: [PATCH 5/5] fix: add same-repo guard for review comments and fix merge conflict step - Gate pull_request_review_comment on same-repo check to prevent silent failures on fork PRs (secrets unavailable for forks) - Replace rebase instruction with comment-based notification since claude-code-action cannot perform git merge/rebase operations Addresses CodeRabbit review feedback on PR #56. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/claude.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index c26c538f..004c6efa 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -26,6 +26,7 @@ jobs: contains(github.event.comment.body, '@claude') && contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (github.event_name == 'pull_request_review_comment' && + github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.comment.body, '@claude') && contains(fromJson('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) runs-on: ubuntu-latest @@ -94,4 +95,5 @@ jobs: - If you can address the feedback, make the fix, push, and mark the conversation as resolved. - If the comment requires human judgment, leave a reply explaining what you need. 4. Check CI status. If CI fails, read the logs, fix the issues, and push again. Repeat until CI passes. - 5. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge. + 5. If the PR has merge conflicts, leave a comment noting the conflicts and tag code owners for manual resolution. + 6. When CI is green, all actionable review comments are resolved, and the PR is ready, read the CODEOWNERS file and leave a comment tagging the relevant code owners to review and merge.