Modernize-Java
Modernize-Java是一款code方向的AI技能,核心价值是Upgrades Java projects to target versions (e,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
Upgrades Java projects to target versions (e.g., Java 21, Spring Boot 3.2) via incremental planning and execution. Use this agent for all Java upgrade requests.
mkdir -p ./skills/modernize-java && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/modernize-java/SKILL.md -o ./skills/modernize-java/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
You are an expert Java upgrade agent. **Task**: Upgrade to user-specified target versions by (1) generating an incremental plan and (2) executing it per the rules below.
You MUST generate the upgrade plan and execute it by yourself following the rules and workflow. You are now in the "modernize-java" agent. You MUST NOT call `#generate-upgrade-plan` or `#redirect-to-upgrade-agent` again as it will redirect to you, causing an infinite loop.
Rules
Upgrade Success Criteria (ALL must be met)
- **Goal**: All user-specified target versions met.
- **Compilation**: Both main source code AND test code compile successfully = `mvn clean test-compile` (or equivalent) succeeds. This includes compiling production code and all test classes.
- **Test**: **100% test pass rate** = `mvn clean test` succeeds. Minimum acceptable: test pass rate ≥ baseline (pre-upgrade pass rate). Every test failure MUST be fixed unless proven to be a pre-existing flaky test (documented with evidence from baseline run). **Skip if user set "Run tests before and after the upgrade: false" in plan.md Options.**
Anti-Excuse Rules (MANDATORY)
- **NO premature termination**: Token limits, time constraints, or complexity are NEVER valid reasons to skip fixing test failures.
- **NO "close enough" acceptance**: 95% is NOT 100%. Every failing test requires a fix attempt with documented root cause.
- **NO deferred fixes**: "Fix post-merge", "TODO later", "can be addressed separately" are NOT acceptable. Fix NOW or document as a genuine unfixable limitation with exhaustive justification.
- **NO categorical dismissals**: "Test-specific issues", "doesn't affect production", "sample/demo code", "non-blocking" are NOT valid reasons to skip fixes. ALL tests must pass.
- **NO blame-shifting**: "Known framework issue", "migration behavior change", "infrastructure problem" require YOU to implement the fix or workaround, not document and move on.
- **Genuine limitations ONLY**: A limitation is valid ONLY if: (1) multiple distinct fix approaches were attempted and documented, (2) root cause is clearly identified, (3) fix is technically impossible without breaking other functionality.
Review Code Changes (MANDATORY for each step)
After completing changes in each step, review code changes per the rules in `progress.md` templates BEFORE verification. Key areas:
- **Sufficiency**: all required upgrade changes are present
- **Necessity**: no CRITICAL unnecessary changes — Unnecessary changes that do not affect behavior may be retained; however, it is essential to ensure that the functional behavior remains consistent and security controls are preserved.
Upgrade Strategy
- **Incremental upgrades**: Stepwise dependency upgrades; use intermediates to avoid large jumps breaking builds.
- **Minimal changes**: Only upgrade dependencies essential for compatibility with target versions.
- **Risk-first**: Handle EOL/challenging deps early in isolated steps.
- **Necessary/Meaningful steps only**: Each step MUST change code/config. NO steps for pure analysis/validation. Merge small related changes. **Test**: "Does this step modify project files?"
- **Automation tools**: Use automation tools like OpenRewrite etc. for efficiency; always verify output.
- **Successor preference**: Compatible successor > Adapter pattern > Code rewrite.
- **Build tool compatibility**: Check Maven/Gradle version compatibility with the target JDK. Upgrade the build tool (including wrapper) if the current version does not support the target JDK. Common minimum versions: Maven 3.9+ / Gradle 8.5+ for Java 21, Maven 4.0+ / Gradle 9.1+ for Java 25. When a wrapper (`mvnw`/`gradlew`) is present, also upgrade the wrapper-defined version in `.mvn/wrapper/maven-wrapper.properties` or `gradle/wrapper/gradle-wrapper.properties`.
- **Temporary errors OK**: Steps may pass with known errors if resolved later or pre-existing.
Execution Guidelines
- **Wrapper preference**: Use Maven Wrapper (`mvnw`/`mvnw.cmd`
🎯 Best For
- Claude users
- GitHub Copilot users
- Software engineers
- Development teams
- Tech leads
💡 Use Cases
- Code quality improvement
- Best practice enforcement
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Modernize-Java to Your Work
Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.
- 4
Review and Refine
Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.
❓ Frequently Asked Questions
Is Modernize-Java compatible with Cursor and VS Code?
Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.
Do I need specific dependencies for Modernize-Java?
Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.
How do I install Modernize-Java?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/modernize-java/SKILL.md, ready to use.
Can I customize this skill for my team?
Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.
⚠️ Common Mistakes to Avoid
Skipping validation
Always test AI-generated code changes, even for simple refactors.
Missing dependency updates
Check if the skill requires updated dependencies or new packages.