@gobing-ai/spur 0.3.40 → 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,176 @@
1
+ ---
2
+ name: code-implementation
3
+ description: "The implementation competency — turn a task's requirements, AC, and design into production code: task-driven scope, stack-pattern selection, root-cause debugging, a Solution change-map. Triggers: \"implement\", \"write code\", \"add feature\", \"fix the bug\", \"refactor\", \"code this task\"."
4
+ license: Apache-2.0
5
+ metadata:
6
+ author: spur
7
+ version: "1.0"
8
+ platforms: "claude-code,codex,openclaw,opencode,antigravity"
9
+ interactions:
10
+ - technique
11
+ competency: implementation
12
+ openclaw:
13
+ emoji: "⚙️"
14
+ ---
15
+
16
+ # code-implementation — the implementation competency
17
+
18
+ Turn a task's requirements, acceptance criteria, and design into production code. This is the deep
19
+ competency the spine (`sp:spur-dev`) dispatches to at its `implement` step — it owns
20
+ *how to implement well*, not *when to implement* (the spine decides that). Every deterministic write
21
+ to the corpus still goes through `spur task update` (the CLI-gated write contract in
22
+ `sp:spur-dev`'s `cross-cutting.md`).
23
+
24
+ ## When to use
25
+
26
+ - **New implementation** — write the code for a task whose requirements and design are settled.
27
+ - **Bug fixes** — reproduce, isolate root cause, fix the cause not the symptom (see debugging).
28
+ - **Refactors with test safety** — restructure behind passing tests.
29
+ - **The pipeline's `implement` step** — `/sp:dev-run --mode implement <wbs>` dispatches here.
30
+
31
+ Do **not** use this skill for:
32
+
33
+ - **Coverage / gap analysis / test extension** — that is `sp:code-testing`.
34
+ - **Test-first discipline (red-green-refactor)** — that is `sp:test-driven-development` (composed with this skill).
35
+ - **System design / architecture decisions** — that is `sp:sys-architecture` (decide the shape first).
36
+ - **Review / verification** — that is `sp:code-verification`.
37
+ - **Driving the lifecycle** — that is the spine, `sp:spur-dev`.
38
+ - **Re-launching the task pipeline from inside implement** — see anti-recursion below (bug-742).
39
+
40
+ ## Anti-recursion (pipeline implement step — bug-742)
41
+
42
+ When this skill is entered via `/sp:dev-run --mode implement <wbs>` (the form
43
+ `task-pipeline.yaml` `implement` uses as a **pure slash command** — ADR-043):
44
+
45
+ 1. Work **only** in the current working tree on that WBS. Implement code + author `## Solution`.
46
+ 2. **NEVER invoke** `spur workflow run` for `task-pipeline.yaml` (or any full task pipeline).
47
+ 3. **NEVER invoke** `/sp:dev-run` **without** an explicit `--mode implement`. Omitting the mode
48
+ defaults to full pipeline and **recurses** into another `implement` step (bug-742).
49
+ 4. Do **not** call `/sp:dev-runall`, `/sp:dev-verify`, or other lifecycle stages from inside this
50
+ skill — the pipeline (or `--next` chain) owns those hops.
51
+
52
+ The structural guard is the slash form itself (`--mode implement`). Prose in the workflow YAML
53
+ `agent.run` `input` is the wrong place for this rule; it belongs here and in `dev-run.md`.
54
+
55
+ ## One WBS per implement pass (task 0487 R1)
56
+
57
+ The target WBS is the **only** task you implement. Sibling tasks in the corpus are context you do
58
+ not have and work you were not asked to do.
59
+
60
+ - **Read** the target task file, the tasks named in its `dependencies`, its `feature_id` feature
61
+ file, and the source files its Requirements / Design / Plan name. That is the whole input set.
62
+ - **Ignore every other `todo` / `wip` task in the tree**, including ones whose files changed
63
+ recently. A task that looks half-finished is not an invitation — a freshly *committed* task can
64
+ legitimately still be `status: todo` because its verify/wrap hops have not run yet.
65
+ - **Never implement a requirement belonging to another WBS**, even when it looks like a
66
+ prerequisite. If the target genuinely cannot proceed without it, stop and say so — a blocked task
67
+ is a cheap finding; a two-task diff costs the reverts.
68
+
69
+ Why this is a rule and not a nicety: driving task 0486 lost several hours to exactly this. Task 0485
70
+ was committed but still `todo` in the tree, and two different executors (omp run `ca130182`, claude
71
+ run `b16bfbf4`) each pulled 0485's observability feature and its tests into 0486's diff, unprompted.
72
+ A third agent reproduced it. The scope creep had to be detected and reverted four times.
73
+
74
+ The pipeline enforces this on the way out: the implement step's `requireDiff` gate also checks diff
75
+ *scope* against the files and explicit directory/glob prefixes the task body backticks, and routes
76
+ the run to `failed` naming any file outside them (new files beside a declared file are allowed;
77
+ bypass: run var `implementScopeGuard: "off"`). It compares snapshots taken immediately before and
78
+ after dispatch, so dirt already in the tree is not attributed to this pass. Keeping the diff to one task's
79
+ surfaces is what keeps that gate quiet.
80
+
81
+ ## Implement scope: do not run the project quality gate
82
+
83
+ During implement, the pipeline's `test` hop runs `${vars.qualityGateCmd}` (the full project gate:
84
+ `bun run format && bun run spur-check`) immediately after this step and is the gate that actually
85
+ decides pass/fail. Running it inside implement is pure redundancy — it cannot change the outcome and
86
+ only burns wall clock and context budget.
87
+
88
+ - **Run only targeted probes** to validate your changes: `bun test <file>`,
89
+ `bun test <file> --test-name-pattern "<test>"`, or `bunx tsc --noEmit` on a single package.
90
+ - **NEVER run** `bun run test`, `bun run spur-check`, `bun run check`, or any other full-suite /
91
+ project-gate command from inside implement. These belong to the pipeline's `test` hop.
92
+ - If a targeted probe reveals a failure you cannot fix within implement scope, note it in
93
+ `## Solution` and let the `test` hop's fixall handle it — do not pre-empt the gate.
94
+
95
+ ## Behavior
96
+
97
+ This skill behaves as a **technique**: given a task (read its Background, AC, Design, Plan), it maps
98
+ requirements to files, picks the narrowest verification, implements in small slices fixing root
99
+ causes, and writes a `## Solution` change-map via `spur task update`. It implements **only** behavior
100
+ that traces to the task's AC or design — adjacent cleanup is recorded as a follow-up, not folded in.
101
+
102
+ Full procedure: **[references/implementation-patterns.md](references/implementation-patterns.md)** —
103
+ preconditions, task-driven scope, pattern selection, progress persistence, handoff to testing/review.
104
+
105
+ ## Composition with the discipline + test skills
106
+
107
+ - **`sp:test-driven-development`** — when the work is test-first, this skill composes with the TDD discipline:
108
+ TDD designs the failing test, this skill writes the minimal code to pass it.
109
+ - **`sp:code-testing`** — after implementation, coverage/gap work runs there. The per-stack adapters
110
+ (`stacks/<stack>.md`) that name build/test commands and idioms live in `code-testing` (operationally
111
+ loaded by its detect→load→run flow); reference them cross-skill when you need the stack's idioms.
112
+
113
+ ## Debugging
114
+
115
+ When implementation hits a failing gate, a failing test, a runtime defect, or flaky behavior, switch
116
+ to the root-cause-first workflow: **[references/debugging.md](references/debugging.md)** —
117
+ reproduce → isolate → minimal fix → regression guard.
118
+
119
+ ## Common Rationalizations
120
+
121
+ | Rationalization | Reality |
122
+ |---|---|
123
+ | "The spec is clear — I don't need to read the callers." | Code that looks orthogonal is how regressions ship (R5). Read the exports you touch and their immediate callers before writing. |
124
+ | "I'll add the tests in a follow-up." | Untested production code is unverified code. The task's test step is not optional; behavior ships with its test. |
125
+ | "This abstraction will be useful later." | Speculative abstraction is complexity without a caller (R2). Build for the requirement in front of you; add the seam when the second use arrives. |
126
+ | "Close enough to the AC — the intent is there." | "Close enough" is a FAIL at verify. Implement to the literal AC; if the AC is wrong, fix the AC, don't approximate it. |
127
+ | "I'll improve this adjacent code while I'm here." | Drive-by edits widen the diff and the blast radius (R3). Stay in scope; split unrelated cleanup into its own task. |
128
+ | "Task 0485 is still `todo` and clearly unfinished — I'll finish it while I'm in here." | It is not your WBS. `todo` often just means the verify/wrap hops have not run yet. Implementing it costs the reverts and fails the scope guard (0487 R1). |
129
+ | "It compiles and runs, so it's done." | Compiling is not the bar. Done is the AC met, tests green, and the `## Solution` change-map written. |
130
+
131
+ ## Red Flags
132
+
133
+ - Writing code without having read the immediate callers of what you're changing.
134
+ - A `## Solution` section that lists files but not what changed or why.
135
+ - A `## Solution` section with file references that are not in backtick `` `path:line` `` form (L3 requirement: `` `packages/app/src/foo.ts:123` `` or `` `packages/app/src/bar.ts:10-20` ``; paths from repo root).
136
+ - A new abstraction with exactly one caller and no second use in sight.
137
+ - The diff touches files unrelated to the task's scope.
138
+ - The diff touches another WBS's surfaces, or the pass reads sibling `todo` / `wip` task files.
139
+ - "Done" claimed with no test run pasted.
140
+ - Silently changing an AC's meaning to match what was built.
141
+ - From implement mode: launching `spur workflow run …task-pipeline…` or `/sp:dev-run` without
142
+ `--mode implement` (recursive pipeline — bug-742).
143
+
144
+ ## Gotchas
145
+
146
+ 1. **The task is the scope.** Implement only what traces to AC/design; record adjacent cleanup as a
147
+ follow-up WBS rather than expanding the change.
148
+ 2. **Root cause, not symptom.** A green gate reached by suppressing a check is not done.
149
+ 3. **Never let a partial deliverable look complete.** Mark deferred requirements visibly in Solution
150
+ and Review with the follow-up WBS.
151
+ 4. **The spine owns the lifecycle.** This skill writes `## Solution`; status transitions and the
152
+ other sections are the spine's / other competencies' concern.
153
+ 5. **Implement is not the pipeline driver.** Pipeline YAML may only pass the pure slash
154
+ `/sp:dev-run --mode implement <wbs> …` (ADR-043). If anti-recursion text is missing from the
155
+ skill/command and you are tempted to paste it into YAML `input:`, put it here instead.
156
+
157
+ ## See also
158
+
159
+ - **`sp:spur-dev`** — the spine that dispatches this competency at the `implement` step.
160
+ - **`sp:code-testing`** — coverage and test extension; owns the per-stack adapters.
161
+ - **`sp:test-driven-development`** — the test-first discipline this skill composes with.
162
+ - **`sp:sys-architecture`** — decide the design/shape before implementing it.
163
+ - **[Verification Before Completion](../spur-dev/references/cross-cutting.md#verification-before-completion)** — no "done / passing / fixed" claim without fresh, pasted evidence run this turn.
164
+
165
+ ## Platform Notes
166
+
167
+ ### Claude Code
168
+
169
+ Invoked via `/sp:dev-run --mode implement <wbs>` (which the pipeline's `implement` step calls), or
170
+ directly via `Skill(skill="sp:code-implementation", args="<wbs>")`. Deterministic writes use the
171
+ `spur` CLI via the Bash tool.
172
+
173
+ ### Codex / OpenClaw / OpenCode / Antigravity
174
+
175
+ Invoke this skill directly for implementation technique; run the `spur` CLI via the Bash tool for
176
+ corpus writes. The skill is the SSOT; commands and the pipeline step are thin wrappers.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: debugging
3
+ description: "Root-cause-first debugging workflow for failed gates, failing tests, runtime defects, and flaky behavior during the sp execution loop."
4
+ see_also:
5
+ - code-implementation
6
+ - code-testing
7
+ - code-verification
8
+ ---
9
+
10
+ # Debugging
11
+
12
+ Use this reference when the execution loop hits an unexplained failure: a test fails for an unclear
13
+ reason, a runtime error appears, behavior is intermittent, or repeated fixes expose new failures.
14
+ The rule is simple: **root cause before fix**. Do not patch the symptom just to move the pipeline.
15
+
16
+ ## When To Switch Into Debugging
17
+
18
+ Switch from implementation or testing into debugging when any of these happen:
19
+
20
+ - a test failure is not explained by the current requirement change
21
+ - a command fails differently after a fix attempt
22
+ - behavior is intermittent or timing-dependent
23
+ - a regression appears after a recent change
24
+ - two fix attempts fail to move the same gate
25
+ - the observed symptom is far from the code that was changed
26
+
27
+ If three fixes fail consecutively, stop implementation and reframe. That usually means the defect is
28
+ in an assumption, seam, or test setup, not in the line being edited.
29
+
30
+ ## Four-Phase Workflow
31
+
32
+ 1. **Capture the symptom.** Preserve the exact command, error message, stack trace, input, and
33
+ environment. If you cannot reproduce it, you cannot verify the fix.
34
+ 2. **Trace to origin.** Start where the error appears, then follow the data and call chain backward:
35
+ what called this, what value was passed, where did that value originate?
36
+ 3. **Test one hypothesis.** State one cause, predict what evidence should change, then run the
37
+ smallest probe. Change one variable at a time.
38
+ 4. **Fix at the source.** Add or update a regression test first when practical, apply the smallest
39
+ source fix, then run the narrow test and the relevant wider gate.
40
+
41
+ ## Failure Taxonomy
42
+
43
+ | Pattern | Signal | Debug Strategy |
44
+ |---------|--------|----------------|
45
+ | Null or undefined propagation | type/null error at a downstream call | Trace return values upward; validate at the boundary that introduced the value. |
46
+ | Race or ordering bug | intermittent failure, timing sensitivity | Add deterministic synchronization; avoid sleeps as proof. |
47
+ | State corruption | output is wrong after shared mutable state changes | Isolate mutation points; prefer immutable or copied state at seams. |
48
+ | Type/shape mismatch | field access fails or logic takes the wrong branch | Resolve the actual type definition; add a parser/guard at input boundaries. |
49
+ | Config drift | works locally but not in another environment | Centralize config loading; validate expected keys and paths at startup. |
50
+ | Resource leak | degrades over time, hangs, or leaves handles open | Check acquisition/release pairs on every path. |
51
+ | N+1 or repeated I/O | slow request or command with repeated calls | Batch, cache, or move lookup outside loops. |
52
+
53
+ ## Evidence Standard
54
+
55
+ Every debugging handoff or solution note should include:
56
+
57
+ - failing command or reproduction input
58
+ - root cause, not just symptom
59
+ - evidence that confirmed it
60
+ - fix applied
61
+ - verification command and result
62
+
63
+ Do not claim "fixed" from a green narrow probe alone when the defect class could affect the wider
64
+ gate. Run the smallest meaningful wider check before handing back to the pipeline.
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: implementation-patterns
3
+ description: "Production implementation discipline for the sp execution loop: task-driven scope, branch/worktree hygiene, stack pattern selection, progress persistence, and handoff."
4
+ see_also:
5
+ - code-implementation
6
+ - code-testing
7
+ ---
8
+
9
+ # Implementation Patterns
10
+
11
+ This reference is the core of the `code-implementation` competency skill — the discipline the
12
+ spine's `implement` step dispatches to. It is not a separate command: deterministic writes still go
13
+ through `spur task update`, and the spine (`sp:spur-dev`) owns the lifecycle that invokes this skill.
14
+
15
+ ## Preconditions
16
+
17
+ Before writing code:
18
+
19
+ 1. Read the task's Background, Acceptance Criteria, Design, and Plan.
20
+ 2. Confirm the task is small enough to implement as one coherent change. If it is not, split or
21
+ create follow-up tasks before coding.
22
+ 3. Check the worktree and branch. Avoid mixing unrelated changes into the implementation evidence.
23
+ 4. Identify the stack and local conventions before adding files.
24
+ 5. Choose the narrowest verification command that proves the first behavior.
25
+ 6. **Reuse context from prior chain steps.** When this skill is invoked via a `--next` chain
26
+ (refine → run → verify), the calling session already holds the task file, `spur task check`
27
+ output, and any files read during refinement. Before re-reading a file, check whether it is
28
+ already in context — re-reading the task file or re-running `spur task check` when the prior
29
+ step's result is still valid wastes tokens and drags cache hit rate below 40%. Only re-fetch
30
+ when the underlying state changed (e.g. you just wrote a section and need the updated check).
31
+ Apply the same discipline to skill/command reference files: if the task's own references or
32
+ the refine step already loaded them, reference the in-context copy rather than re-reading.
33
+
34
+ ## Task-Driven Implementation
35
+
36
+ The task is the source of scope. Implement only behavior that traces to the task's acceptance
37
+ criteria or design. If you discover adjacent cleanup, record it as a follow-up unless it directly
38
+ unblocks the requirement.
39
+
40
+ **Scope the context to the target WBS (task 0487 R1).** The input set is the target task file, the
41
+ tasks named in its `dependencies`, its `feature_id` feature file, and the source files its
42
+ Requirements / Design / Plan name — nothing else. Other `todo` / `wip` tasks in the corpus are out
43
+ of scope even when recently changed: a committed task can still read `todo` because its verify/wrap
44
+ hops have not run. Implementing one alongside the target is the 0486 conflation (see
45
+ `../SKILL.md` § One WBS per implement pass), and the pipeline's diff-scope guard fails the step for
46
+ it.
47
+
48
+ Use this sequence:
49
+
50
+ 1. **Map requirement to files.** Identify the module, seam, config, docs, or tests that must change.
51
+ 2. **Choose a test strategy.** Use `sp:test-driven-development` for test-first work, or `sp:code-testing` for
52
+ gap-filling coverage on existing code.
53
+ 3. **Implement in a small slice.** Keep the first slice narrow enough to verify.
54
+ 4. **Run the narrow check.** Fix root causes, not symptoms.
55
+ 5. **Update the task Solution.** The `implement` step owns `## Solution`; write a change map through
56
+ `spur task update <wbs> --section Solution --from-file <tmp>`.
57
+ Every file reference in the Solution MUST use backtick `` `path:line` `` form with paths from
58
+ repo root (e.g. `` `packages/app/src/foo.ts:123` `` or `` `packages/app/src/bar.ts:10-20` ``).
59
+ Prose `path:line` without backticks will fail `spur task check` (L3 stale-anchor detection).
60
+ `spur task record --solution-from-diff` is complementary — it backfills the change map from
61
+ git diff — but implement-time Solution is the authoritative source and must carry the
62
+ backtick format.
63
+
64
+ ## Pattern Selection
65
+
66
+ Use existing local patterns first. Only introduce a new abstraction when it removes real complexity,
67
+ matches an established seam, or gives a second concrete adapter/caller.
68
+
69
+ | Domain | Default Pattern |
70
+ |--------|-----------------|
71
+ | API shape | Resource or operation names that match existing route/contract vocabulary; structured errors with context. |
72
+ | Persistence | Existing DAO/service boundary; one lock/write domain for corpus changes. |
73
+ | Config | Existing zod/config loader; no ad hoc environment reads in feature code. |
74
+ | Process/file I/O | Existing runtime/process/file-system seam where the app already has one. |
75
+ | Tests | Behavior names, boundary mocks only, fixtures/builders for noisy inputs. |
76
+ | Documentation | Authoritative docs only; update `04_DESIGN.md` for command/config/schema changes. |
77
+
78
+ ## Progress Persistence
79
+
80
+ Long implementation steps should leave resumable evidence:
81
+
82
+ - code changes stay scoped to the task
83
+ - Solution lists changed files and why
84
+ - Testing records commands run and result
85
+ - Review records open risks or deferred work
86
+
87
+ If the task ships a partial deliverable, mark it visibly in Solution and Review with the deferred
88
+ requirement and follow-up WBS. Do not let a partial implementation look complete.
89
+
90
+ ## Task-Type Awareness
91
+
92
+ The implement step assumes a standard implementation task (`template: default`). When the task
93
+ carries a different template, the implement agent MUST check the task's frontmatter `template`
94
+ field and adjust its scope:
95
+
96
+ | Template | Scope | Primary input |
97
+ |----------|-------|---------------|
98
+ | `default` | Implement `## Requirements` → code changes | `## Requirements` R-items, `## Design`, `## Plan` |
99
+ | `review` | Fix the findings in `#### Review Findings` → code changes | `#### Review Findings` table (under `### Background`), `## Plan` |
100
+ | `brainstorm` | Research/ideation → `## Solution` write-up | `## Background` prompt, `## Design` constraints |
101
+
102
+ The implement agent reads the template field first, then picks the correct input section. For a
103
+ `review` task, the `#### Review Findings` table IS the requirements — fix each finding in
104
+ severity order (P1 → P2 → P3 → P4), then re-review.
105
+
106
+ ## Handoff To Testing And Review
107
+
108
+ Implementation is complete only when:
109
+
110
+ - the relevant narrow checks pass
111
+ - the Solution section has a useful change map
112
+ - no known requirement is silently deferred
113
+ - the next gate can run without needing hidden context from the implementer
@@ -0,0 +1,231 @@
1
+ ---
2
+ name: code-improvement
3
+ description: "Surface architectural friction and propose deepening opportunities — refactors that turn shallow, tightly-coupled modules into deep, testable, AI-navigable ones. Triggers: \"improve architecture\", \"find refactoring opportunities\", \"shallow module\", \"hard to test\", \"reduce coupling\", \"deepen modules\"."
4
+ license: Apache-2.0
5
+ metadata:
6
+ author: spur
7
+ version: "1.0"
8
+ platforms: "claude-code,codex,openclaw,opencode,antigravity"
9
+ interactions:
10
+ - reviewer
11
+ - pipeline
12
+ modes:
13
+ - review
14
+ openclaw:
15
+ emoji: "🏗️"
16
+ see_also:
17
+ - sp:code-verification
18
+ - sp:functional-review
19
+ - sp:spur-dev
20
+ ---
21
+
22
+ # Spur Code Improvement
23
+
24
+ The **architecture and structural depth** counterweight to `sp:code-verification`'s SECUA review.
25
+ Where code-verification asks "is the code correct/secure/efficient?", code-improvement asks "is the
26
+ architecture deep, testable, and navigable — or is it a pile of shallow pass-through modules held
27
+ together by tight coupling?"
28
+
29
+ ## When to Use
30
+
31
+ **Trigger keywords:** improve architecture, refactor, shallow module, tightly coupled, untestable,
32
+ AI-navigable, deepening, consolidate modules, reduce coupling, architectural friction, hard to
33
+ test, pass-through module.
34
+
35
+ Load this skill when:
36
+
37
+ - Surfacing architectural friction and deepening opportunities as ranked candidates.
38
+ - Running the architecture dimension of a multi-dimensional review (`/sp:dev-review --focus architecture`).
39
+ - Auditing a module or package for structural debt before a refactor.
40
+ - Producing an advisory (non-blocking) deepening report to accompany a SECUA review.
41
+
42
+ Do **not** use this skill for:
43
+
44
+ - Requirements traceability (use `sp:functional-review`).
45
+ - SECUA quality review (use `sp:code-verification`).
46
+ - Implementing the refactor (use `sp:code-implementation` — this skill *surfaces*, it does not ship).
47
+
48
+ ## Key Distinctions
49
+
50
+ | Skill | Question it answers |
51
+ |-------|---------------------|
52
+ | **`sp:code-improvement`** | Is the architecture deep / testable / navigable? (structural depth) |
53
+ | **`sp:functional-review`** | Are all task requirements implemented? (requirements completeness) |
54
+ | **`sp:code-verification`** | Is the code correct, secure, efficient, usable? (SECUA quality) |
55
+
56
+ A complete `/sp:dev-review --focus all` runs all three. This skill owns the **architecture**
57
+ dimension; the others are out of scope here.
58
+
59
+ ## Cross-cutting rules (inherited from sp:spur-dev)
60
+
61
+ CLI-gated section writes: see
62
+ [spur-dev/cross-cutting.md](../spur-dev/references/cross-cutting.md). Universal honesty gate: see
63
+ [Verification Before Completion](../spur-dev/references/cross-cutting.md#verification-before-completion).
64
+
65
+ ---
66
+
67
+ ## Improvement Lenses
68
+
69
+ Five signals indicate a shallow or tightly-coupled module. Each defines a symptom, a diagnostic,
70
+ and the deepening direction. Full definitions and examples in
71
+ [references/deepening-signals.md](references/deepening-signals.md).
72
+
73
+ | # | Signal | Symptom | Deepening direction |
74
+ |---|--------|---------|--------------------|
75
+ | 1 | **Shallow module** | A module whose interface is as complex as its implementation | Collapse it into its caller or give it a real body |
76
+ | 2 | **Tight coupling** | Two modules that must change together | Introduce a seam (interface, event, or DTO) |
77
+ | 3 | **Wrong seam** | Abstraction boundary in the wrong place | Move responsibility across the seam |
78
+ | 4 | **Weak locality** | Related logic scattered across modules | Co-locate by responsibility |
79
+ | 5 | **Poor test surface** | Logic that can only be tested through a large stack | Extract a pure function or inject a boundary |
80
+
81
+ ---
82
+
83
+ ## Severity
84
+
85
+ | Severity | Blocking? | Description |
86
+ |----------|-----------|-------------|
87
+ | **blocker** | yes — must fix before merge | The architecture cannot support the current or next change without a structural fix. Examples: circular dependency, module with no test surface, a seam that leaks domain types across a boundary. |
88
+ | **major** | yes (in pipeline context) | Significant friction: a shallow module duplicated 3+ ways, tight coupling that forces coordinated changes across packages, a wrong seam that blocks a planned feature. |
89
+ | **minor** | advisory | Local friction: a module slightly too shallow, coupling that's awkward but not coordinated. |
90
+ | **advisory** | advisory | Deepening opportunity: the code works and is testable, but would be cleaner with a deeper module. Always non-blocking. |
91
+
92
+ **Under the pipeline** (`/sp:dev-review` in a task run), `blocker` and `major` block the
93
+ `approve(HITL)` gate. `minor` and `advisory` are recorded but do not block. **Standalone** reviews
94
+ are advisory-only — the operator decides what to act on.
95
+
96
+ ---
97
+
98
+ ## Workflow
99
+
100
+ ### Step 1 — Establish scope
101
+
102
+ ```bash
103
+ spur task show <wbs> --json # for a pipeline run
104
+ # OR a path glob for standalone:
105
+ # scope = 'src/api/' | 'packages/domain/' | 'plugins/sp/'
106
+ ```
107
+
108
+ For a pipeline run, derive the diff scope the same way `sp:code-verification` Step 3 does (the
109
+ task's last commit → changed `*.ts/*.tsx/*.js/*.jsx`). For standalone, the `path` argument is the
110
+ scope.
111
+
112
+ ### Step 2 — Explore (read the map)
113
+
114
+ Build a module-level map of the scope:
115
+
116
+ - List the modules (files / directories) in scope.
117
+ - For each, read its exports and immediate callers (use LSP `references` / `definition` where
118
+ available; fall back to `grep` + `read`).
119
+ - Identify the module's **interface** (exported surface) and its **implementation** (non-exported
120
+ body). A module is shallow when the interface is as complex as the implementation.
121
+
122
+ ### Step 3 — Apply the five lenses
123
+
124
+ For each module in scope, check each of the five improvement signals:
125
+
126
+ 1. **Shallow module?** Is the exported surface as complex as the body? (interface-to-impl ratio
127
+ ≈ 1:1)
128
+ 2. **Tight coupling?** Does this module change in lockstep with another? (grep for co-changed
129
+ symbols, shared mutable state, deep relative imports)
130
+ 3. **Wrong seam?** Is the abstraction boundary in the wrong place? (domain types leaking across a
131
+ transport seam, a service importing a DAO directly instead of through a repository, etc.)
132
+ 4. **Weak locality?** Is related logic scattered? (a single responsibility spread across N files)
133
+ 5. **Poor test surface?** Can the core logic be tested without standing up a large stack? (no pure
134
+ extraction, no injectable boundary)
135
+
136
+ For each signal hit, record a **candidate** using the Candidate Format below.
137
+
138
+ ### Step 4 — Present candidates
139
+
140
+ Emit the ranked candidate list. Do **not** implement — this skill surfaces, it does not ship. The
141
+ operator (or `sp:code-implementation`) decides what to act on.
142
+
143
+ ### Step 5 — Grilling (optional, `--auto` skips)
144
+
145
+ For each `blocker`/`major` candidate, state the single hardest *challenge* to the deepening
146
+ proposal ("what breaks if we do this?") and the single hardest *defense*. If the defense cannot
147
+ answer the challenge, downgrade the severity or drop the candidate. Three cycles max; stop sooner
148
+ if satisfied.
149
+
150
+ ---
151
+
152
+ ## Candidate Format
153
+
154
+ Each candidate is a structured finding:
155
+
156
+ ```markdown
157
+ ### C{n} — {signal name} in `{module}`
158
+
159
+ - **Severity:** blocker | major | minor | advisory
160
+ - **Signal:** shallow module | tight coupling | wrong seam | weak locality | poor test surface
161
+ - **Location:** `path/to/module.ts:42`
162
+ - **Symptom:** <1-2 sentences — what's wrong, concretely>
163
+ - **Evidence:** <file:line anchors showing the signal>
164
+ - **Deepening proposal:** <the structural change that would fix it>
165
+ - **Challenge:** <the hardest objection to the proposal>
166
+ - **Defense:** <the answer to the challenge, or "none — downgrade">
167
+ - **Affected files:** <list of files the refactor would touch>
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Context Inputs
173
+
174
+ - **`CONTEXT.md`** (if present in the repo root or a package) — domain vocabulary. Use its terms
175
+ in symptom descriptions to keep candidates readable for the team.
176
+ - **`docs/adr/`** (if present) — architectural decisions. A candidate that contradicts an ADR
177
+ must cite the ADR and propose superseding it (do not silently diverge — same rule as the docs
178
+ constitution).
179
+ - **Neither present?** Proceed without them; the five signals are self-contained.
180
+
181
+ ---
182
+
183
+ ## Multi-dimensional review integration
184
+
185
+ When invoked as the `--focus architecture` dimension of `/sp:dev-review`:
186
+
187
+ - The scope is the task's diff (pipeline) or the `path` arg (standalone).
188
+ - `blocker`/`major` candidates block the `approve(HITL)` gate alongside any SECUA blockers from
189
+ `sp:code-verification`.
190
+ - The candidate list is recorded in the task's `## Review` section (written by the pipeline's
191
+ `record` step via `spur task update --section`).
192
+ - This skill does **not** write to the task file directly — the pipeline (or the operator) does.
193
+
194
+ Standalone, the skill emits the candidate list as advisory output; the operator acts on it.
195
+
196
+ ---
197
+
198
+ ## Common Rationalizations
199
+
200
+ | Rationalization | Reality |
201
+ |---|---|
202
+ | "It works, so the architecture is fine." | Working code can still be shallow or tightly coupled. This skill judges *depth*, not correctness. |
203
+ | "We can refactor that later." | "Later" is how structural debt compounds. A `blocker` says *now*; `advisory` says *later*. |
204
+ | "It's just a small wrapper." | A small wrapper IS the shallow module. Collapse it or give it a real body. |
205
+ | "The coupling is necessary for performance." | Cite the measurement. Unmeasured "necessity" is rationalization. |
206
+ | "I don't see how to deepen this." | If the proposal has no defense after Grilling, drop the candidate — don't pad the report. |
207
+
208
+ ---
209
+
210
+ ## Gotchas
211
+
212
+ 1. **Surface, don't ship.** This skill produces candidates. Implementation is `sp:code-implementation`.
213
+ 2. **Advisory by default standalone.** Only under the pipeline do `blocker`/`major` block.
214
+ 3. **ADR awareness.** A candidate that contradicts an ADR proposes superseding it — never silently
215
+ diverge (mirrors the docs constitution's binding rule).
216
+ 4. **No file:line, no candidate.** Every candidate's `Evidence` field must cite specific anchors.
217
+ 5. **Grilling is a filter, not a ritual.** Three cycles max; if the defense fails, drop or downgrade.
218
+
219
+ ---
220
+
221
+ ## Platform Notes
222
+
223
+ ### Claude Code
224
+
225
+ Invoke via `Skill(skill="sp:code-improvement", args="<path|wbs>")`. LSP `references` /
226
+ `definition` are available for the Explore step.
227
+
228
+ ### Codex / OpenClaw / OpenCode / Antigravity
229
+
230
+ Run `spur` CLI via Bash; `grep` + `read` for the Explore step if no LSP. The skill is the SSOT;
231
+ execute the workflow steps inline.