2 +description: Total deslop, optimization, rule alignment, architecture refactor, cruft removal, and test rework of one extension
3 +argument-hint: "<
extension> [focus]"
10 +Resolve the extension directory under `extensions/`.
11 +Stop with one question when the target is ambiguous.
12 +Optional focus narrows priority, never scope.
16 +- `coding-guidelines`, `desloppy`, `vertical-slices` skills.
17 +- `extensions/AGENTS.md`, `extensions/DEBUG.md`, `extensions/SETTINGS.md`.
18 +- `.system/specs/PX-SPEC-DZLVGRW4-pi-extension-architecture/index.md` and the approved plans for it.
19 +- The extension's `README.md`, `package.json`, `mise.toml`, and every source and test file.
23 +Treat the extension as if written today against the current rules and architecture.
25 +Preserve user-observable behavior except where the removal is the point; list every intentional behavior change.
28 + Remove accidental complexity, duplication, needless indirection, weak types, defensive noise, commented-out code, stale comments, and `any` reach-ins.
30 + Fast `session_start`, lazy-loaded command and tool implementations, no startup subprocesses, network, or filesystem scans, minimal context impact.
31 + Measure before claiming gains.
32 +3. Align to project rules.
33 + Generated settings and debug helpers only, no direct `getFlag`/`registerFlag`/settings reads, no `console.*` in runtime, Pi peers in `peerDependencies`, no sibling imports, tool widgets honoring native expansion, cross-platform paths and executables.
34 +4. Refactor to the package architecture.
35 + Everything the generated `dist/<name>` package needs is declared under `pi-ext` (entries, resources, assets, justified externals).
36 + Runtime files resolve relative to `import.meta.url`; extension-dependent paths derive from it.
37 + Portable third-party code bundles; every external carries a demonstrated incompatibility.
38 + No dependence on repository source, workspace links, or ancestor `node_modules`.
40 + Legacy compatibility shims, dead settings, migration code for versions no one runs, unused exports, unused dependencies, obsolete docs.
41 + Check Git history when unsure whether something is still load-bearing; delete when it is not.
43 + Delete tests that assert implementation details, mock the unit under test, duplicate other tests, snapshot volatile data, or pass regardless of behavior.
44 + Add tests for real behavior that is untested: contract loading through Pi, tool and command dispatch, settings precedence, error paths, cancellation, platform fallbacks, relocation of the generated package.
45 + Keep the mandatory harness test.
46 + Prefer deterministic inputs and controlled fake executables over mocks.
50 +Work in vertical slices; each slice leaves the extension loadable and its tests green.
51 +Debug root causes; never paper over failures.
52 +Change generated files only through their templates and `//:codegen`.
53 +Do not touch other extensions except to fix a shared template when the rules demand it.
55 +Verify after each slice and freshly at the end:
57 +- `mise run //extensions/<name>:lint`
58 +- `mise run //extensions/<name>:test`
59 +- `mise run //extensions/<name>:check`
60 +- `mise run //extensions/<name>:verify-package`
62 +Run root `//:check` and `//:test` once at the end.
63 +Update `README.md` to match the result; keep it terse and link sources.
64 +Do not commit unless the user asks.
68 +- Removed: files, exports, dependencies, settings, compatibility paths, with line counts before and after.
69 +- Behavior changes: each one, with rationale.
70 +- Tests: deleted with reason, added with covered behavior.
71 +- Measurements: startup, bundle size, context impact, before and after.
72 +- Verification results, read in full.
73 +- Open questions or rule conflicts found in the extension or the rules themselves.