Skip to content

Integrate Claude Code into development workflows#18

Closed
danielorbach wants to merge 14 commits intomainfrom
claude-code-workflows
Closed

Integrate Claude Code into development workflows#18
danielorbach wants to merge 14 commits intomainfrom
claude-code-workflows

Conversation

@danielorbach
Copy link
Collaborator

Mentioning @claude in any issue or pull request now triggers a response with write access to the repository, Go tooling, and web research. The existing Dependabot workflow gains Claude-assisted review for minor and major dependency updates, completing the three-tier automation that was deferred in #16.

Minor updates are reviewed and auto-merged if Claude approves. Major updates receive analysis with migration notes and changelog research, but require a human to approve and merge. Tool permissions follow a least-privilege model: gh pr review commands are narrowly scoped, and major reviews explicitly disallow approval via --disallowedTools. The minor review prompt flags v0.x dependencies, where semver permits breaking changes in minor bumps.

Closes #5, closes #6.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Claude Code automation to respond to @claude mentions and extends the Dependabot auto-merge workflow to include Claude-assisted review for minor/major dependency updates, aligning with the repo’s tiered dependency management approach.

Changes:

  • Introduces a new claude.yml workflow that runs Claude Code when @claude is mentioned in supported GitHub events.
  • Updates the Dependabot automation workflow to have Claude review minor updates (approve + auto-merge) and analyze major updates (comment-only).
  • Adjusts workflow permissions to support Claude’s token generation and PR review actions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
.github/workflows/dependabot-automerge.yml Adds Claude review steps for minor/major Dependabot PRs and enables auto-merge for minor updates.
.github/workflows/claude.yml Adds a Claude Code workflow that triggers on @claude mentions across issue/PR-related events.
Comments suppressed due to low confidence (1)

.github/workflows/dependabot-automerge.yml:36

  • The workflow no longer restricts pull_request to branches: [main], which means it can run (and potentially approve/auto-merge) Dependabot PRs targeting any branch. If you only intend automation for mainline dependency updates, re-add the branch filter to avoid unexpected merges on release/feature branches.
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:
    # 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"
      - ".github/workflows/**"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +144 to +151
- 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.
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.
Comment on lines +29 to +40
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
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.
Comment on lines +17 to +26
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

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.
Comment on lines +61 to +62
--allowedTools "Bash(go:*)"
--allowedTools "WebSearch,WebFetch"
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.
Based on the baseline template by Claude Code's /install-github-app
command.
Without write permissions Claude can only read the repository and post
comments. Write access to contents, pull-requests, and issues enables
Claude to resolve PR comments with code changes, create branches, and
respond to issues. The id-token: write permission is required for the
action to generate GitHub app tokens.
Without web tools Claude cannot research documentation, fetch changelogs,
or look up best practices when asked. WebSearch and WebFetch are
significantly less privileged than the existing Bash execution and
repository write permissions already granted.
The agent determines whether to approve on its own.
Major updates may contain breaking changes that warrant human review.
Claude analyzes the diff, fetches release notes and changelogs, and posts
a review comment with migration notes, but does NOT approve or merge.

The --disallowedTools flag explicitly prevents gh pr review --approve,
providing a safety net beyond the prompt instruction.
Three issues addressed:

1. Bot actor validation: claude-code-action v1.0.30 added checkHumanActor
   validation that rejects bot-triggered workflows by default. The
   allowed_bots input opts in Dependabot explicitly.

2. Repository context: without a local checkout, gh commands fail to infer
   the repository. GH_REPO provides this context explicitly.

3. Tool scoping: minor reviews are restricted to gh pr diff/view/review.
   Major reviews additionally allow WebFetch and WebSearch for changelog
   research but explicitly disallow approval commands. --max-turns caps
   prevent runaway behavior (25 minor, 50 major).
Separates the non-deterministic Claude approval from the deterministic
merge operation, making the workflow behavior more predictable. Reorders
steps so reviews come first, then merges (patch and minor).
Adds ASCII diagram of the review & merge paths, notes on pull_request
vs pull_request_target (OIDC limitation with Dependabot PRs), and
squash commit body overrides.
Explains that enabling commit signing would allow Claude to commit via
MCP, which is undesirable for dependency review workflows.
A local checkout lets Claude inspect the codebase with Read/Grep/Glob,
run Go tooling (go mod graph, go vet), and infer the repo context from
the git remote. This eliminates the GH_REPO workaround and the git
credential errors that appeared without a working directory.

The checkout is conditional on minor or major updates; patch PRs skip
it since they are auto-approved without Claude.
The workflow permissions are read-only except for PR approval, which
is already guarded by narrow gh pr review scoping (and --disallowedTools
for major). The remaining gh subcommands (issue, search, run, workflow,
release) are safe to allow and help Claude research context. Go tooling
lets Claude verify compilation and inspect the dependency graph.
Semver treats everything before v1.0.0 as unstable: minor bumps in
v0.x may contain breaking changes. The prompt now flags this so Claude
applies extra scrutiny to pre-v1 minor updates.
@danielorbach danielorbach force-pushed the claude-code-workflows branch from 2323bf2 to 50756b9 Compare March 12, 2026 00:12
@danielorbach
Copy link
Collaborator Author

Dropping the claude.yml app integration per this decision. The Dependabot review work from this branch continues in a follow-up PR.

@danielorbach danielorbach changed the title Respond to @claude mentions and review Dependabot updates with Claude Code Integrate Claude Code into development workflows Mar 12, 2026
@danielorbach danielorbach deleted the claude-code-workflows branch March 12, 2026 00:32
danielorbach added a commit that referenced this pull request Mar 12, 2026
The existing Dependabot workflow auto-approves and merges patch updates
but left minor and major updates for human review (see #16). This
completes the three-tier automation by replacing those TODOs with
Claude-assisted review.

Minor updates are reviewed and auto-merged if Claude approves. Major
updates receive analysis with migration notes and changelog research,
but require a human to approve and merge. Tool permissions follow a
least-privilege model: `gh pr review` commands are narrowly scoped, and
major reviews explicitly disallow approval via `--disallowedTools`. The
minor review prompt flags v0.x dependencies, where semver permits
breaking changes in minor bumps.

Review and merge are split into separate jobs so each can declare its
own least-privilege permission set: the review job holds `id-token:
write` for Claude's OIDC tokens but only `contents: read`, while the
merge job holds `contents: write` but no `id-token`. This follows the
principle of least privilege at the job level, narrowing the blast
radius of each token.

The Claude Code "app" integration for issues and PRs (originally planned
in #5) was
[dropped](#5 (comment))
in favor of the local Claude Code experience; the prior attempt is
preserved in #18.

Closes #6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuring Dependabot for dependency management Installing the Claude Code GitHub workflow

2 participants