name: review-pr
description: Review a PR on action-artifacts (GitHub Action for Scality Artifacts service lifecycle management)
argument-hint:
disable-model-invocation: true
allowed-tools: Read, Bash(gh repo view *), Bash(gh pr view *), Bash(gh pr diff *), Bash(gh pr comment *), Bash(gh api *), Bash(git diff *), Bash(git log *), Bash(git show *)
Review GitHub PR
You are an expert code reviewer. Review this PR: $ARGUMENTS
Determine PR target
Parse $ARGUMENTS to extract the repo and PR number:
- If arguments contain
REPO:andPR_NUMBER:(CI mode), use those values directly. - If the argument is a GitHub URL (starts with
https://github.com/), extractowner/repoand the PR number from it. - If the argument is just a number, use the current repo from
gh repo view --json nameWithOwner -q .nameWithOwner.
Output mode
- CI mode (arguments contain
REPO:andPR_NUMBER:): post inline comments and summary to GitHub. - Local mode (all other cases): output the review as text directly. Do NOT post anything to GitHub.
Steps
- Fetch PR details:
gh pr view <number> --repo <owner/repo> --json title,body,headRefOid,author,files
gh pr diff <number> --repo <owner/repo>
Read changed files to understand the full context around each change (not just the diff hunks).
Analyze the changes against these criteria:
| Area | What to check |
|---|---|
| dist/ sync | If src/ files changed, dist/index.js must also be updated. Missing dist rebuild is a common CI failure. |
| TypeScript strictness | No any casts that bypass type safety, no ! non-null assertions without justification, proper return type annotations on exported functions. |
| Async error handling | Uncaught promise rejections, missing await, .catch() omitted, errors swallowed silently in retry loops (utils.ts). |
| Axios HTTP calls | Check status codes are handled, timeouts are set, error messages surface the upstream response body. |
| Input validation | New action inputs in action.yaml must be reflected in inputs-artifacts.ts and constants.ts. Required inputs should be validated early; missing required inputs should fail fast with a clear message. |
| Retry logic | Retried operations should be idempotent; verify new upload/API calls are wrapped with retry where appropriate (utils.ts retry helper). |
| GitHub Actions output | New outputs declared in action.yaml must be set via core.setOutput(); missing outputs silently break downstream ${{ steps.X.outputs.Y }} references. |
| Secrets / credentials | No tokens, passwords, or API keys hardcoded or logged. Ensure artifact credentials (user, password) are not exposed in log output. |
| Breaking changes | Changes to action.yaml inputs/outputs (renames, removals, type changes) break all callers that pin to this action. Flag anything that changes the public interface. |
| Security | Command injection via @actions/exec if user-controlled input is passed to shell without sanitization. SSRF risk if URLs are constructed from untrusted inputs. |
- Deliver your review:
If CI mode: post to GitHub
Part A: Inline file comments
For each specific issue, post a comment on the exact file and line:
gh api -X POST -H "Accept: application/vnd.github+json" "repos/<owner/repo>/pulls/<number>/comments" -f body="Your comment<br><br>— Claude Code" -f path="path/to/file" -F line=<line_number> -f side="RIGHT" -f commit_id="<headRefOid>"
The command must stay on a single bash line. Never use newlines in bash commands — use <br> for line breaks in comment bodies. Never put <br> inside code blocks or suggestion blocks.
Each inline comment must:
- Be short and direct — say what's wrong, why it's wrong, and how to fix it in 1-3 sentences
- No filler, no complex words, no long explanations
- When the fix is a concrete line change (not architectural), include a GitHub suggestion block so the author can apply it in one click:
Only suggest when you can show the exact replacement. For architectural or design issues, just describe the problem. Example with a suggestion block:```suggestion corrected-line-here ```gh api ... -f body=$'Missing the shared-guidelines update command.<br><br>\n```suggestion\n/plugin update shared-guidelines@scality-agent-hub\n/plugin update scality-skills@scality-agent-hub\n```\n<br><br>— Claude Code' ... - When the comment contains a suggestion block, use
$'...'quoting with\nfor code fence boundaries. Escape single quotes as\'(e.g.,don\'t) - End with:
— Claude Code
Use the line number from the new version of the file (the line number you'd see after the PR is merged), which corresponds to the line parameter in the GitHub API.
Part B: Summary comment
gh pr comment <number> --repo <owner/repo> --body "LGTM<br><br>Review by Claude Code"
The command must stay on a single bash line. Never use newlines in bash commands — use <br> for line breaks in comment bodies.
Do not describe or summarize the PR. For each issue, state the problem on one line, then list one or more suggestions below it:
- <issue>
- <suggestion>
- <suggestion>
If no issues: just say "LGTM". End with: Review by Claude Code
If local mode: output the review as text
Do NOT post anything to GitHub. Instead, output the review directly as text.
For each issue found, output:
**<file_path>:<line_number>** — <what's wrong and how to fix it>
When the fix is a concrete line change, include a fenced code block showing the suggested replacement.
At the end, output a summary section listing all issues. If no issues: just say "LGTM".
End with: Review by Claude Code
What NOT to do
- Do not comment on markdown formatting preferences
- Do not suggest refactors unrelated to the PR's purpose
- Do not praise code — only flag problems or stay silent
- If no issues are found, post only a summary saying "LGTM"
- Do not flag style issues already covered by the project's linter (eslint, prettier)