141-java-refactoring-with-modern-features — скилл для Claude Code
Скилл переводит старый Java-код на современные возможности языка: лямбды, Stream API, Optional, java.time. Пригодится, когда проект пора чистить от легаси.
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a claude-codeЧто делает 141-java-refactoring-with-modern-features
Скилл ищет места, где Java-код можно переписать на возможностях Java 8+ и новее. В список входят лямбды и ссылки на методы вместо анонимных классов, Stream API вместо циклов с Iterator, Optional для null-безопасных API, java.time вместо Date и Calendar, фабричные методы коллекций (List.of(), Set.of(), Map.of()), текстовые блоки, вывод типов через var. Отдельно разобраны возможности Java 25: гибкие тела конструкторов (JEP 513) и объявления импорта модулей (JEP 511).
Устроено как последовательность шагов. Сначала скилл требует собрать проект командой ./mvnw compile или mvn compile и остановиться, если сборка падает. Потом читает справочник references/141-java-refactoring-with-modern-features.md с примерами хорошего и плохого кода по каждой теме и выбирает кандидатов на переписывание. Дальше правки вносятся постепенно, с сохранением поведения, а в конце прогоняется ./mvnw clean verify или mvn clean verify.
Сборка до начала работы — не формальность. Если проект не компилируется, скилл останавливается и не трогает код, потому что иначе не отличить старую ошибку от внесённой. При неясной области задачи он задаёт уточняющий вопрос, а при нехватке файлов или инструментов сообщает, чего нет.
Какие задачи решает
- переписать анонимные классы на лямбды и ссылки на методы
- заменить циклы с
Iteratorна Stream API - убрать проверки на null через
Optional - перевести работу с датами с
DateиCalendarнаjava.time - собрать неизменяемые коллекции через
List.of()иMap.of()
Примеры запросов агенту
- пройдись по сервисному слою и замени анонимные классы на лямбды
- перепиши этот цикл с
Iteratorна Stream API - замени
Dateнаjava.timeв этом классе
Как установить 141-java-refactoring-with-modern-features
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a claude-code2Вручную: положить файлы
~/.claude/skills/141-java-refactoring-with-modern-features/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/141-java-refactoring-with-modern-features/
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a codex2Вручную: положить файлы
.agents/skills/141-java-refactoring-with-modern-features/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a cursor2Вручную: положить файлы
.cursor/skills/141-java-refactoring-with-modern-features/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install jabrena/plinth 141-java-refactoring-with-modern-features2Вручную: положить файлы
.github/skills/141-java-refactoring-with-modern-features/SKILL.md1Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a gemini-cli2Командой платформы
gemini skills install https://github.com/jabrena/plinth --path skills/141-java-refactoring-with-modern-featuresВручную: положить файлы
.devin/skills/141-java-refactoring-with-modern-features/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о 141-java-refactoring-with-modern-features
Как установить 141-java-refactoring-with-modern-features в Claude?
Выполните npx skills add jabrena/plinth --skill 141-java-refactoring-with-modern-features -a claude-code. Файл скилла окажется по пути ~/.claude/skills/141-java-refactoring-with-modern-features/SKILL.md.
Что делает 141-java-refactoring-with-modern-features?
Находит в Java-коде места, которые можно переписать на возможностях Java 8+ и Java 25, и вносит правки по шагам. Перед этим собирает проект, после — прогоняет полную проверку.
Что нужно, чтобы скилл сработал?
Проект должен компилироваться до начала работы: скилл запускает ./mvnw compile или mvn compile и останавливается при ошибке сборки. Если область задачи непонятна, он сначала задаст уточняющий вопрос.
Исходный текст
SKILL.md · Apache-2.0
--- name: 141-java-refactoring-with-modern-features description: Use when you need to refactor Java code to adopt modern Java features (Java 8+) — including migrating anonymous classes to lambdas, replacing Iterator loops with Stream API, adopting Optional for null safety, switching from legacy Date/Calendar to java.time, using collection factory methods, applying text blocks, var inference, or leveraging Java 25 features like flexible constructor bodies and module import declarations. This should trigger for requests such as Review Java code for modern Java development; Apply best practices for modern Java development in Java code; Modernize Java code with records pattern matching or switch expressions; Replace legacy idioms with modern Java features; Adopt Java 8+ language features safely. Part of Plinth Toolkit license: Apache-2.0 metadata: author: Juan Antonio Breña Moral version: 0.19.0 --- # Modern Java Development Guidelines (Java 8+) Identify and apply modern Java (Java 8+) refactoring opportunities to improve readability, maintainability, and performance. **What is covered in this Skill?** - Lambda expressions and method references (over anonymous classes) - Stream API for declarative collection processing - `Optional` for null-safe APIs - `java.time` API (replacing `Date`/`Calendar`) - Default interface methods, `var` type inference - Unmodifiable collection factory methods (`List.of()`, `Set.of()`, `Map.of()`) - Text blocks for multi-line strings - Java 25 Flexible Constructor Bodies (JEP 513) - Java 25 Module Import Declarations (JEP 511) **Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples. ## Constraints Before applying any modern Java refactoring, ensure the project compiles. If compilation fails, stop immediately — do not proceed until the project compiles successfully. After applying improvements, run full verification. - **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any changes - **SAFETY**: If compilation fails, stop immediately — do not proceed until the project compiles successfully - **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements - **BEFORE APPLYING**: Read the reference for detailed good/bad examples, constraints, and safeguards for each modern Java feature - **EDGE CASE**: If request scope is ambiguous, stop and ask a clarifying question before applying changes - **EDGE CASE**: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance ## When to use this skill - Review Java code for modern Java development - Apply best practices for modern Java development in Java code - Modernize Java code with records pattern matching or switch expressions - Replace legacy idioms with modern Java features - Adopt Java 8+ language features safely ## Workflow 1. **Compile project before modernization** Run `./mvnw compile` or `mvn compile` and stop immediately if compilation fails. 2. **Read modern-Java reference and identify candidates** Read `references/141-java-refactoring-with-modern-features.md` and identify high-value opportunities to adopt modern Java features. 3. **Apply modern Java refactorings** Refactor incrementally using appropriate language/library features while preserving behavior and readability. 4. **Verify with full build** Run `./mvnw clean verify` or `mvn clean verify` after applying improvements. ## Reference For detailed guidance, examples, and constraints, see [references/141-java-refactoring-with-modern-features.md](references/141-java-refactoring-with-modern-features.md).
© Juan Antonio Breña Moral · Apache-2.0 · jabrena/plinth