--- name: compress description: "Use right after writing new feature code or finishing a refactor in Smith: compress duplication, needless layers, and weak abstractions in the touched code into a smaller DRY design without asking." --- # Compress Make code smaller, clearer, and more powerful by removing repetition and accidental complexity. DRY design compression, not code golf. Runs unattended: no questions, no approval gates, no stopping between passes. ## Scope - Code touched by the current change (`jj diff --stat`, or the area the user names). - Behavior, tests, and public API stay; breaking change → list under Remaining, do not apply. - Second scope surfaces → list under Remaining, do not chase. ## Targets - Near-duplicate fns, modules, data shapes, errors, tests, command handlers. - Boilerplate better served by helper, enum, table, or data-driven path. - Overbroad abstractions hiding simple control flow. - Under-abstracted repeated logic that drifts. - Needless wrappers, pass-through methods, dead layers, repeated conversions. - Stringly typed domains that belong in enums, newtypes, typed config. ## Bar - One good abstraction over many clever ones. - Ownership stays clear; no new `clone`, `Arc`, `Mutex`, dynamic dispatch without justification. - `Result` + `?` stays explicit. - Benchmark before perf-motivated compression. ## Work 1. Read touched code and local patterns before proposing shared shapes. 2. Run scoped gates; keep pre-existing failures visible. 3. Rank candidates by drift risk removed per line changed; apply low and medium behavior-risk edits, log high. 4. Existing tests do not pin behavior → add focused test before compressing. 5. Run scoped gates again. ## Report ```markdown ## Status complete | blocked | failed ## Candidates - `path` · duplication · proposal · benefit · risk ## Changes - `path` · change · why ## Behavior risk low | medium | high ## Tests - gates run, before and after ## Remaining - deferred candidates, breaking proposals ```