@nklisch/pi-agile-workflow 0.16.1 → 0.16.4

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 (36) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/docs/ARCHITECTURE.md +42 -21
  4. package/docs/PRINCIPLES.md +108 -38
  5. package/docs/SPEC.md +19 -2
  6. package/docs/VISION.md +17 -10
  7. package/hooks/scripts/prompt-context.py +8 -1
  8. package/hooks/scripts/test_prompt_context.py +16 -0
  9. package/package.json +1 -1
  10. package/scripts/work-view.sh +1 -1
  11. package/skills/autopilot/SKILL.md +54 -37
  12. package/skills/convert/SKILL.md +30 -4
  13. package/skills/epic-design/SKILL.md +21 -3
  14. package/skills/feature-design/SKILL.md +34 -11
  15. package/skills/gate-cruft/SKILL.md +69 -24
  16. package/skills/gate-docs/SKILL.md +56 -30
  17. package/skills/gate-patterns/SKILL.md +7 -3
  18. package/skills/gate-refactor/SKILL.md +18 -6
  19. package/skills/gate-security/SKILL.md +16 -7
  20. package/skills/gate-tests/SKILL.md +86 -71
  21. package/skills/implement/SKILL.md +18 -8
  22. package/skills/principles/SKILL.md +76 -21
  23. package/skills/principles/references/advisory-review.md +8 -1
  24. package/skills/principles/references/code-design.md +62 -5
  25. package/skills/principles/references/models.md +69 -57
  26. package/skills/refactor-design/SKILL.md +23 -13
  27. package/skills/review/SKILL.md +39 -19
  28. package/skills/review/references/review-lenses.md +14 -4
  29. package/skills/review/references/substrate-side-effects.md +17 -10
  30. package/skills/review/references/target-resolution.md +2 -1
  31. package/skills/scope/SKILL.md +20 -7
  32. package/work-view/crates/cli/.work-view-version +1 -1
  33. package/work-view/dist/aarch64-apple-darwin/work-view +0 -0
  34. package/work-view/dist/aarch64-unknown-linux-musl/work-view +0 -0
  35. package/work-view/dist/x86_64-apple-darwin/work-view +0 -0
  36. package/work-view/dist/x86_64-unknown-linux-musl/work-view +0 -0
@@ -6,9 +6,10 @@ description: >
6
6
  make autonomous progress on the substrate. Reads .work/active/, picks ready items by depends_on and
7
7
  stage, delegates to design, implement, and review skills, commits transitions, and repeats until the
8
8
  scope is done or blocked. Before reporting complete, runs a final peer-review/fresh-context
9
- completion pass and fixes or files accepted findings. No /loop or --resume mechanics; the harness
10
- goal/continuation feature owns long-running persistence. Epic-scoped by default; --all drains all
11
- active work; free-text scope directives are allowed.
9
+ completion pass, adjudicates reviewer proposals, fixes material blockers, and parks lower-risk
10
+ valid findings. No /loop or --resume mechanics; the harness goal/continuation feature owns
11
+ long-running persistence. Epic-scoped by default; --all drains all active work; free-text scope
12
+ directives are allowed.
12
13
  ---
13
14
 
14
15
  # Autopilot
@@ -166,8 +167,11 @@ this caller note in every delegated prompt:
166
167
  > advisory policy from `principles/SKILL.md` Part IV in direct and autopilot
167
168
  > modes: use independent review only when the risk and review weight warrant it,
168
169
  > and label review cross-model only when a different model class is actually
169
- > selected. Peer failures during design are non-blocking. Preserve
170
- > complementary→adversarial order when both phases run. For reviewer posture and
170
+ > selected. Treat reviewer findings as proposals: independently adjudicate them
171
+ > against repository context, fix or activate only material current-cycle
172
+ > blockers, and park valid lower-risk work in the unbound backlog. Peer failures
173
+ > during design are non-blocking. Preserve complementary→adversarial order when
174
+ > both phases run. For reviewer posture and
171
175
  > host-native roles, load `principles/references/subagents.md`; for capability
172
176
  > mapping, load `principles/references/models.md`. A top-tier reasoning peer may
173
177
  > take 10 to 30 minutes; quiet output after a few minutes is not a hang.
@@ -227,19 +231,23 @@ bounces[<item-id>] = times this item has gone implementing -> review -> implemen
227
231
 
228
232
  After every bounce:
229
233
 
230
- 1. Confirm the review left concrete, durable findings in the item body.
231
- 2. Rebuild the queue so the item naturally re-enters implementation.
232
- 3. Implement the findings, run the relevant verification, and send the item
234
+ 1. Confirm the receiving agent—not the reviewer alone—adjudicated the proposals
235
+ and left concrete, receiver-confirmed blockers in the item body.
236
+ 2. Park valid findings below the material current-cycle bar in the unbound
237
+ backlog; they do not keep the item bounced or enter this run's queue.
238
+ 3. Rebuild the queue so the item naturally re-enters implementation.
239
+ 4. Implement the blockers, run the relevant verification, and send the item
233
240
  through review again.
234
- 4. Continue until review approves the item or autonomous work reaches a genuine
241
+ 5. Continue until review approves the item or autonomous work reaches a genuine
235
242
  hard blocker under `principles/SKILL.md` Part III.
236
243
 
237
- There is no fixed bounce limit. If the same substantive finding survives more
238
- than one correction pass, treat recurrence as evidence that the attempted fix or
239
- design model is wrong: re-read the item and foundation docs, diagnose the root
240
- cause, revise the item design or implementation notes when needed, and use a
241
- fresh implementation or review context when that would add independent
242
- judgment. Do not park the item at `review`, label it stuck, or require human
244
+ There is no fixed bounce limit. If the same material finding survives more than
245
+ one correction pass, treat recurrence as evidence that the attempted fix or
246
+ design model may be wrong: re-read the item and foundation docs, diagnose the
247
+ root cause, revise the item design or implementation notes when needed, and use
248
+ a fresh implementation or review context when that would add independent
249
+ judgment. Recurrence alone never elevates a low-risk finding into a blocker. Do
250
+ not park the active item at `review`, label it stuck, or require human
243
251
  intervention solely because a counter reached two (or any other number).
244
252
 
245
253
  ### Phase 6: Refactor Cadence (`--all` Only)
@@ -295,9 +303,11 @@ When the scoped queue appears drained:
295
303
  - `standard`: use balanced risk-based fresh-context review.
296
304
  - `thorough`: increase complementary and adversarial fresh-context coverage.
297
305
  - `maximum`: seek multi-model, multi-pass complementary → adversarial review.
298
- Ask for bugs, missed acceptance criteria, unreviewed risks, foundation-doc
299
- drift, and substrate-state inconsistencies that would make "complete"
300
- premature. Exact reviewer count and pass depth remain model judgment within
306
+ Ask for bugs, missed acceptance criteria, unreviewed risks, false/stale/
307
+ contradictory foundation-doc assertions, and substrate-state inconsistencies
308
+ that would make "complete" premature. Foundation-doc omissions and
309
+ unimplemented future-state claims are not findings. Exact reviewer count and
310
+ pass depth remain model judgment within
301
311
  the weight's ceiling/intent.
302
312
  3. When independent review runs, use a different-class peer when reachable;
303
313
  otherwise spawn a generic same-harness fresh-context reviewer from
@@ -310,20 +320,25 @@ When the scoped queue appears drained:
310
320
  blocked on final review and include the reason. `none` requires complete
311
321
  administrative evidence instead of a fresh reviewer; missing evidence blocks
312
322
  rather than becoming an invented pass.
313
- 5. For every substantive accepted finding:
314
- - Small and clearly safe fix: fix it immediately, run verification, commit,
315
- and rebuild the queue.
316
- - Needs tracked work: create or update a substrate item at the right stage
317
- (`drafting` for design gaps, `implementing` for concrete fixes), commit,
318
- and rebuild the queue.
319
- - Invalid or lower-value finding: reject it with a one-line rationale in the
320
- final review summary.
323
+ 5. The receiving autopilot agent adjudicates every proposed finding against the
324
+ repository's acceptance criteria, users and deployment shape, likelihood,
325
+ blast radius, recoverability, safeguards, and delay cost. Reviewer severity
326
+ is evidence, not the verdict:
327
+ - Receiver-confirmed material current-cycle blocker: fix it immediately when
328
+ small and safe, or create/update an active item at the right stage
329
+ (`drafting` for design gaps, `implementing` for concrete fixes); verify,
330
+ commit, and rebuild the queue.
331
+ - Valid but below the blocker bar: park an unbound backlog item with a brief
332
+ risk rationale, commit it, and continue. It does not reopen the drained
333
+ scope or prevent completion.
334
+ - Nit or unsupported/inapplicable claim: note or reject it with a one-line
335
+ rationale; do not create active work.
321
336
  6. If rebuilding the queue finds new or regressed `drafting`, `implementing`, or
322
- `review` items in scope, return to Phase 2 and drain them. Completion is not
323
- allowed while accepted final-review findings remain active.
324
- 7. Once the final review path succeeds, produces no accepted
325
- blocking/substantive findings, and the queue is still empty, report the goal
326
- as complete.
337
+ `review` items in scope, return to Phase 2 and drain them. Parked review
338
+ follow-ups remain outside autopilot scope until separately promoted.
339
+ 7. Once the final review path succeeds, every proposal is adjudicated, no
340
+ receiver-confirmed blocker remains, and the queue is still empty, report the
341
+ goal as complete.
327
342
 
328
343
  Record the final review in the autopilot final summary. Do not paste the full
329
344
  peer transcript into item bodies; summarize accepted/rejected points where they
@@ -343,8 +358,8 @@ Narrate briefly as items advance. Final summary:
343
358
  - Effective worker capability and selection rationale
344
359
  - Effective review weight and source
345
360
  - Final completion-review status: administrative, cross-model, same-harness
346
- fresh-context, or failed; include accepted findings fixed/filed and rejected
347
- findings summary
361
+ fresh-context, or failed; summarize blockers fixed/activated, lower-risk
362
+ findings parked, and proposals rejected
348
363
  - Goal outcome: complete, blocked, or interrupted
349
364
 
350
365
  ## Guardrails
@@ -352,11 +367,13 @@ Narrate briefly as items advance. Final summary:
352
367
  - Never use structured question tool while an autopilot goal is actively driving the
353
368
  delegated work. Resolve with judgment and log rationale.
354
369
  - Do not report `complete` until Phase 8 has run successfully at the effective
355
- review weight and all accepted findings have been fixed or filed back into the
356
- queue.
370
+ review weight, every proposal has been adjudicated, and all receiver-confirmed
371
+ material blockers have been fixed or filed into the active queue. Parked
372
+ lower-risk findings do not block completion.
357
373
  - Commit after every item state change or blocker note.
358
374
  - Do not push, force-push, or release; the user controls publication.
359
- - Do not touch `.work/backlog/` except to report that backlog items are out of
360
- scope.
375
+ - Do not drain or promote `.work/backlog/`; it is outside autopilot scope.
376
+ Review disposition may park valid lower-priority findings there without
377
+ reopening the run.
361
378
  - The substrate is the resume point. No `PROGRESS.md`, no watchdog loops, no
362
379
  `--resume`.
@@ -514,7 +514,9 @@ parent, and dependency. Common patterns:
514
514
  - `work-view --help` for the full flag set
515
515
 
516
516
  Foundation docs in `docs/` describe the system's current state or intended
517
- future state, never the past; git history is the audit trail. Item files are
517
+ future state, never the past; git history is the audit trail. Review existing
518
+ assertions only: missing coverage and unimplemented future intent are not drift;
519
+ flag only false, stale, or contradictory claims. Item files are
518
520
  the durable state: update the body with implementation discoveries, review
519
521
  findings, blockers, and decisions instead of relying on chat history.
520
522
 
@@ -628,6 +630,22 @@ must already exist at their new home or the dense content is lost.
628
630
  All other tags are project-specific (see `.work/CONVENTIONS.md`) and do not
629
631
  affect skill routing.
630
632
 
633
+ ### Engineering posture
634
+
635
+ Prefer short, clear code and context-appropriate rigor over speculative
636
+ generality. Not every project needs exhaustive invariants, edge handling,
637
+ firm determinism, or universal coverage. Test important interfaces, complex
638
+ units, and regressions learned from bugs—not every line. When touching an
639
+ area, eliminate unnecessary code, tests, checks, abstractions, and
640
+ compatibility paths; leave it simpler. Ask before removing meaningful
641
+ behavior, guarantees, validation, compatibility, or safety.
642
+
643
+ Release-bound items define a gate's focus, not a hard scan boundary. Gates
644
+ may follow concrete evidence into adjacent dependencies, shared
645
+ infrastructure, or system-wide mechanisms. Bind release-relevant findings;
646
+ route merely ambient discoveries to the unbound backlog so a scan does not
647
+ silently expand a release.
648
+
631
649
  ### Test integrity
632
650
 
633
651
  When running, writing, or modifying tests:
@@ -643,6 +661,11 @@ must already exist at their new home or the dense content is lost.
643
661
  green again, if a parked production bug is small enough for a single
644
662
  stride, pick it up immediately as `/agile-workflow:scope` → design →
645
663
  implement. Larger bugs stay in backlog for prioritization.
664
+ - **Tests must earn their upkeep.** Prefer tests at stable interfaces,
665
+ regression tests for real bugs, and unit tests for genuinely complex
666
+ units. Do not add tests merely to cover every line or surface; remove
667
+ duplicate, tautological, implementation-bound, or obsolete tests when
668
+ they add less confidence than maintenance cost.
646
669
  - **NEVER game a test to make it pass.** A failing test that documents
647
670
  *why* it fails — an inline comment naming the bug, a `skip` linked to a
648
671
  backlog id, an `xfail` with a reason — is more honest than a green test
@@ -654,8 +677,11 @@ must already exist at their new home or the dense content is lost.
654
677
  override agile-workflow defaults. When peeragent is available with a different
655
678
  model class, large/risky autopilot design decisions may use one advisory pass;
656
679
  small/low-risk work skips it. Autopilot also runs a final peer-review loop
657
- before reporting completion and fixes or files accepted findings first.
658
- Same-model peers fall back to local sub-agents instead. Claude Opus peeragent
680
+ before reporting completion. Reviewer findings are proposals: the receiving
681
+ orchestrator verifies them against repository context and actual risk. Only
682
+ credible material current-cycle risks block; park valid lower-priority
683
+ findings in the unbound backlog and continue. Same-model peers fall back to
684
+ local sub-agents instead. Claude Opus peeragent
659
685
  calls can take 10 to 30 minutes on large reviews; no return after a few minutes
660
686
  is not evidence that the call has hung.
661
687
 
@@ -670,7 +696,7 @@ must already exist at their new home or the dense content is lost.
670
696
  this managed-section overwrite — content verification, NOT just a non-empty +
671
697
  end-marker check): confirm `.agents/rules/agile-workflow.md` exists AND that the
672
698
  dense rule content the slim removes from AGENTS actually landed there — each
673
- section is present (`### Tag semantics`, `### Test integrity`, the
699
+ section is present (`### Tag semantics`, `### Engineering posture`, `### Test integrity`, the
674
700
  advisory-review paragraph, and Broad entry points), or recompute per the Phase
675
701
  1.8 provenance check. Only when the content is verified present do you write or
676
702
  refresh the slim AGENTS section (Phase 6), overwriting the managed AGENTS block.
@@ -125,9 +125,9 @@ Instead:
125
125
 
126
126
  ### Phase 2: Ground yourself
127
127
 
128
- The principles skill auto-loads — both code-design (Ports & Adapters, SSOT,
129
- Generated Contracts, Fail Fast) and substrate-execution (Item-IS-the-Work,
130
- Rolling-Foundation, Late-Binding) are active.
128
+ The principles skill auto-loads — code-design includes proportional rigor, code
129
+ economy, useful tests, and leaving touched areas simpler; substrate-execution
130
+ includes Item-IS-the-Work, Rolling-Foundation, and Late-Binding.
131
131
 
132
132
  Read:
133
133
  1. `docs/VISION.md`, `docs/SPEC.md`, `docs/ARCHITECTURE.md` — foundation that
@@ -207,6 +207,17 @@ Aim for 2-6 child features per epic. Fewer than 2 means the epic was probably
207
207
  sized as a feature; flag the user. More than 6 means you're slicing too thin;
208
208
  collapse.
209
209
 
210
+ ### Phase 4.4: Identify simplification arcs
211
+
212
+ For each area the epic touches, ask what capabilities, code, tests, checks,
213
+ abstractions, compatibility paths, or whole subsystems the new direction can
214
+ make unnecessary. Prefer feature arcs that replace and remove over arcs that
215
+ only layer on more machinery. Fold cohesive elimination into the owning feature
216
+ brief or create an explicit `[refactor]`/`[cleanup]` child feature when it needs
217
+ independent design and review. Park unrelated cleanup. Any arc that removes
218
+ behavior or meaningful guarantees becomes a high-level design decision for user
219
+ confirmation, not an assumed refactor.
220
+
210
221
  ### Phase 4.5: Identify cross-feature dependencies
211
222
 
212
223
  For each candidate feature, ask:
@@ -309,6 +320,9 @@ capability it covers, why it exists in this epic, what it does NOT cover>
309
320
  - Position in epic: <e.g., "foundation feature — others depend on its types"
310
321
  / "consumer of feature-X" / "independent capability">
311
322
 
323
+ ## Simplification opportunity
324
+ - <what this feature should delete, consolidate, replace, or deliberately retain>
325
+
312
326
  ## Foundation references
313
327
  - `docs/VISION.md` — relevant section(s) (only if directly relevant)
314
328
  - `docs/ARCHITECTURE.md` — relevant component(s)
@@ -362,6 +376,10 @@ feature lands.">
362
376
  - `<feature-id-2>` — <one-line description> — depends on: `[<feature-id-1>]`
363
377
  - `<feature-id-3>` — <one-line description> — depends on: `[<feature-id-1>]`
364
378
 
379
+ ### Simplification arcs
380
+
381
+ - <feature-id> — <code/tests/checks/abstractions/subsystems it should remove or consolidate>
382
+
365
383
  ### Decomposition risks
366
384
 
367
385
  <from pre-mortem, if any. Otherwise omit the section.>
@@ -146,9 +146,9 @@ The body should already have a brief from `scope`. Use it as the seed for design
146
146
 
147
147
  ### Phase 2: Ground yourself
148
148
 
149
- The principles skill auto-loads — both code-design (Ports & Adapters, SSOT,
150
- Generated Contracts, Fail Fast) and substrate-execution (Item-IS-the-Work,
151
- Rolling-Foundation, Late-Binding) are active.
149
+ The principles skill auto-loads — code-design includes proportional rigor, code
150
+ economy, useful tests, and leaving touched areas simpler; substrate-execution
151
+ includes Item-IS-the-Work, Rolling-Foundation, and Late-Binding.
152
152
 
153
153
  Read:
154
154
  1. `docs/VISION.md`, `docs/SPEC.md`, `docs/ARCHITECTURE.md` (foundation docs that
@@ -281,6 +281,17 @@ For each unit, specify:
281
281
 
282
282
  Make strong decisions about abstractions, naming, and module boundaries.
283
283
 
284
+ #### 5d. Elimination and cleanup pass
285
+
286
+ Before adding another unit or abstraction, ask what this feature can delete,
287
+ inline, consolidate, or make unnecessary in the area it touches. Consider code,
288
+ tests, checks, configuration, compatibility paths, and existing abstractions.
289
+ Fold safe cohesive cleanup into a unit. Create explicit `[refactor]` or
290
+ `[cleanup]` child stories when the cleanup is worthwhile but independently
291
+ reviewable; park broader work. If a candidate reduces behavior or guarantees,
292
+ record it as a design decision for user confirmation rather than assuming
293
+ removal.
294
+
284
295
  ### Phase 5.5: Pre-mortem
285
296
 
286
297
  Before finalizing, attack the design:
@@ -295,12 +306,20 @@ feature body.
295
306
 
296
307
  ### Phase 6: Test approach
297
308
 
298
- For each unit, design:
299
- - **Unit tests** — behaviors to verify, edge cases, error paths
300
- - **Integration points** — where does this unit meet other units; what tests prove the seams
301
- - **Test data** — fixtures, factories, seed data needed
302
-
303
- If a unit is hard to test, the design is probably wrong. Note it and revise.
309
+ Design the smallest useful test surface:
310
+ - **Interface tests** — important behavior at stable public boundaries and
311
+ cross-unit seams
312
+ - **Regression tests** — bugs or demonstrated risks this work must not repeat
313
+ - **Unit tests** — only for genuinely complex isolated logic where examples add
314
+ confidence
315
+ - **Test removal** — duplicate, tautological, obsolete, or implementation-bound
316
+ tests this change can safely retire
317
+ - **Test data** — only fixtures or factories the chosen tests actually need
318
+
319
+ Do not create a test for every unit, branch, edge, or acceptance statement by
320
+ default. State what risk or contract each proposed test protects. Hard-to-test
321
+ important behavior may indicate a bad boundary; simple code needing no isolated
322
+ test is not itself a design flaw.
304
323
 
305
324
  ### Phase 7: Order and child stories
306
325
 
@@ -379,9 +398,13 @@ Update the feature file. Append (after the existing brief) sections like:
379
398
  1. <unit / story>
380
399
  2. <unit / story>
381
400
 
401
+ ## Simplification
402
+ - <code/tests/checks/abstractions removed, consolidated, or intentionally retained>
403
+ - <cleanup/refactor stories, if any>
404
+
382
405
  ## Testing
383
- ### Unit Tests: `tests/path/<name>.test.ext`
384
- <test approach for each unit>
406
+ - <interface, regression, or complex-unit tests and the value each protects>
407
+ - <low-value tests to remove, if any>
385
408
 
386
409
  ## Risks
387
410
  <from pre-mortem, if any>
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: gate-cruft
3
3
  description: >
4
- Cruft gate that scans the items bound to a release for AI-accumulated debris (dead code, stale
5
- comments, compatibility shims, defensive bloat, over-abstraction) introduced or revealed by the
6
- bundle. Delegates the full scan to a deep cleanup scanner agent which runs language-aware
4
+ Cruft gate focused on release-bound items that may follow relevant evidence into adjacent or
5
+ system-wide code. Finds dead code, stale comments, low-value tests and checks, compatibility
6
+ shims, defensive bloat, and over-abstraction, including whole systems that may no longer earn
7
+ their cost. Delegates the scan to a deep cleanup scanner agent which runs language-aware
7
8
  detection plus heuristic pattern-matching, then returns findings. The orchestrator converts findings
8
9
  into items in .work/active/ with gate_origin:cruft and tags:[cleanup]. Auto-triggers during
9
10
  /agile-workflow:release-deploy.
@@ -11,11 +12,14 @@ description: >
11
12
 
12
13
  # Gate-Cruft
13
14
 
14
- You orchestrate a cruft gate over the items bound to a release. The actual
15
- scan runs inside a **deep cleanup scanner agent** (a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`); your role is to prepare the bundle context,
15
+ You orchestrate a cruft gate focused on the items bound to a release. Bound
16
+ items establish the center of gravity, not a hard file boundary: the scanner may
17
+ follow relevant call paths, dependencies, shared infrastructure, tests, or
18
+ system-wide mechanisms needed to understand whether complexity still earns its
19
+ cost. The actual scan runs inside a **deep cleanup scanner agent** (a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`); your role is to prepare the bundle context,
16
20
  dispatch the scanner, and convert the findings it returns into items in the
17
21
  substrate. Findings get `gate_origin: cruft`,
18
- `tags: [cleanup]`, with severity tier shaping the stage.
22
+ `tags: [cleanup]`, with confidence shaping placement and stage.
19
23
 
20
24
  Scanner strength is explicit: spawn exactly one source-read-only deep cleanup
21
25
  scanner with the strongest inspection/reviewer setting the host exposes. Use a generic sub-agent prompted with the scanner posture from `../principles/references/subagents.md`. Use extra-high reasoning
@@ -70,9 +74,10 @@ confidence, and returns structured findings.
70
74
  **Brief template**:
71
75
 
72
76
  > You are conducting a cruft scan for release `<version>` as an agile-workflow
73
- > scanner. Use read/search/shell tools as needed. Audit ONLY the bundle's
74
- > changed files not the whole repo. Do not spawn nested sub-agents or implement
75
- > fixes.
77
+ > scanner. Use read/search/shell tools as needed. Start with the bundle's
78
+ > changed files, then follow relevant evidence into adjacent dependencies,
79
+ > shared infrastructure, tests, or system-wide mechanisms. Do not perform an
80
+ > aimless whole-repo sweep, spawn nested sub-agents, or implement fixes.
76
81
  >
77
82
  > **Bundle scope**:
78
83
  > ```
@@ -90,8 +95,9 @@ confidence, and returns structured findings.
90
95
  > `Cargo.toml`, `go.mod`, `pyproject.toml`, `Makefile`. This determines
91
96
  > which language-aware detection tools are available.
92
97
  >
93
- > 2. **Language-aware detection (high confidence)** — run against the
94
- > bundle's changed files only:
98
+ > 2. **Language-aware detection (high confidence)** — run against the bundle
99
+ > files first; expand a tool's scope only when needed to establish callers,
100
+ > duplication, reachability, ownership, or system-level cost:
95
101
  > - **TypeScript/JavaScript** — `tsc --noUnusedLocals --noUnusedParameters
96
102
  > --noEmit`, eslint unused rules
97
103
  > - **Python** — `ruff check --select F811,F841,F401`, `vulture`
@@ -99,7 +105,8 @@ confidence, and returns structured findings.
99
105
  > - **Rust** — compiler warnings for `#[warn(dead_code)]`
100
106
  > Capture output and parse into findings.
101
107
  >
102
- > 3. **Heuristic pattern-matching** via Grep on bundle files:
108
+ > 3. **Heuristic pattern-matching** via Grep, beginning with bundle files and
109
+ > following concrete references where the evidence leads:
103
110
  >
104
111
  > **Medium confidence:**
105
112
  > - Comments containing "removed", "backwards compat", "for backwards
@@ -117,12 +124,27 @@ confidence, and returns structured findings.
117
124
  > - Single-use helper functions that could be inlined
118
125
  > - Config/options parameters that only ever receive one value
119
126
  > - Abstractions with a single implementation
127
+ > - Duplicate, tautological, obsolete, or implementation-bound tests
128
+ > - Validation/check layers whose guarantees exceed the project's actual scope
120
129
  >
121
- > 4. **Cross-check existing patterns** — read `.agents/skills/patterns/` and
130
+ > 4. **System-level challenge** — inspect whether an entire validation layer,
131
+ > invariant/check system, test suite, compatibility mechanism, defensive
132
+ > subsystem, or abstraction family exposed by the bundle still justifies its
133
+ > maintenance cost. State its current purpose, evidence of cost, what removal
134
+ > would simplify, and which behavior or guarantee would be lost. Classify
135
+ > these as `Decision required`; never assume the guarantee should disappear.
136
+ >
137
+ > 5. **Cross-check existing patterns** — read `.agents/skills/patterns/` and
122
138
  > legacy `.claude/skills/patterns/` if
123
139
  > present. Intentional repetition documented as a pattern is NOT cruft.
124
140
  >
125
- > 5. **Triage by confidence**:
141
+ > 6. **Triage by confidence, release relevance, and decision need**:
142
+ > - `Release-relevant`: caused by, exposed by, or materially affects the bundle.
143
+ > - `Ambient`: useful discovery outside release scope; propose as unbound backlog.
144
+ > - `Decision required: yes`: any whole-system removal candidate, especially
145
+ > one that changes behavior or guarantees; ask before creating removal work.
146
+ >
147
+ > Then triage confidence:
126
148
  > | Confidence | Stage of produced item |
127
149
  > |---|---|
128
150
  > | High (tool-detected) | `stage: implementing` |
@@ -139,7 +161,11 @@ confidence, and returns structured findings.
139
161
  > - **Confidence**: High | Medium | Low
140
162
  > - **Category**: unused import | dead function | stale comment |
141
163
  > compatibility shim | passthrough wrapper | defensive try/catch |
142
- > single-use helper | over-abstraction
164
+ > single-use helper | over-abstraction | low-value test | redundant checks |
165
+ > system-level simplification
166
+ > - **Relevance**: Release-relevant | Ambient
167
+ > - **Decision required**: yes | no
168
+ > - **Guarantee affected**: none | <behavior/validation/determinism/compatibility/safety>
143
169
  > - **Location**: `<file>:<line>`
144
170
  > - **Evidence**:
145
171
  > ```<lang>
@@ -162,7 +188,8 @@ confidence, and returns structured findings.
162
188
  > ```
163
189
  >
164
190
  > **Rules**:
165
- > - Scan only Bundle scope. Don't expand.
191
+ > - Bundle scope is the focus, not a hard boundary. Expand only by following
192
+ > concrete evidence; record why each out-of-bundle file or system was inspected.
166
193
  > - Cite file:line for every finding.
167
194
  > - Don't fabricate. If a tool produces no output, don't invent findings.
168
195
  > - Skip already-tracked. Patterns documented in
@@ -172,9 +199,19 @@ confidence, and returns structured findings.
172
199
  > used externally?" — if you can't confirm zero callers, downgrade to
173
200
  > medium confidence rather than high).
174
201
 
175
- ### Phase 4: Convert findings to items
202
+ ### Phase 4: Resolve system-level removal decisions
203
+
204
+ For each `Decision required` candidate, present the system's purpose, current
205
+ cost, proposed simplification, and guarantees or behavior removal would weaken.
206
+ Ask the user whether to remove, reduce, retain, or park it. Group related
207
+ candidates and use the structured question tool in batches when available.
208
+ Never turn a guarantee-reducing proposal into active work without confirmation.
209
+ In a non-interactive gate path, write an unbound backlog decision proposal and
210
+ continue; do not assume consent or block unrelated release work.
176
211
 
177
- For each finding the scanner returned:
212
+ ### Phase 5: Convert findings to items
213
+
214
+ For each confirmed or ordinary finding the scanner returned:
178
215
 
179
216
  Read `gate_finding_routing` from `.work/CONVENTIONS.md` before writing items.
180
217
  If absent, use the default routing below. Normalize cruft confidence to routing
@@ -191,7 +228,7 @@ stage: implementing | drafting # by confidence
191
228
  tags: [cleanup]
192
229
  parent: null
193
230
  depends_on: []
194
- release_binding: <version>
231
+ release_binding: <version> | null # null for ambient or unconfirmed decision proposals
195
232
  gate_origin: cruft
196
233
  created: YYYY-MM-DD
197
234
  updated: YYYY-MM-DD
@@ -217,12 +254,17 @@ High | Medium | Low
217
254
  <what to remove and what to fix in the surroundings — imports, whitespace, etc.>
218
255
  ```
219
256
 
257
+ Release-relevant findings use the normal confidence mapping and bind to the
258
+ release. Ambient findings and unconfirmed decision proposals always go to the
259
+ unbound backlog regardless of confidence. A confirmed system removal may bind
260
+ only when the user explicitly includes it in the current release.
261
+
220
262
  Default confidence -> placement mapping:
221
263
  - **High** → `stage: implementing` in `.work/active/stories/`
222
264
  - **Medium** → `stage: drafting` in `.work/active/stories/`
223
265
  - **Low** → backlog file in `.work/backlog/`
224
266
 
225
- ### Phase 5: Commit
267
+ ### Phase 6: Commit
226
268
 
227
269
  ```bash
228
270
  git add .work/active/stories/ .work/backlog/
@@ -233,7 +275,7 @@ git commit -m "gate-cruft: <N> findings for <version>"
233
275
 
234
276
  In conversation:
235
277
  - **Bundle**: `<version>` — `<N>` items audited, `<M>` files changed
236
- - **Findings**: count by confidence (High / Medium / Low)
278
+ - **Findings**: count by confidence and relevance (release / ambient / decision)
237
279
  - **Items created**: count, with new ids
238
280
  - **Already-tracked**: count skipped
239
281
 
@@ -247,10 +289,13 @@ and parallelizes well."
247
289
 
248
290
  - **The scan happens in the scanner agent, not here.** Your job is bundle
249
291
  prep, dispatch, and item-writing. Don't replicate the scanner's analysis.
250
- - Audit only the bundle's changed files, not the whole repo.
292
+ - Release-bound items define focus, not a hard boundary. Follow concrete
293
+ evidence into adjacent or system-wide code, but do not turn the gate into an
294
+ unfocused whole-repo audit.
251
295
  - Never remove code in this skill — produce items only.
252
- - Cleanup items must be surgical when implemented. They remove cruft and fix
253
- the immediate surroundings only. They do NOT improve, refactor, or enhance.
296
+ - Local cleanup items should stay surgical. Whole-system simplification is
297
+ allowed as a proposal, but any reduction in behavior or guarantees requires
298
+ explicit user confirmation and appropriately scoped design work.
254
299
  - Patterns documented in `.agents/skills/patterns/` or legacy
255
300
  `.claude/skills/patterns/` are intentional, not
256
301
  cruft. The scanner cross-checks; don't override.