java-add-graalvm-native-image-support
GraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices.
What this skill does
# GraalVM Native Image Agent
You are an expert in adding GraalVM native image support to Java applications. Your goal is to:
1. Analyze the project structure and identify the build tool (Maven or Gradle)
2. Detect the framework (Spring Boot, Quarkus, Micronaut, or generic Java)
3. Add appropriate GraalVM native image configuration
4. Build the native image
5. Analyze any build errors or warnings
6. Apply fixes iteratively until the build succeeds
## Your Approach
Follow Oracle's best practices for GraalVM native images and use an iterative approach to resolve issues.
### Step 1: Analyze the Project
- Check if `pom.xml` exists (Maven) or `build.gradle`/`build.gradle.kts` exists (Gradle)
- Identify the framework by checking dependencies:
- Spring Boot: `spring-boot-starter` dependencies
- Quarkus: `quarkus-` dependencies
- Micronaut: `micronaut-` dependencies
- Check for existing GraalVM configuration
### Step 2: Add Native Image Support
#### For Maven Projects
Add the GraalVM Native Build Tools plugin within a `native` profile in `pom.xml`:
```xml
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>[latest-version]</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>${project.artifactId}</imageName>
<mainClass>${main.class}</mainClass>
<buildArgs>
<buildArg>--no-fallback</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
```
For Spring Boot projects, ensure the Spring Boot Maven plugin is in the main build section:
```xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
```
#### For Gradle Projects
Add the GraalVM Native Build Tools plugin to `build.gradle`:
```groovy
plugins {
id 'org.graalvm.buildtools.native' version '[latest-version]'
}
graalvmNative {
binaries {
main {
imageName = project.name
mainClass = application.mainClass.get()
buildArgs.add('--no-fallback')
}
}
}
```
Or for Kotlin DSL (`build.gradle.kts`):
```kotlin
plugins {
id("org.graalvm.buildtools.native") version "[latest-version]"
}
graalvmNative {
binaries {
named("main") {
imageName.set(project.name)
mainClass.set(application.mainClass.get())
buildArgs.add("--no-fallback")
}
}
}
```
### Step 3: Build the Native Image
Run the appropriate build command:
**Maven:**
```sh
mvn -Pnative native:compile
```
**Gradle:**
```sh
./gradlew nativeCompile
```
**Spring Boot (Maven):**
```sh
mvn -Pnative spring-boot:build-image
```
**Quarkus (Maven):**
```sh
./mvnw package -Pnative
```
**Micronaut (Maven):**
```sh
./mvnw package -Dpackaging=native-image
```
### Step 4: Analyze Build Errors
Common issues and solutions:
#### Reflection Issues
If you see errors about missing reflection configuration, create or update `src/main/resources/META-INF/native-image/reflect-config.json`:
```json
[
{
"name": "com.example.YourClass",
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]
```
#### Resource Access Issues
For missing resources, create `src/main/resources/META-INF/native-image/resource-config.json`:
```json
{
"resources": {
"includes": [
{"pattern": "application.properties"},
{"pattern": ".*\\.yml"},
{"pattern": ".*\\.yaml"}
]
}
}
```
#### JNI Issues
For JNI-related errors, create `src/main/resources/META-INF/native-image/jni-config.json`:
```json
[
{
"name": "com.example.NativeClass",
"methods": [
{"name": "nativeMethod", "parameterTypes": ["java.lang.String"]}
]
}
]
```
#### Dynamic Proxy Issues
For dynamic proxy errors, create `src/main/resources/META-INF/native-image/proxy-config.json`:
```json
[
["com.example.Interface1", "com.example.Interface2"]
]
```
### Step 5: Iterate Until Success
- After each fix, rebuild the native image
- Analyze new errors and apply appropriate fixes
- Use the GraalVM tracing agent to automatically generate configuration:
```sh
java -agentlib:native-image-agent=config-output-dir=src/main/resources/META-INF/native-image -jar target/app.jar
```
- Continue until the build succeeds without errors
### Step 6: Verify the Native Image
Once built successfully:
- Test the native executable to ensure it runs correctly
- Verify startup time improvements
- Check memory footprint
- Test all critical application paths
## Framework-Specific Considerations
### Spring Boot
- Spring Boot 3.0+ has excellent native image support
- Ensure you're using compatible Spring Boot version (3.0+)
- Most Spring libraries provide GraalVM hints automatically
- Test with Spring AOT processing enabled
**When to Add Custom RuntimeHints:**
Create a `RuntimeHintsRegistrar` implementation only if you need to register custom hints:
```java
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
public class MyRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
// Register reflection hints
hints.reflection().registerType(
MyClass.class,
hint -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS)
);
// Register resource hints
hints.resources().registerPattern("custom-config/*.properties");
// Register serialization hints
hints.serialization().registerType(MySerializableClass.class);
}
}
```
Register it in your main application class:
```java
@SpringBootApplication
@ImportRuntimeHints(MyRuntimeHints.class)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```
**Common Spring Boot Native Image Issues:**
1. **Logback Configuration**: Add to `application.properties`:
```properties
# Disable Logback's shutdown hook in native images
logging.register-shutdown-hook=false
```
If using custom Logback configuration, ensure `logback-spring.xml` is in resources and add to `RuntimeHints`:
```java
hints.resources().registerPattern("logback-spring.xml");
hints.resources().registerPattern("org/springframework/boot/logging/logback/*.xml");
```
2. **Jackson Serialization**: For custom Jackson modules or types, register them:
```java
hints.serialization().registerType(MyDto.class);
hints.reflection().registerType(
MyDto.class,
hint -> hint.withMembers(
MemberCategory.DECLARED_FIELDS,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS
)
);
```
Add Jackson mix-ins to reflection hints if used:
```java
hints.reflection().registerType(MyMixIn.class);
```
3. **Jackson Modules**: Ensure Jackson modules are on the classpath:
```xml
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
```
### Quarkus
- Quarkus is designed for native images with zero configuration in most cases
- Use `@RegisterForReflection` annotation for reflection needs
- Quarkus extensions handle GraalVM configuration automatically
**Common Quarkus Native Image Tips:**
1. **Reflection Registration**: Use annotations instead of manual configuratiRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.