Java Distiller
Transform Java code into its cleanest, most modern, idiomatic form. Distill away verbosity, legacy patterns, and accidental complexity — keep only the essence.
Philosophy
- Distill, don't decorate — remove complexity, don't add abstractions
- Modern Java first — use Java 25 features wherever they simplify the code
- Functional over imperative — prefer streams, lambdas, and declarative style when clearer
- Less code, more meaning — every remaining line should earn its place
Workflow
- Read the input code carefully
- Identify transformation opportunities (see references/transformations.md)
- Apply transformations — prioritize those with the highest impact-to-risk ratio
- Present the distilled code with a brief explanation of what changed and why
Transformation Priority
Apply in this order — high-impact, low-risk first:
- Syntax modernization — var, text blocks, switch expressions, module imports
- API upgrades — java.time, java.nio.file, HttpClient, List.of/Map.of
- Pattern adoption — records, sealed interfaces, pattern matching
- Functional style — streams over loops, lambdas over anonymous classes
- Concurrency modernization — virtual threads, structured concurrency, scoped values
- Structural simplification — flatten hierarchies, inline trivial methods, remove dead code
Output Format
## Distilled
```java
// transformed code
```
### Changes
- <what changed> — <why it's better>
- ...
Rules
- Preserve behavior exactly — distilling is refactoring, not rewriting
- Do not add comments, javadoc, or logging that wasn't there
- Do not add error handling beyond what exists unless the original code has a bug
- Do not introduce new dependencies
- Remove unnecessary blank lines, redundant modifiers, and dead imports
- Use
var where the type is obvious from the right-hand side
- Use module imports (
import module java.net.http;) over individual type imports
- Prefer
void main() over public static void main(String[] args) when appropriate
- When multiple transformations compete, choose the one that produces fewer lines
- If the code is already clean and modern, say so — don't force changes
Detailed Transformation Catalog
See references/transformations.md for the complete catalog of before/after transformation patterns organized by category.
1---2name: java-distiller3description: Simplify, modernize, refactor, and beautify Java code to produce clean, idiomatic Java 25. Use when asked to distill, simplify, modernize, upgrade, refactor, clean up, beautify, or improve Java code. Triggers on "distill this Java", "modernize this code", "simplify this Java", "upgrade to modern Java", "refactor to Java 25", "clean up this code", "make this idiomatic", "beautify this Java", or when Java code needs transformation to current standards. Not for writing new code from scratch — use java-development for that.4---56# Java Distiller78Transform Java code into its cleanest, most modern, idiomatic form. Distill away verbosity, legacy patterns, and accidental complexity — keep only the essence.910## Philosophy1112- **Distill, don't decorate** — remove complexity, don't add abstractions13- **Modern Java first** — use Java 25 features wherever they simplify the code14- **Functional over imperative** — prefer streams, lambdas, and declarative style when clearer15- **Less code, more meaning** — every remaining line should earn its place1617## Workflow18191. Read the input code carefully202. Identify transformation opportunities (see [references/transformations.md](references/transformations.md))213. Apply transformations — prioritize those with the highest impact-to-risk ratio224. Present the distilled code with a brief explanation of what changed and why2324## Transformation Priority2526Apply in this order — high-impact, low-risk first:27281. **Syntax modernization** — var, text blocks, switch expressions, module imports292. **API upgrades** — java.time, java.nio.file, HttpClient, List.of/Map.of303. **Pattern adoption** — records, sealed interfaces, pattern matching314. **Functional style** — streams over loops, lambdas over anonymous classes325. **Concurrency modernization** — virtual threads, structured concurrency, scoped values336. **Structural simplification** — flatten hierarchies, inline trivial methods, remove dead code3435## Output Format3637````markdown38## Distilled3940```java41// transformed code42```4344### Changes45- <what changed> — <why it's better>46- ...47````4849## Rules5051- Preserve behavior exactly — distilling is refactoring, not rewriting52- Do not add comments, javadoc, or logging that wasn't there53- Do not add error handling beyond what exists unless the original code has a bug54- Do not introduce new dependencies55- Remove unnecessary blank lines, redundant modifiers, and dead imports56- Use `var` where the type is obvious from the right-hand side57- Use module imports (`import module java.net.http;`) over individual type imports58- Prefer `void main()` over `public static void main(String[] args)` when appropriate59- When multiple transformations compete, choose the one that produces fewer lines60- If the code is already clean and modern, say so — don't force changes6162## Detailed Transformation Catalog6364See [references/transformations.md](references/transformations.md) for the complete catalog of before/after transformation patterns organized by category.