---
slug: "sirfetch-d-pi-code-review"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/Sirfetch-d/pi-code-review@main/README.md"
repo: "https://github.com/Sirfetch-d/pi-code-review"
source_file: "README.md"
branch: "main"
---
# pi-code-review

High-signal multi-agent pull request reviews for [Pi](https://pi.dev).

The package launches isolated Pi subprocesses to review task completion, scope, introduced bugs, regressions, permission and security risks, maintenance risks, and applicable `AGENTS.md` rules. Every candidate issue is independently validated; only findings with confidence of at least 80 are reported.

## Requirements

- Pi on Node.js 22.19 or newer
- Git repository hosted on GitHub
- [GitHub CLI](https://cli.github.com/) installed and authenticated
- An active model in the current Pi session
- The local checkout at the PR head commit with no tracked worktree changes

Pi packages execute with the current user's full system permissions. Review package source before installation. Child review agents disable discovered extensions, skills, prompt templates, themes, and context files, and receive only Pi's `read`, `grep`, `find`, and `ls` tools.

## Install

```bash
pi install npm:@sirfetch-d/pi-code-review
```

Remove it with:

```bash
pi remove npm:@sirfetch-d/pi-code-review
```

## Usage

Review the PR associated with the current branch:

```text
/code-review
```

Review a PR by number or URL:

```text
/code-review 123
/code-review https://github.com/owner/repo/pull/123
```

Reviews are terminal-only by default. Publishing requires the explicit flag:

```text
/code-review 123 --comment
```

All child agents inherit the current Pi model and thinking level. Override both for one invocation:

```text
/code-review 123 --model anthropic/claude-opus-4-6 --thinking high
```

Supported thinking levels are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.

## Review pipeline

1. Resolve the PR and skip closed, draft, duplicate-head, automated, or clearly trivial reviews.
2. Read only `AGENTS.md` files in the ancestor path of each changed file.
3. Summarize the intended task.
4. Run two instruction reviewers, two bug/risk reviewers, and one task objective/scope reviewer concurrently.
5. Independently validate every candidate issue with validation concurrency capped at four.
6. Filter invalid, low-confidence, duplicate, and out-of-diff findings.
7. Render the terminal report or submit one atomic GitHub `COMMENT` review.

While the review runs, Pi shows an animated stage indicator with elapsed time and reviewer or validator completion counts. The conversation retains concise milestones for PR resolution, triage, task summary, independent review, validation, and the final result. It never displays child-agent reasoning or raw subprocess output.

Final terminal and GitHub review templates automatically use Chinese when the root or applicable scoped `AGENTS.md` content is predominantly Chinese. This localization does not change model prompts, intermediate results, or review decisions; generated finding content is preserved verbatim.

A reviewer receives the exact dynamic changed-file list and must return a matching coverage receipt. A mismatched reviewer retries once with missing and unexpected paths identified; a second mismatch makes the review incomplete. Invalid output from a required stage after one isolated repair attempt, model failure, or cancellation also makes the review incomplete. If triage alone returns invalid output twice, the command reports the fallback and continues reviewing because ambiguity defaults to review. Incomplete reviews are never published.

## GitHub comments

`--comment` publishes one pull request review. Mappable findings become inline comments; task omissions without a safe diff location remain in the review summary. Terminal and GitHub summaries include an explicit advisory merge recommendation. The package never submits a formal GitHub approval or requests changes.

Published reviews include an AI-generated disclaimer and a hidden package-version/head-SHA marker. A second `--comment` run on the same head SHA is skipped; a new head SHA can be reviewed again.

## Troubleshooting

- Pi opens without its normal startup information: set `"quietStartup": false` in `~/.pi/agent/settings.json`. Use `pi --verbose` for a one-time override. This package does not change Pi's startup setting.
- `No active Pi model is selected`: select a model in Pi before running the command.
- `gh ... exited`: run `gh auth status` and confirm the current checkout matches the PR URL repository.
- No PR for the current branch: pass a PR number or URL.
- PR head mismatch: check out the target PR head and remove or commit tracked worktree changes before reviewing.
- Review incomplete: inspect the reported failed stage and rerun. The package does not convert partial coverage into a clean result.
- Large PR incomplete: use a model with sufficient context or split the pull request. Diff content is never silently truncated.

## Development

```bash
npm install --ignore-scripts
npm run check
npm run test
npm run pack:check
```

The implementation follows the approved [design](https://github.com/Sirfetch-d/pi-code-review/blob/HEAD/docs/superpowers/specs/2026-07-12-pi-code-review-design.md). Release history is recorded in the [changelog](https://github.com/Sirfetch-d/pi-code-review/blob/HEAD/CHANGELOG.md).

## License

MIT
