openrewrite

Fix import-order test failures in OpenRewrite recipe tests.

14|4|Updated Oct 20, 2025
One-click install
npx skills add https://github.com/motlin/claude-code-plugins --skill openrewrite
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openrewrite
Source: https://github.com/motlin/claude-code-plugins/tree/main/plugins/java/skills/openrewrite
Command: npx skills add https://github.com/motlin/claude-code-plugins --skill openrewrite

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OpenRewrite recipe tests frequently fail due to minor import order differences rather than actual transformation issues, causing frustration and wasted development time. This Skill provides a clear path to resolve these common test failures.

Core Features & Use Cases

  • Import Order Fixes: Guides on diagnosing and fixing import ordering discrepancies in OpenRewrite recipe tests.
  • JavaTemplate Configuration: Provides best practices for configuring JavaTemplate with correct imports and context sensitivity.
  • Test Expectation Adjustment: Advises on accepting OpenRewrite's generated import order in tests instead of forcing a specific, often incorrect, order.
  • Quick Fix Steps: Offers a rapid workflow to copy actual output from failing tests and update expectations, ensuring tests pass efficiently.
  • Use Case: When developing or maintaining OpenRewrite recipes, use this skill to quickly identify and resolve import ordering issues in your tests, allowing you to focus on the core logic of your code transformations.

Quick Start

Analyze the failing OpenRewrite test and fix the import ordering issue.

Frequently Asked Questions about openrewrite

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix import order failures in OpenRewrite recipe tests?

Import order test failures occur when OpenRewrite's generated imports don't match your expected order. Copy the actual output from the failing test and update your test expectations to match OpenRewrite's deterministic import ordering, rather than forcing a specific manual order.

What's the best way to configure JavaTemplate imports in OpenRewrite recipes?

Configure JavaTemplate with explicit imports, enable contextSensitive handling for import management, and specify classpath settings to ensure consistent import behavior. This alignment prevents test-diff-based failures caused by import mismatches.

Why do OpenRewrite recipe tests fail on import ordering?

OpenRewrite applies deterministic or non-deterministic import ordering during code transformation. Test failures result from misaligned expectations rather than transformation logic issues. Diagnosing the actual import order in test output reveals the root cause.

Can I automate fixing import order issues in OpenRewrite tests?

Yes. Use a rapid workflow: analyze the failing test, identify the actual import order OpenRewrite generated, copy that output, and update test expectations. This quick-fix approach lets you focus on recipe logic rather than import management.

Do I need to understand JavaTemplate import handling to develop OpenRewrite recipes?

Yes. Proper JavaTemplate configuration with explicit imports and context sensitivity is essential for preventing import-order test failures during recipe development and maintenance.

What's the difference between deterministic and non-deterministic import ordering in OpenRewrite?

Deterministic import ordering produces consistent results across runs; non-deterministic can vary. OpenRewrite's import strategies depend on recipe configuration. Understanding which applies to your recipe helps you set appropriate test expectations.