Instal·la
npx skillscat add bex-co/beancount-io/routine-logic-simplifier Instal·la des del registre de SkillsCat.
Task: Simplify convoluted business logic, behavior-preserving
Usage: /routine-logic-simplifier [package-or-path]
Pick one genuinely convoluted unit, pin its current behavior with tests,
rewrite it in place so it reads simply, prove nothing changed, and ship via/ship.
Contract
Read .agents/skills/routine-shared/contract.md first — preconditions,
scope resolution, verify gates, ship protocol, budget, universal STOPs. Floor
even without it: never ship red; one finding per ship; anything in aDO_NOT_DO.md is a hard STOP.
Workflow
1. Scope
Resolve scope per the contract.
2. Discover
Find hotspots worth the risk:
git log --oneline -- <pkg>— files that keep appearing infix:commits;
churn is where convolution costs the most.- Read for the smells: nesting past ~3 levels, long boolean chains, one
function interleaving parsing + decision + formatting, repeated re-derivation
of the same intermediate value.
Pick one unit (a function or a small cluster). Convoluted-but-working code
nobody touches is a weak finding; convoluted code with churn is a strong one.
3. Prove it (pin first)
- Existing tests must cover the unit's observable behavior, or you write
pinning tests first — inputs/outputs as they are today, including the weird
edges. - If the behavior cannot be safely pinned (nondeterminism, giant I/O surface),
skip the finding — an unpinned simplification is a gamble, not
maintenance.
4. Fix
Simplify in place: flatten nesting with early returns, name the
intermediate values, split interleaved concerns into local helpers. Introduce
no new abstractions — no new interfaces, layers, or files unless splitting
one oversized file is itself the simplification. Zero behavior change, byte for
byte where observable.
5. Verify
Pinning tests and the owning package's full gate, all green. The pinning tests
ship with the change.
6. Ship
Compose /ship for this one unit. Loop within budget.
What NOT to do
- Never fold a behavior change into the refactor. A bug discovered
mid-simplify is a separateroutine-logic-bugfixerfinding — note it, finish
the behavior-preserving simplification, report the bug in the summary. - Don't remove indirection layers (single-impl interfaces, passthrough
wrappers) — that isroutine-abstraction-improver's job. - Don't "simplify" by deleting handling for edge cases you can't prove
unreachable — that's how convoluted code got its reputation for being
load-bearing. - Don't reformat or rename beyond the unit you picked; keep the diff reviewable.
Arguments
$ARGUMENTS