@gobing-ai/spur 0.3.41 → 0.3.42

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 (185) hide show
  1. package/.claude-plugin/marketplace.json +15 -0
  2. package/README.md +15 -1
  3. package/config/templates/AGENTS.md +5 -3
  4. package/config/workflows/task-pipeline.yaml +103 -12
  5. package/package.json +15 -12
  6. package/plugins/README.md +655 -0
  7. package/plugins/sp/README.md +621 -0
  8. package/plugins/sp/agents/expert-spur.md +109 -0
  9. package/plugins/sp/agents/super-coder.md +126 -0
  10. package/plugins/sp/agents/super-planner.md +283 -0
  11. package/plugins/sp/agents/super-reviewer.md +154 -0
  12. package/plugins/sp/commands/dev-arch.md +30 -0
  13. package/plugins/sp/commands/dev-brainstorm.md +40 -0
  14. package/plugins/sp/commands/dev-changelog.md +28 -0
  15. package/plugins/sp/commands/dev-daily.md +29 -0
  16. package/plugins/sp/commands/dev-debug.md +29 -0
  17. package/plugins/sp/commands/dev-dogfood.md +33 -0
  18. package/plugins/sp/commands/dev-featurechange.md +130 -0
  19. package/plugins/sp/commands/dev-find-conflict.md +51 -0
  20. package/plugins/sp/commands/dev-find-issue.md +76 -0
  21. package/plugins/sp/commands/dev-find-next.md +60 -0
  22. package/plugins/sp/commands/dev-fixall.md +33 -0
  23. package/plugins/sp/commands/dev-gitmsg.md +28 -0
  24. package/plugins/sp/commands/dev-gtd.md +97 -0
  25. package/plugins/sp/commands/dev-handover.md +26 -0
  26. package/plugins/sp/commands/dev-idea.md +50 -0
  27. package/plugins/sp/commands/dev-next.md +31 -0
  28. package/plugins/sp/commands/dev-parallel.md +30 -0
  29. package/plugins/sp/commands/dev-plan.md +46 -0
  30. package/plugins/sp/commands/dev-refine.md +48 -0
  31. package/plugins/sp/commands/dev-refineall.md +65 -0
  32. package/plugins/sp/commands/dev-refresh.md +32 -0
  33. package/plugins/sp/commands/dev-reverse.md +32 -0
  34. package/plugins/sp/commands/dev-review.md +31 -0
  35. package/plugins/sp/commands/dev-run.md +63 -0
  36. package/plugins/sp/commands/dev-runall.md +80 -0
  37. package/plugins/sp/commands/dev-simplify.md +39 -0
  38. package/plugins/sp/commands/dev-unit.md +29 -0
  39. package/plugins/sp/commands/dev-verify.md +48 -0
  40. package/plugins/sp/commands/dev-verifyall.md +72 -0
  41. package/plugins/sp/commands/dev-wrap.md +30 -0
  42. package/plugins/sp/commands/dev-wrapall.md +33 -0
  43. package/plugins/sp/commands/rule-add.md +18 -0
  44. package/plugins/sp/commands/rule-refine.md +18 -0
  45. package/plugins/sp/commands/rule-scan.md +18 -0
  46. package/plugins/sp/commands/spur-init.md +22 -0
  47. package/plugins/sp/commands/workflow-add.md +18 -0
  48. package/plugins/sp/commands/workflow-refine.md +18 -0
  49. package/plugins/sp/hooks/agent-hint.ts +60 -0
  50. package/plugins/sp/hooks/careful-guard.ts +147 -0
  51. package/plugins/sp/hooks/context-post-tool.ts +325 -0
  52. package/plugins/sp/hooks/context-session-start.ts +182 -0
  53. package/plugins/sp/hooks/context-session-stop.ts +95 -0
  54. package/plugins/sp/hooks/hooks.json +51 -0
  55. package/plugins/sp/hooks/pi/guard-extension.ts +341 -0
  56. package/plugins/sp/hooks/task-write-guard.ts +84 -0
  57. package/plugins/sp/plugin.json +8 -0
  58. package/plugins/sp/scripts/batch-preflight.ts +204 -0
  59. package/plugins/sp/scripts/daily-summary/daily-summary.ts +606 -0
  60. package/plugins/sp/scripts/daily-summary/logger.ts +28 -0
  61. package/plugins/sp/scripts/dogfood-testing/detect-pipeline-driving.ts +363 -0
  62. package/plugins/sp/scripts/dogfood-testing/validate-report.ts +168 -0
  63. package/plugins/sp/scripts/feature-sync-bounded.ts +451 -0
  64. package/plugins/sp/scripts/stage-registry-adapter.ts +1341 -0
  65. package/plugins/sp/scripts/task-size-precheck.ts +202 -0
  66. package/plugins/sp/scripts/validate-commands.ts +651 -0
  67. package/plugins/sp/scripts/validate-flag-contracts.ts +875 -0
  68. package/plugins/sp/skills/brainstorm/SKILL.md +361 -0
  69. package/plugins/sp/skills/brainstorm/agents/openai.yaml +14 -0
  70. package/plugins/sp/skills/brainstorm/examples/ideation-example.md +209 -0
  71. package/plugins/sp/skills/brainstorm/metadata.openclaw +7 -0
  72. package/plugins/sp/skills/brainstorm/references/grilling-interview.md +68 -0
  73. package/plugins/sp/skills/brainstorm/references/workflows.md +255 -0
  74. package/plugins/sp/skills/branch-workflow/SKILL.md +109 -0
  75. package/plugins/sp/skills/branch-workflow/references/branch-lifecycle.md +69 -0
  76. package/plugins/sp/skills/branch-workflow/references/worktree-patterns.md +100 -0
  77. package/plugins/sp/skills/code-implementation/SKILL.md +176 -0
  78. package/plugins/sp/skills/code-implementation/references/debugging.md +64 -0
  79. package/plugins/sp/skills/code-implementation/references/implementation-patterns.md +113 -0
  80. package/plugins/sp/skills/code-improvement/SKILL.md +231 -0
  81. package/plugins/sp/skills/code-improvement/references/deepening-signals.md +205 -0
  82. package/plugins/sp/skills/code-review/SKILL.md +112 -0
  83. package/plugins/sp/skills/code-review/references/receiving-code-review.md +70 -0
  84. package/plugins/sp/skills/code-review/references/review-lenses.md +117 -0
  85. package/plugins/sp/skills/code-review/references/self-review-checklist.md +53 -0
  86. package/plugins/sp/skills/code-review/references/verification-before-completion.md +68 -0
  87. package/plugins/sp/skills/code-simplification/SKILL.md +225 -0
  88. package/plugins/sp/skills/code-testing/SKILL.md +108 -0
  89. package/plugins/sp/skills/code-testing/references/stacks/bun-ts.md +165 -0
  90. package/plugins/sp/skills/code-testing/references/stacks/go.md +88 -0
  91. package/plugins/sp/skills/code-testing/references/stacks/python.md +117 -0
  92. package/plugins/sp/skills/code-testing/references/test-loop-breaker.md +37 -0
  93. package/plugins/sp/skills/code-testing/references/test-output-discipline.md +52 -0
  94. package/plugins/sp/skills/code-testing/references/unit-testing.md +212 -0
  95. package/plugins/sp/skills/code-verification/SKILL.md +535 -0
  96. package/plugins/sp/skills/code-verification/references/code-improvement.md +39 -0
  97. package/plugins/sp/skills/code-verification/references/secu-review.md +94 -0
  98. package/plugins/sp/skills/code-verification/references/verdict-schema.md +141 -0
  99. package/plugins/sp/skills/conflict-finding/SKILL.md +254 -0
  100. package/plugins/sp/skills/conflict-finding/references/authority-resolution.md +258 -0
  101. package/plugins/sp/skills/conflict-finding/references/comparison-protocol.md +277 -0
  102. package/plugins/sp/skills/conflict-finding/references/finding-contract.md +346 -0
  103. package/plugins/sp/skills/conflict-finding/references/remediation-routing.md +276 -0
  104. package/plugins/sp/skills/daily-summary/SKILL.md +171 -0
  105. package/plugins/sp/skills/daily-summary/agents/openai.yaml +13 -0
  106. package/plugins/sp/skills/doc-evolve/SKILL.md +175 -0
  107. package/plugins/sp/skills/doc-evolve/references/operations.md +93 -0
  108. package/plugins/sp/skills/dogfood-testing/SKILL.md +608 -0
  109. package/plugins/sp/skills/dogfood-testing/references/monitor-ledger.md +211 -0
  110. package/plugins/sp/skills/dogfood-testing/references/report-template.md +351 -0
  111. package/plugins/sp/skills/doubt-driven-development/SKILL.md +136 -0
  112. package/plugins/sp/skills/functional-review/SKILL.md +364 -0
  113. package/plugins/sp/skills/functional-review/references/verdict-schema.md +133 -0
  114. package/plugins/sp/skills/indexed-context/SKILL.md +164 -0
  115. package/plugins/sp/skills/issue-finding/SKILL.md +424 -0
  116. package/plugins/sp/skills/issue-finding/agents/openai.yaml +15 -0
  117. package/plugins/sp/skills/issue-finding/examples/expected-findings.json +27 -0
  118. package/plugins/sp/skills/issue-finding/examples/session-test-loop.jsonl +23 -0
  119. package/plugins/sp/skills/issue-finding/references/session-formats.md +121 -0
  120. package/plugins/sp/skills/next-feature/SKILL.md +125 -0
  121. package/plugins/sp/skills/next-feature/references/handoff-routing.md +92 -0
  122. package/plugins/sp/skills/next-feature/references/proposal-contract.md +49 -0
  123. package/plugins/sp/skills/next-feature/references/ranking-rubric.md +52 -0
  124. package/plugins/sp/skills/next-feature/references/signal-derivation.md +67 -0
  125. package/plugins/sp/skills/next-router/SKILL.md +181 -0
  126. package/plugins/sp/skills/next-router/references/messages.md +90 -0
  127. package/plugins/sp/skills/next-router/references/routing-table.md +216 -0
  128. package/plugins/sp/skills/parallel-execution/SKILL.md +148 -0
  129. package/plugins/sp/skills/parallel-execution/references/dispatch-surface.md +100 -0
  130. package/plugins/sp/skills/parallel-execution/references/fan-out-patterns.md +101 -0
  131. package/plugins/sp/skills/parallel-execution/references/result-synthesis.md +94 -0
  132. package/plugins/sp/skills/reverse-engineering/SKILL.md +375 -0
  133. package/plugins/sp/skills/reverse-engineering/agents/openai.yaml +18 -0
  134. package/plugins/sp/skills/source-driven-development/SKILL.md +124 -0
  135. package/plugins/sp/skills/spec-decomposition/SKILL.md +117 -0
  136. package/plugins/sp/skills/spec-decomposition/references/decomposition.md +539 -0
  137. package/plugins/sp/skills/spur-cli/SKILL.md +133 -0
  138. package/plugins/sp/skills/spur-cli/references/agent.md +179 -0
  139. package/plugins/sp/skills/spur-cli/references/features/acceptance-criteria.md +82 -0
  140. package/plugins/sp/skills/spur-cli/references/features/hierarchy-mece.md +177 -0
  141. package/plugins/sp/skills/spur-cli/references/features/roadmap-priority.md +84 -0
  142. package/plugins/sp/skills/spur-cli/references/features/verbs.md +122 -0
  143. package/plugins/sp/skills/spur-cli/references/features.md +234 -0
  144. package/plugins/sp/skills/spur-cli/references/init.md +119 -0
  145. package/plugins/sp/skills/spur-cli/references/message.md +98 -0
  146. package/plugins/sp/skills/spur-cli/references/rules/authoring-rules.md +212 -0
  147. package/plugins/sp/skills/spur-cli/references/rules/fine-tuning.md +148 -0
  148. package/plugins/sp/skills/spur-cli/references/rules/operations.md +228 -0
  149. package/plugins/sp/skills/spur-cli/references/rules/validation-and-extension.md +129 -0
  150. package/plugins/sp/skills/spur-cli/references/rules.md +209 -0
  151. package/plugins/sp/skills/spur-cli/references/serve.md +58 -0
  152. package/plugins/sp/skills/spur-cli/references/tasks/l3-guard-cheatsheet.md +98 -0
  153. package/plugins/sp/skills/spur-cli/references/tasks/section-editing.md +95 -0
  154. package/plugins/sp/skills/spur-cli/references/tasks/verbs.md +361 -0
  155. package/plugins/sp/skills/spur-cli/references/tasks.md +278 -0
  156. package/plugins/sp/skills/spur-cli/references/team.md +133 -0
  157. package/plugins/sp/skills/spur-cli/references/workflows/authoring-workflows.md +226 -0
  158. package/plugins/sp/skills/spur-cli/references/workflows/operations.md +211 -0
  159. package/plugins/sp/skills/spur-cli/references/workflows/validation-and-extension.md +129 -0
  160. package/plugins/sp/skills/spur-cli/references/workflows.md +355 -0
  161. package/plugins/sp/skills/spur-dev/SKILL.md +224 -0
  162. package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +196 -0
  163. package/plugins/sp/skills/spur-dev/references/cross-cutting.md +664 -0
  164. package/plugins/sp/skills/spur-dev/references/decision-brief.md +80 -0
  165. package/plugins/sp/skills/spur-dev/references/dev-operations.md +546 -0
  166. package/plugins/sp/skills/spur-dev/references/done-housekeeping.md +164 -0
  167. package/plugins/sp/skills/spur-dev/references/execution-batch.md +727 -0
  168. package/plugins/sp/skills/spur-dev/references/execution-workflow.md +350 -0
  169. package/plugins/sp/skills/spur-dev/references/feature-link-helper.md +191 -0
  170. package/plugins/sp/skills/spur-dev/references/flag-glossary.md +417 -0
  171. package/plugins/sp/skills/spur-dev/references/gate-checklists.md +171 -0
  172. package/plugins/sp/skills/spur-dev/references/glossary.md +95 -0
  173. package/plugins/sp/skills/spur-dev/references/idea-evaluation.md +80 -0
  174. package/plugins/sp/skills/spur-dev/references/inline-pipeline-driver.md +88 -0
  175. package/plugins/sp/skills/spur-dev/references/planning-workflow.md +302 -0
  176. package/plugins/sp/skills/spur-dev/references/product-planning.md +206 -0
  177. package/plugins/sp/skills/spur-dev/references/section-batching.md +24 -0
  178. package/plugins/sp/skills/sys-architecture/SKILL.md +155 -0
  179. package/plugins/sp/skills/sys-architecture/references/decision-method.md +137 -0
  180. package/plugins/sp/skills/sys-architecture/references/upkeep-survey.md +75 -0
  181. package/plugins/sp/skills/sys-debugging/SKILL.md +228 -0
  182. package/plugins/sp/skills/sys-debugging/references/debugging-protocol.md +62 -0
  183. package/plugins/sp/skills/test-driven-development/SKILL.md +248 -0
  184. package/plugins/sp/skills/wayfinder/SKILL.md +292 -0
  185. package/spur.js +6093 -5180
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: dispatch-surface
3
+ description: "Decision rule for choosing the native subagent versus `spur agent run` when dispatching work to another agent. Trigger-keyed, not preference-stated."
4
+ see_also:
5
+ - parallel-execution
6
+ - fan-out-patterns
7
+ - result-synthesis
8
+ ---
9
+
10
+ # Dispatch Surface: Native Subagent vs `spur agent run`
11
+
12
+ This is the SSOT for **which execution surface carries a dispatch** to another agent. It owns
13
+ *one axis only* - in-session native subagent versus out-of-process `spur agent run`. It does not
14
+ own which model tier runs the work; that is ADR-033's `model_policy` (see [Composition with
15
+ ADR-033](#composition-with-adr-033)).
16
+
17
+ The `parallel-execution` skill already owns the dispatch *disciplines* (file-handoffs over pasted
18
+ context, per-role model selection, durable ledgers, never pre-judge the reviewer). Choosing the
19
+ surface a dispatch travels over is the same competency, so the rule lives here alongside them.
20
+
21
+ ## The default
22
+
23
+ **Use the native subagent when the host platform provides one.**
24
+
25
+ Native subagents (Claude Code `Skill()`/`Task`, Codex, OpenCode, etc.) are cheaper to spawn, share
26
+ the session's tooling and working directory, and compose with the orchestrating agent's context.
27
+ On a platform that provides them, `spur agent run` is the exception, not the default.
28
+
29
+ ## Escalation triggers to `spur agent run`
30
+
31
+ Escalate off the native subagent **only** when one of these observable conditions holds. Each is
32
+ checkable without operator judgment - if you cannot point to concrete evidence of one, stay on the
33
+ native subagent.
34
+
35
+ | # | Trigger | What it means | Example evidence |
36
+ | --- | --------- | --------------- | ------------------ |
37
+ | 1 | **Different model or coding agent required** | The step needs a model or a coding agent the host session cannot provide (`--model`, `--agent`). | "verify on o3" where the host is Claude Code; "run this through omp" from a non-omp host. |
38
+ | 2 | **Headless or unattended step** | The step must run without a live session - scheduled, detached, or driven by a non-interactive caller. | A batch launched by `spur workflow run --async` with no operator attached. |
39
+ | 3 | **Durable auditable run record required** | The dispatch must produce a persisted run record (cost ledger, trace, exit code) for after-the-fact audit. | `spur agent run` writes `.spur/run/` artifacts; a native subagent does not. |
40
+ | 4 | **Workspace or credential isolation required** | The step must run in a separate workspace, worktree, or credential scope from the orchestrating session. | A destructive step isolated to a throwaway worktree; a step that must not inherit the session's `cwd` secrets. |
41
+
42
+ ## The naming requirement
43
+
44
+ **When you escalate to `spur agent run`, name which trigger applied - in the dispatch, in the
45
+ report, or in the batch ledger.** "Used `spur agent run` because trigger 3 (durable auditable
46
+ record)" is a complete statement; "used `spur agent run`" is not.
47
+
48
+ This is what makes the choice auditable after the fact. A blanket "prefer subagents when possible"
49
+ is unfalsifiable - an agent can rationalize either surface under it, which is how
50
+ `parallel-execution/SKILL.md` drifted to telling Claude Code to fan out through `spur agent run`
51
+ on the one platform that ships native subagents. Naming one of four checkable conditions makes a
52
+ wrong choice visible in the transcript.
53
+
54
+ ## Composition with ADR-033
55
+
56
+ [ADR-033](../../../../../docs/00_ADR.md) owns **model-tier selection** through the stage registry's
57
+ `model_policy` (`min_tier` + ordered `fallback` chain, keyed on the canonical `stage_id`). This
58
+ reference owns **execution-surface selection**. The two axes are orthogonal and vary independently:
59
+
60
+ - A `cheap`-tier step can run in-session on a native subagent.
61
+ - A `capable-3`-tier step can run headless through `spur agent run`.
62
+
63
+ Do not fold surface choice into `model_policy` - that would couple two axes that vary independently
64
+ and put prompt-layer routing policy into a domain-layer registry. This reference decides *which
65
+ surface carries the work*; ADR-033 decides *which tier runs on it*. Read both; apply each to its
66
+ own axis.
67
+
68
+ ## The sandbox reliability tax on `spur agent run`
69
+
70
+ `spur agent run` runs the target agent as an external process. Under a sandboxed Bash session it
71
+ can fail outright when the external agent writes its own storage outside the sandbox's allowlist.
72
+
73
+ **Reproduced during H6 intake:**
74
+
75
+ ```text
76
+ $ spur agent run "..." --agent omp
77
+ SQLiteError: attempt to write a readonly database (SQLITE_READONLY)
78
+ at .../pi-coding-agent/dist/cli.js:2825
79
+ ```
80
+
81
+ The cause: omp writes its `AgentStorage` SQLite DB under `$HOME/node_modules/`, a path the
82
+ sandboxed Bash session holds read-only. The same failure took down the idea-pipeline's `discovery`
83
+ step (exit code 3, ~1.5s) - the step never reached the agent's logic; it died on storage init.
84
+
85
+ This is **not** a reason to abandon `spur agent run` - triggers 1-4 still justify it. It is a
86
+ reason to (a) prefer the native subagent when no trigger applies, and (b) when a trigger does
87
+ apply, ensure the run executes in a context that can write the target agent's storage (a
88
+ non-sandboxed shell, or a workspace that owns the storage path). The upstream fix lives in
89
+ pi-coding-agent's storage-path resolution; it is out of scope here and recorded as motivating
90
+ evidence only.
91
+
92
+ ## See also
93
+
94
+ - **`parallel-execution`** SKILL.md - the dispatch disciplines this rule sits beside.
95
+ - **[fan-out-patterns.md](fan-out-patterns.md)** - the four fan-out shapes; surface choice is
96
+ orthogonal to pattern choice.
97
+ - **[result-synthesis.md](result-synthesis.md)** - merging parallel outputs; applies regardless of
98
+ which surface carried each dispatch.
99
+ - **ADR-033** - model-tier routing via the stage registry; this rule composes with it, never
100
+ duplicates it.
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: fan-out-patterns
3
+ description: "Catalog of proven fan-out shapes with per-pattern token-cost estimates, when-to-use decision tables, and anti-patterns."
4
+ see_also:
5
+ - parallel-execution
6
+ - result-synthesis
7
+ ---
8
+
9
+ # Fan-Out Patterns
10
+
11
+ Four proven patterns for parallel subagent execution. Each pattern has a distinct work shape, cost profile, and result expectation. **Match the work shape to the pattern** — don't force a pattern onto mismatched work.
12
+
13
+ ## Pattern catalog
14
+
15
+ ### 1. N-way Investigation
16
+
17
+ **Use when:** One question, N independent search angles. Each subagent searches a different dimension — by file, by pattern, by subsystem, by time range. The angles are blind to each other by design (multi-modal sweep).
18
+
19
+ **Token cost:** ~N × 3k tokens per subagent + ~2k synthesis.
20
+
21
+ **Decision criteria:**
22
+
23
+ - Single question with multiple search strategies
24
+ - No dependency between search angles
25
+ - Results must be deduped (different angles may find the same thing)
26
+
27
+ **Example:** "Find all hardcoded secrets in this codebase" → subagent 1 scans by regex, subagent 2 scans by entropy, subagent 3 scans config files, subagent 4 scans CI/CD.
28
+
29
+ **Anti-pattern:** Using N-way investigation when one angle would find everything. If `rg "API_KEY"` covers 90%, don't fan out 4 ways to find the last 10% — the marginal gain doesn't justify the cost.
30
+
31
+ ### 2. Competency-Lens Review
32
+
33
+ **Use when:** One artifact (PR, diff, design doc), N review dimensions. Each subagent reviews through a single lens (correctness, security, performance, maintainability, usability). This is the pattern behind adversarial verification.
34
+
35
+ **Token cost:** ~N × 5k tokens per subagent + ~3k synthesis.
36
+
37
+ **Decision criteria:**
38
+
39
+ - Single artifact with multiple quality dimensions
40
+ - Dimensions are independent (security findings don't depend on perf findings)
41
+ - Synthesis must surface conflicts (e.g., perf improvement that weakens security)
42
+
43
+ **Example:** Code review of a PR → correctness lens, security lens, efficiency lens, maintainability lens. Each subagent produces per-lens findings; synthesis merges into a unified P1–P4 table.
44
+
45
+ **Anti-pattern:** Using competency-lens review when a single reviewer would catch everything. For a 20-line change, one thorough review beats 3 shallow ones.
46
+
47
+ ### 3. Independent-Task Batch
48
+
49
+ **Use when:** M tasks with zero dependency edges between them. Each task runs through its pipeline independently. This is the `sp:super-planner` parallel mode.
50
+
51
+ **Token cost:** ~M × 8k tokens per task + ~3k batch synthesis.
52
+
53
+ **Decision criteria:**
54
+
55
+ - Multiple tasks from the same batch
56
+ - Topo-sort confirms zero dependency edges between the selected subset
57
+ - No file-overlap conflicts (different tasks touch different files)
58
+ - Token budget supports M parallel runs
59
+
60
+ **Example:** Feature A1 decomposes into 5 tasks. Topo-sort shows tasks 2, 3, and 4 have no dependencies on each other → fan out 3-way. Tasks 1 and 5 are sequential (5 depends on 1).
61
+
62
+ **Anti-pattern:** Fanning out tasks that touch the same files. Two tasks both editing `src/auth/login.ts` WILL produce a merge conflict. Serialize or assign to one subagent.
63
+
64
+ ### 4. Adversarial Verification Panel
65
+
66
+ **Use when:** One claim needs N independent skeptics. Each subagent tries to REFUTE the claim. A claim survives if ≥2/3 affirm. This is the highest-confidence verification pattern.
67
+
68
+ **Token cost:** ~N × 4k tokens per subagent + ~2k synthesis.
69
+
70
+ **Decision criteria:**
71
+
72
+ - Single factual or testable claim
73
+ - Subagents are prompted to REFUTE (adversarial stance)
74
+ - Vote threshold: ≥ majority must affirm for the claim to survive
75
+ - Use odd N (3, 5) to avoid ties
76
+
77
+ **Example:** "This refactoring preserves all existing behavior" → 3 subagents independently try to find counterexamples. 2/3 find none → claim survives. 1/3 finds a break → claim is refuted, finding logged.
78
+
79
+ **Anti-pattern:** Using adversarial panel for subjective questions. "Is this code readable?" has no objective refutation criteria — use competency-lens review instead.
80
+
81
+ ## When-to-use decision table
82
+
83
+ | Work shape | Pattern | N recommended |
84
+ | ------------ | --------- | --------------- |
85
+ | One question, multiple search angles | N-way investigation | 3–5 |
86
+ | One artifact, multiple quality dimensions | Competency-lens review | 3–4 |
87
+ | M independent tasks | Independent-task batch | 2–8 (budget-limited) |
88
+ | One claim, need high confidence | Adversarial panel | 3–5 (odd) |
89
+ | Sequential dependency chain | **Do not fan out** | — |
90
+ | Single file touched by multiple tasks | **Do not fan out** | — |
91
+ | Token budget < 20k remaining | **Do not fan out** | — |
92
+
93
+ ## Token-budget guard
94
+
95
+ Before fanning out N subagents, check:
96
+
97
+ ```
98
+ remaining_budget >= (N × per_subagent_estimate) + synthesis_estimate
99
+ ```
100
+
101
+ If not: reduce N, or serialize. A fan-out that exhausts the budget mid-run leaves partial results that are worse than sequential. The driver is responsible for this check — the skill provides the estimates; the orchestrator applies them.
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: result-synthesis
3
+ description: "Merge/dedup/conflict-resolution strategies for parallel subagent outputs, anti-patterns, and the unified-report template."
4
+ see_also:
5
+ - parallel-execution
6
+ - fan-out-patterns
7
+ ---
8
+
9
+ # Result Synthesis
10
+
11
+ Parallel subagent outputs must be **synthesized**, not concatenated. Raw dumps from N subagents are noise; a synthesized report is signal. This reference defines the synthesis contract — the rules every fan-out pattern's merge step follows.
12
+
13
+ ## The synthesis contract
14
+
15
+ ### 1. Dedup
16
+
17
+ Merge findings that share the same `file:line` anchor. Keep the **highest-severity** version.
18
+
19
+ ```
20
+ Subagent A: src/auth.ts:42 — P2 — missing null check
21
+ Subagent B: src/auth.ts:42 — P3 — variable naming unclear
22
+
23
+ Merged: src/auth.ts:42 — P2 — missing null check (P3 naming note appended)
24
+ ```
25
+
26
+ **Rule:** same file + same line → one finding. Different lines in the same file are distinct findings.
27
+
28
+ ### 2. Resolve conflicts
29
+
30
+ When two subagents disagree on the same claim, **surface the disagreement explicitly**. Don't silently pick one.
31
+
32
+ ```
33
+ Subagent A: "The Redis migration is safe — all writes are idempotent"
34
+ Subagent B: "The Redis migration is unsafe — key TTL change breaks cache warming"
35
+
36
+ Synthesis: ⚠ CONFLICT — Redis migration safety
37
+ A: safe (writes idempotent)
38
+ B: unsafe (TTL breaks cache warming)
39
+ → Escalate to operator for resolution
40
+ ```
41
+
42
+ **Rule:** conflicts are findings, not failures. Surface them with both positions stated; let the operator resolve.
43
+
44
+ ### 3. Rank by confidence
45
+
46
+ Sort synthesized results:
47
+ 1. HIGH confidence (empirically verified, source-cited)
48
+ 2. MEDIUM confidence (reasoned, but not empirically verified)
49
+ 3. LOW confidence (heuristic, pattern-match, or uncertain)
50
+ 4. Unresolved conflicts (both sides stated)
51
+
52
+ Within each tier, sort by severity (P1 → P2 → P3 → P4).
53
+
54
+ ### 4. Unified format
55
+
56
+ Emit one coherent output. The unified report has:
57
+
58
+ ```
59
+ ## Synthesized Results
60
+
61
+ ### HIGH Confidence
62
+ | # | Finding | Source | Severity | File:Line |
63
+ |---|---------|--------|----------|-----------|
64
+
65
+ ### MEDIUM Confidence
66
+ ...
67
+
68
+ ### Conflicts (unresolved)
69
+ ...
70
+
71
+ ### Dropped (deduped into higher-severity)
72
+ ...
73
+
74
+ **Synthesis stats:** N subagents, M raw findings, K after dedup, J conflicts
75
+ ```
76
+
77
+ ## Anti-patterns
78
+
79
+ | Anti-pattern | Why it fails | Fix |
80
+ |-------------|-------------|-----|
81
+ | **Silent truncation** | "10 items found" but only 8 reported — 2 silently dropped | Always report total → after-dedup counts; document what was dropped and why |
82
+ | **Raw concatenation** | Pasting N subagent outputs end-to-end without merging | Apply the synthesis contract: dedup → resolve → rank → format |
83
+ | **Majority-wins on facts** | "3 subagents say X, 1 says Y → X is correct" — but Y has the evidence | Weight by evidence, not count. One subagent with a repro wins over three without |
84
+ | **Synthesis without audit** | Merged report with no trace of which subagent found what | Every synthesized finding carries a `Source` column naming the originating subagent |
85
+ | **Conflicts resolved silently** | Two opposing findings merged into one without surfacing the disagreement | Conflicts are an explicit section in the unified report |
86
+
87
+ ## Synthesis cost
88
+
89
+ Budget ~2k tokens for synthesis per pattern. The synthesis step is:
90
+ 1. Read all subagent outputs (cached from their runs)
91
+ 2. Apply dedup + conflict detection
92
+ 3. Emit unified report
93
+
94
+ Don't re-run subagents during synthesis — their outputs are the input. If a subagent output is malformed or empty, log it as a **dropped subagent** in the synthesis stats.
@@ -0,0 +1,375 @@
1
+ ---
2
+ name: reverse-engineering
3
+ description: "Depth-driven codebase reverse engineering with orthogonal mode, focus, and output format controls. Use for unfamiliar codebases, architecture/design reconstruction, onboarding docs, technical debt assessment, and evidence-backed audit reports."
4
+ license: Apache-2.0
5
+ version: 1.1.0
6
+ created_at: 2026-03-28
7
+ updated_at: 2026-07-09
8
+ tags: [analysis-core, reverse-engineering, hld, audit, codebase-analysis, architecture, design]
9
+ metadata:
10
+ author: cc-agents
11
+ platforms: "claude-code,codex,openclaw,opencode,antigravity,pi"
12
+ category: analysis-core
13
+ interactions:
14
+ - pipeline
15
+ - reviewer
16
+ severity_levels:
17
+ - critical
18
+ - high
19
+ - medium
20
+ pipeline_steps:
21
+ - orient
22
+ - index
23
+ - classify
24
+ - trace
25
+ - synthesize
26
+ - audit
27
+ openclaw:
28
+ emoji: "🔍"
29
+ see_also:
30
+ - sp:source-driven-development
31
+ ---
32
+
33
+ # sp:reverse-engineering — Codebase Reverse Engineering
34
+
35
+ Analyze unfamiliar or under-documented codebases and reconstruct their current state with evidence. The skill separates three controls:
36
+
37
+ 1. **Mode**: analysis depth.
38
+ 2. **Focus**: analysis lens.
39
+ 3. **Format**: output encoding.
40
+
41
+ Mode must not mix action verbs, subject areas, or serialization formats. For example, `json` is a format, not a mode; `data` is a focus, not a mode; `scan` is an internal action, not a user-facing depth.
42
+
43
+ ## When to Use
44
+
45
+ **Use PROACTIVELY when:**
46
+
47
+ - User shares an unfamiliar codebase or repo URL.
48
+ - User asks what a project does, how it is structured, or how it runs.
49
+ - User requests HLD, architecture docs, system design docs, ER diagrams, sequence diagrams, or onboarding docs.
50
+ - User needs a technical debt, security, maintainability, performance, or architecture audit.
51
+ - User wants to understand current state before refactoring.
52
+
53
+ **Do NOT use for:**
54
+
55
+ - Implementing code changes. Use `sp:code-implementation`.
56
+ - Debugging a specific runtime failure. Use `sp:sys-debugging`.
57
+ - Writing tests. Use `sp:test-driven-development`.
58
+ - Quick structural code search. Use grep/glob tools directly.
59
+ - Creating indexed context files. This skill may read `.spur/context/` context, but it must not create or mutate it.
60
+
61
+ ## Control Model
62
+
63
+ ### Mode: Analysis Depth
64
+
65
+ | Mode | Complexity | Purpose | Required Outputs | Optional Outputs |
66
+ |---|---:|---|---|---|
67
+ | `briefing` | 1 | Fast executive reconnaissance for "what is this repo?" | purpose hypothesis, tech stack, repo archetype, entry points, key manifests, top 3 risks/unknowns | dependency highlights |
68
+ | `structure` | 2 | Static repository and component map | repository tree summary, module/component table, ownership/boundary notes, dependency map, entry point map | simple component diagram |
69
+ | `architecture` | 3 | Runtime and system architecture documentation | architecture pattern, system context diagram, runtime topology, major flows, cross-cutting concerns, integration map | deployment view, sequence diagrams for main flows |
70
+ | `design` | 4 | Detailed design reconstruction for implementation understanding | architecture summary, data model, API/command/interface contracts, domain model, important sequence diagrams, ER diagram when data evidence exists | class/UML-style diagram, failure modes |
71
+ | `full` | 5 | Comprehensive reverse-engineering package | all `design` outputs plus quality/security audit, modernization roadmap, open questions, evidence index, machine-readable summary | per-module deep dives |
72
+
73
+ ### Focus: Analysis Lens
74
+
75
+ Focus changes emphasis, not depth.
76
+
77
+ | Focus | Effect |
78
+ |---|---|
79
+ | `all` | Balanced coverage for the selected mode. Default. |
80
+ | `stack` | Emphasize languages, frameworks, package managers, runtimes, build tooling, and deploy tooling. |
81
+ | `dependencies` | Emphasize internal and external dependency graph, integration points, and coupling. |
82
+ | `data` | Emphasize persistence, schemas, models, repositories, migrations, and ER diagram evidence. |
83
+ | `flows` | Emphasize request, command, job, event, or business process traces and sequence diagrams. |
84
+ | `api` | Emphasize HTTP routes, RPC surfaces, CLI commands, events, SDKs, and public contracts. |
85
+ | `security` | Emphasize auth, authorization, secrets, validation, injection risk, and exposure boundaries. |
86
+ | `quality` | Emphasize maintainability, complexity, dead code, duplication, testability, and refactoring seams. |
87
+ | `performance` | Emphasize hot paths, blocking I/O, caching, query patterns, and scalability risks. |
88
+
89
+ ### Format: Output Encoding
90
+
91
+ | Format | Purpose |
92
+ |---|---|
93
+ | `markdown` | Human-readable report. Default. |
94
+ | `json` | Machine-readable summary for downstream skills or automation. |
95
+ | `both` | Markdown report plus JSON summary block or output file. |
96
+
97
+ ## Mode Selection Algorithm
98
+
99
+ 1. Parse explicit arguments if provided:
100
+ - `--mode briefing|structure|architecture|design|full`
101
+ - `--focus all|stack|dependencies|data|flows|api|security|quality|performance`
102
+ - `--format markdown|json|both`
103
+ 2. If mode is missing, infer it from user intent:
104
+ - "what is this", "quick overview", "what stack" -> `briefing`
105
+ - "repo structure", "module map", "component map" -> `structure`
106
+ - "architecture", "HLD", "system design" -> `architecture`
107
+ - "ER diagram", "data model", "sequence diagram", "API contract", "detailed design" -> `design`
108
+ - "reverse engineer everything", "full audit", "complete docs" -> `full`
109
+ 3. If focus is missing, infer it from user intent:
110
+ - stack/runtime/tooling -> `stack`
111
+ - dependencies/integrations/coupling -> `dependencies`
112
+ - database/schema/model/repository -> `data`
113
+ - workflow/request lifecycle/business process -> `flows`
114
+ - routes/endpoints/commands/events/contracts -> `api`
115
+ - security/auth/secrets/validation -> `security`
116
+ - tech debt/maintainability/refactor -> `quality`
117
+ - latency/scalability/caching/queries -> `performance`
118
+ - otherwise -> `all`
119
+ 4. If format is missing:
120
+ - Use `json` only when the user explicitly asks for machine-readable output.
121
+ - Use `both` when the user asks for a report and reusable structured data.
122
+ - Otherwise use `markdown`.
123
+ 5. If ambiguity remains, choose the lowest depth that can satisfy the request. Prefer `architecture` for generic "analyze this codebase".
124
+
125
+ ## Analysis Workflow
126
+
127
+ Execute phases in order. Stop at the phase boundary required by the selected mode unless focus or evidence requires a deeper targeted read.
128
+
129
+ ### Phase 1: Orient
130
+
131
+ 1. Identify project root and target path.
132
+ 2. Check whether `.spur/context/anatomy.md` exists.
133
+ 3. Locate manifests and config files: `package.json`, `bun.lockb`, `go.mod`, `Cargo.toml`, `pyproject.toml`, `requirements.txt`, `pom.xml`, `build.gradle`, Docker/Kubernetes files, CI files.
134
+ 4. Identify likely language, framework, package manager, runtime, and deploy model.
135
+ 5. Record uncertainty when inferred from naming or layout rather than manifest evidence.
136
+
137
+ ### Phase 2: Index
138
+
139
+ 1. If `.spur/context/anatomy.md` exists, use it to prioritize reads and reduce token usage.
140
+ 2. Otherwise use file search to build a bounded map of source, config, tests, scripts, docs, migrations, and generated/vendor directories.
141
+ 3. Exclude or de-prioritize generated, vendored, build output, dependency cache, lockfile-only, binary-heavy, and snapshot-heavy paths unless they are directly relevant.
142
+ 4. For monorepos, identify packages/apps and either ask for scope or analyze each package at the requested depth if feasible.
143
+
144
+ ### Phase 3: Classify
145
+
146
+ Classify the codebase as one or more archetypes:
147
+
148
+ - frontend SPA / SSR / static site
149
+ - backend API / worker / service
150
+ - fullstack app
151
+ - CLI tool
152
+ - library / framework
153
+ - plugin system
154
+ - infrastructure repo
155
+ - monorepo
156
+ - mixed or unclear
157
+
158
+ Include evidence for classification, such as manifest scripts, entry files, route definitions, command declarations, exports, Docker entrypoints, or package layout.
159
+
160
+ ### Phase 4: Trace
161
+
162
+ Trace only as deeply as the selected mode requires:
163
+
164
+ - `briefing`: entry points and obvious high-level modules.
165
+ - `structure`: module boundaries, package graph, and dependency direction.
166
+ - `architecture`: runtime topology, integrations, main flows, cross-cutting concerns.
167
+ - `design`: data model, interfaces/contracts, sequence flows, domain model, failure modes.
168
+ - `full`: design-level tracing plus audit, roadmap, open questions, and evidence index.
169
+
170
+ ### Phase 5: Synthesize
171
+
172
+ Generate the selected format. Every factual claim about stack, entry points, modules, data, flows, APIs, integrations, and risks must include evidence when source files are available.
173
+
174
+ ### Phase 6: Audit
175
+
176
+ Run audit analysis when:
177
+
178
+ - mode is `full`
179
+ - focus is `security`, `quality`, `performance`, or `all` at `architecture` depth or deeper
180
+ - user explicitly requests audit, risk, technical debt, or review
181
+
182
+ Audit categories:
183
+
184
+ | Category | What to Find | Evidence Required |
185
+ |---|---|---|
186
+ | Security | hardcoded secrets, unsafe auth, missing authorization, injection risks, unsanitized external input, exposed endpoints | `file/path:line` |
187
+ | Correctness | broken control flow, invalid assumptions, race conditions, missing error handling, data loss paths | `file/path:line` |
188
+ | Performance | N+1 queries, blocking I/O, unbounded loops, missing caching, inefficient hot paths | `file/path:line` or measured metric |
189
+ | Maintainability | oversized modules, circular dependencies, dead code, duplication, fragile abstractions | `file/path:line` or file metrics |
190
+ | Architecture | tight coupling, unclear boundaries, leaky layers, missing abstractions, inconsistent module ownership | multiple file references |
191
+
192
+ ## Output Contracts
193
+
194
+ ### `briefing`
195
+
196
+ ```markdown
197
+ # Codebase Briefing: [Project]
198
+
199
+ | Field | Value |
200
+ |---|---|
201
+ | Analysis Date | YYYY-MM-DD |
202
+ | Target | `path` |
203
+ | Mode / Focus / Format | `briefing` / `[focus]` / `markdown` |
204
+ | Confidence | High / Medium / Low |
205
+
206
+ ## Purpose Hypothesis
207
+
208
+ [1-3 sentences with evidence]
209
+
210
+ ## Tech Stack
211
+
212
+ | Layer | Technology | Evidence | Confidence |
213
+ |---|---|---|---|
214
+
215
+ ## Entry Points
216
+
217
+ | Entry | Purpose | Evidence |
218
+ |---|---|---|
219
+
220
+ ## Top Risks / Unknowns
221
+
222
+ | Risk | Why It Matters | Evidence / Gap |
223
+ |---|---|---|
224
+ ```
225
+
226
+ ### `structure`
227
+
228
+ Required sections:
229
+
230
+ - Briefing summary
231
+ - Repository map
232
+ - Module/component table
233
+ - Entry point map
234
+ - Dependency map
235
+ - Boundary notes
236
+ - Optional component diagram
237
+
238
+ ### `architecture`
239
+
240
+ Required sections:
241
+
242
+ - Executive summary
243
+ - Architecture pattern
244
+ - System context diagram
245
+ - Runtime topology
246
+ - Component responsibilities
247
+ - Integration map
248
+ - Main flows
249
+ - Cross-cutting concerns
250
+ - Architecture risks
251
+
252
+ ### `design`
253
+
254
+ Required sections:
255
+
256
+ - Architecture summary
257
+ - Domain model
258
+ - Data model and ER diagram when evidence exists
259
+ - API/command/event/interface contracts
260
+ - Sequence diagrams for important flows
261
+ - Class/module relationship diagram when source structure supports it
262
+ - Failure modes and operational assumptions
263
+
264
+ ### `full`
265
+
266
+ Required sections:
267
+
268
+ - All `design` sections
269
+ - Security, correctness, performance, maintainability, and architecture audit
270
+ - Prioritized remediation roadmap
271
+ - Open questions and unknowns
272
+ - Evidence index
273
+ - Machine-readable summary if requested or useful for downstream skills
274
+
275
+ ### JSON Summary Schema
276
+
277
+ Use this shape for `--format json` or `--format both`. Omit fields only when the evidence is unavailable and include an `unknowns` entry explaining why.
278
+
279
+ ```json
280
+ {
281
+ "target": "path",
282
+ "analysisDate": "YYYY-MM-DD",
283
+ "mode": "architecture",
284
+ "focus": "all",
285
+ "confidence": "high|medium|low",
286
+ "stack": [],
287
+ "entryPoints": [],
288
+ "components": [],
289
+ "dependencies": [],
290
+ "dataModel": [],
291
+ "interfaces": [],
292
+ "flows": [],
293
+ "risks": [],
294
+ "unknowns": [],
295
+ "evidence": []
296
+ }
297
+ ```
298
+
299
+ ## Evidence Rules
300
+
301
+ - Cite `file/path:line` for claims derived from source files.
302
+ - Cite manifest paths for stack and package manager claims.
303
+ - Cite multiple files for architectural boundary claims when possible.
304
+ - Mark inferred claims with `Confidence: Medium` or `Confidence: Low`.
305
+ - Never invent services, databases, tables, endpoints, actors, diagrams, or business flows that are not supported by evidence.
306
+ - If line numbers are unavailable from a tool, cite the file path and state that line numbers were not available.
307
+
308
+ ## Diagram Rules
309
+
310
+ Use Mermaid only. Every diagram must be syntactically valid and must reflect evidence.
311
+
312
+ | Diagram | Mermaid Type | When to Use |
313
+ |---|---|---|
314
+ | System context / component topology | `flowchart LR` or `graph TD` | `structure`, `architecture`, `design`, `full` |
315
+ | Runtime or business flow | `sequenceDiagram` | `architecture`, `design`, `full`, or focus `flows` |
316
+ | Data model | `erDiagram` | focus `data`, `design`, `full` when schema/model evidence exists |
317
+ | Class/module relationship | `classDiagram` | `design` or `full` when source types/classes support it |
318
+
319
+ Fallback behavior:
320
+
321
+ - If data evidence is missing, write "No reliable ER diagram can be produced from available evidence."
322
+ - If a sequence cannot be traced end-to-end, diagram only the observed partial flow and mark missing links.
323
+ - If class-level structure is too dynamic or not class-based, use a component graph instead of forcing `classDiagram`.
324
+
325
+ ## Indexed Context Integration
326
+
327
+ The indexed-context layer is optional and opportunistic.
328
+
329
+ 1. If `.spur/context/anatomy.md` exists, read it before raw file reads to prioritize high-value files.
330
+ 2. If `.spur/context/learnings.md` exists, use it only for project preferences and known context.
331
+ 3. If `.spur/context/buglog.md` exists, use it only as supporting evidence for known bug history.
332
+ 4. Do not create, update, or require `.spur/context/` files.
333
+ 5. Verify final claims against source files whenever source files are available.
334
+ 6. If `.spur/context/` is absent, proceed normally without warning unless the user explicitly requested indexed context.
335
+
336
+ ## Edge Cases
337
+
338
+ | Scenario | Handling |
339
+ |---|---|
340
+ | Empty/minimal codebase | Return `briefing` with "insufficient evidence", list missing artifacts, suggest next files needed. |
341
+ | Monorepo | Identify packages/apps; ask for scope unless `--auto` or requested mode can safely summarize all packages. |
342
+ | No clear entry point | List candidates with confidence and evidence; do not choose one as definitive. |
343
+ | Binary-heavy repo | Focus on manifests, scripts, config, docs, and visible source. |
344
+ | Generated/vendor-heavy repo | Exclude generated/vendor paths from architecture conclusions unless directly relevant. |
345
+ | Framework convention over configuration | State inferred convention and cite framework-specific file patterns. |
346
+ | Multiple languages/stacks | Report each stack separately and identify integration boundaries. |
347
+ | Missing data/schema evidence | Skip ER diagram or mark as partial. |
348
+ | Huge codebase | Produce staged output: briefing first, then deeper sections by package or focus. |
349
+
350
+ ## Severity Definitions
351
+
352
+ | Severity | Criteria | Examples |
353
+ |---|---|---|
354
+ | Critical | Security risk, data loss potential, exploitable vulnerability, blocking correctness bug | SQL injection, hardcoded credentials, destructive race condition |
355
+ | High | Significant reliability, performance, maintainability, or architecture risk | N+1 query in hot path, missing auth boundary, unbounded queue growth |
356
+ | Medium | Meaningful improvement with bounded blast radius | duplication, unclear ownership, weak typing at boundary |
357
+ | Low | Cosmetic or local maintainability issue | naming inconsistency, minor docs gap |
358
+
359
+ ## Platform Notes
360
+
361
+ ### Claude Code
362
+
363
+ - Use available Read/Glob/Grep/LSP tools for evidence.
364
+ - For large codebases, analyze orientation and audit concerns in parallel when platform delegation is available.
365
+ - Keep final claims evidence-backed; do not rely on memory alone.
366
+
367
+ ### Codex / OpenClaw / OpenCode / Antigravity / Pi
368
+
369
+ - Prefer `rg` and `rg --files` for scanning.
370
+ - Use structural tools such as `ast-grep` when available for route, class, function, and import discovery.
371
+ - Do not advertise direct analyzer scripts unless such scripts exist in this skill directory.
372
+
373
+ ## Additional Resources
374
+
375
+ - **Claim verification**: `sp:source-driven-development`