Code Review Tutorial
Prerequisites
Before starting this tutorial, ensure:
uf initcompleted — your project has Divisor review agents deployed (.opencode/agents/divisor-*.md)ghCLI installed and authenticated —/uf.review-prusesghto fetch PR metadata and CI results
which gh && gh auth statusIf gh is not installed, get it from
cli.github.com. If not authenticated, run gh auth login.
Step 1: Pre-PR Review with /uf.review-council
Before you push your changes and create a PR, run /uf.review-council to catch issues locally:
/uf.review-council
/uf.review-council [N] # optionally specify a PR number
/uf.review-council code [N] # explicitly select code review modeWhen a PR number is provided, the council posts its consolidated findings as a GitHub PR review after completing the local review. Without a PR number, the review runs locally only.
What Happens
The review council runs in two phases:
Phase 1: CI Soft Gate — runs your project’s build, test, and lint commands (derived from .github/workflows/). When a check fails, the council determines whether the failure is new (introduced by your branch) or pre-existing (already broken on main). New failures block the review — no point reviewing code that introduces regressions. Pre-existing failures are reported as informational findings but do not block. The council checks the main baseline via the GitHub CI API first, falling back to a temporary git worktree if API data is unavailable.
Phase 2: Divisor Review — launches 5+ review personas in parallel, each with a different focus:
| Persona | Focus |
|---|---|
| Adversary | Security, resilience, edge cases |
| Architect | Structure, conventions, patterns |
| Guard | Intent drift, scope discipline |
| Testing | Test coverage, isolation, assertions |
| SRE | Deployment, operational readiness |
| Curator | Documentation gaps |
Expected Output
Phase 1: CI Gate
✓ npm run build — passed (536ms)
Phase 2: Divisor Review
Adversary: APPROVE (0 findings)
Architect: APPROVE (1 LOW — weight inconsistency)
Guard: APPROVE (0 findings)
Testing: APPROVE (0 findings)
SRE: APPROVE (0 findings)
Curator: APPROVE (0 findings)
Council Verdict: APPROVEIf any persona returns REQUEST CHANGES, the council verdict is REQUEST CHANGES. Fix the findings and re-run. The review council iterates up to 3 times, auto-fixing LOW and MEDIUM findings where possible.
Gaze integration (optional): If Gaze is installed, the review council runs quality analysis (CRAP scores, test coverage) as Phase 1b. This is informational — it does not block the verdict.
Optional: Post to GitHub
When a PR exists for your branch, /uf.review-council can post its consolidated findings as a GitHub PR review. The council detects an open PR automatically via gh pr view, or you can specify a PR number explicitly with /uf.review-council N.
How it works: After all personas complete their local review, the council aggregates their findings into a single GitHub review with per-persona sections. The council verdict maps to a GitHub review event:
| Council Verdict | GitHub Review Event | When It Occurs |
|---|---|---|
| APPROVE | APPROVE | All personas approve with no findings |
| APPROVE WITH ADVISORIES | COMMENT | All personas approve but one or more include advisory findings (LOW-severity observations or informational notes) |
| REQUEST CHANGES | REQUEST_CHANGES | Any persona returns REQUEST CHANGES |
Pre-posting safety checks:
- Duplicate detection — skips posting if the council has already posted an identical review on the same commit
- Stale review dismissal — warns if previous council reviews on older commits should be dismissed
- CODEOWNER warnings — alerts if the PR modifies files owned by teams not represented in the review
Before posting, the council asks for human confirmation. No review is posted without your explicit approval.
Graceful degradation: If gh is not installed, not authenticated, or no PR exists for the current branch, /uf.review-council runs the full local review without errors. GitHub posting is strictly optional — the local review workflow is unchanged.
Step 2: Push and Create a PR
Once the review council approves, push your changes and create a PR:
/uf.finaleOr manually:
git push -u origin my-branch
gh pr create --title "feat: add user auth" --body "..."Step 3: Post-PR Review with /uf.review-pr
After the PR is created and CI has run, review the PR:
/uf.review-prThis auto-detects the open PR for your current branch. To review a specific PR (including someone else’s):
/uf.review-pr 42What Happens
/uf.review-pr runs a structured review informed by CI results:
- Resolve PR — auto-detect or use the provided PR number
- Fetch metadata — title, description, changed files, branch info
- CI check results — fetch pass/fail status for every check
- Causality classification — for each failing check, determine if it is PR-caused or pre-existing
- Local tool pre-flight — run tools only for checks CI did not already cover
- Scoped diff — fetch the PR diff (skipping lock files, generated code, binaries)
- Spec alignment — locate the associated spec for intent checking
- AI review — judgment on alignment, security, and architecture
- Structured report — severity-classified findings
- Verdict posting — posts the verdict as a GitHub PR review for all outcomes (APPROVE, REQUEST_CHANGES, or COMMENT)
Expected Output
PR #42: feat: add user auth
Branch: feature/user-auth → main
Files changed: 8 (+342, -12)
CI Checks:
✓ Build & Test — passed
✓ Lint — passed
✗ yamllint — FAILED (pre-existing)
Causality Analysis:
yamllint: base branch FAIL, PR FAIL → Pre-existing
(This failure exists independently of your PR)
Local Pre-flight:
Skipped: build (CI passed), lint (CI passed)
Review Findings:
[HIGH] Missing error handling in auth.go:42
[MEDIUM] Consider extracting helper function at auth.go:87
Verdict: 2 findings (1 HIGH, 1 MEDIUM)Step 4: Understanding CI Causality
When CI checks fail on your PR, the key question is: did my changes cause this?
/uf.review-pr answers this by checking whether the same check also fails on the base branch:
| Base Branch | PR Check | Classification |
|---|---|---|
| Pass | Fail | PR-caused — your changes introduced this |
| Fail | Fail | Pre-existing — failure exists independently |
| No data | Fail | Unknown — treated as PR-caused (conservative) |
PR-caused failures are reported as HIGH or CRITICAL findings. These are your regressions.
Pre-existing failures are reported separately and do not block the PR verdict. They are not your problem — but /uf.review-pr can help fix them.
Step 5: Fix Branches for Pre-existing Failures
When pre-existing failures are found, /uf.review-pr offers to create a fix branch:
I identified 1 pre-existing CI failure:
- yamllint: trailing whitespace in config/database.yml
Would you like me to create a fix branch?If you agree, it creates fix/pr-42-yamllint from the base branch with a minimal fix. The branch stays local — you review and push when ready.
Safety guards:
- Will not create a fix branch if you have uncommitted changes (dirty-tree guard)
- Will not overwrite an existing branch with the same name (collision check)
- Will not attempt non-trivial fixes spanning more than 3 files
The Complete Loop
The two review commands fit into the standard development workflow:
/speckit.specify # define the work
↓
/uf.unleash # implement autonomously
↓
/uf.review-council # validate locally (pre-PR)
↓
/uf.finale # commit, push, create PR
↓
/uf.review-pr # review with CI data (post-PR)
↓
Merge # after reviewer approvalYou can use either command independently — they do not depend on each other. But together they catch issues at two different points: before the code leaves your machine and after it runs through CI. Additionally, /uf.review-council N can optionally post its findings to an existing PR, bridging the pre-PR and post-PR stages when you want multi-persona review results visible on the PR itself.
Decision Table
| Situation | Command | Why |
|---|---|---|
| Before pushing | /uf.review-council | Catch issues locally with 5+ parallel reviewers |
| Post council findings to a PR | /uf.review-council N | Multi-persona local review with findings posted as a GitHub PR review |
| After creating a PR | /uf.review-pr | Review with CI results and causality analysis |
| Reviewing someone else’s PR | /uf.review-pr 42 | Works on any PR by number |
| CI failed, unsure if my fault | /uf.review-pr | Causality classification separates your regressions from noise |
| Want maximum coverage | Both in sequence | /uf.review-council pre-push, /uf.review-pr post-PR |
/uf.review-council Nvs/uf.review-pr N: Both target a specific PR, but they serve different purposes./uf.review-council Nruns the full multi-persona local review and posts the aggregated findings to the PR./uf.review-pr Nfetches CI results, performs causality analysis (PR-caused vs pre-existing failures), and reviews the PR diff with that context. Use/uf.review-council Nwhen you want the council’s multi-persona review visible on the PR; use/uf.review-pr Nwhen you need CI-aware review with causality classification.
See Also
- Common Workflows –
/uf.review-councilvs/uf.review-prcomparison table and full command reference - Quick Start – Install and verify the toolchain
- Developer Guide – Daily workflow with the
ufCLI