docs/users/features/code-review.md
Review code changes for correctness, security, performance, and code quality using
/review.
# Review local uncommitted changes
/review
# Review a pull request (by number or URL)
/review 123
/review https://github.com/org/repo/pull/123
# Review and post inline comments on the PR
/review 123 --comment
# Review a specific file
/review src/utils/auth.ts
If there are no uncommitted changes, /review will let you know and stop — no agents are launched.
The /review command runs a multi-stage pipeline:
Step 1: Determine scope (local diff / PR worktree / file)
Step 2: Load project review rules
Step 3: Run deterministic analysis (linter, typecheck) [zero LLM cost]
Step 4: 5 parallel review agents [5 LLM calls]
|-- Agent 1: Correctness & Security
|-- Agent 2: Code Quality
|-- Agent 3: Performance & Efficiency
|-- Agent 4: Undirected Audit
'-- Agent 5: Build & Test (runs shell commands)
Step 5: Deduplicate --> Batch verify --> Aggregate [1 LLM call]
Step 6: Reverse audit (find coverage gaps) [1 LLM call]
Step 7: Present findings + verdict
Step 8: Autofix (user-confirmed, optional)
Step 9: Post PR inline comments (if requested)
Step 10: Save report + incremental cache
Step 11: Clean up (remove worktree + temp files)
| Agent | Focus |
|---|---|
| Agent 1: Correctness & Security | Logic errors, null handling, race conditions, injection, XSS, SSRF |
| Agent 2: Code Quality | Style consistency, naming, duplication, dead code |
| Agent 3: Performance & Efficiency | N+1 queries, memory leaks, unnecessary re-renders, bundle size |
| Agent 4: Undirected Audit | Business logic, boundary interactions, hidden coupling |
| Agent 5: Build & Test | Runs build and test commands, reports failures |
All agents run in parallel. Findings from Agents 1-4 are verified in a single batch verification pass (one agent reviews all findings at once, keeping LLM calls fixed). After verification, a reverse audit agent re-reads the entire diff with knowledge of all confirmed findings to catch issues that every other agent missed. Reverse audit findings skip the verification step (the agent already has full context) and are included directly as high-confidence results.
Before the LLM agents run, /review automatically runs your project's existing linters and type checkers:
| Language | Tools detected |
|---|---|
| TypeScript/JavaScript | tsc --noEmit, npm run lint, eslint |
| Python | ruff, mypy, flake8 |
| Rust | cargo clippy |
| Go | go vet, golangci-lint |
| Java | mvn compile, checkstyle, spotbugs, pmd |
| C/C++ | clang-tidy (if compile_commands.json available) |
| Other | Auto-discovered from CI config (.github/workflows/*.yml, etc.) |
For projects that don't match standard patterns (e.g., OpenJDK), /review reads CI configuration files to discover what lint/check commands the project uses. No user configuration needed.
Deterministic findings are tagged with [linter] or [typecheck] and skip LLM verification — they are ground truth.
If a tool is not installed or times out, it is skipped with an informational note.
| Severity | Meaning | Posted as PR comment? |
|---|---|---|
| Critical | Must fix before merging (bugs, security, data loss, build failures) | Yes (high-confidence only) |
| Suggestion | Recommended improvement | Yes (high-confidence only) |
| Nice to have | Optional optimization | No (terminal only) |
Low-confidence findings appear in a separate "Needs Human Review" section in the terminal and are never posted as PR comments.
After presenting findings, /review offers to auto-apply fixes for Critical and Suggestion findings that have clear solutions:
Found 3 issues with auto-fixable suggestions. Apply auto-fixes? (y/n)
edit tool (targeted replacements, not full-file rewrites)When reviewing a PR, /review creates a temporary git worktree (.qwen/tmp/review-pr-<number>) instead of switching your current branch. This means:
npm ci, etc.) so linting and build/test work/review of the same PR automatically cleans up the stale worktree before starting freshYou can review PRs from other repositories by passing the full URL:
/review https://github.com/other-org/other-repo/pull/456
This runs in lightweight mode — no worktree, no linter, no build/test, no autofix. The review is based on the diff text only (fetched via GitHub API). PR comments can still be posted if you have write access.
| Capability | Same-repo | Cross-repo |
|---|---|---|
| LLM review (Agents 1-4 + verify + reverse audit) | ✅ | ✅ |
| Agent 5: Build & test | ✅ | ❌ (no local codebase) |
| Deterministic analysis (linter/typecheck) | ✅ | ❌ |
| Cross-file impact analysis | ✅ | ❌ |
| Autofix | ✅ | ❌ |
| PR inline comments | ✅ | ✅ (if you have write access) |
| Incremental review cache | ✅ | ❌ |
Use --comment to post findings directly on the PR:
/review 123 --comment
Or, after running /review 123, type post comments to publish findings without re-running the review.
What gets posted:
What stays terminal-only:
After the review, context-aware tips appear as ghost text. Press Tab to accept:
| State after review | Tip | What happens |
|---|---|---|
| Local review with unfixed findings | fix these issues | LLM interactively fixes each finding |
| PR review with findings | post comments | Posts PR inline comments (no re-review) |
| PR review, zero findings | post comments | Approves the PR on GitHub (LGTM) |
| Local review, all clear | commit | Commits your changes |
Note: fix these issues is only available for local reviews. For PR reviews, use Autofix (Step 8) — the worktree is cleaned up after the review, so post-review interactive fixing is not possible.
You can customize review criteria per project. /review reads rules from these files (in order):
.qwen/review-rules.md (Qwen Code native).github/copilot-instructions.md (preferred) or copilot-instructions.md (fallback — only one is loaded, not both)AGENTS.md — ## Code Review sectionQWEN.md — ## Code Review sectionRules are injected into the LLM review agents (1-4) as additional criteria. For PR reviews, rules are read from the base branch to prevent a malicious PR from injecting bypass rules.
Example .qwen/review-rules.md:
# Review Rules
- All API endpoints must validate authentication
- Database queries must use parameterized statements
- React components must not use inline styles
- Error messages must not expose internal paths
When reviewing a PR that was previously reviewed, /review only examines changes since the last review:
# First review — full review, cache created
/review 123
# PR updated with new commits — only new changes reviewed
/review 123
If you switch models (via /model) and re-review the same PR, /review detects the model change and runs a full review instead of skipping:
# Review with model A
/review 123
# Switch model
/model
# Review again — full review with model B (not skipped)
/review 123
# → "Previous review used qwen3-coder. Running full review with gpt-4o for a second opinion."
Cache is stored in .qwen/review-cache/ and tracks both the commit SHA and model ID. Make sure this directory is in your .gitignore (a broader rule like .qwen/* also works). If the cached commit was rebased away, it falls back to a full review.
For same-repo reviews, results are saved as a Markdown file in your project's .qwen/reviews/ directory (cross-repo lightweight reviews skip report persistence):
.qwen/reviews/2026-04-06-143022-pr-123.md
.qwen/reviews/2026-04-06-150510-local.md
Reports include: timestamp, diff stats, deterministic analysis results, all findings with verification status, and the verdict.
When code changes modify exported functions, classes, or interfaces, the review agents automatically search for all callers and check compatibility:
For large diffs (>10 modified symbols), analysis prioritizes functions with signature changes.
The review pipeline uses a fixed number of LLM calls regardless of how many findings are produced:
| Stage | LLM calls | Notes |
|---|---|---|
| Deterministic analysis (Step 3) | 0 | Shell commands only |
| Review agents (Step 4) | 5 (or 4) | Run in parallel; Agent 5 skipped in cross-repo mode |
| Batch verification (Step 5) | 1 | Single agent verifies all findings at once |
| Reverse audit (Step 6) | 1 | Finds coverage gaps; findings skip verification |
| Total | 7 or 6 | Same-repo: 7; cross-repo: 6 (no Agent 5) |
The review intentionally excludes:
Silence is better than noise. Every comment should be worth the reader's time.