Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Claude Code Assistant Workflow
#
# Responds to @claude mentions in issues, pull requests, and review comments.
#
# Documentation:
# - Setup and configuration: <https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md>
# - Automation patterns: <https://github.com/anthropics/claude-code-action/blob/main/docs/solutions.md>
# - Custom automations: <https://github.com/anthropics/claude-code-action/blob/main/docs/custom-automations.md>
# - FAQ and troubleshooting: <https://github.com/anthropics/claude-code-action/blob/main/docs/faq.md>
#
# Examples of Claude in action:
# - <https://github.com/anthropics/claude-code-action/blob/main/.github/workflows/claude.yml>
# - <https://github.com/anthropics/claude-code-action/pulls>

name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

Comment on lines +17 to +26
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says mentioning @claude in any issue or pull request triggers a response, but this workflow does not listen to pull_request events (opened/edited). As-is, @claude in the PR title/body won’t trigger a run unless someone also posts a comment/review containing @claude. Consider adding a pull_request trigger (typically types: [opened, edited]) if you want PR-body mentions to work.

Copilot uses AI. Check for mistakes.
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 # Needed for Claude to commit code changes and documentation updates
pull-requests: write # Needed for Claude to create and update pull requests
issues: write # Needed for Claude to create and update issues
id-token: write
actions: read # Required for Claude to read CI results on PRs
Comment on lines +29 to +40
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow grants broad write permissions and triggers on any @claude mention in issue/PR comments. If the repository is public (or accepts outside contributors), any user can mention @claude and cause this job to run with write access and access to secrets.ANTHROPIC_API_KEY. Add an explicit trust gate (e.g., require author_association to be OWNER/MEMBER/COLLABORATOR, or restrict to a hardcoded allowlist of users/teams) before running the action.

Copilot uses AI. Check for mistakes.
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Run Claude Code
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

# Enable web research tools for documentation and best practices
# Go tooling allows Claude to run tests, build, format, and analyze Go code
# See https://docs.claude.com/en/docs/claude-code/cli-reference for available options
claude_args: |
--allowedTools "Bash(go:*)"
--allowedTools "WebSearch,WebFetch"
Comment on lines +59 to +60
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude_args repeats --allowedTools on separate lines. If the Claude CLI treats repeated flags as “last one wins”, this would drop either the Go tooling allowance or the web tooling allowance. Prefer a single --allowedTools flag with a combined comma-separated list (or use the action’s documented multi-flag format) to ensure both are applied.

Suggested change
--allowedTools "Bash(go:*)"
--allowedTools "WebSearch,WebFetch"
--allowedTools "Bash(go:*),WebSearch,WebFetch"

Copilot uses AI. Check for mistakes.
125 changes: 106 additions & 19 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
# Dependabot Auto-merge Workflow
#
# Patch updates auto-merge after CI passes. Minor and major updates
# require human review until LLM-assisted review is available (#5).
# Patch and minor updates enable auto-merge; major updates require human merge:
# - Patch: auto-approved (low-risk)
# - Minor: Claude reviews, approves if acceptable
# - Major: Claude advises, human must approve and merge
#
# Squash commits default to using the PR description as body, but
# Dependabot PRs include lengthy changelogs and compatibility notes.
# The merge step overrides the body to keep commit messages clean.
# ┌────────────────────────────────────────────────────────────────────┐
# │ Review & Merge │
# ├────────────────────────────────────────────────────────────────────┤
# │ 1. Fetch metadata │
# │ 2. Auto-approve patch ──────────────────────> 5. Auto-merge patch │
# │ 3. Claude review minor ─────────────────────> 6. Auto-merge minor │
# │ 4. Claude review major ─────────────────────> (human merge) │
# └────────────────────────────────────────────────────────────────────┘
#
# Squash commits default to using the PR description as body, but Dependabot
# PRs include lengthy changelogs and compatibility notes. Each step overrides
# the body to keep commit messages clean.

name: "🤖 Dependabot"
name: "🤖 ClauDependabot"

on:
# Using pull_request (not pull_request_target) because the OIDC approach for
# GitHub app impersonation does not appear to work with Dependabot PRs.
# See: https://github.com/anthropics/claude-code-action/issues/713
#
# This means Claude jobs will fail if Dependabot updates this file itself,
# but we've minimized actions here to reduce that risk.
pull_request:
branches: [main]
# Path filter avoids creating workflow runs for unrelated PRs while
# still catching all Dependabot updates (Go modules and Actions).
# Path filter avoids creating workflow runs for unrelated PRs while still
# catching all Dependabot updates (Go modules and GitHub Actions).
paths:
- "go.mod"
- "go.sum"
Expand All @@ -22,9 +38,10 @@ on:
permissions:
contents: write # Required by: gh pr merge --auto
pull-requests: write # Required by: gh pr review --approve
id-token: write # Required for Claude to generate GitHub app tokens

jobs:
automerge:
mergeview:
name: Review & Merge
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
Expand All @@ -43,16 +60,75 @@ jobs:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# TODO(#5): Review minor updates with Claude before auto-merging.
# Once the Claude Code workflow lands, add a step here that uses
# claude-code-action to review the diff and approve if acceptable,
# followed by an auto-merge step gated on the same condition.
- name: Checkout for review
uses: actions/checkout@v6

- name: Review minor
if: steps.metadata.outputs.update-type == 'version-update:semver-minor'
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
allowed_bots: dependabot
prompt: |
This is a Dependabot PR for a minor version update.

Package ecosystem: ${{ steps.metadata.outputs.package-ecosystem }}
Dependency: ${{ steps.metadata.outputs.dependency-names }}
Update: ${{ steps.metadata.outputs.previous-version }} → ${{ steps.metadata.outputs.new-version }}
PR: ${{ github.event.pull_request.html_url }}

Use `gh pr diff` and `gh pr view` to review the changes.

Minor updates should be backwards-compatible. However, for v0.x
dependencies, minor bumps may contain breaking changes per semver.
Review those with extra caution.

If the changes look reasonable, approve the PR with a message that
includes your model identifier (e.g. "Reviewed by claude-sonnet-4-20250514").

Use: gh pr review --approve --body "your message"
claude_args: |
--allowedTools "Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*)"
--allowedTools "Bash(gh issue:*),Bash(gh search:*),Bash(gh run:*),Bash(gh workflow:*),Bash(gh release:*)"
--allowedTools "Bash(go:*),WebFetch,WebSearch"
--max-turns 25

- name: Review major
if: steps.metadata.outputs.update-type == 'version-update:semver-major'
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
allowed_bots: dependabot
prompt: |
This is a Dependabot PR for a MAJOR version update.

Package ecosystem: ${{ steps.metadata.outputs.package-ecosystem }}
Dependency: ${{ steps.metadata.outputs.dependency-names }}
Update: ${{ steps.metadata.outputs.previous-version }} → ${{ steps.metadata.outputs.new-version }}
PR: ${{ github.event.pull_request.html_url }}

Use `gh pr diff` and `gh pr view` to review the changes.

# TODO(#5): Analyze major updates with Claude, require human merge.
# Major updates may contain breaking changes. The planned step uses
# claude-code-action to post a review comment with migration notes
# and risk analysis, but does not approve or merge. A human reads
# the analysis and decides whether to proceed.
Major updates may have breaking changes. Please:

1. Fetch the dependency's release page and CHANGELOG to understand what changed
2. Check the README for migration guides
3. Review the codebase for usages of this dependency
4. If changes are needed, comment on the PR with suggested fixes

For github_actions ecosystem specifically:
- Review the workflow files in .github/workflows/ that use this action
- Check for deprecated inputs, outputs, or runner requirements

Do NOT approve, merge, or push commits to this PR.
Use `gh pr review --comment` to post your analysis and any suggested code changes.
IMPORTANT: Place all parameters AFTER --comment (e.g., `gh pr review --comment --body "..." <PR_URL>`).
claude_args: |
--allowedTools "Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review --comment:*),Bash(gh pr review -c:*)"
--allowedTools "Bash(gh issue:*),Bash(gh search:*),Bash(gh run:*),Bash(gh workflow:*),Bash(gh release:*)"
--allowedTools "Bash(go:*),WebFetch,WebSearch"
--disallowedTools "Bash(gh pr review --approve:*),Bash(gh pr review -a:*)"
--max-turns 50

- name: Auto-merge patch
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
Expand All @@ -65,3 +141,14 @@ jobs:
changes carry minimal risk of breaking existing functionality.

Compatibility score: ${{ steps.metadata.outputs.compatibility-score }}%

- name: Auto-merge minor
if: steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL" --body "$BODY"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: |
This minor update was reviewed by Claude before merging.
Comment on lines +145 to +152
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-merge minor runs solely based on update-type == semver-minor and does not verify that the preceding Claude step actually approved the PR. If Claude decides the update is risky and posts a comment (or takes no approval action), this step would still enable auto-merge (subject to repo protections). Gate the merge step on the PR having an approval from the intended reviewer (e.g., query reviews via gh pr view --json reviews) or have the Claude step explicitly set an output that indicates approval was granted.

Suggested change
- name: Auto-merge minor
if: steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL" --body "$BODY"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: |
This minor update was reviewed by Claude before merging.
- name: Check minor approval
id: check_minor_approval
if: steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: |
APPROVED_COUNT="$(gh pr view "$PR_URL" --json reviews --jq '.reviews | map(select(.state == "APPROVED")) | length')"
echo "Found $APPROVED_COUNT approved reviews"
if [ "$APPROVED_COUNT" -gt 0 ]; then
echo "approved=true" >> "$GITHUB_OUTPUT"
else
echo "approved=false" >> "$GITHUB_OUTPUT"
fi
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Auto-merge minor
if: >-
steps.metadata.outputs.update-type == 'version-update:semver-minor' &&
steps.check_minor_approval.outputs.approved == 'true'
run: gh pr merge --auto --squash "$PR_URL" --body "$BODY"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BODY: |
This minor update was reviewed and approved before merging.

Copilot uses AI. Check for mistakes.

Compatibility score: ${{ steps.metadata.outputs.compatibility-score }}%
Loading