$npx -y skills add giuseppe-trisciuoglio/developer-kit --skill graalvm-native-imageProvides expert guidance for building GraalVM Native Image executables from Java applications. Use when converting JVM applications to native binaries, optimizing cold start times, reducing memory footprint, configuring native build tools for Maven or Gradle, resolving reflection
| 1 | # GraalVM Native Image for Java Applications |
| 2 | |
| 3 | Expert skill for building high-performance native executables from Java applications using GraalVM Native Image, dramatically reducing startup time and memory consumption. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | GraalVM Native Image compiles Java applications ahead-of-time (AOT) into standalone native executables. These executables start in milliseconds, require significantly less memory than JVM-based deployments, and are ideal for serverless functions, CLI tools, and microservices where fast startup and low resource usage are critical. |
| 8 | |
| 9 | This skill provides a structured workflow to migrate JVM applications to native binaries, covering build tool configuration, framework-specific patterns, reflection metadata management, and an iterative approach to resolving native build failures. |
| 10 | |
| 11 | ## When to Use |
| 12 | |
| 13 | Use this skill when: |
| 14 | - Converting a JVM-based Java application to a GraalVM native executable |
| 15 | - Optimizing cold start times for serverless or containerized deployments |
| 16 | - Reducing memory footprint (RSS) of Java microservices |
| 17 | - Configuring Maven or Gradle with GraalVM Native Build Tools |
| 18 | - Resolving `ClassNotFoundException`, `NoSuchMethodException`, or missing resource errors in native builds |
| 19 | - Generating or editing `reflect-config.json`, `resource-config.json`, or other GraalVM metadata files |
| 20 | - Using the GraalVM tracing agent to collect reachability metadata |
| 21 | - Implementing `RuntimeHints` for Spring Boot native support |
| 22 | - Building native images with Quarkus or Micronaut |
| 23 | |
| 24 | ## Instructions |
| 25 | |
| 26 | ### 1. Contextual Project Analysis |
| 27 | |
| 28 | Before any configuration, analyze the project to determine the build tool, framework, and dependencies: |
| 29 | |
| 30 | **Detect the build tool:** |
| 31 | |
| 32 | ```bash |
| 33 | # Check for Maven |
| 34 | if [ -f "pom.xml" ]; then |
| 35 | echo "Build tool: Maven" |
| 36 | # Check for Maven wrapper |
| 37 | [ -f "mvnw" ] && echo "Maven wrapper available" |
| 38 | fi |
| 39 | |
| 40 | # Check for Gradle |
| 41 | if [ -f "build.gradle" ] || [ -f "build.gradle.kts" ]; then |
| 42 | echo "Build tool: Gradle" |
| 43 | [ -f "build.gradle.kts" ] && echo "Kotlin DSL" |
| 44 | [ -f "gradlew" ] && echo "Gradle wrapper available" |
| 45 | fi |
| 46 | ``` |
| 47 | |
| 48 | **Detect the framework by analyzing dependencies:** |
| 49 | |
| 50 | - **Spring Boot**: Look for `spring-boot-starter-*` in `pom.xml` or `build.gradle` |
| 51 | - **Quarkus**: Look for `quarkus-*` dependencies |
| 52 | - **Micronaut**: Look for `micronaut-*` dependencies |
| 53 | - **Plain Java**: No framework dependencies detected |
| 54 | |
| 55 | **Check the Java version:** |
| 56 | |
| 57 | ```bash |
| 58 | java -version 2>&1 |
| 59 | # GraalVM Native Image requires Java 17+ (recommended: Java 21+) |
| 60 | ``` |
| 61 | |
| 62 | **Identify potential native image challenges:** |
| 63 | |
| 64 | - Reflection-heavy libraries (Jackson, Hibernate, JAXB) |
| 65 | - Dynamic proxy usage (JDK proxies, CGLIB) |
| 66 | - Resource bundles and classpath resources |
| 67 | - JNI or native library dependencies |
| 68 | - Serialization requirements |
| 69 | |
| 70 | ### 2. Build Tool Configuration |
| 71 | |
| 72 | Configure the appropriate build tool plugin based on the detected environment. |
| 73 | |
| 74 | **For Maven projects**, add a dedicated `native` profile to keep the standard build clean. See the [Maven Native Profile Reference](references/maven-native-profile.md) for full configuration. |
| 75 | |
| 76 | Key Maven setup: |
| 77 | |
| 78 | ```xml |
| 79 | <profiles> |
| 80 | <profile> |
| 81 | <id>native</id> |
| 82 | <build> |
| 83 | <plugins> |
| 84 | <plugin> |
| 85 | <groupId>org.graalvm.buildtools</groupId> |
| 86 | <artifactId>native-maven-plugin</artifactId> |
| 87 | <version>0.10.6</version> |
| 88 | <extensions>true</extensions> |
| 89 | <executions> |
| 90 | <execution> |
| 91 | <id>build-native</id> |
| 92 | <goals> |
| 93 | <goal>compile-no-fork</goal> |
| 94 | </goals> |
| 95 | <phase>package</phase> |
| 96 | </execution> |
| 97 | </executions> |
| 98 | <configuration> |
| 99 | <imageName>${project.artifactId}</imageName> |
| 100 | <buildArgs> |
| 101 | <buildArg>--no-fallback</buildArg> |
| 102 | </buildArgs> |
| 103 | </configuration> |
| 104 | </plugin> |
| 105 | </plugins> |
| 106 | </build> |
| 107 | </profile> |
| 108 | </profiles> |
| 109 | ``` |
| 110 | |
| 111 | Build with: `./mvnw -Pnative package` |
| 112 | |
| 113 | **For Gradle projects**, apply the `org.graalvm.buildtools.native` plugin. See the [Gradle Native Plugin Reference](references/gradle-native-plugin.md) for full configuration. |
| 114 | |
| 115 | Key Gradle setup (Kotlin DSL): |
| 116 | |
| 117 | ```kotlin |
| 118 | plugins { |
| 119 | id("org.graalvm.buildtools.native") version "0.10.6" |
| 120 | } |
| 121 | |
| 122 | graalvmNative { |
| 123 | binaries { |
| 124 | nam |