agentleFS
soujavasoujava/agent-skills/skills/java-distiller/SKILL.md

java-distiller

Skill10 starsChanged 4 months agoMITView on GitHub

Simplify, modernize, refactor, and beautify Java code to produce clean, idiomatic Java. 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 21+", "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 an appropriate Java development skill for that.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the input code carefully

    line 20
  2. Distinctive:

    Do not add comments, Javadoc, or logging that wasn't there

    line 53
  3. Distinctive:

    Do not add error handling beyond what exists unless the original code has a bug

    line 54
  4. Distinctive:

    Do not introduce new dependencies

    line 55
  5. Distinctive:

    Remove unnecessary blank lines, redundant modifiers, and dead imports

    line 56
  6. Very specific:

    Use var where the type is obvious from the right-hand side

    line 57
  7. Very specific:

    Use module imports (import module java.net.http;) over individual type imports when the target JDK supports them

    line 58
  8. Very specific:

    Prefer void main() over public static void main(String[] args) when appropriate

    line 59
  9. Distinctive:

    When multiple transformations compete, choose the one that produces fewer lines

    line 60
  10. Distinctive:

    If the code is already clean and modern, say so — don't force changes

    line 61

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 21+ 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
  • Preserve exact behavior — distilling is refactoring, not rewriting

Workflow

  1. Read the input code carefully
  2. Identify transformation opportunities (see references/transformations.md)
  3. Apply transformations — prioritize those with the highest impact-to-risk ratio
  4. Present the distilled code with a brief explanation of what changed and why

Transformation Priority

Apply in this order — high-impact, low-risk first:

  1. Syntax modernization — var, text blocks, switch expressions, pattern matching, module imports
  2. API upgrades — java.time, java.nio.file, HttpClient, List.of/Map.of, Optional, Stream
  3. Pattern adoption — records, sealed interfaces, pattern matching for instanceof and switch
  4. Functional style — streams over loops, lambdas over anonymous classes, method references
  5. Concurrency modernization — virtual threads, structured concurrency, scoped values (only when the codebase already uses them or the target JDK supports them)
  6. Structural simplification — flatten hierarchies, inline trivial methods, remove dead code

Output Format

## Distilled Java Code

```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 when the target JDK supports them
  • 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
  • Respect the project's target Java version; do not introduce preview features unless explicitly enabled

Detailed Transformation Catalog

See references/transformations.md for the complete catalog of before/after transformation patterns organized by category.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.