Skip to content
44 changes: 44 additions & 0 deletions .github/workflows/claude-pr-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Claude PR Triage

on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
triage-pr:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude PR Triage
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
allowed_non_write_users: "*"
prompt: |
Triage the following pull request in the miden-base repository by adding appropriate labels.

Repository: ${{ github.repository }}
PR number: ${{ github.event.pull_request.number }}

Steps:
1. Run `gh label list` to see all available labels.
2. Run `gh pr view ${{ github.event.pull_request.number }} --json title,body,files` to inspect the PR.
3. Apply the most relevant labels using `gh pr edit ${{ github.event.pull_request.number }} --add-label <label>`.

Label selection guidance for miden-base:
- Type: bug, enhancement, refactor, documentation, chore, breaking-change
- Area: based on changed files (accounts, notes, transactions, block-kernel, crypto, etc.)
- Maintainer: add "pr-from-maintainers" if the PR author's association is OWNER,
MEMBER, or COLLABORATOR. The author's association is: ${{ github.event.pull_request.author_association }}

Only add labels that exist in the repo. Do not post any comments.
67 changes: 67 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Check actor is a maintainer
id: check-permission
uses: actions/github-script@v7
with:
script: |
const association =
context.payload.comment?.author_association ||
context.payload.review?.author_association ||
context.payload.issue?.author_association;
const allowed = ['OWNER', 'MEMBER', 'COLLABORATOR'].includes(association);
if (!allowed) {
core.notice(`Skipping: author association is ${association}`);
}
return allowed;

- name: Checkout repository
if: steps.check-permission.outputs.result == 'true'
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
if: steps.check-permission.outputs.result == 'true'
id: claude
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# 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:*)'

Loading