OpenRewrite recipe development and test maintenance. Use when writing OpenRewrite recipes, fixing test failures, or working with import ordering in recipe tests.
/plugin marketplace add motlin/claude-code-plugins/plugin install java@motlin-claude-code-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill provides guidelines for developing OpenRewrite recipes and maintaining their tests, with a focus on import ordering issues.
š§ OpenRewrite recipe tests often fail due to import order differences, not actual transformation issues.
OpenRewrite recipe tests fail with diffs showing only import order differences:
-import java.util.List;
-import org.assertj.core.api.Assertions;
+import org.assertj.core.api.Assertions;
+import java.util.List;
OpenRewrite manages imports automatically based on:
Ensure your JavaTemplate is properly configured:
JavaTemplate template = JavaTemplate
.builder("Your.template.code()")
.imports(
"org.assertj.core.api.Assertions",
"org.eclipse.collections.impl.utility.Iterate"
)
.contextSensitive() // Important for proper context handling
.javaParser(JavaParser.fromJavaVersion()
.classpath("assertj-core", "eclipse-collections", "eclipse-collections-api")
)
.build();
Don't forget to call:
maybeAddImport("org.assertj.core.api.Assertions");
maybeAddImport("org.eclipse.collections.impl.utility.Iterate");
maybeRemoveImport("old.package.OldClass");
Accept the actual import order that OpenRewrite produces:
ā Instead of forcing a specific order:
// DON'T expect a specific order you want
"import java.util.List;\n" +
"import org.assertj.core.api.Assertions;\n"
ā Use the actual order OpenRewrite produces:
// DO accept the order OpenRewrite generates
"import org.assertj.core.api.Assertions;\n" +
"import org.eclipse.collections.impl.utility.Iterate;\n" +
"\n" +
"import java.util.List;\n"
OpenRewrite typically orders imports as:
java.*, javax.*)The ~~> prefix in test expectations is not standard in all codebases. It's used in some OpenRewrite projects to indicate "ignore everything before this line" but isn't recognized in all contexts. If you see it failing, remove it and use exact matching instead.
@Test
void replacesVerifyWithAssertJ() {
rewriteRun(
java(
// Input
"""
import org.eclipse.collections.impl.test.Verify;
import java.util.List;
class Test {
void test() {
List<String> list = List.of("a", "b", "c");
Verify.assertCount(2, list, each -> each.length() > 0);
}
}
""",
// Expected output - use actual order from test failure
"""
import org.assertj.core.api.Assertions;
import org.eclipse.collections.impl.utility.Iterate;
import java.util.List;
class Test {
void test() {
List<String> list = List.of("a", "b", "c");
Assertions.assertThat(Iterate.count(list, each -> each.length() > 0)).isEqualTo(2);
}
}
"""
)
);
}
Maven POM files should follow a consistent dependency ordering structure. See the pom-ordering skill for detailed guidelines.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.