| name | code-review |
| description | description: 'Perform AI code review on local changes or a GitHub PR, duplicating the LLLLKKKK/rtp-llm review bot format (P0-P3 ratings, checklists, strengths). Use when: pre-reviewing before PR submission, reviewing a PR diff, or self-checking staged changes.' Use when this capability is needed. |
name: code-review
description: 'Perform AI code review on local changes or a GitHub PR, duplicating the LLLLKKKK/rtp-llm review bot format (P0-P3 ratings, checklists, strengths). Use when: pre-reviewing before PR submission, reviewing a PR diff, or self-checking staged changes.'
AI Code Review Bot
Perform structured code review that matches the rtp-llm upstream review system (LLLLKKKK's AI-assisted review bot).
Inputs
- Target: one of:
local — review unstaged/staged git diff in the workspace (default)
branch <name> — review diff of branch vs main
pr <URL> — fetch and review a GitHub PR diff
files <path1> <path2> ... — review specific files
- Scope (optional):
full (default) or quick (skip checklists, issues only)
- Language (optional):
zh (Chinese, default — matches upstream) or en (English)
When to Use
- Before submitting a PR to alibaba/rtp-llm — catch issues the review bot will flag
- After pushing fixes to check if review round is clean
- Self-review of any code change
Procedure
1. Gather the Diff
Based on the target:
- local: Run
git diff HEAD (or git diff --cached for staged only)
- branch: Run
git diff main...<branch> -- . ':!internal_source'
- pr: Fetch diff via
curl -sH "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/{owner}/{repo}/pulls/{number}
- files: Read the specified files and compare against main
Filter out:
- Files under
internal_source/ (internal overlay, not reviewed)
- Binary files, generated files, lock files (unless lock file is the point of the PR)
- Files with only whitespace/comment changes (note them as P3 at most)
2. Analyze Each Changed File
For each file in the diff, analyze against the three checklists below. Track:
- Issues: problems that should be raised as P0/P1/P2/P3
- Checklist violations: checklist items that fail (linked to issues or checklist-only)
- Strengths: positive patterns worth calling out
3. Classify Issues by Priority
| Level | Name | Criteria | Effect |
|---|
| P0 | Critical | Security vulnerability, credential/URL leak, data loss, crash in production path | BLOCKING — must fix before merge |
| P1 | Blocking | Correctness bug, breaking API change, missing referenced target, test infrastructure that silently skips, state/resource leak | BLOCKING — must fix before merge |
| P2 | Non-blocking Suggestion | DRY violation, missing tests for new logic, hardcoded paths, loose test tolerance, type discipline issues, missing error handling | Non-blocking — should fix but won't block merge |
| P3 | Minor Nit | Trailing whitespace, import order, naming conventions, docstring style, dead code comments | Non-blocking — nice to fix |
Status decision:
- If any P0 or P1 exists → Status: BLOCKING
- Otherwise → Status: LGTM + include "lgtm ready to ci"
4. Output the Review
Use this exact format (matching upstream bot output):
## AI Code Review - PR #<number or "local">
Status: <LGTM | BLOCKING>
Summary: P0/<count> · P1/<count> · P2/<count> · P3/<count>
[if LGTM] lgtm ready to ci
### Blocking Issues
#### P0
• <issue title> @ `<file:line>`
◦ 建议:<specific actionable suggestion>
#### P1
• <issue title> @ `<file:line>`
◦ 建议:<specific actionable suggestion>
### Non-blocking Suggestions
#### P2
• <issue title> @ `<file:line>`
◦ 建议:<specific actionable suggestion>
#### P3
• <issue title> @ `<file:line>`
◦ 建议:<specific actionable suggestion>
### Checklist Violations (<fail count> fail / <total checked> total)
General Principles Checklist
• [6.1] <category> — <rule> → issue `<linked issue title>` <explanation>
OR
• [6.1] <category> — <rule> → checklist-only <explanation why not promoted to issue>
RTP-LLM Checklist
• [<letter>] <category> — <rule> → issue `<linked issue title>` <explanation>
Python Static-First Checklist
• [P.<letter>] <category> — <rule> → issue `<linked issue title>` <explanation>
### Strengths
• <positive observation about the code>
• <another positive observation>
Formatting rules:
- If a P-level section has 0 items, omit that section entirely
- Each issue must reference a specific file:line
- Each suggestion (建议) must be concrete and actionable — no vague "consider improving"
- Checklist items link to issues with
→ issue '<title>' or note → checklist-only with rationale
- Strengths should acknowledge genuinely good patterns (not filler)
- Default language is Chinese for issue titles and suggestions (matching upstream)
Checklists
General Principles Checklist [6.1]
Run ALL items against every PR. Mark pass/fail for each. Only report failures in output.
Software Engineering
Architecture
Tests
Quality
RTP-LLM Domain Checklist
Run for PRs touching rtp-llm-specific code. Skip for pure infra/docs changes.
[A] Compatibility & Configuration
[B] Correctness & Logic
[C] API & Protocol
[D] Performance
[E] Device Integration (CUDA / ROCm / XPU)
[H] Testing & CI
[I] Code Quality
Python Static-First Checklist
Run for PRs with Python changes. Skip for pure C++/Bazel/config changes.
[P.A] Static Structure & Type Discipline
[P.B] Function Design
[P.F] Language Pitfalls
[P.G] Test Conventions
[P.H] Type Annotations
Special Rules
Checklist-only vs Issue
When a checklist item fails but doesn't warrant its own P-level issue:
- Mark as
→ checklist-only with brief rationale (e.g., "matches existing pattern in same file", "impact too small to justify separate fix")
- This happens when: the violation is inherited from existing code, the fix would be a separate refactor PR, or the risk is purely theoretical
Comparing with Peer Implementations
Before flagging a pattern as a violation, check:
- Do CUDA/ROCm/CPU implementations of the same component use the same pattern?
- Is this an established convention in the rtp-llm codebase?
- If yes → note as
checklist-only ("沿用既有模式,不单独立 issue")
Scaling Checklist Depth
- Small PRs (1-3 files, <100 lines): Run all checklists but with ~23-30 total items
- Medium PRs (4-10 files, 100-500 lines): Full checklists, ~56 total items
- Large PRs (10+ files, 500+ lines): Full checklists with sub-items expanded, ~93-104 total items
- Report total as
(<fail> fail / <total checked> total)
Internal URL Detection (always P0)
Always scan for these patterns — they are automatic P0 blockers:
alibaba-inc.com
artlab.alibaba
/mnt/nas1/
aliyuncs.com.*key
--access-key-id
--access-key-secret
Version Number Checks
If PR updates dependency versions:
- Verify version is monotonically increasing (not regressing)
- Verify lock file hash matches the new wheel/package
- Verify Python version in lock file matches target runtime
Output
The complete review in the format specified in Step 4 above. Must include:
- Status line (LGTM or BLOCKING)
- Summary counts
- All P-level issue sections (only non-empty ones)
- Checklist violations section
- Strengths section (minimum 2 items)
Source: aslanxie/rtp-llm-xpu — distributed by TomeVault.