-
Notifications
You must be signed in to change notification settings - Fork 196
Add Claude Code automatic PR reviews #842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Claude Code Review | ||
|
|
||
| on: | ||
| pull_request: | ||
| # Only auto-review PRs into dev. Promotions from dev to main re-package | ||
| # already-reviewed work, and comment @claude on any PR for an on-demand review. | ||
| branches: [dev] | ||
| types: [opened, synchronize, ready_for_review, reopened] | ||
| # To limit reviews to certain files, uncomment and adjust: | ||
| # paths: | ||
| # - "**/*.sql" | ||
| # - "**/*.ps1" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| claude-review: | ||
| # Skip draft PRs (reviewed when marked ready) and fork PRs: GitHub does not | ||
| # expose repo secrets to workflows triggered from forks, so the review can | ||
| # only run on same-repo branches. Use @claude comments for fork PRs. | ||
| if: ${{ !github.event.pull_request.draft && github.event.pull_request.head.repo.full_name == github.repository }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| id-token: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code Review | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
| track_progress: true | ||
| prompt: | | ||
| REPO: ${{ github.repository }} | ||
| PR NUMBER: ${{ github.event.pull_request.number }} | ||
|
|
||
| This repository contains Erik Darling's SQL Server troubleshooting stored | ||
| procedures. Most changes are to large, self-contained T-SQL stored | ||
| procedures, plus PowerShell tooling and CI scripts. The repository | ||
| CLAUDE.md is the canonical T-SQL style guide. | ||
|
|
||
| Review this pull request with these priorities: | ||
|
|
||
| 1. Correctness: logic errors, NULL handling, dynamic SQL construction | ||
| (quoting, QUOTENAME, parameterized sp_executesql), cursor handling, | ||
| error handling, and overflow safety (COUNT_BIG, ROWCOUNT_BIG). | ||
| 2. SQL Server version compatibility: procedures support a range of | ||
| versions (generally 2016 through 2025, plus Azure SQL DB and Managed | ||
| Instance where the procedure documents support). Flag newer T-SQL | ||
| syntax (STRING_AGG, CONCAT_WS, GREATEST/LEAST, TRIM, etc.) or DMV | ||
| columns used without the version/feature gating patterns the | ||
| procedure already uses elsewhere. | ||
| 3. Self-containment: procedures must not gain dependencies on helper | ||
| functions, views, or other database objects. | ||
| 4. Style: flag clear CLAUDE.md violations (tabs, -- comments instead of | ||
| /* */ blocks, abbreviated data types or keywords, missing table | ||
| aliases, missing semicolons). Do not nitpick. | ||
|
|
||
| Repo-specific rules: | ||
| - Install-All/DarlingData.sql is auto-generated by CI. If this PR edits | ||
| it directly, flag that as a blocking problem: only per-procedure | ||
| source files should change. | ||
| - The @version / @version_date lines in procedures only change in | ||
| release PRs from the maintainer (erikdarlingdata). If any other PR | ||
| bumps them, ask for that to be reverted. | ||
|
|
||
| The PR branch is already checked out in the current working directory. | ||
|
|
||
| Use inline comments for specific issues and one summary comment for the | ||
| overall review. Only the GitHub comments you post will be seen, so put | ||
| all feedback there rather than in a normal response. If the changes look | ||
| good, say so briefly and do not invent problems. | ||
|
|
||
| claude_args: | | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| 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: | ||
| # Only users with write access to the repo can trigger this; the action | ||
| # enforces that check on the commenting user. This is also the way to get a | ||
| # review on fork PRs, where the automatic review workflow cannot run. | ||
| 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 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Run Claude Code | ||
| uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor/optional: unlike
claude-code-review.yml, this workflow has noconcurrencygroup. If a user posts several@claudecomments in quick succession on the same PR/issue, multiple runs could execute concurrently and push conflicting commits to the same branch. Not a blocker, but worth considering something like:(
cancel-in-progress: falsesince you likely don't want to cancel a change already in progress, just serialize new triggers.)