Stop Letting Claude Code Hallucinate Your Modernization: Write OpenRewrite LST Recipes Instead A developer argues that using autonomous AI agents to directly rewrite large Java codebases is risky, and instead recommends using Claude Code CLI to author deterministic OpenRewrite LST recipes for large-scale migrations like JDK 26 upgrades. The approach involves generating type-safe recipes with Claude Code, validating them against OpenRewrite's type-attribution engine, and executing them via the rewrite-maven-plugin for reproducible diffs. Stop Letting Claude Code Hallucinate Your Modernization: Write OpenRewrite LST Recipes Instead Letting autonomous AI agents directly rewrite million-line Java monoliths is a dangerous game of Russian roulette with silent runtime bugs. The real way to execute large-scale JDK 26 upgrades is using Claude Code CLI to author deterministic OpenRewrite LST recipes—not blindly edit source files. Want to go deeper? javalld.com https://javalld.com — machine coding interview problems with working Java code and full execution traces. Why Most Developers Get This Wrong - Yolo-prompting Claude Code CLI to edit hundreds of .java files directly, introducing non-existent API calls and broken imports. - Treating OpenRewrite Lossless Semantic Trees LST like naive regex text manipulation instead of type-attributed AST structures. - Relying on LLM self-correction loops to fix hallucinated method signatures instead of relying on the Java compiler. The Right Way Use Claude Code CLI to generate, unit-test, and refine type-safe OpenRewrite Java recipes, then let rewrite-maven-plugin execute them deterministically. - Prompt Claude Code to extend org.openrewrite.java.JavaVisitor targeting specific legacy patterns e.g., Spring Boot 3+ or Jakarta EE migrations . - Validate recipe execution against OpenRewrite's type-attribution engine to guarantee zero semantic drift across your codebase. - Execute the generated recipe via mvn rewrite:run in a clean CI container for 100% reproducible diffs. - Isolate LLM non-determinism to the recipe authoring phase—keep your production target repo completely deterministic. Show Me The Code or Example Prompt Claude Code CLI to generate this exact imperatively-safe recipe structure: Key Takeaways - LLMs generate logic; deterministic AST engines transform code—never confuse the two responsibilities. - Generating OpenRewrite recipes via Claude Code gives you compiler-backed type safety across enterprise-scale Java migrations. - If an AI-driven refactor isn't backed by a Lossless Semantic Tree parser, it belongs nowhere near your production monolith.