{"id":"356758f5-9e61-4fee-953c-af5c8929e3cb","shortId":"MyUQ7T","kind":"skill","title":"141-java-refactoring-with-modern-features","tagline":"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 fact","description":"# Modern Java Development Guidelines (Java 8+)\n\nIdentify and apply modern Java (Java 8+) refactoring opportunities to improve readability, maintainability, and performance.\n\n**What is covered in this Skill?**\n\n- Lambda expressions and method references (over anonymous classes)\n- Stream API for declarative collection processing\n- `Optional` for null-safe APIs\n- `java.time` API (replacing `Date`/`Calendar`)\n- Default interface methods, `var` type inference\n- Unmodifiable collection factory methods (`List.of()`, `Set.of()`, `Map.of()`)\n- Text blocks for multi-line strings\n- Java 25 Flexible Constructor Bodies (JEP 513)\n- Java 25 Module Import Declarations (JEP 511)\n\n**Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.\n\n## Constraints\n\nBefore 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.\n\n- **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any changes\n- **SAFETY**: If compilation fails, stop immediately — do not proceed until the project compiles successfully\n- **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements\n- **BEFORE APPLYING**: Read the reference for detailed good/bad examples, constraints, and safeguards for each modern Java feature\n- **EDGE CASE**: If request scope is ambiguous, stop and ask a clarifying question before applying changes\n- **EDGE CASE**: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance\n\n## When to use this skill\n\n- Review Java code for modern Java development\n- Apply best practices for modern Java development in Java code\n\n## Workflow\n\n1. **Compile project before modernization**\n\nRun `./mvnw compile` or `mvn compile` and stop immediately if compilation fails.\n\n2. **Read modern-Java reference and identify candidates**\n\nRead `references/141-java-refactoring-with-modern-features.md` and identify high-value opportunities to adopt modern Java features.\n\n3. **Apply modern Java refactorings**\n\nRefactor incrementally using appropriate language/library features while preserving behavior and readability.\n\n4. **Verify with full build**\n\nRun `./mvnw clean verify` or `mvn clean verify` after applying improvements.\n\n## Reference\n\nFor detailed guidance, examples, and constraints, see [references/141-java-refactoring-with-modern-features.md](references/141-java-refactoring-with-modern-features.md).","tags":["141","java","refactoring","with","modern","features","cursor","rules","jabrena","agent-skills","ai-skills","claude"],"capabilities":["skill","source-jabrena","skill-141-java-refactoring-with-modern-features","topic-agent-skills","topic-ai-skills","topic-claude","topic-claude-code","topic-claude-code-skills","topic-claude-code-subagents","topic-claude-skills","topic-cursor-agent","topic-cursor-ai","topic-cursor-skills","topic-cursorai","topic-github-copilot"],"categories":["cursor-rules-java"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/jabrena/cursor-rules-java/141-java-refactoring-with-modern-features","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add jabrena/cursor-rules-java","source_repo":"https://github.com/jabrena/cursor-rules-java","install_from":"skills.sh"}},"qualityScore":"0.631","qualityRationale":"deterministic score 0.63 from registry signals: · indexed on github topic:agent-skills · 362 github stars · SKILL.md body (2,633 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-26T12:53:35.449Z","embedding":null,"createdAt":"2026-04-18T22:02:02.540Z","updatedAt":"2026-04-26T12:53:35.449Z","lastSeenAt":"2026-04-26T12:53:35.449Z","tsv":"'/mvnw':187,212,306,361 '1':300 '141':1 '2':317 '25':122,129 '3':339 '4':355 '511':134 '513':127 '8':22,54,61 'adopt':17,35,335 'ambigu':245 'anonym':25,82 'api':34,85,95,97 'appli':57,149,157,180,193,220,223,253,289,340,369 'applic':153 'appropri':347 'area':148 'ask':248,270 'base':151 'behavior':352 'best':290 'block':115 'bodi':125 'build':359 'calendar':100 'candid':325 'case':240,256 'chang':195,254 'clarifi':250 'class':26,83 'clean':213,217,362,366 'code':15,143,284,298 'collect':47,88,108 'compil':165,167,177,188,191,198,208,301,307,310,315 'constraint':155,231,377 'constructor':124 'core':147 'cover':72 'date':99 'date/calendar':43 'declar':87,132 'default':101 'detail':228,373 'develop':51,288,295 'edg':239,255 'ensur':162 'exampl':141,154,230,375 'express':77 'fact':48 'factori':109 'fail':168,199,316 'featur':7,20,238,338,349 'file':260 'flexibl':123 'full':183,358 'good/bad':142,229 'guidanc':276,374 'guidelin':52 'high':331 'high-valu':330 'identifi':55,324,329 'immedi':170,201,313 'import':131 'improv':65,181,221,370 'includ':23 'increment':345 'infer':106 'input':259 'interfac':102 'iter':30 'java':3,14,19,21,50,53,59,60,121,128,160,237,283,287,294,297,321,337,342 'java-refactoring-with-modern-featur':2 'java.time':45,96 'jep':126,133 'lambda':28,76 'language/library':348 'legaci':42 'line':119 'list.of':111 'loop':31 'maintain':67 'mandatori':185 'map.of':113 'method':79,103,110 'migrat':24 'miss':264,268 'modern':6,18,49,58,159,236,286,293,304,320,336,341 'modern-java':319 'modul':130 'multi':118 'multi-lin':117 'mvn':190,216,309,365 'need':11 'null':38,93 'null-saf':92 'opportun':63,333 'option':36,90 'organ':139 'pattern':144 'perform':69 'practic':291 'preserv':351 'proceed':173,204,273 'process':89 'project':164,176,207,302 'question':251 'read':224,318,326 'readabl':66,354 'recommend':150 'refactor':4,13,62,161,343,344 'refer':80,137,226,322,371 'references/141-java-refactoring-with-modern-features.md':327,379,380 'replac':29,98 'report':265 'request':242 'requir':258 'review':282 'run':182,186,211,305,360 'safe':94 'safeguard':233 'safeti':39,196 'scope':135,243 'see':378 'set.of':112 'setup':275 'skill':75,281 'skill-141-java-refactoring-with-modern-features' 'source-jabrena' 'stop':169,200,246,312 'stream':33,84 'string':120 'success':178,209 'switch':40 'text':114 'tool':262 'topic-agent-skills' 'topic-ai-skills' 'topic-claude' 'topic-claude-code' 'topic-claude-code-skills' 'topic-claude-code-subagents' 'topic-claude-skills' 'topic-cursor-agent' 'topic-cursor-ai' 'topic-cursor-skills' 'topic-cursorai' 'topic-github-copilot' 'type':105 'unmodifi':107 'use':8,46,279,346 'valu':332 'var':104 'verif':184 'verifi':210,214,218,356,363,367 'whether':271 'workflow':299","prices":[{"id":"a02769ed-e0fa-4e05-ace9-9b09ca820a0f","listingId":"356758f5-9e61-4fee-953c-af5c8929e3cb","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"jabrena","category":"cursor-rules-java","install_from":"skills.sh"},"createdAt":"2026-04-18T22:02:02.540Z"}],"sources":[{"listingId":"356758f5-9e61-4fee-953c-af5c8929e3cb","source":"github","sourceId":"jabrena/cursor-rules-java/141-java-refactoring-with-modern-features","sourceUrl":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/141-java-refactoring-with-modern-features","isPrimary":false,"firstSeenAt":"2026-04-18T22:02:02.540Z","lastSeenAt":"2026-04-26T12:53:35.449Z"}],"details":{"listingId":"356758f5-9e61-4fee-953c-af5c8929e3cb","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"jabrena","slug":"141-java-refactoring-with-modern-features","github":{"repo":"jabrena/cursor-rules-java","stars":362,"topics":["agent-skills","ai-skills","claude","claude-code","claude-code-skills","claude-code-subagents","claude-skills","cursor-agent","cursor-ai","cursor-skills","cursorai","github-copilot","intellij-idea","java","prompting","system-prompts"],"license":"apache-2.0","html_url":"https://github.com/jabrena/cursor-rules-java","pushed_at":"2026-04-26T12:50:01Z","description":"A curated and opinionated collection of Skills and Agents to be used in modern SDLC workflows for Java Enterprise development with your favorite AI Agent harness.","skill_md_sha":"35804dc8548dc50f91e0fcf23c80f408cdd2f8ca","skill_md_path":"skills/141-java-refactoring-with-modern-features/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/jabrena/cursor-rules-java/tree/main/skills/141-java-refactoring-with-modern-features"},"layout":"multi","source":"github","category":"cursor-rules-java","frontmatter":{"name":"141-java-refactoring-with-modern-features","license":"Apache-2.0","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. Part of cursor-rules-java project"},"skills_sh_url":"https://skills.sh/jabrena/cursor-rules-java/141-java-refactoring-with-modern-features"},"updatedAt":"2026-04-26T12:53:35.449Z"}}