modernize-java
Skill345 starsChanged 12 months agoMITView on GitHub
Update Java code to modern language features — records, switch expressions, pattern matching, virtual threads, sealed classes, text blocks, and current collection idioms. Triggers on Java source files.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/hooks/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- onboardSkill
- security-reviewSkill
- spring-controllerSkill
- spring-serviceSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Update the target code to use modern Java features:
- Distinctive: line 14
Records: instead of mutable POJOs where the type is a value carrier
- Distinctive: line 19
Sealed classes: when the type hierarchy is closed
- Distinctive: line 26
Don't change behavior — preserve the public API and observable semantics.
- Very specific: line 27
Don't apply var where the inferred type would harm readability (e.g., factory results that could be any of several types).
- Distinctive: line 28
If the project's target Java version is below 21, skip the 21+ features and note it in your summary.
- Distinctive: line 29
Run the test suite after non-trivial changes.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.
Files
Modernize Java Code
Update the target code to use modern Java features:
- Records instead of mutable POJOs where the type is a value carrier
- Switch expressions with arrow syntax and exhaustiveness checking
- Pattern matching for
instanceofandswitch - Local variable type inference (
var) where it helps readability - Virtual threads (Java 21+) for I/O-bound operations —
Executors.newVirtualThreadPerTaskExecutor() - Sealed classes when the type hierarchy is closed
- Text blocks for multiline strings
- Sequenced collections (Java 21+) where ordered access matters
- Collection factory methods (
List.of,Map.of,Map.entry)
Constraints
- Don't change behavior — preserve the public API and observable semantics.
- Don't apply
varwhere the inferred type would harm readability (e.g., factory results that could be any of several types). - If the project's target Java version is below 21, skip the 21+ features and note it in your summary.
- Run the test suite after non-trivial changes; if tests don't exist, surface that as a follow-up rather than as a blocker.
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
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.

