Skip to content

Instantly share code, notes, and snippets.

@PetkevichPavel
Created July 19, 2025 19:11
Show Gist options
  • Select an option

  • Save PetkevichPavel/091df6f7b0aa1fced67a9912da7ad207 to your computer and use it in GitHub Desktop.

Select an option

Save PetkevichPavel/091df6f7b0aa1fced67a9912da7ad207 to your computer and use it in GitHub Desktop.
GitHub Action Template
name: Claude 4 PR Review
on:
pull_request:
types: [opened, synchronize]
jobs:
claude-review:
name: Claude AI Code Review
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get PR Diff
run: |
git fetch origin ${{ github.base_ref }}
git diff origin/${{ github.base_ref }}...HEAD > pr_diff.txt
- name: Run Claude PR Review
env:
CLAUDE_API_KEY: ${{ secrets.CLAUDE_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
REVIEW=$(curl -s https://github.com/myage-health/repo_name/api/claude-review \
-H "Authorization: Bearer $CLAUDE_API_KEY" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"diff": "$(jq -Rs . < pr_diff.txt)",
"prompt": "Please review the following pull request diff. Point out bugs, risks, unclear logic, style issues, or improvements. Respond as a concise but technical GitHub review comment."
}
EOF
)
echo "$REVIEW" > review_comment.md
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/reviews \
-d @- <<EOF
{
"body": $(jq -Rs . < review_comment.md),
"event": "COMMENT"
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment