Arguments: <target> [--reviewers auto|security,performance,...] [--base-branch main] [--all] [--deep] [--no-context] [--fast] [--rigorous]. Wherever <arguments> appears below, substitute the text the user typed after the skill name.
team-review
Execution harness
Selected topology: parallel-subagents, with role delivery by inline-prompt. Start one isolated
runtime subagent per dispatched worker. When role delivery is inline-prompt, paste that role's
Markdown body into the dispatch prompt verbatim: the worker must receive the whole role, not a
summary of it.
Harness obligations, none of them optional:
- Every dispatched worker runs in its own subagent context, and never reads another worker's
result.
- Follow the dispatch plan below in phase order. A phase starts only after every phase it needs has
closed, and a phase closes only when every worker it dispatched is recorded
delivered or
failed. A worker reports delivered or failed in its final message; there is no shared task
list, so the coordinator keeps that record itself.
- Dispatch only roles from this set, and only as the plan says:
api-contract-auditor, chicken-egg-detector, cleanup-auditor, code-auditor, data-integrity-auditor, distributed-flow-auditor, logic-integrity-auditor, premise-auditor, resource-lifecycle-auditor, security-auditor, temporal-resilience-auditor, ui-race-auditor
- Only the phase that declares the report artifact may write it.
Dispatch plan:
scope: runs in the orchestrating context; produces artifact:review-brief.
context-building: runs in the orchestrating context; needs scope; consumes artifact:review-brief; produces artifact:context-map.
dimension-detection: runs in the orchestrating context; needs context-building; consumes artifact:context-map; produces selection:reviewers.
independent-review: one worker per item of selection:reviewers, each bound to the role the selection names (any role this plugin declares), each in its own isolated context, in parallel where the host allows; barrier all-delivered; needs dimension-detection; consumes artifact:review-brief, artifact:context-map; produces artifact:reviewer-result.
delivery-accounting: runs in the orchestrating context; needs independent-review; consumes artifact:reviewer-result; produces artifact:delivery-ledger.
initial-consolidation: runs in the orchestrating context; needs delivery-accounting; consumes artifact:reviewer-result, artifact:delivery-ledger; produces artifact:initial-findings.
cross-examination: logic-integrity-auditor and premise-auditor, once each, each in its own isolated context, in parallel where the host allows; barrier all-delivered; needs initial-consolidation; consumes artifact:initial-findings; produces artifact:cross-examination.
consolidation: one code-auditor in an isolated context; needs cross-examination; consumes artifact:initial-findings, artifact:cross-examination, artifact:delivery-ledger; produces artifact:final-report.
report-delivery: runs in the orchestrating context; needs consolidation; consumes artifact:final-report.
Role bodies ship with this package under roles/, and the phase graph and record schemas under
contracts/team-review.workflow.toml.
Method
Execution requirements
This workflow fans out over the dimensions its detection step selects. Dispatch, scheduling and result
collection belong to the host harness, generated from contracts/team-review.workflow.toml. What this
workflow requires of any harness is fixed, and none of it is optional:
- every reviewer runs in its own context and never reads another reviewer's result
- exactly the selected dimensions are dispatched, once each
- every expected reviewer is recorded
delivered or failed before anything is consolidated
- cross-examination runs after that barrier, in fresh contexts
- only the consolidation phase writes the final report
If the host cannot run reviewers in isolated contexts, stop and say so. A review whose dimensions
shared a context is not the artifact this workflow claims to produce.
Team Review (Pipeline)
Orchestrate a multi-dimensional code review as a 6-phase pipeline:
- Phase 0 -- Scope and Discovery: resolve the target (0), detect which dimensions the change warrants (0b), and discover independently what evidence this review needs (0c), reading no X-ray output at all.
- Phase 1 -- Context Building: X-ray analysis (1a) runs in parallel with a blind second derivation of the same premises (1c); the two are joined into
01-knowledge-provenance.md (1d); an interconnect map is built last (1b), covering contracts, invariants, assumptions, domain rules and integration hot-spots. Output goes to .team-review/.
- Phase 2 -- Adversarial Review (parallel): specialized reviewers read the context files and hunt for violations within their dimension. Every finding declares the load-bearing premise it stands on and where that premise came from. Each reviewer writes structured findings to
.team-review/findings-<dim>.md.
- Phase 3 -- Monitor and Collect: every spawned reviewer delivers findings or an explicit no-findings report before consolidation starts.
- Phase 4 -- Consolidation and Gates: findings are deduplicated and organized by severity, with agreement weighted by premise provenance; then the verification panel runs (4b, Lens 0's premise veto first) and the completeness critic asks what the review missed (4c).
- Phase 5 -- Report & Cleanup.
The pipeline lets reviewers find problems that are invisible from local-only inspection: broken implicit contracts, invariant drift, bypass paths to business rules, non-idempotent retry paths, terminal state mutations. Two derivations run side by side in Phase 1 so that the review has a second observer, rather than one observer consulted N times.
Raw mode: pass --no-context to run the old parallel-only behavior (no Phase 0c, no context phase, no logic-integrity-auditor, no premise-auditor in either mode).
Skills to Load
Before starting, invoke these skills to inform the review process:
senior-review:review-quality-gates -- context-sharing pattern, adversarial verification panel, completeness critic
senior-review:defect-taxonomy -- 140+ defect subcategories with CWE/OWASP mappings (includes logic-integrity.md)
Pre-flight Checks
Confirm the harness can dispatch isolated reviewers; stop if it cannot.
Parse <arguments>:
<target>: file path, directory, git diff range (e.g., main...HEAD), or PR number (e.g., #123)
--reviewers: comma-separated dimensions OR auto (default: auto)
--base-branch: base branch for diff comparison (default: main)
--all: force all dimensions regardless of auto-detection
--deep: run Phase 1a codebase-xray in full mode (default: --depth=lite)
--no-context: skip Phase 0c and Phase 1 entirely and run reviewers with raw code only (raw mode; logic-integrity-auditor and premise-auditor are also skipped)
--fast: skip the verification + completeness-critic gate entirely (Phase 4b and 4c)
--rigorous: verify every finding above the confidence floor, ignoring the cost-guard cap
Check for existing .team-review/state.json:
- If present with
status: "in_progress": ask user whether to resume or start fresh (archive to .team-review-<ISO-timestamp>/).
- If present with
status: "complete": ask whether to archive and start fresh.
- If absent: proceed to new session.
Initialize .team-review/ with state.json:
{
"target": "<arguments>",
"status": "in_progress",
"flags": {
"reviewers": "auto",
"all": false,
"deep": false,
"no_context": false,
"fast": false,
"rigorous": false
},
"current_phase": 0,
"phases": {
"phase_0_resolution": "pending",
"phase_0b_detection": "pending",
"phase_0c_evidence_discovery": "pending",
"phase_1c_premise_audit": "pending",
"phase_1d_reconciliation": "pending",
"phase_1a_xray": "pending",
"phase_1b_interconnect": "pending",
"phase_2_review": "pending",
"phase_3_consolidation": "pending",
"phase_4b_verification": "pending",
"phase_4c_critic": "pending",
"phase_4_report": "pending"
},
"files_created": [],
"xray": {
"run_id": null,
"run_dir": null,
"target": null,
"depth": null
},
"started_at": "ISO_TIMESTAMP"
}
Phase 0: Target Resolution
- Determine target type:
- File/Directory: use as-is for review scope
- Git diff range:
git diff {range} --name-only to get changed files
- PR number:
gh pr diff {number} --name-only to get changed files
- Collect the full diff content for later distribution to reviewers.
- Collect the list of changed file paths and extensions for Phase 0b.
- Write
.team-review/00-scope.md with target, files, flags. Append a ## Pre-review work tree section containing the output of git status --porcelain at this moment: the Phase 5 workspace hygiene check diffs against it. Mark phase complete in state.json.
Phase 0b: Context Detection (when --reviewers auto or omitted)
Analyze changed files and codebase to determine which review dimensions are relevant. Skip if explicit --reviewers list was provided.
Always-on dimensions (run for every review)
| Dimension |
Agent |
Rationale |
| Security |
senior-review:security-auditor |
Every change can introduce vulnerabilities |
| Architecture |
senior-review:code-auditor |
Coupling, abstractions, failure flows, pattern consistency, scoring |
| Logic integrity |
senior-review:logic-integrity-auditor |
Hunts violations of contracts/invariants/domain rules surfaced in Phase 1b (skipped if --no-context) |
| Codebase hygiene |
senior-review:cleanup-auditor |
The full pass across all five dimensions that need source comprehension, over the whole codebase: dead code, orphan assets, phantom/unused deps plus barrel-file and eager-bundle bloat, stale documentation, and lifecycle archaeology. /senior-review:code-review and /senior-review:pr-review run only the lite subset (dead code, scoped to the diff), so this dimension is where the other four get covered at all |
| Workspace hygiene |
repo-hygiene:workspace-auditor |
Everything the filesystem and git decide without reading a symbol: filesystem garbage, generated artifacts tracked in VCS, .gitignore completeness and archaeology, scratch and pipeline-output directories, orphan doc-assets, git auxiliary state. Disjoint from the row above by construction, so the two never contest the same finding |
Conditional dimensions (auto-detected from context)
Run these checks against the changed files and codebase to decide which extra reviewers to spawn.
Five of these dimensions live in other plugins: React performance (react-development), platform / runtime integration (platform-engineering), structural entropy (abstraction-architect), testing quality (testing), and TypeScript type safety (typescript-development). All five are hard dependencies of senior-review, so the marketplace installs them with it and no dimension can go missing at runtime. A dimension is skipped only when its signal did not match the codebase, which is a statement about the code and never about the install. If a spawn fails with "Agent type not found", the install is broken: stop and report it rather than continuing with a silently reduced review.
| Signal |
Detection rule |
Dimension activated |
Agent |
| UI/frontend files |
Changed files include .tsx, .jsx, .vue, .svelte, .component.ts, or files containing scroll/focus/layout manipulation |
UI race conditions |
senior-review:ui-race-auditor |
| React project |
package.json has react in dependencies AND changed files include .tsx/.jsx |
React performance |
react-development:react-performance-optimizer |
| TypeScript project |
Changed files match \.tsx?$ AND tsconfig.json exists at the project root |
TypeScript type safety |
typescript-development:type-safety-auditor |
| Non-React frontend |
Frontend files detected but no React dependency |
General performance |
senior-review:code-auditor (performance dimension) |
| Fullstack app |
2+ signals: frontend framework in package.json, backend framework config, API route definitions, docker-compose.yml with multiple services, Tauri/Electron config |
Platform / runtime integration |
platform-engineering:platform-reviewer |
| Multi-service / messaging |
Changed files touch API routes, message handlers, gRPC definitions, queue consumers/producers, or docker-compose.yml with multiple services |
Distributed flows |
senior-review:distributed-flow-auditor |
| Init/startup code |
Changed files touch startup sequences, dependency injection, config bootstrap, migration runners, or service registration |
Circular dependencies |
senior-review:chicken-egg-detector |
| Long-running / scheduled execution |
Diff or changed files touch timers, schedulers, polling loops, retry/reconnect logic, cron jobs, queue workers, background daemons, updaters, or watchdogs (see detection command 5b) |
Temporal resilience (what does the user see after this has been failing for a day?) |
senior-review:temporal-resilience-auditor |
| Persistence code |
Diff or changed files touch schemas, models, ORM entities, repositories, raw SQL, cache layers, or transaction boundaries (see detection command 5c) |
Data integrity (can the store be made to hold an impossible state?) |
senior-review:data-integrity-auditor |
| Resource acquisition |
Diff or changed files acquire files, sockets, connections, subprocesses, listeners, subscriptions, locks, tasks, or timers, especially in manual-resource languages (C/C++/Rust/Go) or async-heavy code (see detection command 5d) |
Resource lifecycle (does every acquire release on success, error, AND cancellation?) |
senior-review:resource-lifecycle-auditor |
| Test files |
Changed files match test_*, *_test.*, *.spec.*, *.test.*, conftest.py, __tests__/ |
Testing quality |
testing:test-suite-auditor |
| API files |
Changed files touch a formal contract file (*.proto, openapi*.y*ml, swagger*, *.graphql, asyncapi*, JSON Schema), or route definitions, serializers, or DTO/model declarations |
API contracts |
senior-review:api-contract-auditor |
| Migration files |
Changed files match database migration patterns (Alembic, Django, Rails, Prisma, SQL migrations) |
Data migrations |
senior-review:data-integrity-auditor (migration dimension) |
| Diff target adding code |
Target resolved to a diff in Phase 0 (git range, PR number, or uncommitted changes) AND the diff adds at least one function, method, class, module, constant table, or block longer than roughly five lines. Never activated for plain file/directory targets: there is no diff to anchor on, and the whole-tree question belongs to /abstraction-architect:audit |
Structural entropy (does this diff add a second place where a concept the codebase already owns lives? Seven dimensions over two evidence tracks, diff-anchored: duplicated domain knowledge, competing sources of truth, redundant representation, duplicated or derivable state, missed unification, prior art available, abstraction fitness) |
abstraction-architect:abstraction-architect (mode diff) |
Detection implementation
Run these bash commands to gather signals:
# 1. Classify changed file extensions
echo "$CHANGED_FILES" | sed 's/.*\.//' | sort | uniq -c | sort -rn
# 2. Check for React
cat package.json 2>/dev/null | grep -q '"react"' && echo "REACT=true"
# 2b. Check for a TypeScript project
echo "$CHANGED_FILES" | grep -qE '\.tsx?$' && [ -f tsconfig.json ] && echo "TS_PROJECT=true"
# 3. Check for fullstack signals (count matches)
FULLSTACK_SIGNALS=0
[ -f package.json ] && grep -qE '"(react|vue|svelte|angular|next|nuxt)"' package.json && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))
grep -rql 'fastapi\|django\|flask\|express\|nest\|hono\|actix\|axum' pyproject.toml Cargo.toml package.json 2>/dev/null && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))
ls -d */routes */api */endpoints 2>/dev/null && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))
[ -f docker-compose.yml ] && grep -c 'image:\|build:' docker-compose.yml | awk '$1>1{print "MULTI_SERVICE"}' && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))
# 4. Check for multi-service / messaging patterns in diff
echo "$DIFF_CONTENT" | grep -qiE 'rabbitmq\|amqp\|kafka\|grpc\|pubsub\|queue\|celery\|dramatiq' && echo "MESSAGING=true"
echo "$CHANGED_FILES" | grep -qiE 'routes?\b|api/|endpoints?/|handlers?/' && echo "API_FILES=true"
# Formal contract files. Kept separate from API_FILES on purpose: a change to
# openapi.yaml or schema.graphql matches none of the path patterns above, and
# it is the single strongest signal for the api-contract-auditor dimension.
echo "$CHANGED_FILES" | grep -qiE '\.proto$|\.graphql$|\.gql$|openapi.*\.(ya?ml|json)$|swagger.*\.(ya?ml|json)$|asyncapi.*\.(ya?ml|json)$|schema.*\.json$' && echo "CONTRACT_FILES=true"
# 5. Check for init/startup patterns in diff
echo "$DIFF_CONTENT" | grep -qiE 'def main\b|if __name__|app\.on_startup|@app\.on_event|lifespan|create_app|bootstrap|init_' && echo "STARTUP=true"
# 5b. Check for long-running / scheduled execution patterns (temporal resilience)
echo "$DIFF_CONTENT" | grep -qiE 'setInterval|setTimeout|cron|schedule|\bretry|reconnect|backoff|watchdog|heartbeat|keepalive|\bpoll(ing)?\b|background.?(task|worker|job)|daemon|updater' && echo "TEMPORAL=true"
# 5c. Check for persistence code (data integrity)
echo "$DIFF_CONTENT" | grep -qiE '\btransaction\b|\bcommit\b|rollback|UPDATE |INSERT |upsert|\bunique\b|constraint|ON CONFLICT|FOR UPDATE|select_for_update|session\.add|\.objects\.|prisma\.|typeorm|sqlalchemy|redis|cache\.(get|set|del)' && echo "PERSISTENCE=true"
# 5d. Check for resource acquisition (resource lifecycle)
echo "$DIFF_CONTENT" | grep -qiE 'open\(|createReadStream|createWriteStream|\bsocket\b|getConnection|acquire|addEventListener|subscribe\(|\block\b|mutex|semaphore|new Worker|subprocess|Popen|spawn\(|go func|tokio::spawn|asyncio\.create_task|createObjectURL' && echo "RESOURCES=true"
# 6. Check for test and migration files
echo "$CHANGED_FILES" | grep -qiE 'test_|_test\.|\.spec\.|\.test\.|conftest|__tests__' && echo "TEST_FILES=true"
echo "$CHANGED_FILES" | grep -qiE 'migrat|alembic|versions/' && echo "MIGRATION_FILES=true"
Display detected dimensions
After detection, display the plan:
Context detection complete:
- Always: security, architecture, logic-integrity, codebase-hygiene, workspace-hygiene
- Detected: ui-races (6 .tsx files), react-perf (React project), ts-safety (TypeScript project), distributed-flows (API routes + RabbitMQ), temporal-resilience (retry + scheduler code), data-integrity (ORM writes + transactions), abstraction (diff adds 4 units)
- Skipped: platform (not fullstack), chicken-egg (no startup code)
Pipeline plan:
Phase 0c: review evidence discovery (inline)
Phase 1a: codebase-xray (--depth=lite) | Phase 1c: premise-auditor (parallel, blind)
Phase 1d: knowledge reconciliation (inline)
Phase 1b: codebase-xray:semantic-interconnect-mapper
Phase 2: {N} reviewers in parallel
Phase 3: consolidation
Phase 4: report
Every reason on the Skipped line is a statement about the code, never about the install: "not fullstack" means the code did not need the dimension. Every agent this command can spawn comes from a plugin senior-review declares as a hard dependency, so there is no "plugin not installed" reason and no generic fallback. If a spawn fails with "Agent type not found", stop and report the broken install instead of continuing with a silently reduced review.
Mark phase_0b_detection complete in state.json.
Phase 0c: Review Evidence Discovery
Runs inline in the orchestrating context, on every invocation except raw mode (--no-context). That flag means "give me the raw mode", and a normally-on phase does not override it: 01a-review-knowledge-leads.md distributed to N reviewers is itself shared context, so keeping this phase alive under the flag would make findings legitimately shared-context, let Lens 0 fire, and stop the mode reproducing the pre-pipeline behaviour it exists to provide.
This phase owns discovery of what evidence is relevant to this review. X-ray owns discovery of how the repository documents itself. The two are different jobs and the division is deliberate.
This phase MUST NOT read .codebase-xray/ in any form, including the mirror and the output of previous runs. A previous X-ray run is still an X-ray derivation, and admitting one would contaminate the single artifact that has to be demonstrably independent of X-ray. X-ray's leads enter at the Phase 1d join and nowhere earlier.
- Read
CLAUDE.md, AGENTS.md and equivalent project instruction files, and follow any navigation rule they state. If the project says a specific file is where to look first to find where a concept lives, open that file before opening any code. Discover the conventions from the repository itself, never from a prior X-ray run.
- Extract the concepts, domains and symbols the diff touches. Names of changed functions, classes, modules and config keys are the starting set; add the domain nouns that appear in the diff's own strings and comments.
- For each concept, search the project's indexes and documentation for a relevant entry, and search the tests for behaviour that encodes it.
- Write
.team-review/01a-review-knowledge-leads.md.
This file is immutable once written. No later phase appends to it. X-ray's own leads are joined into a separate derived artifact in Phase 1d, precisely so that the snapshot Phase 1c consumes cannot change underneath it.
Output: .team-review/01a-review-knowledge-leads.md
# Review Knowledge Leads
> Leads, not truth. Immutable once written.
> Discovered by senior-review independently of any X-ray output.
## Navigation rules followed
| Source | Rule |
|--------|------|
## Concepts touched by this diff
| Concept | Where it appears in the diff |
|---------|------------------------------|
## Leads
| Concept | Document / test | Anchor | Status |
|---------|-----------------|--------|--------|
## Concepts with no lead found
[One line each. This list is the honest statement of what nobody documented.]
Mark phase_0c_evidence_discovery complete in state.json.
Phase 1: Context Building
The sub-phases below are listed in execution order, not in label order: 1a and 1c start together, 1d joins them, 1b runs last on the joined result. Nothing named here is missing.
Skip this phase entirely if --no-context was passed. Mark phase_1a_xray, phase_1c_premise_audit, phase_1d_reconciliation, phase_1b_interconnect, and phase_0c_evidence_discovery as skipped in state.json. Jump to Phase 2 with raw target files only.
Phase 1a: X-Ray Analysis
codebase-xray:analyze is a workflow of the codebase-xray plugin, not an agent. Nothing dispatches it as a worker: it runs in this context, the way a user would invoke it, with its arguments. The host lists it under the codebase-xray plugin as analyze (a host that renders workflows as skills suffixes it -workflow). The codebase-xray:xray-method skill is the method that workflow applies; loading the method alone runs no phase and creates no run directory. The distinction matters because the rest of this command (Phase 1b, Phase 2) dispatches many plugin:name workers and the same shape names workflows and skills; treat Phase 1a as running a workflow, full stop.
- Run the
codebase-xray:analyze workflow against the target, in this context:
- Default mode:
--depth=lite (structure + interfaces + risks only)
- If
--deep flag: full analysis
- Target scope: the files from Phase 0
- Read
.codebase-xray/runs.json to resolve the run the workflow just created, and record it in state.json -> xray as run_id, run_dir, target and depth. Every later phase derives its paths from this block and never from the .codebase-xray/ root. $XRAY_RUN_DIR below always means state.json -> xray.run_dir. If the run cannot be resolved, halt: an unresolvable provenance is a broken pipeline, not a reason to fall back to the mirror.
- Verify on completion that at minimum
01-structure.md, 02-interfaces.md, and 05-risks.md exist.
- Mark
phase_1a_xray complete.
If the workflow is unavailable (plugin not installed) or produces no output, halt the pipeline and report the error. Do not fall back to spawning a general-purpose agent to fake the X-ray output -- the file naming and section anchors that Phase 1b/Phase 2 depend on come from the workflow itself, and a freelance fallback breaks the contract for logic-integrity-auditor.
Phase 1c: Independent Premise Derivation (parallel with 1a)
Spawn immediately when Phase 1a starts. Do not wait for X-ray. The whole point of this phase is that it derives without seeing what X-ray derived.
Spawn one teammate with subagent_type: senior-review:premise-auditor.
Prompt:
Mode 1: independent derivation.
Target scope: [contents of .team-review/00-scope.md]
Knowledge leads: .team-review/01a-review-knowledge-leads.md
Diff: {diff content}
Derive independently what is true about the concepts this diff touches.
Write .team-review/01b-independent-claims.md in the format your agent
definition prescribes.
You have NO access to .codebase-xray/ or to .team-review/02-interconnect.md.
Neither exists for you. Do not look for them, and report contamination if
anything in this prompt paraphrases an X-ray conclusion.
Wait for both 1a and 1c before starting Phase 1d. Mark phase_1c_premise_audit complete.
Under raw mode (--no-context) this phase does not run, because there is no shared derivation for it to be independent of.
Phase 1d: Knowledge Reconciliation (join)
Runs inline once both 1a and 1c have completed. The premise auditor never compares its own derivation: comparison is done by others, downstream, which is what makes its blindness verifiable rather than merely asserted.
Read .team-review/01a-review-knowledge-leads.md, $XRAY_RUN_DIR/knowledge/documentation-leads.md and .team-review/01b-independent-claims.md. Write:
Degradation when X-ray produced no leads. If $XRAY_RUN_DIR/knowledge/documentation-leads.md does not exist, record Inherited from X-Ray: not produced under that heading and suppress the asymmetry diagnostic described below for this run. An absent file is not a discovery gap, and treating it as one would report an X-ray gap on every row: a systematically false signal from the mechanism built to stop false signals. A reused older run, a Phase 0 that failed, and an X-ray version predating Phase 0 all land here. Everything else in this phase proceeds normally: Missing and Disputed are still computed from 01a and 01b.
Output: .team-review/01-knowledge-provenance.md
# Knowledge Provenance
> Derived view, produced after both discovery branches completed.
> The canonical artifact consumed downstream. 01a and 01b are its sources.
## Independently discovered by Senior Review
[rows from 01a-review-knowledge-leads.md]
## Inherited from X-Ray
[rows from $XRAY_RUN_DIR/knowledge/documentation-leads.md]
## Missing
| Concept | In scope because |
|---------|------------------|
| [concept] | [where it appears in the diff] |
## Disputed
| Claim | Independent derivation says | X-ray says |
|-------|------------------------------|------------|
| [claim] | [X at file:line] | [Y at file:line] |
Missing and Disputed are different states and must never collapse into one section. Absence of evidence is not contradictory evidence.
| Section |
Maps to in the interconnect map |
Never |
Missing |
a coverage gap, and unverified on any related row |
never disputed: nobody finding documentation is not two sources disagreeing |
Disputed |
disputed, both file:line sides cited |
never silently resolved in favour of either derivation |
Collapsing them would drain disputed of the precise meaning the rest of this work depends on, which is that two derivations reached incompatible conclusions and a reviewer must settle it.
The duty of autonomous rediscovery. X-ray's documentation leads are an input, never a completeness guarantee. Any concept 01a carried that X-ray's leads missed stays under Independently discovered by Senior Review; a concept neither branch found goes to Missing. Neither is downgraded because the other branch was silent. Without this duty, the completeness of X-ray's discovery becomes the next shared premise, which is the failure this pipeline exists to prevent.
Two asymmetries here are diagnostics worth reading, not noise. A row present in Independently discovered by Senior Review and absent from Inherited from X-Ray means X-ray's discovery had a gap. The reverse means Phase 0c had one. Both are recorded and neither is silently reconciled. Neither is reportable when X-ray produced no leads file at all: the degradation rule above governs that case.
Mark phase_1d_reconciliation complete.
Phase 1b: Semantic Interconnect Mapping
Spawn a single teammate with subagent_type: codebase-xray:semantic-interconnect-mapper.
Prompt:
Build the interconnect map for this review.
Target scope: [contents of .team-review/00-scope.md]
X-ray output: $XRAY_RUN_DIR (files: 01-structure.md, 02-interfaces.md, 05-risks.md, knowledge/documentation-leads.md, ...)
Independent claims: .team-review/01b-independent-claims.md
Knowledge provenance: .team-review/01-knowledge-provenance.md
Read $XRAY_RUN_DIR and the target files. Produce .team-review/02-interconnect.md
following the exact output format in your agent definition (Call Graph,
Contracts formal/structural/implicit, Invariants, Domain Rules, Assumptions,
Integration Hot-Spots, Change Impact Radius, Reviewer Hints).
Every claim must cite file:line. No recommendations, no fixes.
Compare the independent claims against your own derivation. Every
contradiction becomes a `disputed` row citing both sides. Do not resolve
contradictions and do not prefer your own derivation by default.
Wait for completion. Verify .team-review/02-interconnect.md exists and contains the required anchors (## Contracts, ## Invariants, ## Domain Rules, ## Assumptions, ## Integration Hot-Spots, ## Reviewer Hints). Empty sections are acceptable but the anchors must exist.
Mark phase_1b_interconnect complete.
Phase 2: Adversarial Review (parallel)
- The team forms implicitly when the first teammate is spawned (no
TeamCreate step; the team name is session-derived and any team_name passed to the Agent tool is ignored).
- For each selected dimension (always-on + detected conditional), use
Agent tool to spawn a teammate using the most specialized agent.
Dimension-to-agent mapping
| Dimension |
subagent_type |
| Security |
senior-review:security-auditor |
| Architecture (+ failure flows, patterns, scoring) |
senior-review:code-auditor |
| Logic integrity (contracts/invariants/domain rules) |
senior-review:logic-integrity-auditor |
| Structural entropy (duplicated knowledge, competing owners, redundant representation, derivable state, missed unification, prior art, abstraction fitness) |
abstraction-architect:abstraction-architect |
| Codebase hygiene (full pass: dead code, assets, deps, docs, lifecycle archaeology) |
senior-review:cleanup-auditor |
| Workspace hygiene (garbage, tracked build output, .gitignore, scratch, doc-assets, git state) |
repo-hygiene:workspace-auditor |
| UI race conditions |
senior-review:ui-race-auditor |
| React performance |
react-development:react-performance-optimizer |
| TypeScript type safety |
typescript-development:type-safety-auditor |
| General performance |
senior-review:code-auditor |
| Platform / runtime integration |
platform-engineering:platform-reviewer |
| Distributed flows |
senior-review:distributed-flow-auditor |
| Circular dependencies |
senior-review:chicken-egg-detector |
| Temporal resilience (failure-over-time) |
senior-review:temporal-resilience-auditor |
| Data integrity (persistence semantics) |
senior-review:data-integrity-auditor |
| Resource lifecycle (ownership and release) |
senior-review:resource-lifecycle-auditor |
| Testing quality |
testing:test-suite-auditor |
| API contracts |
senior-review:api-contract-auditor |
| Data migrations |
senior-review:data-integrity-auditor |
Reviewer prompt template (context-aware)
Every reviewer receives the same structural prompt. The key addition vs the old parallel-only mode is the context paths.
You are reviewing for the {dimension} dimension.
## Target
[Insert contents of .team-review/00-scope.md]
## Diff
{diff content}
## Context files (read these before analyzing code)
- X-ray output: $XRAY_RUN_DIR (see 01-structure.md, 02-interfaces.md, 05-risks.md)
- Interconnect map: .team-review/02-interconnect.md
- Knowledge provenance: .team-review/01-knowledge-provenance.md
### Epistemic status of the shared context
The shared context is NOT ground truth. It is an index of hypotheses produced by
one upstream observer.
- Claims marked `verified` may be reused directly.
- Claims marked `documented`, `unverified` or `disputed` are hypotheses. You MUST
independently re-derive any such claim before using it as the premise of a finding.
- Actively search for code paths, tests or documents that contradict the context.
Finding one is a result, not a failure.
- Silence in the context is not evidence of absence. A concern the map does not
mention may still be real; look anyway.
Per `## Reviewer Hints` in the interconnect map, focus your reading on these anchors:
{anchors-for-this-dimension from the map's Reviewer Hints section}
## Instructions
Follow your agent definition's analysis phases, knowledge-base loading, output format, and severity classification. Cite file:line for every finding.
## Premise declaration (required on every finding)
Every finding carries two extra fields:
- **Load-bearing premise:** the single proposition whose falsity collapses this
finding. It must be minimal, falsifiable and scoped.
Bad: "The implementation is broken."
Bad: "Heartbeat handling is incorrect." (a paraphrase of your finding)
Good: "No credential-bearing response path exists after registration."
- **premise_provenance:** one of `independent`, `shared-context`, `mixed`.
This records CAUSAL DEPENDENCE, not citation. If you absorbed the premise from
the X-ray output or the interconnect map, it is `shared-context`, even if
your finding never cites an anchor. `mixed` means part of the premise rests on
shared context and part on evidence you derived yourself. Declare `independent`
only when you re-derived the whole premise from code, tests or documents you
read yourself.
Write your output to .team-review/findings-{dimension}.md using the structured format your agent prescribes.
If --no-context was set, omit the "Context files" and "Reviewer Hints" sections and do NOT spawn the logic-integrity-auditor.
Structural entropy dimension addendum. abstraction-architect:abstraction-architect takes named inputs rather than a free-form dimension prompt. Append this block to its prompt:
mode: diff
codebase_path: {target root}
xray_path: {$XRAY_RUN_DIR when Phase 1a ran and produced output, otherwise "none"}
concept_index_path: {target root}/.abstraction-architect/concept-index.json
changed_files: {the same file list used to build the diff above}
report_path: .team-review/findings-abstraction.md
severity_floor: medium
Four things about this reviewer, because they invert the default reviewer contract:
- Its search space is the whole codebase, not the diff. The diff is only the anchor; the existing representation it is hunting for is by definition in files that did not change. Do not scope it to the changed files.
- It runs fine on
--depth=lite output, since it consumes only 01-structure.md and 02-interfaces.md. Do not force --deep on its account.
--no-context does NOT skip it (that rule removes only logic-integrity-auditor). It runs with xray_path: none and degrades to Glob plus Grep, reporting the reduced confidence in its Gaps section.
- It reads a concept index at
.abstraction-architect/concept-index.json when one exists, which is what makes its knowledge-track dimensions (duplicated domain knowledge, competing sources of truth, redundant representation, duplicated state) worth running on a diff. The index is produced by /abstraction-architect:audit in global mode. When it is absent or stale the reviewer degrades to diff-anchored discovery and declares the reduced coverage; it never blocks. This reviewer never writes the index.
Testing dimension addendum. testing:test-suite-auditor partly inverts the default reviewer contract. Append this to its prompt:
Scope: run D2 to D8 only on tests owned by the changed modules; keep D1/D9
statistics suite-wide for context. Do NOT run the full suite inside this
review (no-run semantics): reuse metrics from CI history or existing report
artifacts, and mark anything unmeasured as such. Findings in this command's
severity format. Write your output to .team-review/findings-testing.md.
Two notes on why: a review is diff-anchored, so a whole-suite execution would dominate the phase's wall clock for findings mostly outside the diff; and suite-wide inventory statistics still matter because parallel-file and cross-layer-duplicate findings are invisible when only the changed test file is read.
The workspace-hygiene dimension
This dimension is not a senior-review agent. Spawn one teammate with
subagent_type: repo-hygiene:workspace-auditor, which owns every check the
filesystem and git decide without reading a symbol.
You are auditing workspace hygiene for a team review of {target}.
Load the repo-hygiene:repo-hygiene skill and run its catalog at the FULL
profile: C1 filesystem garbage, C2 generated artifacts tracked in git,
C3 .gitignore completeness, C4 .gitignore archaeology, C5 scratch and
pipeline-output directories, C6 orphan doc-assets, C7 git auxiliary state.
Report only. Remove nothing, and never run a destructive git command: C7 is
detection-only because a dropped stash or a removed worktree leaves no diff
for any commit to revert.
Anything that needs source comprehension is not yours. Put it under "Not
mine" and name senior-review:cleanup-auditor. The two dimensions are disjoint
by construction, so a finding either of you could have raised means one of
you widened.
Write your output to .team-review/findings-workspace-hygiene.md.
Its perimeter and cleanup-auditor's do not overlap, so Phase 4 consolidation
has nothing to deduplicate between them. A finding appearing in both reports is
a boundary violation to investigate, not an echo to fold.
Spawn and task creation
name: {dimension}-reviewer (e.g., "security-reviewer", "logic-integrity-reviewe
…(truncated)
1---2name: team-review3description: Six-phase pipeline. Builds X-ray and interconnect context first, then runs specialized dimensions in parallel so cross-component logic bugs surface, not just local ones. TRIGGER WHEN: the user wants a multi-reviewer review of a whole codebase or a large change, or asks for the deepest review available.4---56> Arguments: `<target> [--reviewers auto|security,performance,...] [--base-branch main] [--all] [--deep] [--no-context] [--fast] [--rigorous]`. Wherever `<arguments>` appears below, substitute the text the user typed after the skill name.78# team-review910<!-- Generated by the Daodan compiler for codex. Edit the kernel, never this file. -->1112## Execution harness1314Selected topology: **parallel-subagents**, with role delivery by **inline-prompt**. Start one isolated15runtime subagent per dispatched worker. When role delivery is `inline-prompt`, paste that role's16Markdown body into the dispatch prompt verbatim: the worker must receive the whole role, not a17summary of it.1819Harness obligations, none of them optional:2021- Every dispatched worker runs in its own subagent context, and never reads another worker's22 result.23- Follow the dispatch plan below in phase order. A phase starts only after every phase it needs has24 closed, and a phase closes only when every worker it dispatched is recorded `delivered` or25 `failed`. A worker reports delivered or failed in its final message; there is no shared task26 list, so the coordinator keeps that record itself.27- Dispatch only roles from this set, and only as the plan says: `api-contract-auditor`, `chicken-egg-detector`, `cleanup-auditor`, `code-auditor`, `data-integrity-auditor`, `distributed-flow-auditor`, `logic-integrity-auditor`, `premise-auditor`, `resource-lifecycle-auditor`, `security-auditor`, `temporal-resilience-auditor`, `ui-race-auditor`28- Only the phase that declares the report artifact may write it.2930Dispatch plan:31321. `scope`: runs in the orchestrating context; produces `artifact:review-brief`.332. `context-building`: runs in the orchestrating context; needs `scope`; consumes `artifact:review-brief`; produces `artifact:context-map`.343. `dimension-detection`: runs in the orchestrating context; needs `context-building`; consumes `artifact:context-map`; produces `selection:reviewers`.354. `independent-review`: one worker per item of `selection:reviewers`, each bound to the role the selection names (any role this plugin declares), each in its own isolated context, in parallel where the host allows; barrier `all-delivered`; needs `dimension-detection`; consumes `artifact:review-brief`, `artifact:context-map`; produces `artifact:reviewer-result`.365. `delivery-accounting`: runs in the orchestrating context; needs `independent-review`; consumes `artifact:reviewer-result`; produces `artifact:delivery-ledger`.376. `initial-consolidation`: runs in the orchestrating context; needs `delivery-accounting`; consumes `artifact:reviewer-result`, `artifact:delivery-ledger`; produces `artifact:initial-findings`.387. `cross-examination`: `logic-integrity-auditor` and `premise-auditor`, once each, each in its own isolated context, in parallel where the host allows; barrier `all-delivered`; needs `initial-consolidation`; consumes `artifact:initial-findings`; produces `artifact:cross-examination`.398. `consolidation`: one `code-auditor` in an isolated context; needs `cross-examination`; consumes `artifact:initial-findings`, `artifact:cross-examination`, `artifact:delivery-ledger`; produces `artifact:final-report`.409. `report-delivery`: runs in the orchestrating context; needs `consolidation`; consumes `artifact:final-report`.4142Role bodies ship with this package under `roles/`, and the phase graph and record schemas under43`contracts/team-review.workflow.toml`.4445## Method4647## Execution requirements4849This workflow fans out over the dimensions its detection step selects. Dispatch, scheduling and result50collection belong to the host harness, generated from `contracts/team-review.workflow.toml`. What this51workflow requires of any harness is fixed, and none of it is optional:5253- every reviewer runs in its own context and never reads another reviewer's result54- exactly the selected dimensions are dispatched, once each55- every expected reviewer is recorded `delivered` or `failed` before anything is consolidated56- cross-examination runs after that barrier, in fresh contexts57- only the consolidation phase writes the final report5859If the host cannot run reviewers in isolated contexts, stop and say so. A review whose dimensions60shared a context is not the artifact this workflow claims to produce.6162# Team Review (Pipeline)6364Orchestrate a multi-dimensional code review as a **6-phase pipeline**:65660. **Phase 0 -- Scope and Discovery**: resolve the target (0), detect which dimensions the change warrants (0b), and discover independently what evidence this review needs (0c), reading no X-ray output at all.671. **Phase 1 -- Context Building**: X-ray analysis (1a) runs in parallel with a blind second derivation of the same premises (1c); the two are joined into `01-knowledge-provenance.md` (1d); an interconnect map is built last (1b), covering contracts, invariants, assumptions, domain rules and integration hot-spots. Output goes to `.team-review/`.682. **Phase 2 -- Adversarial Review (parallel)**: specialized reviewers read the context files and hunt for violations within their dimension. Every finding declares the load-bearing premise it stands on and where that premise came from. Each reviewer writes structured findings to `.team-review/findings-<dim>.md`.693. **Phase 3 -- Monitor and Collect**: every spawned reviewer delivers findings or an explicit no-findings report before consolidation starts.704. **Phase 4 -- Consolidation and Gates**: findings are deduplicated and organized by severity, with agreement weighted by premise provenance; then the verification panel runs (4b, Lens 0's premise veto first) and the completeness critic asks what the review missed (4c).715. **Phase 5 -- Report & Cleanup**.7273The pipeline lets reviewers find problems that are invisible from local-only inspection: broken implicit contracts, invariant drift, bypass paths to business rules, non-idempotent retry paths, terminal state mutations. Two derivations run side by side in Phase 1 so that the review has a second observer, rather than one observer consulted N times.7475**Raw mode**: pass `--no-context` to run the old parallel-only behavior (no Phase 0c, no context phase, no `logic-integrity-auditor`, no `premise-auditor` in either mode).7677## Skills to Load7879Before starting, invoke these skills to inform the review process:80- `senior-review:review-quality-gates` -- context-sharing pattern, adversarial verification panel, completeness critic81- `senior-review:defect-taxonomy` -- 140+ defect subcategories with CWE/OWASP mappings (includes `logic-integrity.md`)8283## Pre-flight Checks84851. Confirm the harness can dispatch isolated reviewers; stop if it cannot.862. Parse `<arguments>`:87 - `<target>`: file path, directory, git diff range (e.g., `main...HEAD`), or PR number (e.g., `#123`)88 - `--reviewers`: comma-separated dimensions OR `auto` (default: `auto`)89 - `--base-branch`: base branch for diff comparison (default: `main`)90 - `--all`: force all dimensions regardless of auto-detection91 - `--deep`: run Phase 1a `codebase-xray` in full mode (default: `--depth=lite`)92 - `--no-context`: skip Phase 0c and Phase 1 entirely and run reviewers with raw code only (raw mode; `logic-integrity-auditor` and `premise-auditor` are also skipped)93 - `--fast`: skip the verification + completeness-critic gate entirely (Phase 4b and 4c)94 - `--rigorous`: verify every finding above the confidence floor, ignoring the cost-guard cap953. Check for existing `.team-review/state.json`:96 - If present with `status: "in_progress"`: ask user whether to resume or start fresh (archive to `.team-review-<ISO-timestamp>/`).97 - If present with `status: "complete"`: ask whether to archive and start fresh.98 - If absent: proceed to new session.994. Initialize `.team-review/` with `state.json`:100101 ```json102 {103 "target": "<arguments>",104 "status": "in_progress",105 "flags": {106 "reviewers": "auto",107 "all": false,108 "deep": false,109 "no_context": false,110 "fast": false,111 "rigorous": false112 },113 "current_phase": 0,114 "phases": {115 "phase_0_resolution": "pending",116 "phase_0b_detection": "pending",117 "phase_0c_evidence_discovery": "pending",118 "phase_1c_premise_audit": "pending",119 "phase_1d_reconciliation": "pending",120 "phase_1a_xray": "pending",121 "phase_1b_interconnect": "pending",122 "phase_2_review": "pending",123 "phase_3_consolidation": "pending",124 "phase_4b_verification": "pending",125 "phase_4c_critic": "pending",126 "phase_4_report": "pending"127 },128 "files_created": [],129 "xray": {130 "run_id": null,131 "run_dir": null,132 "target": null,133 "depth": null134 },135 "started_at": "ISO_TIMESTAMP"136 }137 ```138139## Phase 0: Target Resolution1401411. Determine target type:142 - **File/Directory**: use as-is for review scope143 - **Git diff range**: `git diff {range} --name-only` to get changed files144 - **PR number**: `gh pr diff {number} --name-only` to get changed files1452. Collect the full diff content for later distribution to reviewers.1463. Collect the list of changed file paths and extensions for Phase 0b.1474. Write `.team-review/00-scope.md` with target, files, flags. Append a `## Pre-review work tree` section containing the output of `git status --porcelain` at this moment: the Phase 5 workspace hygiene check diffs against it. Mark phase complete in `state.json`.148149## Phase 0b: Context Detection (when `--reviewers auto` or omitted)150151Analyze changed files and codebase to determine which review dimensions are relevant. Skip if explicit `--reviewers` list was provided.152153### Always-on dimensions (run for every review)154155| Dimension | Agent | Rationale |156|-----------|-------|-----------|157| Security | `senior-review:security-auditor` | Every change can introduce vulnerabilities |158| Architecture | `senior-review:code-auditor` | Coupling, abstractions, failure flows, pattern consistency, scoring |159| **Logic integrity** | `senior-review:logic-integrity-auditor` | **Hunts violations of contracts/invariants/domain rules surfaced in Phase 1b** (skipped if `--no-context`) |160| Codebase hygiene | `senior-review:cleanup-auditor` | The **full** pass across all five dimensions that need source comprehension, over the whole codebase: dead code, orphan assets, phantom/unused deps plus barrel-file and eager-bundle bloat, stale documentation, and lifecycle archaeology. `/senior-review:code-review` and `/senior-review:pr-review` run only the lite subset (dead code, scoped to the diff), so this dimension is where the other four get covered at all |161| Workspace hygiene | `repo-hygiene:workspace-auditor` | Everything the filesystem and git decide without reading a symbol: filesystem garbage, generated artifacts tracked in VCS, `.gitignore` completeness and archaeology, scratch and pipeline-output directories, orphan doc-assets, git auxiliary state. Disjoint from the row above by construction, so the two never contest the same finding |162163### Conditional dimensions (auto-detected from context)164165Run these checks against the changed files and codebase to decide which extra reviewers to spawn.166167Five of these dimensions live in other plugins: React performance (`react-development`), platform / runtime integration (`platform-engineering`), structural entropy (`abstraction-architect`), testing quality (`testing`), and TypeScript type safety (`typescript-development`). All five are **hard dependencies** of `senior-review`, so the marketplace installs them with it and no dimension can go missing at runtime. A dimension is skipped only when its **signal did not match** the codebase, which is a statement about the code and never about the install. If a spawn fails with "Agent type not found", the install is broken: stop and report it rather than continuing with a silently reduced review.168169| Signal | Detection rule | Dimension activated | Agent |170|--------|---------------|---------------------|-------|171| **UI/frontend files** | Changed files include `.tsx`, `.jsx`, `.vue`, `.svelte`, `.component.ts`, or files containing scroll/focus/layout manipulation | UI race conditions | `senior-review:ui-race-auditor` |172| **React project** | `package.json` has `react` in dependencies AND changed files include `.tsx`/`.jsx` | React performance | `react-development:react-performance-optimizer` |173| **TypeScript project** | Changed files match `\.tsx?$` AND `tsconfig.json` exists at the project root | TypeScript type safety | `typescript-development:type-safety-auditor` |174| **Non-React frontend** | Frontend files detected but no React dependency | General performance | `senior-review:code-auditor` (performance dimension) |175| **Fullstack app** | 2+ signals: frontend framework in `package.json`, backend framework config, API route definitions, `docker-compose.yml` with multiple services, Tauri/Electron config | Platform / runtime integration | `platform-engineering:platform-reviewer` |176| **Multi-service / messaging** | Changed files touch API routes, message handlers, gRPC definitions, queue consumers/producers, or `docker-compose.yml` with multiple services | Distributed flows | `senior-review:distributed-flow-auditor` |177| **Init/startup code** | Changed files touch startup sequences, dependency injection, config bootstrap, migration runners, or service registration | Circular dependencies | `senior-review:chicken-egg-detector` |178| **Long-running / scheduled execution** | Diff or changed files touch timers, schedulers, polling loops, retry/reconnect logic, cron jobs, queue workers, background daemons, updaters, or watchdogs (see detection command 5b) | Temporal resilience (**what does the user see after this has been failing for a day?**) | `senior-review:temporal-resilience-auditor` |179| **Persistence code** | Diff or changed files touch schemas, models, ORM entities, repositories, raw SQL, cache layers, or transaction boundaries (see detection command 5c) | Data integrity (**can the store be made to hold an impossible state?**) | `senior-review:data-integrity-auditor` |180| **Resource acquisition** | Diff or changed files acquire files, sockets, connections, subprocesses, listeners, subscriptions, locks, tasks, or timers, especially in manual-resource languages (C/C++/Rust/Go) or async-heavy code (see detection command 5d) | Resource lifecycle (**does every acquire release on success, error, AND cancellation?**) | `senior-review:resource-lifecycle-auditor` |181| **Test files** | Changed files match `test_*`, `*_test.*`, `*.spec.*`, `*.test.*`, `conftest.py`, `__tests__/` | Testing quality | `testing:test-suite-auditor` |182| **API files** | Changed files touch a formal contract file (`*.proto`, `openapi*.y*ml`, `swagger*`, `*.graphql`, `asyncapi*`, JSON Schema), or route definitions, serializers, or DTO/model declarations | API contracts | `senior-review:api-contract-auditor` |183| **Migration files** | Changed files match database migration patterns (Alembic, Django, Rails, Prisma, SQL migrations) | Data migrations | `senior-review:data-integrity-auditor` (migration dimension) |184| **Diff target adding code** | Target resolved to a diff in Phase 0 (git range, PR number, or uncommitted changes) AND the diff adds at least one function, method, class, module, constant table, or block longer than roughly five lines. Never activated for plain file/directory targets: there is no diff to anchor on, and the whole-tree question belongs to `/abstraction-architect:audit` | Structural entropy (**does this diff add a second place where a concept the codebase already owns lives?** Seven dimensions over two evidence tracks, diff-anchored: duplicated domain knowledge, competing sources of truth, redundant representation, duplicated or derivable state, missed unification, prior art available, abstraction fitness) | `abstraction-architect:abstraction-architect` (mode `diff`) |185186### Detection implementation187188Run these bash commands to gather signals:189190```bash191# 1. Classify changed file extensions192echo "$CHANGED_FILES" | sed 's/.*\.//' | sort | uniq -c | sort -rn193194# 2. Check for React195cat package.json 2>/dev/null | grep -q '"react"' && echo "REACT=true"196197# 2b. Check for a TypeScript project198echo "$CHANGED_FILES" | grep -qE '\.tsx?$' && [ -f tsconfig.json ] && echo "TS_PROJECT=true"199200# 3. Check for fullstack signals (count matches)201FULLSTACK_SIGNALS=0202[ -f package.json ] && grep -qE '"(react|vue|svelte|angular|next|nuxt)"' package.json && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))203grep -rql 'fastapi\|django\|flask\|express\|nest\|hono\|actix\|axum' pyproject.toml Cargo.toml package.json 2>/dev/null && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))204ls -d */routes */api */endpoints 2>/dev/null && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))205[ -f docker-compose.yml ] && grep -c 'image:\|build:' docker-compose.yml | awk '$1>1{print "MULTI_SERVICE"}' && FULLSTACK_SIGNALS=$((FULLSTACK_SIGNALS+1))206207# 4. Check for multi-service / messaging patterns in diff208echo "$DIFF_CONTENT" | grep -qiE 'rabbitmq\|amqp\|kafka\|grpc\|pubsub\|queue\|celery\|dramatiq' && echo "MESSAGING=true"209echo "$CHANGED_FILES" | grep -qiE 'routes?\b|api/|endpoints?/|handlers?/' && echo "API_FILES=true"210# Formal contract files. Kept separate from API_FILES on purpose: a change to211# openapi.yaml or schema.graphql matches none of the path patterns above, and212# it is the single strongest signal for the api-contract-auditor dimension.213echo "$CHANGED_FILES" | grep -qiE '\.proto$|\.graphql$|\.gql$|openapi.*\.(ya?ml|json)$|swagger.*\.(ya?ml|json)$|asyncapi.*\.(ya?ml|json)$|schema.*\.json$' && echo "CONTRACT_FILES=true"214215# 5. Check for init/startup patterns in diff216echo "$DIFF_CONTENT" | grep -qiE 'def main\b|if __name__|app\.on_startup|@app\.on_event|lifespan|create_app|bootstrap|init_' && echo "STARTUP=true"217218# 5b. Check for long-running / scheduled execution patterns (temporal resilience)219echo "$DIFF_CONTENT" | grep -qiE 'setInterval|setTimeout|cron|schedule|\bretry|reconnect|backoff|watchdog|heartbeat|keepalive|\bpoll(ing)?\b|background.?(task|worker|job)|daemon|updater' && echo "TEMPORAL=true"220221# 5c. Check for persistence code (data integrity)222echo "$DIFF_CONTENT" | grep -qiE '\btransaction\b|\bcommit\b|rollback|UPDATE |INSERT |upsert|\bunique\b|constraint|ON CONFLICT|FOR UPDATE|select_for_update|session\.add|\.objects\.|prisma\.|typeorm|sqlalchemy|redis|cache\.(get|set|del)' && echo "PERSISTENCE=true"223224# 5d. Check for resource acquisition (resource lifecycle)225echo "$DIFF_CONTENT" | grep -qiE 'open\(|createReadStream|createWriteStream|\bsocket\b|getConnection|acquire|addEventListener|subscribe\(|\block\b|mutex|semaphore|new Worker|subprocess|Popen|spawn\(|go func|tokio::spawn|asyncio\.create_task|createObjectURL' && echo "RESOURCES=true"226227# 6. Check for test and migration files228echo "$CHANGED_FILES" | grep -qiE 'test_|_test\.|\.spec\.|\.test\.|conftest|__tests__' && echo "TEST_FILES=true"229echo "$CHANGED_FILES" | grep -qiE 'migrat|alembic|versions/' && echo "MIGRATION_FILES=true"230```231232### Display detected dimensions233234After detection, display the plan:235236```237Context detection complete:238 - Always: security, architecture, logic-integrity, codebase-hygiene, workspace-hygiene239 - Detected: ui-races (6 .tsx files), react-perf (React project), ts-safety (TypeScript project), distributed-flows (API routes + RabbitMQ), temporal-resilience (retry + scheduler code), data-integrity (ORM writes + transactions), abstraction (diff adds 4 units)240 - Skipped: platform (not fullstack), chicken-egg (no startup code)241242Pipeline plan:243 Phase 0c: review evidence discovery (inline)244 Phase 1a: codebase-xray (--depth=lite) | Phase 1c: premise-auditor (parallel, blind)245 Phase 1d: knowledge reconciliation (inline)246 Phase 1b: codebase-xray:semantic-interconnect-mapper247 Phase 2: {N} reviewers in parallel248 Phase 3: consolidation249 Phase 4: report250```251252Every reason on the Skipped line is a statement about the code, never about the install: "not fullstack" means the code did not need the dimension. Every agent this command can spawn comes from a plugin `senior-review` declares as a hard dependency, so there is no "plugin not installed" reason and no generic fallback. If a spawn fails with "Agent type not found", stop and report the broken install instead of continuing with a silently reduced review.253254Mark `phase_0b_detection` complete in `state.json`.255256## Phase 0c: Review Evidence Discovery257258Runs inline in the orchestrating context, on every invocation **except** raw mode (`--no-context`). That flag means "give me the raw mode", and a normally-on phase does not override it: `01a-review-knowledge-leads.md` distributed to N reviewers is itself shared context, so keeping this phase alive under the flag would make findings legitimately `shared-context`, let Lens 0 fire, and stop the mode reproducing the pre-pipeline behaviour it exists to provide.259260This phase owns discovery of **what evidence is relevant to this review**. X-ray owns discovery of how the repository documents itself. The two are different jobs and the division is deliberate.261262**This phase MUST NOT read `.codebase-xray/` in any form**, including the mirror and the output of previous runs. A previous X-ray run is still an X-ray derivation, and admitting one would contaminate the single artifact that has to be demonstrably independent of X-ray. X-ray's leads enter at the Phase 1d join and nowhere earlier.2632641. Read `CLAUDE.md`, `AGENTS.md` and equivalent project instruction files, and follow any navigation rule they state. If the project says a specific file is where to look first to find where a concept lives, open that file before opening any code. Discover the conventions from the repository itself, never from a prior X-ray run.2652. Extract the concepts, domains and symbols the diff touches. Names of changed functions, classes, modules and config keys are the starting set; add the domain nouns that appear in the diff's own strings and comments.2663. For each concept, search the project's indexes and documentation for a relevant entry, and search the tests for behaviour that encodes it.2674. Write `.team-review/01a-review-knowledge-leads.md`.268269**This file is immutable once written.** No later phase appends to it. X-ray's own leads are joined into a separate derived artifact in Phase 1d, precisely so that the snapshot Phase 1c consumes cannot change underneath it.270271**Output:** `.team-review/01a-review-knowledge-leads.md`272273```markdown274# Review Knowledge Leads275276> Leads, not truth. Immutable once written.277> Discovered by senior-review independently of any X-ray output.278279## Navigation rules followed280| Source | Rule |281|--------|------|282283## Concepts touched by this diff284| Concept | Where it appears in the diff |285|---------|------------------------------|286287## Leads288| Concept | Document / test | Anchor | Status |289|---------|-----------------|--------|--------|290291## Concepts with no lead found292[One line each. This list is the honest statement of what nobody documented.]293```294295Mark `phase_0c_evidence_discovery` complete in `state.json`.296297## Phase 1: Context Building298299The sub-phases below are listed in **execution order**, not in label order: 1a and 1c start together, 1d joins them, 1b runs last on the joined result. Nothing named here is missing.300301Skip this phase entirely if `--no-context` was passed. Mark `phase_1a_xray`, `phase_1c_premise_audit`, `phase_1d_reconciliation`, `phase_1b_interconnect`, and `phase_0c_evidence_discovery` as `skipped` in `state.json`. Jump to Phase 2 with raw target files only.302303### Phase 1a: X-Ray Analysis304305> **`codebase-xray:analyze` is a workflow of the `codebase-xray` plugin, not an agent.** Nothing dispatches it as a worker: it runs in this context, the way a user would invoke it, with its arguments. The host lists it under the `codebase-xray` plugin as `analyze` (a host that renders workflows as skills suffixes it `-workflow`). The `codebase-xray:xray-method` skill is the method that workflow applies; loading the method alone runs no phase and creates no run directory. The distinction matters because the rest of this command (Phase 1b, Phase 2) dispatches many `plugin:name` workers and the same shape names workflows and skills; treat Phase 1a as running a workflow, full stop.3063071. Run the `codebase-xray:analyze` workflow against the target, in this context:308 - Default mode: `--depth=lite` (structure + interfaces + risks only)309 - If `--deep` flag: full analysis310 - Target scope: the files from Phase 03112. Read `.codebase-xray/runs.json` to resolve the run the workflow just created, and record it in `state.json -> xray` as `run_id`, `run_dir`, `target` and `depth`. Every later phase derives its paths from this block and never from the `.codebase-xray/` root. `$XRAY_RUN_DIR` below always means `state.json -> xray.run_dir`. If the run cannot be resolved, halt: an unresolvable provenance is a broken pipeline, not a reason to fall back to the mirror.3123. Verify on completion that at minimum `01-structure.md`, `02-interfaces.md`, and `05-risks.md` exist.3134. Mark `phase_1a_xray` complete.314315If the workflow is unavailable (plugin not installed) or produces no output, halt the pipeline and report the error. Do **not** fall back to spawning a `general-purpose` agent to fake the X-ray output -- the file naming and section anchors that Phase 1b/Phase 2 depend on come from the workflow itself, and a freelance fallback breaks the contract for `logic-integrity-auditor`.316317### Phase 1c: Independent Premise Derivation (parallel with 1a)318319Spawn immediately when Phase 1a starts. Do not wait for X-ray. The whole point of this phase is that it derives without seeing what X-ray derived.3203211. Spawn one teammate with `subagent_type: senior-review:premise-auditor`.3222. Prompt:323324 ```325 Mode 1: independent derivation.326327 Target scope: [contents of .team-review/00-scope.md]328 Knowledge leads: .team-review/01a-review-knowledge-leads.md329 Diff: {diff content}330331 Derive independently what is true about the concepts this diff touches.332 Write .team-review/01b-independent-claims.md in the format your agent333 definition prescribes.334335 You have NO access to .codebase-xray/ or to .team-review/02-interconnect.md.336 Neither exists for you. Do not look for them, and report contamination if337 anything in this prompt paraphrases an X-ray conclusion.338 ```3393403. Wait for both 1a and 1c before starting Phase 1d. Mark `phase_1c_premise_audit` complete.341342Under raw mode (`--no-context`) this phase does not run, because there is no shared derivation for it to be independent of.343344### Phase 1d: Knowledge Reconciliation (join)345346Runs inline once both 1a and 1c have completed. The premise auditor never compares its own derivation: comparison is done by others, downstream, which is what makes its blindness verifiable rather than merely asserted.347348Read `.team-review/01a-review-knowledge-leads.md`, `$XRAY_RUN_DIR/knowledge/documentation-leads.md` and `.team-review/01b-independent-claims.md`. Write:349350**Degradation when X-ray produced no leads.** If `$XRAY_RUN_DIR/knowledge/documentation-leads.md` does not exist, record `Inherited from X-Ray: not produced` under that heading and **suppress the asymmetry diagnostic** described below for this run. An absent file is not a discovery gap, and treating it as one would report an X-ray gap on every row: a systematically false signal from the mechanism built to stop false signals. A reused older run, a Phase 0 that failed, and an X-ray version predating Phase 0 all land here. Everything else in this phase proceeds normally: `Missing` and `Disputed` are still computed from `01a` and `01b`.351352**Output:** `.team-review/01-knowledge-provenance.md`353354```markdown355# Knowledge Provenance356357> Derived view, produced after both discovery branches completed.358> The canonical artifact consumed downstream. 01a and 01b are its sources.359360## Independently discovered by Senior Review361[rows from 01a-review-knowledge-leads.md]362363## Inherited from X-Ray364[rows from $XRAY_RUN_DIR/knowledge/documentation-leads.md]365366## Missing367| Concept | In scope because |368|---------|------------------|369| [concept] | [where it appears in the diff] |370371## Disputed372| Claim | Independent derivation says | X-ray says |373|-------|------------------------------|------------|374| [claim] | [X at file:line] | [Y at file:line] |375```376377**Missing and Disputed are different states and must never collapse into one section.** Absence of evidence is not contradictory evidence.378379| Section | Maps to in the interconnect map | Never |380|---|---|---|381| `Missing` | a coverage gap, and `unverified` on any related row | never `disputed`: nobody finding documentation is not two sources disagreeing |382| `Disputed` | `disputed`, both `file:line` sides cited | never silently resolved in favour of either derivation |383384Collapsing them would drain `disputed` of the precise meaning the rest of this work depends on, which is that two derivations reached incompatible conclusions and a reviewer must settle it.385386**The duty of autonomous rediscovery.** X-ray's documentation leads are an input, never a completeness guarantee. Any concept `01a` carried that X-ray's leads missed stays under `Independently discovered by Senior Review`; a concept neither branch found goes to `Missing`. Neither is downgraded because the other branch was silent. Without this duty, the completeness of X-ray's discovery becomes the next shared premise, which is the failure this pipeline exists to prevent.387388Two asymmetries here are diagnostics worth reading, not noise. A row present in `Independently discovered by Senior Review` and absent from `Inherited from X-Ray` means X-ray's discovery had a gap. The reverse means Phase 0c had one. Both are recorded and neither is silently reconciled. Neither is reportable when X-ray produced no leads file at all: the degradation rule above governs that case.389390Mark `phase_1d_reconciliation` complete.391392### Phase 1b: Semantic Interconnect Mapping3933941. Spawn a single teammate with `subagent_type: codebase-xray:semantic-interconnect-mapper`.3952. Prompt:396397 ```398 Build the interconnect map for this review.399400 Target scope: [contents of .team-review/00-scope.md]401 X-ray output: $XRAY_RUN_DIR (files: 01-structure.md, 02-interfaces.md, 05-risks.md, knowledge/documentation-leads.md, ...)402 Independent claims: .team-review/01b-independent-claims.md403 Knowledge provenance: .team-review/01-knowledge-provenance.md404405 Read $XRAY_RUN_DIR and the target files. Produce .team-review/02-interconnect.md406 following the exact output format in your agent definition (Call Graph,407 Contracts formal/structural/implicit, Invariants, Domain Rules, Assumptions,408 Integration Hot-Spots, Change Impact Radius, Reviewer Hints).409410 Every claim must cite file:line. No recommendations, no fixes.411412 Compare the independent claims against your own derivation. Every413 contradiction becomes a `disputed` row citing both sides. Do not resolve414 contradictions and do not prefer your own derivation by default.415 ```4164173. Wait for completion. Verify `.team-review/02-interconnect.md` exists and contains the required anchors (`## Contracts`, `## Invariants`, `## Domain Rules`, `## Assumptions`, `## Integration Hot-Spots`, `## Reviewer Hints`). Empty sections are acceptable but the anchors must exist.4184. Mark `phase_1b_interconnect` complete.419420## Phase 2: Adversarial Review (parallel)4214221. The team forms implicitly when the first teammate is spawned (no `TeamCreate` step; the team name is session-derived and any `team_name` passed to the `Agent` tool is ignored).4232. For each selected dimension (always-on + detected conditional), use `Agent` tool to spawn a teammate using the **most specialized agent**.424425### Dimension-to-agent mapping426427| Dimension | subagent_type |428|-----------|---------------|429| Security | `senior-review:security-auditor` |430| Architecture (+ failure flows, patterns, scoring) | `senior-review:code-auditor` |431| **Logic integrity (contracts/invariants/domain rules)** | `senior-review:logic-integrity-auditor` |432| **Structural entropy (duplicated knowledge, competing owners, redundant representation, derivable state, missed unification, prior art, abstraction fitness)** | `abstraction-architect:abstraction-architect` |433| Codebase hygiene (full pass: dead code, assets, deps, docs, lifecycle archaeology) | `senior-review:cleanup-auditor` |434| Workspace hygiene (garbage, tracked build output, .gitignore, scratch, doc-assets, git state) | `repo-hygiene:workspace-auditor` |435| UI race conditions | `senior-review:ui-race-auditor` |436| React performance | `react-development:react-performance-optimizer` |437| TypeScript type safety | `typescript-development:type-safety-auditor` |438| General performance | `senior-review:code-auditor` |439| Platform / runtime integration | `platform-engineering:platform-reviewer` |440| Distributed flows | `senior-review:distributed-flow-auditor` |441| Circular dependencies | `senior-review:chicken-egg-detector` |442| Temporal resilience (failure-over-time) | `senior-review:temporal-resilience-auditor` |443| Data integrity (persistence semantics) | `senior-review:data-integrity-auditor` |444| Resource lifecycle (ownership and release) | `senior-review:resource-lifecycle-auditor` |445| Testing quality | `testing:test-suite-auditor` |446| API contracts | `senior-review:api-contract-auditor` |447| Data migrations | `senior-review:data-integrity-auditor` |448449### Reviewer prompt template (context-aware)450451Every reviewer receives the same structural prompt. The key addition vs the old parallel-only mode is the **context paths**.452453```454You are reviewing for the {dimension} dimension.455456## Target457[Insert contents of .team-review/00-scope.md]458459## Diff460{diff content}461462## Context files (read these before analyzing code)463- X-ray output: $XRAY_RUN_DIR (see 01-structure.md, 02-interfaces.md, 05-risks.md)464- Interconnect map: .team-review/02-interconnect.md465- Knowledge provenance: .team-review/01-knowledge-provenance.md466467### Epistemic status of the shared context468469The shared context is NOT ground truth. It is an index of hypotheses produced by470one upstream observer.471472- Claims marked `verified` may be reused directly.473- Claims marked `documented`, `unverified` or `disputed` are hypotheses. You MUST474 independently re-derive any such claim before using it as the premise of a finding.475- Actively search for code paths, tests or documents that contradict the context.476 Finding one is a result, not a failure.477- Silence in the context is not evidence of absence. A concern the map does not478 mention may still be real; look anyway.479480Per `## Reviewer Hints` in the interconnect map, focus your reading on these anchors:481{anchors-for-this-dimension from the map's Reviewer Hints section}482483## Instructions484Follow your agent definition's analysis phases, knowledge-base loading, output format, and severity classification. Cite file:line for every finding.485486## Premise declaration (required on every finding)487488Every finding carries two extra fields:489490- **Load-bearing premise:** the single proposition whose falsity collapses this491 finding. It must be minimal, falsifiable and scoped.492 Bad: "The implementation is broken."493 Bad: "Heartbeat handling is incorrect." (a paraphrase of your finding)494 Good: "No credential-bearing response path exists after registration."495- **premise_provenance:** one of `independent`, `shared-context`, `mixed`.496 This records CAUSAL DEPENDENCE, not citation. If you absorbed the premise from497 the X-ray output or the interconnect map, it is `shared-context`, even if498 your finding never cites an anchor. `mixed` means part of the premise rests on499 shared context and part on evidence you derived yourself. Declare `independent`500 only when you re-derived the whole premise from code, tests or documents you501 read yourself.502503Write your output to .team-review/findings-{dimension}.md using the structured format your agent prescribes.504```505506If `--no-context` was set, omit the "Context files" and "Reviewer Hints" sections and do NOT spawn the `logic-integrity-auditor`.507508**Structural entropy dimension addendum.** `abstraction-architect:abstraction-architect` takes named inputs rather than a free-form dimension prompt. Append this block to its prompt:509510```511mode: diff512codebase_path: {target root}513xray_path: {$XRAY_RUN_DIR when Phase 1a ran and produced output, otherwise "none"}514concept_index_path: {target root}/.abstraction-architect/concept-index.json515changed_files: {the same file list used to build the diff above}516report_path: .team-review/findings-abstraction.md517severity_floor: medium518```519520Four things about this reviewer, because they invert the default reviewer contract:521522- Its search space is the **whole codebase**, not the diff. The diff is only the anchor; the existing representation it is hunting for is by definition in files that did not change. Do not scope it to the changed files.523- It runs fine on `--depth=lite` output, since it consumes only `01-structure.md` and `02-interfaces.md`. Do not force `--deep` on its account.524- `--no-context` does NOT skip it (that rule removes only `logic-integrity-auditor`). It runs with `xray_path: none` and degrades to Glob plus Grep, reporting the reduced confidence in its Gaps section.525- It reads a **concept index** at `.abstraction-architect/concept-index.json` when one exists, which is what makes its knowledge-track dimensions (duplicated domain knowledge, competing sources of truth, redundant representation, duplicated state) worth running on a diff. The index is produced by `/abstraction-architect:audit` in global mode. When it is absent or stale the reviewer degrades to diff-anchored discovery and declares the reduced coverage; it never blocks. This reviewer never writes the index.526527**Testing dimension addendum.** `testing:test-suite-auditor` partly inverts the default reviewer contract. Append this to its prompt:528529```530Scope: run D2 to D8 only on tests owned by the changed modules; keep D1/D9531statistics suite-wide for context. Do NOT run the full suite inside this532review (no-run semantics): reuse metrics from CI history or existing report533artifacts, and mark anything unmeasured as such. Findings in this command's534severity format. Write your output to .team-review/findings-testing.md.535```536537Two notes on why: a review is diff-anchored, so a whole-suite execution would dominate the phase's wall clock for findings mostly outside the diff; and suite-wide inventory statistics still matter because parallel-file and cross-layer-duplicate findings are invisible when only the changed test file is read.538539### The workspace-hygiene dimension540541This dimension is not a `senior-review` agent. Spawn one teammate with542`subagent_type: repo-hygiene:workspace-auditor`, which owns every check the543filesystem and git decide without reading a symbol.544545```546You are auditing workspace hygiene for a team review of {target}.547548Load the repo-hygiene:repo-hygiene skill and run its catalog at the FULL549profile: C1 filesystem garbage, C2 generated artifacts tracked in git,550C3 .gitignore completeness, C4 .gitignore archaeology, C5 scratch and551pipeline-output directories, C6 orphan doc-assets, C7 git auxiliary state.552553Report only. Remove nothing, and never run a destructive git command: C7 is554detection-only because a dropped stash or a removed worktree leaves no diff555for any commit to revert.556557Anything that needs source comprehension is not yours. Put it under "Not558mine" and name senior-review:cleanup-auditor. The two dimensions are disjoint559by construction, so a finding either of you could have raised means one of560you widened.561562Write your output to .team-review/findings-workspace-hygiene.md.563```564565Its perimeter and `cleanup-auditor`'s do not overlap, so Phase 4 consolidation566has nothing to deduplicate between them. A finding appearing in both reports is567a boundary violation to investigate, not an `echo` to fold.568569### Spawn and task creation570571- `name`: `{dimension}-reviewer` (e.g., "security-reviewer", "logic-integrity-reviewe572573…(truncated)