com um clique
code-review
Run multi-perspective code review on a PR or the local branch
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Run multi-perspective code review on a PR or the local branch
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Keep the Threa Pi remote-control extension in `extensions/pi-remote/` aligned with the current Pi extension API and Threa bot-runtime public API. Use when asked to update, verify, sync, or troubleshoot the Pi remote plugin, `/remote-control`, or `threa-remote.ts`.
Create a well-structured pull request with proper description, design decisions, and file changes. Use when asked to create a PR, open a PR, or submit changes for review.
Call Threa's public REST API (send/list/search/update/delete messages, list streams/users/members, search memos/attachments) with curl or a Bun script. Use when asked to post messages to a stream, seed a stream with test data, drive the API from automation, dedupe by metadata, inspect a production workspace (streams, messages, members) for troubleshooting, or otherwise hit https://staging.threa.io / https://app.threa.io endpoints with an API key. Reads from production should use the read-only prod key.
Rewrite user-facing copy (marketing pages, docs, headings, UI microcopy, READMEs, PR descriptions) to strip AI-slop and salesy tone, leaving plain, understated, factual prose. Use when asked to "deslopify", "deslop", "remove the AI slop", "make this less salesy/less AI-sounding", "make the copy plainer", or when reviewing copy for slop tells.
Write a session handover doc for the next agent picking up this line of work. Use when asked to "write a handover", "hand over", "handoff doc", or at the end of a session whose work continues in a future session.
Find or deduce the implementation plan for the current feature branch
| name | code-review |
| description | Run multi-perspective code review on a PR or the local branch |
| allowed-tools | Bash(gh api:*), Bash(gh issue view:*), Bash(gh issue list:*), Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*), Bash(gh pr list:*), Bash(gh repo view:*), Bash(git:*) |
Up to 4 parallel Sonnet reviewers — Agent 1: Spec & Design, Agent 2: Correctness & Data Flow, Agent 3: UX, Agent 4: Mobile — with inline self-scoring (threshold ≥80/100) → filtered report. The fan-out scales to the diff (Step 3): UX + Mobile only spawn on frontend changes, and trivial diffs collapse to a single combined agent, so a backend-only PR runs 2 agents and a small one runs 1. The report is ALWAYS printed to chat; when reviewing a GitHub PR it is also posted as a PR comment.
Remote / web sessions:
ghis not installed and the GitHub MCP server cannot reliably update existing issue comments (the supersede step in Step 6 silently no-ops). Ifghfails with "command not found", use thegithub-api-webskill for every GitHub interaction in this skill — list/read/post/PATCH comments viacurl $GH_TOKEN. Do NOT fall back tomcp__github__*for the supersede flow; it cannot edit prior comment bodies.
This skill runs in one of two modes. The default is to review (and post to) the PR the branch is about; only stay local when there is no PR or the user asked you to.
/code-review 903) — the explicit target; or# gh (local sessions):
gh pr view --json number,state,isDraft,url -q '"\(.number)|\(.state)|\(.isDraft)|\(.url)"' 2>/dev/null
# web/remote sessions (no gh): use the github-api-web skill or GitHub MCP —
# GET /repos/OWNER/REPO/pulls?head=OWNER:<branch>&state=open → take the first open PR
If that resolves to an OPEN, non-draft PR, target it and state which PR you picked.Precedence: an explicit "stay local" request wins over an open PR. A provided number always wins. Otherwise, if an open PR exists for the branch, use PR mode and post.
Resolve the base and diff for local mode (PR mode gets its diff from the PR — see Step 2):
base="${BASE:-main}"
if git rev-parse --verify "origin/$base" >/dev/null 2>&1; then base_ref="origin/$base"; else base_ref="$base"; fi
git diff --quiet "$base_ref"...HEAD && git diff --quiet HEAD && echo "NO_CHANGES" || echo "HAS_CHANGES"
# Committed-since-merge-base (three-dot) + uncommitted working-tree edits (vs HEAD).
# Do NOT diff the two-dot `git diff "$base_ref"`: when origin/main has advanced past
# the branch point it folds that unrelated main-ahead churn into the review and
# produces phantom "this PR also changes X" findings.
{ git diff "$base_ref"...HEAD; git diff HEAD; } > /tmp/code-review.diff
git rev-parse HEAD # HEAD SHA for links (only clickable if a remote exists)
git branch --show-current
Skip the review if NO_CHANGES. Store base_ref, the diff path, branch, and HEAD SHA.
gh pr view <N> --json state,isDraft,author -q '"\(.state)|\(.isDraft)|\(.author.login)"'
Skip if: CLOSED/MERGED, isDraft, or bot author (dependabot/renovate/etc).
Check for active unified-review comments to supersede:
gh api repos/OWNER/REPO/issues/N/comments --jq '[.[] | select(.body | contains("unified-review")) | select(.body | contains("unified-review:superseded") | not) | .id]'
Note ALL active IDs — new review supersedes each one.
PR mode:
gh pr view N --json number,title,url,headRefOid,body — store PR metadata + HEAD SHAgh repo view --json owner,name — store OWNER/REPOgh pr diff N > /tmp/code-review.diff — the diff agents read<details> block under <summary>📋 Full implementation plan</summary> from the PR body. Store it or "No plan found".files=$(gh pr diff N --name-only | grep -v -E '\.test\.|\.spec\.|evals/|\.env|\.md$|\.json$')
for f in $files; do
prs=$(gh pr list --state merged --search "path:$f" --limit 3 --json number,title -q '.[] | "#\(.number) \(.title)"')
[ -n "$prs" ] && printf '=== %s ===\n%s\n' "$f" "$prs"
done
Local mode:
/tmp/code-review.diff (Step 0). OWNER/REPO from gh repo view or git remote get-url origin (best-effort, for links only).gh pr list):
mb=$(git merge-base "$base_ref" HEAD)
git diff --name-only "$base_ref"...HEAD | grep -v -E '\.test\.|\.spec\.|evals/|\.env|\.md$|\.json$' | while IFS= read -r f; do
hist=$(git log --no-merges --format='%h %s' -3 "$mb" -- "$f" 2>/dev/null)
[ -n "$hist" ] && printf '=== %s ===\n%s\n' "$f" "$hist"
done
In both modes: read CLAUDE.md files (root + directories touched by the diff). Store historical output as historicalContext and write it to /tmp/code-review-history.txt so Agent 1 can Read it instead of receiving a huge prompt.
The fan-out scales to the diff — spawning all lenses on every change is the single biggest quota drain, so size the review to the work. First triage:
diff=/tmp/code-review.diff
changed_lines=$(grep -cE '^[+-]' "$diff")
sub_files=$(grep -E '^\+\+\+ b/' "$diff" | sed 's#^\+\+\+ b/##' \
| grep -vE '\.(test|spec)\.|/evals/|\.env|\.md$|\.json$|\.lock$')
sub_count=$(printf '%s\n' "$sub_files" | grep -c .)
fe_count=$(printf '%s\n' "$sub_files" | grep -cE 'apps/frontend/|\.(tsx|jsx|css|scss)$|packages/prosemirror/')
printf 'changed_lines=%s substantive_files=%s frontend_files=%s\n' "$changed_lines" "$sub_count" "$fe_count"
Pick the tier from those numbers:
changed_lines ≤ 50 AND sub_count ≤ 2: spawn one combined Sonnet agent that runs every relevant lens (drop UX/Mobile if fe_count = 0) in a single prompt. No fan-out.fe_count ≥ 1. A backend-only diff therefore runs 2 agents, not 4 — UX and Mobile findings cannot exist without frontend changes, so paying for those agents on backend diffs is pure waste.Record which agents you spawned and why (e.g. "backend-only: skipped UX + Mobile") — Step 6 attribution must reflect the actual set.
Agents run run_in_background: true, subagent_type: "general-purpose", model: "sonnet". Each gets: the plan / distilled chat intent, the diff path (/tmp/code-review.diff), and (PR mode) the PR number.
CLAUDE.md handling (quota): Do NOT paste full CLAUDE.md into every agent — it is ~5.5k tokens and duplicating it across agents is the largest avoidable cost. Only Agent 1 receives the full root CLAUDE.md text (plus any touched-directory CLAUDE.md) because it owns the invariant audit. Every other agent gets only the "Quick Invariant Lookup" digest from CLAUDE.md and the instruction: "Read root CLAUDE.md ONLY to confirm a specific invariant before flagging it."
Shared instructions (include in every agent prompt):
Do NOT build/typecheck. Read the diff from /tmp/code-review.diff (PR mode agents may instead run gh pr diff <N>). Rely on the diff; Read a source file ONLY when it is needed to push a specific finding over the ≥80 threshold — do not browse the tree.
Self-score each issue 0-100 before including it. Only output issues scoring ≥80.
Rubric: 0=false positive, 25=maybe/stylistic, 50=real but nitpick, 75=likely real+important, 100=definite+high-impact. CLAUDE.md issues: verify cited instruction actually exists and says what you claim (≤25 if misquoted).
ISSUES:
- file.ts:10-20 | CATEGORY | SCORE | Description
Categories: claude-md, bug, plan, missing-change, abstraction, security, performance, reactivity, historical, data-flow, round-trip, state-lifecycle, ux-consistency, ux-discoverability, ux-affordance, ux-feedback, accessibility, mobile-layout, mobile-touch, mobile-responsive, mobile-regression. No issues → ISSUES: none
Do NOT flag: pre-existing issues — UNLESS the diff converts a latent one into a user-visible or data-integrity bug (an issue the change amplifies is in scope); unchanged lines (except missing corresponding changes), CI-catchable (types/lint/build), general quality without a CLAUDE.md/plan mandate, silenced issues, intentional changes matching PR/chat purpose, theoretical risks — BUT for sync / optimistic-concurrency / event-echo code, an "our own emitted event is delivered back before our ack/commit lands" interleaving is NOT theoretical; if you dismiss a race as rare you must state the timing budget that makes it rare; pedantic nitpicks. Quality over quantity — returning few or no issues is correct when the change is sound.
Agent 1: Spec & Design (gets full CLAUDE.md) — four jobs:
/tmp/code-review-history.txt (recent commits/PRs per touched file). Only flag changes that clearly violate patterns visible from the history. Do NOT make additional history calls — all of it is pre-provided.Agent 2: Correctness & Data Flow (invariant digest only) — three jobs:
version/baseVersion the confirm path wrote, so the next write looks unsynced and collides/duplicates.data-flow / round-trip / state-lifecycle categories for these. Favor concrete sequences ("on the 2nd push expectedVersion is 0 because the edit handler dropped baseVersion") over vague "could race".Agent 3: UX / Interaction Design (frontend diffs only) — user-perceivable behavior, NOT a generic bug hunt:
Agent 4: Mobile / Responsive (frontend diffs only) — user-perceivable on phones/touch/narrow viewports:
isMobile/breakpoint paths actually render the intended mobile layout; do viewport-width and container-width thresholds agree (a mismatch where one says "mobile" and another computes a desktop value is a real bug); can the user always get back/out.pointerType); controls that are invisible or unusable on touch (hover-only, tiny targets, divider/resize affordances).vh/vw/100vh and fixed widths that break with the mobile keyboard or browser chrome; min-width floors causing horizontal overflow; safe-area handling; regressions to existing mobile keyboard/scroll choreography.isMobile.Collect all issues from the spawned agents (2–4, or 1 for a trivial diff). Drop any with score <80. De-duplicate where two agents found the same thing (keep the clearest framing, note both lenses). Verify the highest-impact claims against the source before publishing — a confidently-posted false positive is worse than a missed nitpick; lower the score or drop it if it doesn't hold.
Confidence 1-7: 7=Excellent(none survived), 6=Very Good(minor), 5=Good(few non-blocking), 4=Acceptable(some), 3=Needs Work(multiple), 2=Significant Concerns(blocking), 1=Major Problems.
Re-run Step 1 to ensure the PR hasn't been closed/drafted during review.
Always print the full report to chat (both modes) so the user sees it without leaving the conversation.
PR mode also posts a comment. Use gh pr comment N --body-file …. Link format: https://github.com/OWNER/REPO/blob/FULL_SHA/path/file.ts#L10-L15 (full SHA, 1-2 lines context). In local mode, use the same link format only if a remote/SHA is known; otherwise cite path/file.ts:10-15.
Attribution: Disclose models AND the actual lens set that ran (it varies by tier/surface). Include **Review models:** Orchestrator: <runtime model> | Reviewers: sonnet x<N> (<lenses actually spawned>) — e.g. sonnet x2 (spec+design, correctness+data-flow) for a backend diff, sonnet x4 (spec+design, correctness+data-flow, UX, mobile) for a frontend one, or sonnet x1 (combined) for a trivial diff.
Report body (identical for the chat printout and the PR comment; the PR comment also carries the <!-- unified-review --> marker as its first line):
<!-- unified-review -->
### Code review
**Confidence: X/7** — [Label]
**Review models:** Orchestrator: <runtime model> | Reviewers: sonnet x<N> (<lenses that ran>)
Found N issues:
1. `file.ts:10-20` — Description (CLAUDE.md [INV-XX, <section>]: "<quoted>" | bug: <reason> | ux-consistency: <reason> | mobile-touch: <reason> | etc.)
https://github.com/OWNER/REPO/blob/SHA/path/file.ts#L9-L21
---
<details><summary>📐 Plan Adherence [CLEAN | N issues]</summary>[details]</details>
<details><summary>🔍 Bugs [CLEAN | N issues]</summary>[details]</details>
<details><summary>🔁 Data Flow [CLEAN | N issues]</summary>[details]</details>
<details><summary>📋 CLAUDE.md Compliance [CLEAN | N violations]</summary>[details]</details>
<details><summary>🏗️ Design [CLEAN | N concerns]</summary>[details]</details>
<details><summary>🔒 Security [CLEAN | N issues]</summary>[details]</details>
<details><summary>🎛️ UX [CLEAN | N issues]</summary>[details]</details>
<details><summary>📱 Mobile [CLEAN | N issues]</summary>[details]</details>
🤖 Generated with unified-review automation
<sub>If this review was useful, react with 👍. Otherwise, react with 👎.</sub>
If no issues survived:
<!-- unified-review -->
### Code review
**Confidence: 7/7** — Excellent
**Review models:** Orchestrator: <runtime model> | Reviewers: sonnet x<N> (<lenses that ran>)
No issues found. Checked for <the lenses that actually ran — e.g. bugs, data-flow lifecycle, CLAUDE.md compliance, plan adherence, design quality, and security on a backend diff; add UX and mobile when those agents ran>.
🤖 Generated with unified-review automation
<sub>If this review was useful, react with 👍. Otherwise, react with 👎.</sub>
In local mode, drop the <!-- unified-review --> / reaction-footer lines from the chat printout (they only matter on GitHub).
Supersede old comments (PR mode, for each active ID from Step 1): Fetch old body, replace <!-- unified-review --> with <!-- unified-review:old -->, update with <!-- unified-review:superseded -->, link to new comment, preserve full old content in <details>.
Use gh api -X PATCH repos/OWNER/REPO/issues/comments/ID -f body=... locally, or curl -X PATCH per the github-api-web skill in remote/web sessions. Do not attempt this via mcp__github__* — the MCP server does not expose a working issue-comment edit, and skipping supersede leaves stale reviews stacked on the PR (this is the most common remote-session failure mode for this skill).
Code review complete — <PR #N: URL | local branch <name> vs <base_ref>>
Confidence: X/7
Models: Orchestrator=<runtime model>, Reviewers=sonnet x<N> (<lenses that ran>)
Summary:
- 📐 Plan: <status>
- 🔍 Bugs: <status>
- 🔁 Data flow: <status>
- 📋 CLAUDE.md: <status>
- 🏗️ Design: <status>
- 🔒 Security: <status>
- 🎛️ UX: <status>
- 📱 Mobile: <status>
Key issues: [list if any]