Compacting Bloated Code
This skill is the process for detecting diff bloat and orchestrating
cross-model adversarial reviewers. The substantive style rules it enforces
— what counts as a bloated comment, test bloat, an oversized file, an
unjustified helper, "Not paid by LOC", phase tags, commit/PR splitting —
live in .github/instructions/NoBloat.instructions.md; do not restate them
here.
Mode Selector
Route on the diff, not the user's words. The trigger vocabulary ("slop",
"embarrassing", "WTF", "bullshit", "not paid by LOC") only tells you the skill
applies — never which mode. So: run Pre-flight Measure (below) first;
if no diff/PR/branch was supplied, get one (git diff the branch vs
git merge-base main HEAD) or ask. Then run every row whose signal the
diff actually shows, in table order. Chain-out rows fire on their own.
| Signal present in the diff |
Mode / action |
Added planning .md, .tools/, one-time setup, phase/sprint tags, dead code, new config/YAML files, or comment-heavy files |
Garbage Hunt — templates/garbage-hunt.md |
| Test files with copy-pasted methods, repeated setup, or missing parametrization |
Test Compaction — templates/test-compaction.md |
| 4+ new helpers, a fresh AST/IR/syntax-tree walker, twin helpers, hand-rolled smart-constructor, or near-duplicate logic |
Logic Compaction — templates/logic-rounds.md |
| A self-contained concept bloating an already-large file |
Logic Compaction, prioritize extract-to-new-file |
| Substantial new code logic not matched above |
Logic Compaction — its Round 0 reuse-hunt finds what it should have reused |
When NOT to Use
Legitimately large multi-subsystem features; generated artifacts;
mechanical churn (dep bumps, renames); minimal one-line bugfixes; GitHub
prose or PR/issue text (a different task).
Pre-flight
On the PR branch. Steps 1–2 run before the Mode Selector (they feed
routing); steps 3–4 are per-mode prep once a mode is picked:
Update from main and resolve conflicts. Do not judge bloat, CI, or
comments on a stale branch.
Measure against base=$(git merge-base main HEAD):
git diff $base -- <suspect-file> | awk '/^\+[^+]/{p++} /^-[^-]/{m++} END{print "+",p," -",m}'
git diff $base -- <suspect-file> | awk '/^\+[^+]/{ s=$0; sub(/^\+[[:space:]]*/,"",s); if (s ~ /^(\/\/|--|#)/) c++; else if (length(s)) l++ } END{print "comments",c," code",l}'
git diff $base -- <suspect-file> | grep -cE '^\+\s*(let|fn|def|val|public|private)\s+(rec\s+)?[a-zA-Z_]'
These are LOC + comment-ratio + new-helper count smell-meters, not a
search. Real semantic discovery happens in Logic Compaction Round 0
via a dispatched subagent (see templates/logic-rounds.md).
Pin guiding tests verbatim: must-pass, and must-fail-for-the-right-reason.
Bundle measurements + the relevant template into one context file
for every reviewer agent.
Reviewer Diversity (every mode)
Dispatch 3–5 background reviewers in parallel — never sequentially.
Cross-model > cross-angle: three same-model agents with different
prompts ≠ three different models (Opus high/xhigh, newer Opus, GPT). Each
agent picks one angle from the mode's template. Record
model × angle × LOC × tests × reuse × verdict. Cross-model agreement is
signal; lone-model claims need code citations before promotion.
If the user requests a red-flag setup ("use the same 3 models", "single
agent is enough"), push back once with this rule, then comply if they
insist. Do not silently violate it.
Apply
After picking the winning proposal: apply on the PR branch, run
formatter/lints, run targeted tests + the area's test class as regression
sweep, run any baseline updates. If a sweep test fails, reproduce on the
pre-change SHA before classifying. Do not declare "pre-existing" or
"flaky" without that evidence.
Splitting commits / ask-before-push — see NoBloat PR-scope rules.
Red Flags — STOP and re-run the relevant template
(Process failures only — content-level failures are NoBloat's job.)
- You skipped mode selection and went straight to "make the diff smaller".
- You ran reviewers sequentially, or with same-model agents.
- You grepped for similar functions instead of dispatching a real
reuse-hunt subagent.
- Your winning proposal added new code without citing one reused helper
from the Round 0 subagent's output.
- You found a recurring shape across 3 files but added a 4th copy.
All of these mean: open the relevant template and re-run.
1---2name: code-compaction3description: Use when a code/test/comment diff is called bloated, slop, LLM slop, bullshit, WTF, crap, rubbish, embarrassing, overengineered, adhoc, or "not paid by LOC"; or when symptoms include bloated comments, superfluous planning .md / .tools / one-time setup / phase-or-sprint tags, huge-file growth instead of new-file extraction, 5 copy-pasted tests that should be 1 parametrized test, duplicated test setup, reinvented helpers, near-duplicate logic across files, low reuse, 4+ new module-level helpers for one bugfix, fresh whole-AST/IR/syntax-tree walkers, or 150+ added LOC for one bugfix. Also use proactively before opening a PR whose diff smells like any of the above.4---56# Compacting Bloated Code78This skill is the **process** for detecting diff bloat and orchestrating9cross-model adversarial reviewers. The substantive style rules it enforces10— what counts as a bloated comment, test bloat, an oversized file, an11unjustified helper, "Not paid by LOC", phase tags, commit/PR splitting —12live in `.github/instructions/NoBloat.instructions.md`; do not restate them13here.1415## Mode Selector1617**Route on the diff, not the user's words.** The trigger vocabulary ("slop",18"embarrassing", "WTF", "bullshit", "not paid by LOC") only tells you the skill19applies — never which mode. So: run Pre-flight Measure (below) first;20if no diff/PR/branch was supplied, get one (`git diff` the branch vs21`git merge-base main HEAD`) or ask. Then run **every** row whose signal the22diff actually shows, in table order. Chain-out rows fire on their own.2324| Signal present in the diff | Mode / action |25|---|---|26| Added planning `.md`, `.tools/`, one-time setup, phase/sprint tags, dead code, new config/YAML files, or comment-heavy files | **Garbage Hunt** — `templates/garbage-hunt.md` |27| Test files with copy-pasted methods, repeated setup, or missing parametrization | **Test Compaction** — `templates/test-compaction.md` |28| 4+ new helpers, a fresh AST/IR/syntax-tree walker, twin helpers, hand-rolled smart-constructor, or near-duplicate logic | **Logic Compaction** — `templates/logic-rounds.md` |29| A self-contained concept bloating an already-large file | **Logic Compaction**, prioritize extract-to-new-file |30| Substantial new code logic not matched above | **Logic Compaction** — its Round 0 reuse-hunt finds what it should have reused |3132## When NOT to Use3334Legitimately large multi-subsystem features; generated artifacts;35mechanical churn (dep bumps, renames); minimal one-line bugfixes; GitHub36prose or PR/issue text (a different task).3738## Pre-flight3940On the PR branch. Steps 1–2 run **before** the Mode Selector (they feed41routing); steps 3–4 are per-mode prep once a mode is picked:42431. **Update from main and resolve conflicts.** Do not judge bloat, CI, or44 comments on a stale branch.452. **Measure** against `base=$(git merge-base main HEAD)`:4647 ```bash48 git diff $base -- <suspect-file> | awk '/^\+[^+]/{p++} /^-[^-]/{m++} END{print "+",p," -",m}'49 git diff $base -- <suspect-file> | awk '/^\+[^+]/{ s=$0; sub(/^\+[[:space:]]*/,"",s); if (s ~ /^(\/\/|--|#)/) c++; else if (length(s)) l++ } END{print "comments",c," code",l}'50 git diff $base -- <suspect-file> | grep -cE '^\+\s*(let|fn|def|val|public|private)\s+(rec\s+)?[a-zA-Z_]'51 ```5253 These are LOC + comment-ratio + new-helper count smell-meters, not a54 search. Real semantic discovery happens in Logic Compaction Round 055 via a dispatched subagent (see `templates/logic-rounds.md`).563. **Pin guiding tests verbatim:** must-pass, and must-fail-for-the-right-reason.574. **Bundle measurements + the relevant template** into one context file58 for every reviewer agent.5960## Reviewer Diversity (every mode)6162Dispatch **3–5 background reviewers in parallel** — never sequentially.63**Cross-model > cross-angle**: three same-model agents with different64prompts ≠ three different models (Opus high/xhigh, newer Opus, GPT). Each65agent picks one angle from the mode's template. Record66`model × angle × LOC × tests × reuse × verdict`. Cross-model agreement is67signal; lone-model claims need code citations before promotion.6869**If the user requests a red-flag setup** ("use the same 3 models", "single70agent is enough"), push back once with this rule, then comply if they71insist. Do not silently violate it.7273## Apply7475After picking the winning proposal: apply on the PR branch, run76formatter/lints, run targeted tests + the area's test class as regression77sweep, run any baseline updates. If a sweep test fails, **reproduce on the78pre-change SHA before classifying**. Do not declare "pre-existing" or79"flaky" without that evidence.8081**Splitting commits / ask-before-push** — see NoBloat PR-scope rules.8283## Red Flags — STOP and re-run the relevant template8485(Process failures only — content-level failures are NoBloat's job.)8687- You skipped mode selection and went straight to "make the diff smaller".88- You ran reviewers sequentially, or with same-model agents.89- You grepped for similar functions instead of dispatching a real90 reuse-hunt subagent.91- Your winning proposal added new code without citing one reused helper92 from the Round 0 subagent's output.93- You found a recurring shape across 3 files but added a 4th copy.9495**All of these mean: open the relevant template and re-run.**