From distill
Rigorous code refactoring — every line earns its place. Preserves functionality, removes everything that doesn't justify its existence. Use when user says "/distill", "clean this up", "tighten this", "distill", or wants code quality improved without changing behavior.
How this skill is triggered — by the user, by Claude, or both
Slash command
/distill:distillThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Complexity is the enemy. Every layer of indirection, every clever abstraction, every "just in case" branch is friction. Velocity is paramount, and simplicity is what protects it. Needless code isn't harmless. It's drag.
Complexity is the enemy. Every layer of indirection, every clever abstraction, every "just in case" branch is friction. Velocity is paramount, and simplicity is what protects it. Needless code isn't harmless. It's drag.
Strip code to its purest form. Same behavior, fewer words, clearer intent. This is not a linter. Not a formatter. It's an editorial pass where every line must defend its existence.
Read every file in scope. Understand what the code does, how it connects, what it depends on. You cannot cut what you don't understand. Do not skim. Do not assume. Read.
Walk through the code with these lenses. Every line, every construct, every name.
Existence: Why is this here? What breaks if I delete it? If nothing breaks and nothing loses clarity, it goes.
Comments: Is this comment saying something the code doesn't already say? A comment that restates the code is noise. A comment that explains why something non-obvious exists is signal. Kill the noise, keep the signal.
Naming: Is this name earning its keep? A variable called data in a function that handles three kinds of data is failing. A variable called x in a tight math formula is fine. Context determines the right name length. Names should be as short as possible but no shorter.
Complexity: Is there a simpler way to express this? If you're using a $5 word when a 10-cent word works, swap it. Nested ternaries, clever bit tricks, unnecessarily generic abstractions, deep callback chains. Replace with the dumb, obvious version unless the complexity has a measurable reason to exist.
Abstraction: Is this abstraction pulling its weight? A helper function called once is just indirection. A trait with one implementation is ceremony. A wrapper that adds nothing is a toll booth. Inline it, flatten it, remove the middleman.
Control flow: Is this the simplest path through the logic? Early returns instead of nested ifs. Guard clauses instead of deep branches. Linear flow instead of ping-ponging between functions.
Dead weight: Unused imports, unreachable branches, TODO comments with no ticket, commented-out code, debug prints left behind. All of it goes.
Bad practice: Is this code doing something that will cause real problems? Not style nitpicks. Actual landmines. SQL built from string concatenation, secrets in source, unbounded retries, silent error swallowing, race conditions, auth checks that can be bypassed. If the code works today but is one bad day away from a security hole, data loss, or cascading failure, that's not a cleanup item. That's a flag. Surface it in diagnosis with urgency. "This works, but it shouldn't be done this way because [concrete reason]."
Surface what you found. This is the checkpoint. No changes yet.
Present your findings grouped by pattern, not line-by-line. Keep it tight. Each finding needs a what and a why. Refactoring without a reason is pointless churn.
Format:
Found N things across M files.
**Unnecessary complexity** — [file:fn] uses a generic trait bound where a concrete type works. Only one type ever implements it. Adds indirection for no polymorphism.
**Dead comments** — [file] has 6 comments restating what the code already says. They cost reading time and add zero information.
**Tangled flow** — [file:fn] nests 4 levels deep with if-let chains. Could flatten to guard clauses with early returns. Same logic, half the indentation.
**Naming** — [file] uses `data`, `result`, `temp` for three distinct domain objects. Names should reflect what they carry.
Every finding justifies itself. If you can't articulate why something is a problem, it isn't one. Leave it alone.
Then ask:
"These are the patterns I want to address. Proceed?"
If the user said "don't wait, just do" (or similar) upfront, skip the checkpoint and go straight through. Otherwise, wait for the green light.
After diagnosis (and approval), restructure. This is where you apply what you found.
Rules:
When you don't understand something, stop and ask. This is not optional. If a piece of code looks wrong, redundant, or weirdly structured but you can't explain why it's that way, do not touch it. Ask: "Why does this work like this?" The weird thing might be the point. Retries that look excessive exist because the upstream API is flaky and someone learned that the hard way.
If something smells like a workaround or a hard-won fix, treat it as load-bearing until proven otherwise. A 10-second question beats a confident deletion that breaks prod.
Interview the user. If intent is unclear on multiple things, batch the questions. "Before I touch these, I want to understand why they exist." This is a feature of the skill, not a failure of confidence.
Before presenting changes, verify:
If anything is uncertain, flag it explicitly. Don't ship doubt.
You cleaned your corner. Now look around the room.
Trace outward from the distilled code. What calls it? What does it call? What renders it, consumes it, tests it? If those adjacent files are messy, they're in scope.
How to sweep:
After sweeping, ask the user:
"These files are connected to what I just distilled and could use the same pass: [list files with one-line reasons]. Want me to clean these up too?"
Only proceed if they say yes. Never silently expand scope. But always surface the opportunity. Cleaning one function while its caller is a mess just moves the eyesore.
The goal: when someone reviews the PR, the whole area looks intentional. Not one pristine file surrounded by rough edges.
Show the distilled code. For each file changed, briefly state what changed and why. Keep the explanations tight. One line per change category is plenty.
Format:
## <file_path>
- Removed: <what and why>
- Simplified: <what and why>
- Restructured: <what and why>
If the code was already clean, say so. Don't manufacture changes to justify the pass.
Not all code needs the same intensity. Scale the pass to what's in front of you.
Deep distillation — New or recently written code. Fresh from an agent or a fast coding session. Apply full interrogation. This is where the most waste lives.
Light distillation — Mature, tested code that works. Touch only what clearly needs it. Stable code has earned trust. Don't disturb working systems for marginal gains.
Targeted distillation — User points at a specific area. Focus there. Skip the sweep step. Don't wander into adjacent files looking for problems.
When you're done, someone reading this code should think: "this was written by someone who cares." Not because it's clever. Because it's clear. Because nothing is wasted. Because every line is there for a reason and that reason is obvious.
That's the bar. Hit it.
npx claudepluginhub noahdunnagan/cafe --plugin distillRefines existing code for clarity, readability, and maintainability without changing behavior, interfaces, or outputs. Use for simplify, clean up, refactor for readability requests.
Multi-pass code refactoring that reduces complexity, nesting, and anti-patterns in Python, Go, TypeScript, and Rust while preserving behavior.
Refactors code by removing dead code, extracting duplication, and simplifying deep nesting while preserving behavior. Runs tests before and after to confirm nothing breaks.