Simplify Code
A deslop pipeline that always fans out to focused lane detectives in isolated
context, coalesces their findings, and applies the safe ones. This is the
quality/maintainability sibling to review-code (which owns correctness, security,
and performance) — run it independently when you want to deslop without a bug
review.
Each lane runs the code-simplifier agent against a subset of the AI-slop
rubric, so each instance reasons deeply about one cohesive family instead of
spreading thin across the whole rubric. The skill resolves scope, selects lanes,
dispatches them read-only, then coalesces and applies. Use this instead of the
built-in /simplify, which spawns generic agents without the curated rubric.
When to invoke
- "Simplify this", "clean this up", "deslop", "tidy up", after AI-generated code lands
- Pre-PR cleanup of a feature branch
- "Run simplify-code on the codebase" — a deeper, repo-wide cut (see
codebase mode)
Don't use for: finding bugs / security / perf issues (use review-code); looping
review+simplify until clean (use auto-review-code, which calls this fan-out).
Modes
Pick one before invoking; default branch when there's a diff, else paths.
branch (default) — changed files vs the main branch (git diff --name-only <base>...HEAD).
paths — an explicit file/dir list from the caller, reviewed as-is. Do not default to whole-repo; ask if missing.
codebase — a deliberate repo-wide cut. Do not read every file: hotspot-rank first (largest files, highest churn via git log --format= --name-only | sort | uniq -c | sort -rn | head, and most-recently-changed), take the top slice, and budget each lane to that slice. Always log() what was ranked-in and what was left out — a repo-wide pass that silently samples reads as "covered everything" when it didn't.
Process
1. Resolve scope
branch: base branch (default main; git symbolic-ref refs/remotes/origin/HEAD or an explicit override). Diff range <base>...HEAD; collect changed files. If the working tree is dirty with no branch diff, fall back to git diff/git diff HEAD, then to files edited this conversation.
paths: the caller's explicit list.
codebase: the hotspot-ranked slice (above).
Capture the explicit file list — lane detectives run in isolated context and see only what you pass.
2. Select lanes (domain-gating)
The pipeline always fans out, but a lane only spins up if the scope contains a
file it could match — running a lane with nothing in scope just adds noise (the
same lane-selection review-code does). A lane with no matching files is skipped,
not dispatched.
| Lane |
Rule IDs it owns |
Runs when scope has |
| comments |
comments.placeholder-comments, comments.template-comments, comments.docstring-rationale, comments.change-narration, comments.over-explanatory |
any source file (it carries the delete-vs-tighten gate, so all comment rules MUST stay in this one lane) |
| structure |
structure.duplicate-function-signatures, structure.pass-through-functions, structure.trivial-helper-method, structure.bandaid-special-case, structure.inline-data-blob, dead-code.unused-abstraction |
any source file (owns the cross-file + pre-existing-sibling pass) |
| typing |
typing.codebase-alias-missed, stdlib.reinvented |
a statically-typed / stdlib-rich language (Python, TS, Go, Rust, Java, C#…); skip for markup/config-only |
| complexity |
structure.reducible-complexity, organization.god-module, organization.barrel-file-density |
any source file (god-module/barrel benefit from ≥2 files, but reducible-complexity fires on one) |
| defensive |
defensive.error-swallowing, async.unnecessary-return-await, async.trivial-wrapper |
any source file with error handling or async constructs |
A docs-only or config-only diff may select no lanes — that's a valid outcome; say so and stop.
3. Ground the pass
- Note whether
CLAUDE.md / AGENTS.md / REVIEW_GUIDELINES.md exist (lanes load them for project standards).
- Capture any caller "don't flag X, it's intentional" notes verbatim to forward to every lane. A caller note removes a comment from the delete bucket only — it does NOT exempt it from
comments.over-explanatory tightening.
4. Dispatch the lanes in parallel
Invoke every selected lane in a single message with multiple Task calls so they run concurrently. Each uses subagent_type: sontek-skills:code-simplifier. Each prompt is self-contained (isolated context) and must say:
- Lane focus: "Run the
<lane> lane only. From your rubric, apply exactly these rule IDs: [<ids>]. Report findings for these rules only; ignore every other rule."
- Read-only: "Return your normal per-file findings report (rule IDs + evidence + precise before → after). Do NOT edit any files — this skill applies the fixes."
- Scope: the mode, the diff range or explicit file list, and the changed-file list.
- Grounding: pointer to
CLAUDE.md/AGENTS.md/REVIEW_GUIDELINES.md if present; the caller "don't flag X" notes verbatim.
- Lane-specific:
- structure — "Run the cross-file Phase-0 fingerprint pass over the full scope, AND compare each new/changed function against pre-existing siblings in its package (same dir, sibling subclasses of a shared base)." Pass the full file list.
- typing — "Run the Phase-0b calibration (inversion protocol) and emit the candidates-considered ledger before findings."
5. Coalesce, verify, and apply
- Dedup across lanes. Lanes own disjoint rule IDs, but the same line can surface in two (e.g. an inline-data blob inside an over-complex function). Same file within ±3 lines on the same root issue → one entry; note the corroboration.
- Comment gate already resolved. The delete-vs-tighten arbitration lives entirely inside the comments lane (that's why the comment rules are one lane), so there's no cross-lane comment conflict to referee here.
- Verify the risky ones (optional but preferred). For any structural fix where you can't prove behavior is preserved, dispatch the
finding-verifier agent on the consolidated list before applying — drop REFUTED, keep CONFIRMED/PLAUSIBLE.
- Apply per
auto-review-code's apply policy (don't re-implement it — that skill owns the triage rules):
- Auto-apply low-risk, behavior-preserving fixes where existing tests are the regression guard: slop comments,
comments.docstring-rationale/change-narration/template-comments deletions, comments.over-explanatory tightening, trivial wrappers, defensive try/catch with no semantic loss, test-only helper inlines.
- Always flag (never auto-apply) the higher-risk rules, matching their own rubric notes:
structure.reducible-complexity, organization.god-module, structure.bandaid-special-case (structural refactors), dead-code.unused-abstraction (deletes code + its tests), and anything inlining a production-called helper or changing a public signature/type. State the precise before → after and call sites; let the user decide.
- Dismiss false positives with a one-line rationale (lanes over-flag by design; pruning is the skill's job).
Report what each lane found, what was applied, and what was flagged, in one short summary — no per-finding narration during the pass.
1---2name: simplify-code3description: Review changed code for AI-generated slop and apply fixes. Use when the user says "simplify", "clean this up", "deslop", "tidy up", or after AI-generated code lands. Fans out to focused code-quality lane detectives (comments, structure, typing, complexity, defensive), coalesces their findings, and applies the safe ones.4---56# Simplify Code78A deslop pipeline that always **fans out** to focused lane detectives in isolated9context, coalesces their findings, and applies the safe ones. This is the10quality/maintainability sibling to `review-code` (which owns correctness, security,11and performance) — run it independently when you want to deslop without a bug12review.1314Each lane runs the `code-simplifier` agent against a **subset** of the AI-slop15rubric, so each instance reasons deeply about one cohesive family instead of16spreading thin across the whole rubric. The skill resolves scope, selects lanes,17dispatches them read-only, then coalesces and applies. Use this instead of the18built-in `/simplify`, which spawns generic agents without the curated rubric.1920## When to invoke2122- "Simplify this", "clean this up", "deslop", "tidy up", after AI-generated code lands23- Pre-PR cleanup of a feature branch24- "Run simplify-code on the codebase" — a deeper, repo-wide cut (see `codebase` mode)2526Don't use for: finding bugs / security / perf issues (use `review-code`); looping27review+simplify until clean (use `auto-review-code`, which calls this fan-out).2829## Modes3031Pick one before invoking; default `branch` when there's a diff, else `paths`.3233- **`branch` (default)** — changed files vs the main branch (`git diff --name-only <base>...HEAD`).34- **`paths`** — an explicit file/dir list from the caller, reviewed as-is. Do not default to whole-repo; ask if missing.35- **`codebase`** — a deliberate repo-wide cut. Do **not** read every file: **hotspot-rank** first (largest files, highest churn via `git log --format= --name-only | sort | uniq -c | sort -rn | head`, and most-recently-changed), take the top slice, and budget each lane to that slice. Always `log()` what was ranked-in and what was left out — a repo-wide pass that silently samples reads as "covered everything" when it didn't.3637## Process3839### 1. Resolve scope4041- `branch`: base branch (default `main`; `git symbolic-ref refs/remotes/origin/HEAD` or an explicit override). Diff range `<base>...HEAD`; collect changed files. If the working tree is dirty with no branch diff, fall back to `git diff`/`git diff HEAD`, then to files edited this conversation.42- `paths`: the caller's explicit list.43- `codebase`: the hotspot-ranked slice (above).4445Capture the explicit file list — lane detectives run in isolated context and see only what you pass.4647### 2. Select lanes (domain-gating)4849The pipeline always fans out, but a lane only spins up if the scope contains a50file it could match — running a lane with nothing in scope just adds noise (the51same lane-selection `review-code` does). A lane with no matching files is skipped,52not dispatched.5354| Lane | Rule IDs it owns | Runs when scope has |55|---|---|---|56| **comments** | `comments.placeholder-comments`, `comments.template-comments`, `comments.docstring-rationale`, `comments.change-narration`, `comments.over-explanatory` | any source file (it carries the delete-vs-tighten gate, so all comment rules MUST stay in this one lane) |57| **structure** | `structure.duplicate-function-signatures`, `structure.pass-through-functions`, `structure.trivial-helper-method`, `structure.bandaid-special-case`, `structure.inline-data-blob`, `dead-code.unused-abstraction` | any source file (owns the cross-file + pre-existing-sibling pass) |58| **typing** | `typing.codebase-alias-missed`, `stdlib.reinvented` | a statically-typed / stdlib-rich language (Python, TS, Go, Rust, Java, C#…); skip for markup/config-only |59| **complexity** | `structure.reducible-complexity`, `organization.god-module`, `organization.barrel-file-density` | any source file (god-module/barrel benefit from ≥2 files, but reducible-complexity fires on one) |60| **defensive** | `defensive.error-swallowing`, `async.unnecessary-return-await`, `async.trivial-wrapper` | any source file with error handling or async constructs |6162A docs-only or config-only diff may select **no** lanes — that's a valid outcome; say so and stop.6364### 3. Ground the pass6566- Note whether `CLAUDE.md` / `AGENTS.md` / `REVIEW_GUIDELINES.md` exist (lanes load them for project standards).67- Capture any caller "don't flag X, it's intentional" notes **verbatim** to forward to every lane. A caller note removes a comment from the *delete* bucket only — it does NOT exempt it from `comments.over-explanatory` tightening.6869### 4. Dispatch the lanes in parallel7071Invoke every selected lane in a **single message with multiple Task calls** so they run concurrently. Each uses `subagent_type: sontek-skills:code-simplifier`. Each prompt is self-contained (isolated context) and must say:7273- **Lane focus:** "Run the **`<lane>`** lane only. From your rubric, apply **exactly** these rule IDs: `[<ids>]`. Report findings for these rules only; ignore every other rule."74- **Read-only:** "Return your normal per-file findings report (rule IDs + evidence + precise before → after). **Do NOT edit any files** — this skill applies the fixes."75- **Scope:** the mode, the diff range or explicit file list, and the changed-file list.76- **Grounding:** pointer to `CLAUDE.md`/`AGENTS.md`/`REVIEW_GUIDELINES.md` if present; the caller "don't flag X" notes verbatim.77- **Lane-specific:**78 - **structure** — "Run the cross-file Phase-0 fingerprint pass over the full scope, AND compare each new/changed function against pre-existing siblings in its package (same dir, sibling subclasses of a shared base)." Pass the full file list.79 - **typing** — "Run the Phase-0b calibration (inversion protocol) and emit the candidates-considered ledger before findings."8081### 5. Coalesce, verify, and apply8283- **Dedup across lanes.** Lanes own disjoint rule IDs, but the same line can surface in two (e.g. an inline-data blob inside an over-complex function). Same file within ±3 lines on the same root issue → one entry; note the corroboration.84- **Comment gate already resolved.** The delete-vs-tighten arbitration lives entirely inside the comments lane (that's why the comment rules are one lane), so there's no cross-lane comment conflict to referee here.85- **Verify the risky ones (optional but preferred).** For any structural fix where you can't prove behavior is preserved, dispatch the `finding-verifier` agent on the consolidated list before applying — drop REFUTED, keep CONFIRMED/PLAUSIBLE.86- **Apply per `auto-review-code`'s apply policy** (don't re-implement it — that skill owns the triage rules):87 - **Auto-apply low-risk, behavior-preserving fixes** where existing tests are the regression guard: slop comments, `comments.docstring-rationale`/`change-narration`/`template-comments` deletions, `comments.over-explanatory` tightening, trivial wrappers, defensive `try/catch` with no semantic loss, test-only helper inlines.88 - **Always flag (never auto-apply) the higher-risk rules**, matching their own rubric notes: `structure.reducible-complexity`, `organization.god-module`, `structure.bandaid-special-case` (structural refactors), `dead-code.unused-abstraction` (deletes code + its tests), and anything inlining a production-called helper or changing a public signature/type. State the precise before → after and call sites; let the user decide.89 - **Dismiss false positives** with a one-line rationale (lanes over-flag by design; pruning is the skill's job).9091Report what each lane found, what was applied, and what was flagged, in one short summary — no per-finding narration during the pass.