|
| 1 | +--- |
| 2 | +name: pr-review |
| 3 | +description: Review an open pull request for this project. Checks Go code quality (AGENTS.md), test coverage, and Kubernetes security. Posts findings as a GitHub PR comment. Use when the user asks to review a PR. Invoke with /pr-review [PR-number] or /pr-review to auto-detect the current branch's PR. |
| 4 | +disable-model-invocation: true |
| 5 | +allowed-tools: Bash(gh pr view:*), Bash(gh pr diff:*), Bash(gh pr comment:*), Bash(gh pr list:*), Bash(git rev-parse:*), Bash(git log:*), Agent, TodoWrite |
| 6 | +--- |
| 7 | + |
| 8 | +# PR Review |
| 9 | + |
| 10 | +**Arguments:** $ARGUMENTS (PR number, or empty to auto-detect) |
| 11 | + |
| 12 | +## Step 1: Identify PR |
| 13 | + |
| 14 | +```bash |
| 15 | +# If $ARGUMENTS is a number, use it. Otherwise auto-detect from current branch. |
| 16 | +gh pr view ${ARGUMENTS} --json number,title,url,state,isDraft,body,baseRefName,headRefName 2>/dev/null \ |
| 17 | + || gh pr view --json number,title,url,state,isDraft,body,baseRefName,headRefName |
| 18 | +``` |
| 19 | + |
| 20 | +If the PR is closed or a draft, stop and tell the user. |
| 21 | + |
| 22 | +Record: PR number, title, URL, base branch, head SHA. |
| 23 | + |
| 24 | +```bash |
| 25 | +git rev-parse HEAD |
| 26 | +``` |
| 27 | + |
| 28 | +## Step 2: Fetch PR Context |
| 29 | + |
| 30 | +```bash |
| 31 | +gh pr diff <number> |
| 32 | +gh pr view <number> --json files --jq '[.files[].path] | join("\n")' |
| 33 | +``` |
| 34 | + |
| 35 | +Pass both outputs to all review agents. |
| 36 | + |
| 37 | +## Step 3: Parallel Review |
| 38 | + |
| 39 | +Launch **all three agents simultaneously** in a single message with three parallel Agent tool calls: |
| 40 | + |
| 41 | +**Agent: go-reviewer** |
| 42 | +Prompt: "Review this pull request for Go code quality and AGENTS.md compliance. |
| 43 | +PR #<number>: <title> |
| 44 | +Changed files: <list> |
| 45 | +Diff: |
| 46 | +<diff>" |
| 47 | + |
| 48 | +**Agent: test-analyzer** |
| 49 | +Prompt: "Review this pull request for test coverage. |
| 50 | +PR #<number>: <title> |
| 51 | +Changed files: <list> |
| 52 | +Diff: |
| 53 | +<diff>" |
| 54 | + |
| 55 | +**Agent: security-auditor** |
| 56 | +Prompt: "Review this pull request for Kubernetes security concerns. |
| 57 | +PR #<number>: <title> |
| 58 | +Changed files: <list> |
| 59 | +Diff: |
| 60 | +<diff>" |
| 61 | + |
| 62 | +Wait for all three to complete before proceeding. |
| 63 | + |
| 64 | +## Step 4: Aggregate and Post |
| 65 | + |
| 66 | +Collect findings from all three agents. Only include issues with confidence >= 80. |
| 67 | + |
| 68 | +If no issues meet the threshold, post: |
| 69 | + |
| 70 | +``` |
| 71 | +### Code Review |
| 72 | +
|
| 73 | +No issues found. Checked Go conventions, test coverage, and security. |
| 74 | +
|
| 75 | +🤖 Generated with [Claude Code](https://claude.ai/code) |
| 76 | +``` |
| 77 | + |
| 78 | +Otherwise post: |
| 79 | + |
| 80 | +``` |
| 81 | +### Code Review |
| 82 | +
|
| 83 | +Found N issues: |
| 84 | +
|
| 85 | +**Go Code Quality** |
| 86 | +1. <brief description> — `path/to/file.go#L42` |
| 87 | + > AGENTS.md: "<relevant rule>" |
| 88 | +
|
| 89 | +**Test Coverage** |
| 90 | +2. <brief description> — `path/to/file_test.go` |
| 91 | +
|
| 92 | +**Security** |
| 93 | +3. <brief description> — `path/to/file.go#L10` |
| 94 | +
|
| 95 | +🤖 Generated with [Claude Code](https://claude.ai/code) |
| 96 | +``` |
| 97 | + |
| 98 | +When linking to specific lines, use the full commit SHA: |
| 99 | +`https://github.com/llm-d/llm-d-workload-variant-autoscaler/blob/<full-sha>/path/to/file.go#L42-L45` |
| 100 | + |
| 101 | +Post the comment: |
| 102 | +```bash |
| 103 | +gh pr comment <number> --body "$(cat <<'REVIEW_EOF' |
| 104 | +<aggregated findings> |
| 105 | +REVIEW_EOF |
| 106 | +)" |
| 107 | +``` |
| 108 | + |
| 109 | +Print the PR URL when done. |
0 commit comments