{"slug": "stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst", "title": "Stop Letting Claude Code Hallucinate Your Modernization: Write OpenRewrite LST Recipes Instead", "summary": "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.", "body_md": "##\nStop Letting Claude Code Hallucinate Your Modernization: Write OpenRewrite LST Recipes Instead\n\nLetting 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.\n\nWant to go deeper? [javalld.com](https://javalld.com) — machine coding interview problems with working Java code and full execution traces.\n\n##\nWhy Most Developers Get This Wrong\n\n- Yolo-prompting Claude Code CLI to edit hundreds of\n`.java`\n\nfiles directly, introducing non-existent API calls and broken imports.\n- Treating OpenRewrite Lossless Semantic Trees (LST) like naive regex text manipulation instead of type-attributed AST structures.\n- Relying on LLM self-correction loops to fix hallucinated method signatures instead of relying on the Java compiler.\n\n##\nThe Right Way\n\nUse Claude Code CLI to generate, unit-test, and refine type-safe OpenRewrite Java recipes, then let `rewrite-maven-plugin`\n\nexecute them deterministically.\n\n- Prompt Claude Code to extend\n`org.openrewrite.java.JavaVisitor`\n\ntargeting specific legacy patterns (e.g., Spring Boot 3+ or Jakarta EE migrations).\n- Validate recipe execution against OpenRewrite's type-attribution engine to guarantee zero semantic drift across your codebase.\n- Execute the generated recipe via\n`mvn rewrite:run`\n\nin a clean CI container for 100% reproducible diffs.\n- Isolate LLM non-determinism to the recipe authoring phase—keep your production target repo completely deterministic.\n\n##\nShow Me The Code (or Example)\n\nPrompt Claude Code CLI to generate this exact imperatively-safe recipe structure:\n\n##\nKey Takeaways\n\n- LLMs generate logic; deterministic AST engines transform code—never confuse the two responsibilities.\n- Generating OpenRewrite recipes via Claude Code gives you compiler-backed type safety across enterprise-scale Java migrations.\n- If an AI-driven refactor isn't backed by a Lossless Semantic Tree parser, it belongs nowhere near your production monolith.", "url": "https://wpnews.pro/news/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst", "canonical_source": "https://dev.to/machinecodingmaster/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst-recipes-instead-il6", "published_at": "2026-08-10 04:15:12+00:00", "updated_at": "2026-08-10 04:45:32.459114+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "large-language-models"], "entities": ["Claude Code", "OpenRewrite", "Java", "JDK 26", "rewrite-maven-plugin", "javalld.com"], "alternates": {"html": "https://wpnews.pro/news/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst", "markdown": "https://wpnews.pro/news/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst.md", "text": "https://wpnews.pro/news/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst.txt", "jsonld": "https://wpnews.pro/news/stop-letting-claude-code-hallucinate-your-modernization-write-openrewrite-lst.jsonld"}}