@gtrabanco/pi-agentic-workflow 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +154 -0
  3. package/README.md +148 -0
  4. package/dist/config/defaults.d.ts +8 -0
  5. package/dist/config/defaults.js +11 -0
  6. package/dist/config/load.d.ts +19 -0
  7. package/dist/config/load.js +76 -0
  8. package/dist/config/merge.d.ts +4 -0
  9. package/dist/config/merge.js +43 -0
  10. package/dist/config/schema.d.ts +21 -0
  11. package/dist/config/schema.js +144 -0
  12. package/dist/config/types.d.ts +53 -0
  13. package/dist/config/types.js +12 -0
  14. package/dist/extension/factory.d.ts +47 -0
  15. package/dist/extension/factory.js +49 -0
  16. package/dist/extension/index.d.ts +4 -0
  17. package/dist/extension/index.js +84 -0
  18. package/dist/routing/catalogue.d.ts +35 -0
  19. package/dist/routing/catalogue.js +79 -0
  20. package/dist/routing/dispatch.d.ts +34 -0
  21. package/dist/routing/dispatch.js +191 -0
  22. package/dist/routing/state.d.ts +13 -0
  23. package/dist/routing/state.js +65 -0
  24. package/dist/routing/types.d.ts +90 -0
  25. package/dist/routing/types.js +3 -0
  26. package/dist/settings/console.d.ts +55 -0
  27. package/dist/settings/console.js +266 -0
  28. package/dist/settings/store.d.ts +3 -0
  29. package/dist/settings/store.js +24 -0
  30. package/dist/settings/view.d.ts +11 -0
  31. package/dist/settings/view.js +46 -0
  32. package/package.json +59 -0
  33. package/skills/audit-docs/SKILL.md +171 -0
  34. package/skills/audit-pr/SKILL.md +201 -0
  35. package/skills/audit-pr/references/01_MERGE_GATES.md +24 -0
  36. package/skills/audit-pr/references/02_CLOSURE_AND_SCOPE_GATES.md +83 -0
  37. package/skills/audit-pr/references/03_AUDIT_PROCESS.md +69 -0
  38. package/skills/audit-pr/references/04_VERDICT.md +69 -0
  39. package/skills/audit-pr/references/05_ROUTING_AND_GUARDRAILS.md +58 -0
  40. package/skills/audit-pr/references/PORTABILITY.md +17 -0
  41. package/skills/design-feature/SKILL.md +162 -0
  42. package/skills/design-feature/references/INTERVIEW.md +52 -0
  43. package/skills/design-feature/references/PORTABILITY.md +15 -0
  44. package/skills/design-feature/references/UPSERT_EXAMPLE.md +8 -0
  45. package/skills/design-feature/references/WRITE_AND_UPSERT.md +92 -0
  46. package/skills/discover-repository-state/SKILL.md +83 -0
  47. package/skills/execute-phase/SKILL.md +115 -0
  48. package/skills/execute-phase/references/BATCH_AND_PORTABILITY.md +54 -0
  49. package/skills/execute-phase/references/CLOSEOUT.md +74 -0
  50. package/skills/execute-phase/references/DESCOPE.md +35 -0
  51. package/skills/execute-phase/references/EXECUTION_CONTRACT.md +147 -0
  52. package/skills/execute-phase/references/FOLDING.md +73 -0
  53. package/skills/execute-phase/references/FORGE_BODY.md +24 -0
  54. package/skills/execute-phase/references/HANDOFF.md +21 -0
  55. package/skills/execute-phase/references/OPPORTUNISTIC_FINDING.md +45 -0
  56. package/skills/execute-phase/references/PREFLIGHT.md +152 -0
  57. package/skills/execute-phase/references/UNIT_LOOP.md +88 -0
  58. package/skills/execute-phase/references/WORKFLOWS_FEATURE.md +37 -0
  59. package/skills/execute-phase/references/WORKFLOWS_FIX.md +43 -0
  60. package/skills/execute-phase/references/WORKFLOWS_LEGACY.md +26 -0
  61. package/skills/execute-phase/references/WORKFLOWS_SMALL_PHASED.md +38 -0
  62. package/skills/fold-findings/SKILL.md +141 -0
  63. package/skills/fold-findings/references/FOLD_POLICY.md +43 -0
  64. package/skills/fold-findings/references/FOLD_PROCESS.md +41 -0
  65. package/skills/generate-docs/SKILL.md +145 -0
  66. package/skills/generate-docs/references/ADAPTERS.md +15 -0
  67. package/skills/generate-docs/references/ADAPTER_DISCOVERY.md +33 -0
  68. package/skills/generate-docs/references/GENERATION_PROCESS.md +90 -0
  69. package/skills/init-workspace/SKILL.md +152 -0
  70. package/skills/init-workspace/references/BOOTSTRAP_DISCOVERY.md +70 -0
  71. package/skills/init-workspace/references/BOOTSTRAP_WRITE.md +58 -0
  72. package/skills/init-workspace/references/PORTABILITY.md +16 -0
  73. package/skills/init-workspace/references/UPGRADE.md +83 -0
  74. package/skills/log-session/SKILL.md +159 -0
  75. package/skills/loop-review-fold/SKILL.md +168 -0
  76. package/skills/orchestration-envelope/SKILL.md +81 -0
  77. package/skills/orchestration-envelope/references/TURN_CONTRACT.md +21 -0
  78. package/skills/phase-contract/SKILL.md +82 -0
  79. package/skills/plan-feature/SKILL.md +179 -0
  80. package/skills/plan-feature/references/ROUTING.md +83 -0
  81. package/skills/plan-feature-from-issue/SKILL.md +140 -0
  82. package/skills/plan-feature-scaffold/SKILL.md +93 -0
  83. package/skills/plan-feature-scaffold/references/SCAFFOLD_PROCESS.md +76 -0
  84. package/skills/plan-fix/SKILL.md +115 -0
  85. package/skills/plan-fix/references/PLANNING_PROCESS.md +118 -0
  86. package/skills/plan-fix/references/SPEC_CONTRACT.md +22 -0
  87. package/skills/planning-preflight/SKILL.md +130 -0
  88. package/skills/product-audit/SKILL.md +225 -0
  89. package/skills/product-audit/references/AUDIT_DIMENSIONS.md +24 -0
  90. package/skills/product-audit/references/AUDIT_PROCESS.md +85 -0
  91. package/skills/resolve-repository-state/SKILL.md +79 -0
  92. package/skills/review-a11y/SKILL.md +60 -0
  93. package/skills/review-brand/SKILL.md +65 -0
  94. package/skills/review-change/SKILL.md +156 -0
  95. package/skills/review-change/references/ADVERSARIAL_RECOMMENDATION.md +31 -0
  96. package/skills/review-change/references/ADVERSARIAL_SETUP.md +86 -0
  97. package/skills/review-change/references/ADVERSARIAL_SYNTHESIS.md +53 -0
  98. package/skills/review-change/references/OUTPUT_AND_GUARDRAILS.md +85 -0
  99. package/skills/review-change/references/PERSIST_AND_DECIDE.md +151 -0
  100. package/skills/review-change/references/PORTABILITY.md +74 -0
  101. package/skills/review-change/references/REVIEW_PROCESS.md +86 -0
  102. package/skills/review-code/SKILL.md +69 -0
  103. package/skills/review-debt/SKILL.md +72 -0
  104. package/skills/review-design/SKILL.md +60 -0
  105. package/skills/review-implementation/SKILL.md +108 -0
  106. package/skills/review-implementation/references/CLASSIFY.md +96 -0
  107. package/skills/review-implementation/references/FIND.md +35 -0
  108. package/skills/review-perf/SKILL.md +79 -0
  109. package/skills/review-security/SKILL.md +65 -0
  110. package/skills/review-seo/SKILL.md +65 -0
  111. package/skills/review-verify/SKILL.md +66 -0
  112. package/skills/ship-roadmap/SKILL.md +120 -0
  113. package/skills/ship-roadmap/references/ADVANCE.md +90 -0
  114. package/skills/ship-roadmap/references/AUDIT_AND_MERGE.md +64 -0
  115. package/skills/ship-roadmap/references/CLOSEOUT_AND_LOG.md +26 -0
  116. package/skills/ship-roadmap/references/FOUNDING.md +101 -0
  117. package/skills/ship-roadmap/references/GUARDRAILS.md +56 -0
  118. package/skills/ship-roadmap/references/MODEL_ROUTING.md +14 -0
  119. package/skills/ship-roadmap/references/PORTABILITY.md +34 -0
  120. package/skills/ship-roadmap/references/RECOVERY_AND_SELECTION.md +93 -0
  121. package/skills/ship-roadmap/references/STOP_CONDITIONS.md +9 -0
  122. package/skills/ship-roadmap/references/TERMINAL_REPORT.md +34 -0
  123. package/skills/triage-issue/SKILL.md +148 -0
  124. package/skills/triage-issue/references/AUDIT_FINDINGS.md +35 -0
  125. package/skills/triage-issue/references/FOLD_LEDGER.md +32 -0
  126. package/skills/triage-issue/references/ISSUE_PROCESS.md +101 -0
  127. package/skills/triage-issue/references/LABELS.md +83 -0
  128. package/skills/triage-issue/references/REVIEW_FINDING_PROCESS.md +41 -0
  129. package/skills/verification-contract/SKILL.md +77 -0
  130. package/skills/workflow-status/SKILL.md +143 -0
  131. package/skills/workflow-status/references/CRASH_RECOVERY.md +66 -0
  132. package/skills/workflow-status/references/ENVELOPE_CORE.md +107 -0
  133. package/skills/workflow-status/references/ENVELOPE_FIELDS.md +77 -0
  134. package/skills/workflow-status/references/GUARDRAILS.md +17 -0
  135. package/skills/workflow-status/references/PORTABILITY.md +14 -0
  136. package/skills/workflow-status/references/SENSOR_CORE.md +95 -0
  137. package/skills/workflow-status/references/SENSOR_SIGNALS.md +128 -0
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: review-change
3
+ user-invocable: true
4
+ version: 2.11.5
5
+ argument-hint: <path-or-glob> [--adversarial N] [--synthesize]
6
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
7
+ license: MIT
8
+ description: >
9
+ Review a change with only applicable internal axes, classify every finding,
10
+ persist fix-now work, and return one evidence-backed decision. Findings only;
11
+ --adversarial N uses isolated reviewers; --synthesize fuses supplied reviewer
12
+ tables. Triggers: "review-change", "review this change", "adversarial review".
13
+ ---
14
+
15
+ # Review Change
16
+
17
+ Quality gate: run every applicable review and skip the rest, then synthesize and
18
+ classify one report. **Findings only; never edit or refactor.**
19
+
20
+ ## Turn contract
21
+
22
+ Load and verify the **canonical** [Turn contract](.claude/skills/orchestration-envelope/references/TURN_CONTRACT.md) (11 boxes) before ending every turn. Skill-specific additions (receipt closeout, isolation rule, applicability) live here and in [REVIEW_PROCESS.md](references/REVIEW_PROCESS.md). Missing reference → STOP.
23
+
24
+ For a final PR review, the turn is incomplete until this additional box passes:
25
+
26
+ ```text
27
+ ✓ Decision: REVIEW-PASS + PR exists → `gh pr comment <N> --body-file <path>` RUN;
28
+ then `gh pr view <N> --json comments` RUN and the newest exact-HEAD
29
+ `review-change:pass` marker is confirmed before printing `→ Next:`
30
+ ```
31
+
32
+ The receipt closeout is a precondition of the report, not a follow-up: do not
33
+ print the fixed report block until the comment is current. A clean report
34
+ without that current receipt must not recommend `/audit-pr`.
35
+
36
+ For `REVIEW-FAIL` or `NEEDS-DECISION`, list every open finding ID in the closing
37
+ recommendation, joined with ` + `; the review must never hand off only the first
38
+ finding.
39
+
40
+ Consume the internal [verification contract](<../verification-contract/SKILL.md>);
41
+ the reviewer checks the same frozen `ACCEPTANCE.md` blob as the executor before
42
+ mapping candidate evidence.
43
+
44
+ ## When to use
45
+
46
+ - **Mandatory before every merge.** Review in a context that did not implement
47
+ the change; if it did, stop and hand off to a fresh one. `execute-phase` may
48
+ also recommend optional checkpoints at layer boundary, accumulation or
49
+ sensitivity (`#77`).
50
+ - Use when you need applicable reviews without irrelevant passes.
51
+
52
+ ## Scope
53
+
54
+ Default target is the **current change** (branch diff vs the default branch);
55
+ accept a path/glob to widen or narrow. State the scope at the top of the report.
56
+
57
+ ## Step 0 — Discover the project & the change (always first)
58
+
59
+ Per Workflow conventions + documentation map, decide axes from:
60
+
61
+ 1. **Project nature:** UI (`docs/frontend/`), web/mobile/CLI/library/backend,
62
+ and optional recorded platform skills (extras only).
63
+ 2. **Footprint:** what the diff touches (UI, API, infra, domain). An axis applies
64
+ only when both project and footprint support it.
65
+
66
+ ## Applicability matrix (default; the project's docs refine it)
67
+
68
+ Every axis maps to a skill of the workflow's **own internal review pack**
69
+ (`skills/review-*` — installed with the workflow, so none can be missing):
70
+
71
+ | Axis — internal pack skill | Web | Mobile | Console/CLI | Lib/SDK | Backend/Infra |
72
+ |---|---|---|---|---|---|
73
+ | `review-code` (correctness, simplification, dead code, duplication, arch) | ✓ | ✓ | ✓ | ✓ | ✓ |
74
+ | `review-security` | ✓ | ✓ | ✓ | ✓ | ✓ |
75
+ | `review-verify` (run it, confirm real behavior, tests) | ✓ | ✓ | ✓ | ✓ | ✓ |
76
+ | `review-design` (UI/UX) | ✓ | ✓ | TUI only | ✗ | ✗ |
77
+ | `review-a11y` | ✓ | ✓ | rare | ✗ | ✗ |
78
+ | `review-brand` (voice/copy) | ✓ | ✓ | output text | ✗ | ✗ |
79
+ | `review-perf` | ✓ | ✓ | ✓ | ✓ | ✓ |
80
+ | `review-seo` | ✓ | ✗ | ✗ | ✗ | ✗ |
81
+ | API ergonomics / usage docs (inline pass) | if API | if API | flags/help | ✓✓ | ✓ |
82
+
83
+ > `review-implementation` (the single classifier over the synthesized table —
84
+ > process step 7) and `review-debt` (the debt transform over the classified
85
+ > table — process step 8) are not axis finders: they run once per review, not
86
+ > per axis.
87
+
88
+ ## Isolation rule (default — every pass, not only adversarial)
89
+
90
+ Each applicable pass, the classifier (step 7), and debt transform (step 8) runs
91
+ **isolated/context-clean** and returns only its fixed findings table plus
92
+ `PASS | FAIL`—never diff or prose. Spawn one fresh subagent/headless run per
93
+ pass; without those, use a fresh conversation. Pass only scope, its checklist,
94
+ and Step 0 docs; cap full non-diff reads at 10 (targeted ≤50-line reads/greps
95
+ excluded). The orchestrator retains tables, not sources, and fuses them in step
96
+ 6. Inline fallback is sequential table reduction. A pass runs at its own tier or
97
+ stronger, never weaker.
98
+
99
+
100
+ ## Progressive loading — choose one review route
101
+
102
+ After applicability and isolation are established:
103
+
104
+ The reference allowlist is exactly the seven linked paths below. Never invent or
105
+ read another `references/` path.
106
+
107
+ | Invocation route | LOAD in this order | SKIP |
108
+ |---|---|---|
109
+ | Default review | [review process](references/REVIEW_PROCESS.md) → [adversarial recommendation](references/ADVERSARIAL_RECOMMENDATION.md) → [persist and decide](references/PERSIST_AND_DECIDE.md) → [output and guardrails](references/OUTPUT_AND_GUARDRAILS.md) | synthesis, portability, adversarial setup |
110
+ | `--adversarial N` | review process → [adversarial setup](references/ADVERSARIAL_SETUP.md) before reviewers → [adversarial synthesis](references/ADVERSARIAL_SYNTHESIS.md) before fusion → persist/decide → output/guardrails | portability |
111
+ | `--synthesize` | review process → [adversarial synthesis](references/ADVERSARIAL_SYNTHESIS.md) plus the supplied reviewer tables → persist/decide → output/guardrails | adversarial setup, portability |
112
+ | legacy `--merge` | print the fixed migration refusal below and stop — zero git/forge mutation | everything |
113
+
114
+ **Legacy `--merge` is removed — not an alias.** Calling `/review-change --merge` prints this fixed **migration refusal** and stops **before any git or forge mutation command runs**:
115
+
116
+ ```
117
+ migration: --merge is removed. Table fusion is --synthesize: pass the fixed
118
+ reviewer tables the same way and the synthesis contract fuses them. No
119
+ repository merge is performed by this skill.
120
+ ```
121
+
122
+ Active review paths use only `--synthesize`/fusion language. Add
123
+ [portability](references/PORTABILITY.md) only when contexts, parallelism, slash
124
+ commands or tier controls are unavailable. `docs/workflow/REPOSITORY_STATE.md`
125
+ is evidence for output/guardrails, not a skill reference; that route owns NRS and
126
+ Architectural invariants rules.
127
+
128
+ Resources are one hop from this file. Fixed reviewer/synthesis/output contracts are
129
+ literal. Missing required resource → stop; never approximate a review contract.
130
+
131
+ ## Portability
132
+
133
+ Keep reviewer contexts isolated. Use [portability](references/PORTABILITY.md) for
134
+ sequential/headless fallbacks; never collapse independent adversarial passes.
135
+
136
+ ## Relationship to other skills
137
+
138
+ Orchestrates internal finders (`review-code`, `review-security`, `review-verify`,
139
+ `review-design`, `review-a11y`, `review-brand`, `review-perf`, `review-seo`), then
140
+ one `review-implementation` classifier and `review-debt` transform, isolated by
141
+ default; installed platform packs are optional. `triage-issue` is user-invoked
142
+ only for independent proposals (D3). It is Stage 4: checkpoint reviews are
143
+ optional, the end review is mandatory and fresh. `fix-now` folds in-unit,
144
+ `replan-in-unit` adds user-confirmed phases, and independent work becomes
145
+ proposals. `audit-pr` consumes only the verified PR-comment receipt, never the
146
+ chat report; `product-audit` is the periodic sweep;
147
+ `loop-review-fold` may run this skill fresh and route FAIL to `fold-findings`.
148
+
149
+ ## Done when
150
+
151
+ - One synthesized/classified table covers every applicable axis, lists skipped
152
+ axes with reasons, and includes manual checks. Every finding has a destination:
153
+ fold, confirmed replan phase, surfaced decision, or user-routed proposal; none
154
+ is silently lost and review creates no backlog (D3). Print the closing
155
+ `→ Next:` block (clean → `/audit-pr`; recurring drift → `/product-audit`) and
156
+ change no code.
@@ -0,0 +1,31 @@
1
+ ## Adversarial recommendation checklist (default review)
2
+
3
+ Adversarial multi-reviewer review (`--adversarial N`) is **opt-in — Default
4
+ OFF.** The default route loads only this short checklist; the full
5
+ roles/spawn contract (`ADVERSARIAL_SETUP.md`) loads only for
6
+ `--adversarial N`, and the table-fusion contract (`ADVERSARIAL_SYNTHESIS.md`)
7
+ only for `--adversarial N` / `--synthesize`.
8
+
9
+ **Recommend `--adversarial 2` if ANY box ticks** (this skill surfaces the
10
+ recommendation in its report / `→ Next:` block but proceeds single-reviewer
11
+ unless the user opts in):
12
+
13
+ - ✓ the change is `L`
14
+ - ✓ the change touches a sensitive surface (auth, payments, destructive
15
+ migrations, secrets, CI config)
16
+ - ✓ the reviewing model is **not the strongest model available in the fleet**,
17
+ or is weaker than the model that authored the diff
18
+ - ✓ only one model family is available **and** the change is `≥ M`
19
+
20
+ The model condition is a documented rule of thumb, **surfaced as a report line
21
+ only — never auto-detection.** An agent cannot reliably introspect its own
22
+ model identity, so this skill never tries; it states the condition in prose
23
+ and lets the human (or the orchestrator that knows which model is running)
24
+ judge it.
25
+
26
+ **N ladder (fixed).** `N=2` is the default (the `ship-roadmap` floor). Bump to
27
+ `N=3` when either holds: the change has a security/auth surface, or all
28
+ available reviewers share one model family (the third reviewer buys back some
29
+ of the decorrelation a single family can't provide). `N>3` is **explicitly
30
+ discouraged** — with the ≥1 inclusion threshold in the synthesis contract,
31
+ reviewers beyond 3 mostly add dedupe work at merge time, not new findings.
@@ -0,0 +1,86 @@
1
+ ## Adversarial multi-reviewer mode (`--adversarial N`, opt-in)
2
+
3
+ **Default OFF.** No `--adversarial N` flag → today's single-reviewer behavior
4
+ (step 1 above). This mode only replaces the findings-gathering stage (the
5
+ finder passes in step 4) with the N isolated reviewers; the rest of the
6
+ process — SPEC drift, workflow-discipline, synthesis, classification, debt
7
+ transform, manual verification, outcome routing, report — runs once, over the
8
+ fused table.
9
+
10
+ **N semantics.** `--adversarial` flag not passed at all → single-reviewer mode,
11
+ no message (today's default). `--adversarial` passed **without** a valid N
12
+ (no number given, or a number `< 2`) → usage error: state that `--adversarial`
13
+ needs an integer N≥2 and fall back to the single-reviewer path — never
14
+ silently run 1. `ship-roadmap`'s hard floor always passes `N=2`.
15
+
16
+ **Why N reviewers.** A single adversarial, context-clean reviewer (see the
17
+ turn-contract box) decorrelates some blind spots; running N independent
18
+ reviewers — ideally across **different model families** (a preference, not a
19
+ requirement: an agent with one family runs N same-family reviewers and says so)
20
+ — decorrelates more, at 2–3× the cost of the findings-gathering stage. That cost
21
+ is why the mode stays opt-in and is only **auto-recommended, never forced**.
22
+
23
+ **Recommendation checklist** (when to recommend this mode, and the only
24
+ adversarial content the **default** route loads) and the **N ladder** (choosing
25
+ N when a recommendation fires) live in `ADVERSARIAL_RECOMMENDATION.md`. On an
26
+ adversarial run N is already fixed by the caller's `--adversarial N`, so the
27
+ full roles/spawn contract below needs no ladder. The full contract loads
28
+ **only** for `--adversarial N`.
29
+
30
+ **Reviewer roles (fixed, assigned by index).** Each reviewer *i* gets role *i*
31
+ from this fixed set — never chosen ad hoc:
32
+
33
+ - **R1 — correctness/logic adversary.** Assume the diff is wrong until proven
34
+ otherwise; hunt first for logic errors, wrong conditionals, off-by-one/edge
35
+ cases, silent behavior changes.
36
+ - **R2 — security/inputs adversary.** Hunt first for untrusted input handling,
37
+ injection, auth/authorization gaps, secret handling, and unsafe defaults.
38
+ - **R3 — SPEC-coverage adversary.** Hunt first for what the governing SPEC
39
+ *promises* that the diff does not actually do — unmet acceptance criteria,
40
+ silently narrowed scope, claims contradicted by the code.
41
+
42
+ **A role is an attention priority, NOT an exclusive scope.** The full
43
+ applicable finder checklists stay **mandatory for every reviewer** —
44
+ the role only orders where that reviewer looks first, it never narrows what
45
+ they're allowed to flag. The known failure mode this guards against: a
46
+ role-narrowed reviewer skips an obvious defect because it fell outside "their"
47
+ role. Every reviewer prompt (see the reviewer contract below) must carry this
48
+ sentence, not just the role assignment.
49
+
50
+ **Reviewer contract (single source).** Each of the N reviewers — spawned by
51
+ whichever tier below applies — receives this fixed prompt; only `<i>`/`<role
52
+ name>`/`<scope>` vary per reviewer. This is the **one and only place** the
53
+ reviewer prompt is authored — the Portability paste block later in this skill
54
+ quotes it verbatim, never a rewritten copy:
55
+
56
+ ```
57
+ ROLE: R<i> — <role name, from the fixed set above>
58
+ SCOPE: <diff-only — the branch diff vs the default branch, or the passed path/glob>
59
+
60
+ You are reviewer <i> of N in an adversarial multi-reviewer review. Assume the
61
+ diff is wrong until proven otherwise. Your role orders where you look FIRST —
62
+ it is an attention priority, not an exclusive scope: the full applicable
63
+ finder checklists stay mandatory. Flag anything wrong, not only findings
64
+ inside your role.
65
+
66
+ Return exactly:
67
+ | file:line | axis | Finding | Sev | Evidence |
68
+ |---|---|---|---|---|
69
+ <one row per finding — empty table if none>
70
+ ```
71
+
72
+ **Platform-adaptive spawn (three tiers).** Each of the N reviewers is a
73
+ **context-clean, diff-only, adversarial** run of the applicable finder
74
+ passes, reviewing the same scope — none of them is the
75
+ conversation that wrote the diff, and the orchestrating `review-change`
76
+ conversation never reviews in the same breath as authoring either (the
77
+ turn-contract box still applies to the orchestrator):
78
+
79
+ 1. **Claude Code** → spawn **N subagents in parallel**, one reviewer each.
80
+ Prefer assigning **different model families** across them where more than
81
+ one is available.
82
+ 2. **Another agent with headless invocation** → **N parallel headless
83
+ invocations**, each a fresh context reviewing the diff.
84
+ 3. **Neither** (inline fallback) → **N sequential fresh conversations** —
85
+ slower, the documented floor-of-last-resort so no agent is blocked from
86
+ using this mode.
@@ -0,0 +1,53 @@
1
+ ## Adversarial synthesis
2
+
3
+ **Synthesis contract (single source).** Collect all N reviewers' findings
4
+ tables — each already in the reviewer contract's fixed format above
5
+ (a `provenance` note records which reviewer/source produced each row) — and:
6
+
7
+ - **Dedupe by `file:line` + axis** (two genuinely different findings on the
8
+ same line, different axis, stay separate). Identical findings from multiple
9
+ reviewers collapse into **one** row.
10
+ - Annotate each synthesized row with a `Reviewers n/N` column — how many of
11
+ the N flagged it — as a confidence signal.
12
+ - **Inclusion threshold = ≥1 reviewer.** A finding any single reviewer raised
13
+ enters classification normally; there is no majority/quorum gate to include a
14
+ finding — a real defect only one sharp reviewer caught must not be dropped.
15
+ - **Forbidden — never**, while synthesizing: dropping a finding, downgrading
16
+ its severity, reclassifying it, or re-litigating whether it's real. The
17
+ fusion step's only job is to synthesize; disputing a finding's validity
18
+ happens later, in the normal classification and outcome-routing steps that
19
+ consume the synthesized table — never during the fusion itself.
20
+ - **Externally-produced reviews** (not spawned by this run) are accepted into
21
+ the fusion **only if they already arrive in the reviewer contract's fixed
22
+ table format**. Normalizing free prose into that format is the contributing
23
+ conversation's job, not the fusion step's — it converts to the table first.
24
+ - The synthesized table then flows through the rest of the process above —
25
+ classification, debt transform, manual verification, outcome routing —
26
+ producing the same fixed-format report ending `Decision:
27
+ REVIEW-PASS | REVIEW-FAIL | NEEDS-DECISION` (D10).
28
+
29
+ Prompts use **synthesize/fuse** language, never repository merge terminology —
30
+ this contract fuses review tables; it performs no repository merge.
31
+
32
+ **`--synthesize` mode.** `/review-change --synthesize` is the direct entry
33
+ point for the synthesis contract above — it starts **at the fusion step**,
34
+ skipping the N-reviewer spawn: pass it N pasted findings tables (each already
35
+ in the reviewer contract's fixed format), and it runs the synthesis contract,
36
+ then the rest of the process, to the same fixed report ending `Decision:
37
+ REVIEW-PASS | REVIEW-FAIL | NEEDS-DECISION`. This is how a manual orchestrator — one that ran the N reviewer
38
+ conversations by hand via the Portability paste blocks — hands the results
39
+ back to this skill for fusion, without re-authoring the dedupe/threshold/
40
+ forbidden rules itself: the mode consumes the single synthesis contract above,
41
+ never a second copy of it.
42
+
43
+ **Cadence — once per unit.** The adversarial run (spawn or `--synthesize`)
44
+ happens **once per unit, at the mandatory terminal `review-change`** (the pass
45
+ before `Hardening & PR` — see *Review checkpoint & finishing a unit* in
46
+ `execute-phase`), where the adversarial recommendation checklist is evaluated. The
47
+ one stated exception, not a cadence of its own: a phase touching a sensitive
48
+ surface (auth, payments, destructive migrations, secrets, CI config) may earn
49
+ an **early** adversarial pass scoped to just that phase's diff — still a
50
+ single extra event, not a recurring checkpoint. **Boundary with `#77`** (the general review-checkpoint cadence redesign):
51
+ this section owns *where* the adversarial mode runs (the terminal review, plus
52
+ the sensitive-phase exception); `#77` owns the general every-N-phases
53
+ checkpoint interval — neither issue's change edits the other's sentences.
@@ -0,0 +1,85 @@
1
+ ## Example output (generic)
2
+
3
+ For a change to a backend export module (no UI surface):
4
+
5
+ > Scope: branch diff vs `main` (`src/export/**`). Skipped: design / a11y / SEO /
6
+ > brand — no UI surface.
7
+
8
+ | Axis | Finding | Sev | Class | WHY | Route |
9
+ |---|---|---|---|---|---|
10
+ | security | API token read from a committed file | high | fix-now | Credential exposure | fold into phase |
11
+ | tests | Export handler has no failure-mode test | med | fix-now | Untested error path | fold into phase |
12
+ | architecture | Rate limiter reusable across the fleet | low | proposal | Independent of this unit (D3) | batch proposal + trigger |
13
+
14
+ > Manual-verification (automation can't confirm):
15
+ > - The exported file opens cleanly in a spreadsheet app.
16
+ > - An empty result set still produces a valid (header-only) file.
17
+
18
+ ## Routing
19
+
20
+ Every finding gets a destination under the current-unit contract — none silently
21
+ lost, and none becomes reviewer-created backlog (D3):
22
+
23
+ - **fix-now** → persisted to the unit's `review-findings.md` fold ledger, then
24
+ folded into the current phase (unmerged work) — never a tracked issue, never
25
+ `plan-fix`. Classification honors `review-implementation`'s **current-unit
26
+ contract**: in-scope defects are always fix-now / replan-in-unit — never a
27
+ postpone/tradeoff/wontfix/new-issue escape.
28
+ - **fix-now / `replan-in-unit`** (too large to fold as-is) → keeps its fix-now
29
+ class and ledger row; propose the new SPEC phase(s) to the user, then
30
+ `execute-phase` on the same branch folds it.
31
+ - **fix-now / `decision-required`** → stop and surface the decision to the user;
32
+ the unit blocks until decided. No issue is created.
33
+ - **proposal** (independent future capability) → batched in the report with a
34
+ trigger; only the **user** routes it to `triage-issue`.
35
+ - **ignore** → note the rationale in the report; no further action.
36
+
37
+ The report's `Decision:` line is **three-state** (D10): `REVIEW-PASS` when the
38
+ table is clean, `REVIEW-FAIL` while any fix-now finding is open, and
39
+ `NEEDS-DECISION` when a decision-required finding blocks. Only `REVIEW-PASS`
40
+ **and only when the PR exists** posts the idempotent exact-SHA receipt (step 13
41
+ of *Persist and decide*); `REVIEW-FAIL` leaves findings in the fold ledger and
42
+ posts nothing; `NEEDS-DECISION` blocks without creating an issue. The
43
+ `→ Next:` block in *Persist and decide* step 14 is the single place that maps
44
+ each decision to its next command — never emit a `→ Next:` block that disagrees
45
+ with the `Decision:` line.
46
+
47
+ ## Guardrails
48
+
49
+ - **Findings + tables only. Never refactor or edit code.**
50
+ - Run only applicable axes; never an irrelevant pass (no a11y/SEO/brand for
51
+ CLI/lib/infra). Always report what was skipped and why.
52
+ - Honor the project's **Workflow conventions** (docs-language, evidence): cite
53
+ `file:line`, mark uncertainties *verify*.
54
+ - **Any forge body this review causes (issues/comments filed via `triage-issue`)
55
+ is Markdown, not shell — never hand-escape.** A `\` before a backtick/`*`/`_`
56
+ renders literally (`` \`code\` `` instead of `` `code` ``); bodies go through
57
+ `--body-file <path>`, never an inline `--body "…"`/heredoc. `triage-issue`
58
+ enforces this for the comments it posts — don't undercut it by pre-escaping
59
+ finding text you hand it.
60
+ - **The `REVIEW-PASS` receipt is a PR comment, never a commit** (D6): it goes
61
+ through a temporary `--body-file` (exact body from *Persist and decide* step
62
+ 13), is idempotent by SHA, and is never added to the branch. `REVIEW-FAIL` and
63
+ `NEEDS-DECISION` post no receipt.
64
+
65
+ ## Normalized Repository State
66
+
67
+ Use frozen NRS facts from `docs/workflow/REPOSITORY_STATE.md` as evidence context, but remain read-only. A review may
68
+ propose a contradiction with fresh evidence; it cannot redefine a fact, accept a
69
+ decision, or turn documentation into implementation evidence.
70
+
71
+ ## Architectural invariants
72
+
73
+ Review the diff against the optional project invariant document declared in the
74
+ documentation map (normally `docs/architecture/ARCHITECTURAL_INVARIANTS.md`).
75
+ Its absence is compatible: report `n/a: no project invariants declared`. For
76
+ each applicable rule, cite its ID and repository evidence and classify the
77
+ actual change as `preserves`, `violates`, `introduces`, or `changes`. Consume
78
+ frozen NRS facts when present, but inspect the repository for absent facts and
79
+ route a conflict to `resolve-repository-state`.
80
+
81
+ `preserves` reports `pass`. A `violates`, `introduces`, or `changes` result is
82
+ an `architecture` finding in the synthesized table, with the evidence and route
83
+ `explicit architectural decision`; report it before suggesting any modification.
84
+ The reviewer cannot accept the decision, amend the invariant, or treat the SPEC,
85
+ implementation, or passing test as approval.
@@ -0,0 +1,151 @@
1
+ ## Persist and decide
2
+
3
+ 11. **Persist fix-now findings to the fold ledger.** The unit's **fix-now fold
4
+ ledger** is `review-findings.md`, located beside its other docs
5
+ (`docs/features/<NN>-<slug>/review-findings.md` for a feature,
6
+ `docs/fix/<n>-<topic>/review-findings.md` for a fix), fixed schema:
7
+
8
+
9
+ ```
10
+ | id | file:line | axis | severity | class | route | folded |
11
+ ```
12
+
13
+ **Merged unit → no write** (a PR exists and its state is `MERGED` — check
14
+ `gh pr view --json state` when a PR is open; otherwise the unit is unmerged
15
+ by definition). Otherwise, for each **fix-now** finding: append a row
16
+ (create the file with the header row if it doesn't exist yet), carrying the
17
+ verbatim `Sev` value into `severity`; `folded` always starts `no` —
18
+ `execute-phase`'s fold cycle is the only step that ever flips it to `yes`.
19
+ Re-runs **dedupe by `file:line` + axis** (the same rule the adversarial mode
20
+ uses to merge reviewer findings, above): a finding already on the ledger at
21
+ that `file:line`+axis is not re-appended; a genuinely new finding gets the
22
+ next `Fn` id. **Non-fix-now findings are never written here** — they keep
23
+ their destinations from step 10 (outcome routing): independent future
24
+ capabilities batch as proposals; only the user routes them to `triage-issue`
25
+ (D3).
26
+ 12. **Close out the final-review receipt before reporting.** First derive the
27
+ `Decision` from step 6 and persist step 11. Then, before printing any line of
28
+ the fixed report block or the `→ Next:` block, complete the receipt action
29
+ below. The receipt is a precondition of the report, not a follow-up.
30
+
31
+ The durable, audit-consumable receipt is one idempotent SHA-bound PR comment
32
+ (D6, D7). **Only on `Decision: REVIEW-PASS` AND when the PR exists** (the
33
+ mandatory final review; the PR always exists by then — the phase gate created
34
+ it). `REVIEW-FAIL` and `NEEDS-DECISION` post **no** passing receipt; continue
35
+ to step 13 after recording that status.
36
+
37
+ The reviewed head SHA is the value frozen by `git rev-parse HEAD` in the
38
+ review process. Resolve the PR identity immediately before this action with
39
+ `gh pr view --json number,headRefOid`. No PR → take the documented pre-PR
40
+ path. With a PR, its `headRefOid` **must equal the reviewed head SHA** before
41
+ querying or posting comments. A mismatch means the candidate changed during
42
+ review: do not post a receipt and re-run `/review-change` at the PR head.
43
+
44
+ For `REVIEW-PASS` with a PR, write the body below to a **temporary** Markdown
45
+ file (e.g. `$TMPDIR/review-receipt.md`), then run
46
+ `gh pr comment <N> --body-file <path>` — never inline `--body`, never commit
47
+ the file into the branch. Before posting, run `gh pr view <N> --json comments`
48
+ and inspect the newest matching marker. Same SHA → skip the post; older or
49
+ absent SHA → post. After posting, run the same comment query again and confirm
50
+ the newest marker equals the reviewed head SHA. If that confirmation fails,
51
+ retry the receipt action; do not print a `REVIEW-PASS` report or recommend
52
+ `/audit-pr` while the receipt is not current.
53
+
54
+ Use **exactly** this body:
55
+
56
+ ```markdown
57
+ <!-- review-change:pass sha=<head SHA> contract=v1 -->
58
+ ## review-change: REVIEW-PASS
59
+
60
+ - Reviewed head: `<head SHA>`
61
+ - Scope and applicable axes: <compact list>
62
+ - Acceptance coverage: concise criterion-to-evidence summary
63
+ - Architectural invariants: pass | n/a
64
+ - Current-unit findings open: 0
65
+ - Future-capability proposals: <count; no issues created>
66
+ - Manual verification: <items or none>
67
+ ```
68
+
69
+ 13. **Report block — Return exactly this structure** after step 12 succeeds
70
+ (fixed chat-report block; this is not the end of the turn):
71
+
72
+ ```
73
+ REVIEW CHANGE — scope: <scope>
74
+ Axes run: <list> Skipped: <list + why>
75
+ Architectural invariants: pass | finding (<ID>) | n/a: no project invariants declared
76
+ Receipt: current at <head SHA> | n/a: no PR | none: REVIEW-FAIL/NEEDS-DECISION
77
+
78
+ <the synthesized decision table (step 6)>
79
+
80
+ Manual verification (a human must check):
81
+ - <item> …
82
+
83
+ Proposals (step 10): <n> — batched for the user, no issues created (D3)
84
+
85
+ Summary: <1-2 sentences>
86
+ Decision: REVIEW-PASS | REVIEW-FAIL | NEEDS-DECISION (D10: review says these three; only audit-pr says MERGE-READY)
87
+ ```
88
+
89
+ 14. **Next step.** The `→ Next:` block is **never one static template** — branch
90
+ on the `Decision` value from step 6 and emit the matching block **verbatim,
91
+ as multiple literal lines**. Never join the `·` sub-bullets into one prose
92
+ line — each sub-bullet is its own line, exactly as quoted below.
93
+ For `REVIEW-FAIL` or `NEEDS-DECISION`, list every open finding ID in the
94
+ closing recommendation, joined with ` + `; never hand off only the first.
95
+
96
+ **`Decision: REVIEW-FAIL`** (any fix-now finding open) — the recommended line
97
+ is the fold, never the merge gate. Findings were persisted in step 11; **no
98
+ passing receipt was posted** (step 12):
99
+
100
+ ```
101
+ → Next: /loop-review-fold <unit> — repair all open fix-now findings: <F1> + <F2> + <F3>,
102
+ then re-review changed HEADs within the bounded correction budget
103
+ · manual path → /fold-findings, then re-run /review-change
104
+ · /audit-pr → only after the table is clean (not yet — findings open)
105
+ · any finding routed replan-in-unit? → confirm the proposed SPEC phase(s),
106
+ then /execute-phase on this same branch (yes: list the finding ids; no:
107
+ omit this line)
108
+ · independent proposals → present to the user; only the user routes them
109
+ to /triage-issue
110
+ · adversarial recommendation checklist fired AND this run was
111
+ single-reviewer? → re-run the fold review as /review-change
112
+ --adversarial N (N per the ladder below) instead of single-reviewer
113
+ (yes: <which box fired>; no: omit this line)
114
+ · SPEC drift flagged here AND on a prior unit? → /product-audit (yes: the
115
+ founding assumptions are probably stale — don't keep patching a
116
+ compounding error; no: omit this line)
117
+ ```
118
+
119
+ **`Decision: REVIEW-PASS`** (table clean) — the recommended line is the merge
120
+ gate. Receipt: PR exists → current after step 12 (exact-SHA `REVIEW-PASS` at
121
+ `<head SHA>`); pre-PR checkpoint → no receipt, the `progress.md` compact
122
+ marker covers it (D7):
123
+
124
+ ```
125
+ → Next: /audit-pr — merge gate
126
+ · independent proposals → present to the user; only the user routes them
127
+ to /triage-issue
128
+ · adversarial recommendation checklist fired AND this run was
129
+ single-reviewer? → re-run as /review-change --adversarial N (N per the
130
+ ladder below) before /audit-pr (yes: <which box fired>; no: omit this
131
+ line)
132
+ · SPEC drift flagged here AND on a prior unit? → /product-audit (yes: the
133
+ founding assumptions are probably stale — don't keep patching a
134
+ compounding error; no: omit this line)
135
+ ```
136
+
137
+ **`Decision: NEEDS-DECISION`** (a decision-required finding is open — step
138
+ 10) — block without creating an issue; surface the decision to the user, who
139
+ alone resolves it:
140
+
141
+ ```
142
+ → Next: decision required — resolve all open findings: <F1> + <F2> + <F3>
143
+ before the unit continues
144
+ · present the decision-required finding(s) with evidence; no issue is
145
+ created (D3) and no passing receipt was posted (step 12)
146
+ · once the user decides, re-run /review-change on this same branch
147
+ ```
148
+
149
+ The `/product-audit` line fires **only on recurring drift** — the same kind
150
+ of inconsistency surfacing a second time, not a single isolated finding;
151
+ the yes/no checkbox above is how to decide, in both branches.
@@ -0,0 +1,74 @@
1
+ ## Portability (agents other than Claude Code)
2
+
3
+ The workflow is the contract; Claude Code features are conveniences. On an
4
+ agent that lacks one, apply the fallback — never skip the step the feature
5
+ enables:
6
+
7
+ - **No slash-command menu** — where this skill says `/<skill>`, open that
8
+ skill's `SKILL.md` (wherever your agent installed the skills) and follow it
9
+ literally, in a fresh conversation: hand-offs assume a clean context.
10
+ "Compose in-turn" means the opposite: run that step within this same
11
+ conversation, as part of this review.
12
+ - **Default-pass isolation** — the *Isolation rule* uses the same three spawn
13
+ tiers as `--adversarial N` (subagents / headless / fresh conversations); an
14
+ agent with none of them runs the documented inline fallback: sequential
15
+ in-turn passes, each reduced to its findings table before the next starts.
16
+ - **No per-skill `model:`/`effort:`** — on the `#claude` branch the frontmatter pins these tiers; here, pick tiers yourself:
17
+ this review needs your **strongest** model. Never review a change with a
18
+ model weaker than the one that wrote it — and prefer a different model family
19
+ than the writer's: same-family instances share training blind spots,
20
+ cross-family decorrelates errors.
21
+ - **`--adversarial N` spawn tiers** — Claude Code subagents (tier 1) and
22
+ headless invocation (tier 2) are conveniences; an agent with neither runs the
23
+ tier-3 fallback of N **sequential fresh conversations**, each context-clean
24
+ and diff-only, then fuses their findings by hand per the synthesis contract
25
+ above — slower, never a reason to skip the mode. **One source, two
26
+ wrappers:** the pro path invokes `--adversarial N` / `--synthesize` and this
27
+ skill runs the contracts itself; a manual orchestrator without either flag
28
+ pastes the two blocks below into fresh conversations by hand — both render
29
+ the exact same reviewer/synthesis contract, never a second, drifting copy.
30
+
31
+ **Reviewer-prompt paste block** (one per reviewer, in a fresh conversation;
32
+ fills `<i>`/`<role name>`/`<scope>` from the fixed role set and N ladder
33
+ above — this is the reviewer contract, quoted verbatim):
34
+
35
+ ```
36
+ ROLE: R<i> — <role name, from the fixed set above>
37
+ SCOPE: <diff-only — the branch diff vs the default branch, or the passed path/glob>
38
+
39
+ You are reviewer <i> of N in an adversarial multi-reviewer review. Assume the
40
+ diff is wrong until proven otherwise. Your role orders where you look FIRST —
41
+ it is an attention priority, not an exclusive scope: the full applicable
42
+ finder checklists stay mandatory. Flag anything wrong, not only findings
43
+ inside your role.
44
+
45
+ Return exactly:
46
+ | file:line | axis | Finding | Sev | Evidence |
47
+ |---|---|---|---|---|
48
+ <one row per finding — empty table if none>
49
+ ```
50
+
51
+ **Synthesis-prompt paste block** (one fresh conversation, after collecting
52
+ all N reviewer tables above — this is the synthesis contract, quoted verbatim):
53
+
54
+ ```
55
+ You are fusing N independent adversarial review tables into one. Given the N
56
+ pasted findings tables below (each already in the reviewer contract's fixed
57
+ format):
58
+ - Dedupe by file:line + axis; identical findings from multiple reviewers
59
+ collapse into one row.
60
+ - Add a `Reviewers n/N` column: how many of the N flagged it.
61
+ - Inclusion threshold = ≥1 reviewer — a finding any single reviewer raised
62
+ enters classification normally; no majority/quorum gate.
63
+ - Forbidden — never: drop a finding, downgrade its severity, reclassify it,
64
+ or re-litigate whether it's real. Fusion only — disputes happen in
65
+ triage, not here.
66
+ - Externally-produced reviews are accepted only if already in the fixed
67
+ table format.
68
+
69
+ <N pasted findings tables go here>
70
+
71
+ Return the merged table, then continue through the rest of review-change's
72
+ process to the fixed report ending `Decision: REVIEW-PASS | REVIEW-FAIL |
73
+ NEEDS-DECISION`.
74
+ ```