Agent skill

Java 21 Developer Guide for Grails

by apache in apache/grails-core

Guide for writing modern Java 21 in a Grails and Groovy codebase: records, sealed classes, pattern matching, text blocks and how Java works alongside Groovy.

Apache-2.0Auto-check passedDevelopment

Install Java 21 Developer Guide for Grails

skills CLI
$ npx skills add apache/grails-core --skill java-developer -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install apache/grails-core java-developer --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/apache/grails-core.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/java-developer .claude/skills/java-developer && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
java-developer
GitHub stars
2.9k
Token cost
~1.9k tokens
SKILL.md length
381 words
Files
1
Skills in repo
9
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guide for writing modern Java 21 in a Grails and Groovy codebase: records, sealed classes, pattern matching, text blocks and how Java works alongside Groovy.

  • Writing Java classes that will be used alongside Groovy code
  • SKILL.md covers What I Do, When to Use Me, Java 21 Baseline Features and Java/Groovy Interoperability, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Replacing older Java patterns with records, sealed types or pattern matching

What it does

The skill helps with Java code that lives alongside Groovy in the Grails repository. It covers generating, refactoring and debugging code with Java 21 features, with examples for records, sealed classes, pattern matching for instanceof, text blocks, switch expressions, helpful NullPointerException messages and newer stream and collection APIs, each tied to its JEP number.

It also advises on moving older Java (8, 11 or 17 code) to Java 21 idioms, writing Java that Groovy can call and use, performance optimization, security hardening and module system questions, and tooling such as Gradle builds, JDK setup, JUnit 5 or Spock testing and profiling. A closing section deals with calling Java from Groovy.

When your agent uses it

  • Writing Java classes that will be used alongside Groovy code
  • Replacing older Java patterns with records, sealed types or pattern matching
  • Migrating Java 8, 11 or 17 code to Java 21 idioms
  • Questions about the module system, performance or security hardening in Java

Example prompts

  • “Convert this DTO class to a record and add validation in a compact constructor.”
  • “Rewrite the instanceof checks in ShapeUtils with pattern matching.”
  • “Migrate this utility class from Java 11 style to Java 21 idioms, keeping it callable from Groovy.”

Requirements

  • A Java 21 JDK

What it can do on your machine

Read from SKILL.md and the folder at commit 3d6db18. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java, groovy and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.oracle.com
    • openjdk.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Java 21 Developer Guide for Grails loads about 1.9k tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 381 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from apache/grails-core at commit 3d6db18, republished under its Apache-2.0 licence (© apache). 381 words, ~1,851 tokens.

Download SKILL.mdSave it as .claude/skills/java-developer/SKILL.md (or your agent's skills folder).
name
java-developer
description
Guide for developing on the Java 21 baseline, including modern features, best practices, and integration with Groovy/Grails projects
license
Apache-2.0
<!--
SPDX-License-Identifier: Apache-2.0

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0. 
-->

What I Do

  • Provide guidance on Java 21 syntax, features, and APIs for use in Grails/Groovy projects.
  • Assist with code generation, refactoring, and debugging using modern Java features like records, sealed classes, pattern matching, and text blocks.
  • Recommend best practices for Java code that interoperates with Groovy in mixed-language projects.
  • Guide on tooling: Gradle builds, JDK setup, testing with JUnit 5/Spock, and profiling.

When to Use Me

Use this skill when working on Java code within this repository, especially for:

  • Writing Java classes that will be used alongside Groovy code.
  • Implementing features using records, sealed classes, or pattern matching for instanceof.
  • Migrating older Java code (e.g., Java 8/11/17) to Java 21 idioms.
  • Performance optimization, security hardening, or module system (JPMS) questions.
  • Understanding how Java code integrates with Groovy's dynamic features.

Java 21 Baseline Features

Records (JEP 395)

Immutable data carriers with auto-generated constructors, accessors, equals, hashCode, and toString:

java
public record Book(String title, String author, int year) {
    // Compact constructor for validation
    public Book {
        if (title == null || title.isBlank()) {
            throw new IllegalArgumentException("Title cannot be blank");
        }
    }
}
Sealed Classes (JEP 409)

Restrict which classes can extend or implement a type:

java
public sealed interface Shape permits Circle, Rectangle, Triangle {
    double area();
}

public final class Circle implements Shape {
    private final double radius;
    public Circle(double radius) { this.radius = radius; }
    public double area() { return Math.PI * radius * radius; }
}

public non-sealed class Rectangle implements Shape {
    // Can be further extended
}
Pattern Matching for instanceof (JEP 394)

Eliminate redundant casts:

java
// Before pattern matching
if (obj instanceof String) {
    String s = (String) obj;
    System.out.println(s.length());
}

// Modern Java
if (obj instanceof String s) {
    System.out.println(s.length());
}
Text Blocks (JEP 378)

Multi-line string literals with proper formatting:

java
String json = """
    {
        "name": "Grails",
        "version": "7.0"
    }
    """;

String sql = """
    SELECT id, name, created_at
    FROM users
    WHERE status = 'ACTIVE'
    ORDER BY created_at DESC
    """;
Switch Expressions (JEP 361)

Use switch as an expression with arrow syntax:

java
String result = switch (day) {
    case MONDAY, FRIDAY, SUNDAY -> "Relaxed";
    case TUESDAY -> "Productive";
    case THURSDAY, SATURDAY -> "Moderate";
    case WEDNESDAY -> {
        var temp = calculateWorkload();
        yield temp > 5 ? "Busy" : "Normal";
    }
};
Enhanced NullPointerException Messages (JEP 358)

Detailed NPE messages showing exactly which variable was null:

Cannot invoke "String.length()" because "user.getAddress().getCity()" is null
Helpful Stream and Collection APIs
java
// Stream.toList() - unmodifiable list
List<String> names = users.stream()
    .map(User::getName)
    .toList();

// Collectors improvements
Map<Status, List<User>> byStatus = users.stream()
    .collect(Collectors.groupingBy(User::getStatus));

Java/Groovy Interoperability

Calling Java from Groovy

Groovy seamlessly calls Java code:

groovy
// Java record used in Groovy
def book = new Book("Grails Guide", "Author", 2024)
println book.title()  // Groovy can use property syntax too
println book.title    // Also works
Show full SKILL.md (159 more words)Show less
Calling Groovy from Java
java
// Groovy classes are just Java classes
GroovyService service = new GroovyService();
service.process(data);

// Working with Groovy closures in Java
Closure<String> closure = ...;
String result = closure.call("input");
Best Practices for Mixed Projects
  • Use Java for performance-critical code with @CompileStatic equivalent behavior.
  • Use Java records for DTOs shared between Java and Groovy code.
  • Prefer Java interfaces that Groovy classes implement.
  • Avoid Groovy-specific features (like categories) in APIs consumed by Java.

Build and Testing

Gradle Configuration
groovy
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
    options.compilerArgs += ['-parameters']  // Preserve parameter names
}
Testing with JUnit 5
java
@Test
@DisplayName("Book record should validate title")
void bookShouldValidateTitle() {
    assertThrows(IllegalArgumentException.class, () ->
        new Book("", "Author", 2024)
    );
}

@ParameterizedTest
@ValueSource(strings = {"", " ", "  "})
void blankTitlesShouldBeRejected(String title) {
    assertThrows(IllegalArgumentException.class, () ->
        new Book(title, "Author", 2024)
    );
}
Testing with Spock (from Groovy)
groovy
def "Java record should work in Spock tests"() {
    when:
    def book = new Book("Test", "Author", 2024)

    then:
    book.title() == "Test"
    book.author() == "Author"
}

Performance and Profiling

JVM Options for Java 21
bash
# Recommended GC for most workloads
-XX:+UseG1GC

# For low-latency requirements
-XX:+UseZGC

# Memory settings
-Xms512m -Xmx2g

# Enable JFR for profiling
-XX:StartFlightRecording=duration=60s,filename=recording.jfr
Profiling Tools
  • JDK Flight Recorder (JFR): Built-in low-overhead profiler
  • VisualVM: GUI-based monitoring and profiling
  • async-profiler: Low-overhead sampling profiler

Common Patterns

Null Handling with Optional
java
public Optional<User> findById(Long id) {
    return Optional.ofNullable(repository.get(id));
}

// Usage
String name = findById(id)
    .map(User::getName)
    .orElse("Unknown");
Resource Management with try-with-resources
java
try (var reader = new BufferedReader(new FileReader(path));
     var writer = new BufferedWriter(new FileWriter(output))) {
    reader.lines()
        .map(String::toUpperCase)
        .forEach(line -> writer.write(line + "\n"));
}
Immutable Collections
java
// Create immutable collections
List<String> list = List.of("a", "b", "c");
Set<String> set = Set.of("x", "y", "z");
Map<String, Integer> map = Map.of("one", 1, "two", 2);

// Copy to immutable
List<String> copy = List.copyOf(mutableList);

Code Style Guidelines

  • Follow existing patterns in the codebase.
  • Use var for local variables when the type is obvious from context.
  • Prefer records for simple data carriers.
  • Use sealed classes to model restricted type hierarchies.
  • Add @Override annotation when overriding methods.
  • Use meaningful parameter names (preserved with -parameters flag).

Resources

© apache, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/java-developer of apache/grails-core.

Open the folder on GitHubat commit 3d6db18

Compare with similar skills

Java 21 Developer Guide for Grails next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Java 21 Developer Guide for Grails compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Java 21 Developer Guide for Grails this skillapache/grails-core2.9k—~1.9kAutomated safety check: PassApache-2.0
Javaericrisco/rsc-harness156—~4.6kAutomated safety check: PassMIT
Cobol ModernizationOpenHands/extensions157—~820Automated safety check: PassMIT
Java Idiomsirahardianto/awesome-agv157—~1.5kAutomated safety check: PassMIT
Codingmicronaut-projects/micronaut-openapi114—~2.6kAutomated safety check: PassApache-2.0
Neo4j Driver Java Skillneo4j-contrib/neo4j-skills114—~4.2kAutomated safety check: NotesMIT

Similar skills

  • Java

    ericrisco/rsc-harness

    A skill your agent uses when writing, reviewing or refactoring modern Java (21+, 25 LTS) — records and sealed interfaces as algebraic data types, exhaustive pattern-matching switch over instanceof…

    156 GitHub stars~4.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Cobol Modernization

    OpenHands/extensions

    End-to-end COBOL to Java migration workflow. An agent skill from OpenHands/extensions.

    157 GitHub stars~820 tokensUpdated today
    DevelopmentAuto-check passed
  • Java Idioms

    irahardianto/awesome-agv

    Modern Java (17/21+ LTS) idioms: records, sealed classes, pattern matching switch, Optional hygiene, streams, and JUnit 5 testing.

    157 GitHub stars~1.5k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Coding

    micronaut-projects/micronaut-openapi

    Implement and review Java code changes for Micronaut framework repositories using maintainer standards, including JSpecify null-safety conventions.

    114 GitHub stars~2.6k tokensUpdated today
    Backend & APIsAuto-check passed
  • Neo4j Driver Java Skill

    neo4j-contrib/neo4j-skills

    Neo4j Java Driver v6 — driver lifecycle, Maven/Gradle setup, executableQuery, executeRead/Write managed transactions, explicit transactions, async/reactive patterns, error handling, data type…

    114 GitHub stars~4.2k tokensUpdated today
    MobileAuto-check: notes
  • Java Rules

    softspark/ai-toolkit

    Java coding rules: style, patterns, security, testing. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.1k tokensUpdated today
    Backend & APIsAuto-check passed

More from apache/grails-core

All 9 skills in this repo
  • Grails Developer Guide

    apache/grails-core

    Guides building Grails web applications and REST APIs with GORM, controllers, services, views, plugins and Spock and Geb testing.

    2.9k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Groovy 5 Developer Guide

    apache/grails-core

    Guidance for Groovy 5 work in Grails projects: syntax, closures, traits, DSLs, metaprogramming, Spock tests, static compilation and Java 21 integration.

    2.9k GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Guides changes to the grails-data-hibernate7 module, covering domain binding, Hibernate 5 to 7 migration work, generators and integration specs.

    2.9k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Grails Test Fixer

    apache/grails-core

    Guides running, reviewing and fixing test failures across grails-core modules with Gradle, including targeted runs and the aggregate HTML and Markdown reports.

    2.9k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Grails Violation Fixer

    apache/grails-core

    Guide to running, reading and fixing code style and analysis violations in grails-core with CodeNarc, Checkstyle, PMD, SpotBugs, Spotless and JaCoCo through Gradle.

    2.9k GitHub stars~3.9k tokensUpdated today
    Auto-check passed
  • Grails Gradle Developer

    apache/grails-core

    Guides Gradle 9 build changes in apache/grails-core on the 8.0.x line, favoring the repo's convention plugins, BOM platforms and patterns over generic Gradle advice.

    2.9k GitHub stars~11k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Java 21 Developer Guide for Grails

What does Java 21 Developer Guide for Grails do?

Guide for writing modern Java 21 in a Grails and Groovy codebase: records, sealed classes, pattern matching, text blocks and how Java works alongside Groovy. The skill helps with Java code that lives alongside Groovy in the Grails repository. It covers generating, refactoring and debugging code with Java 21 features, with examples for records, sealed classes, pattern matching for instanceof, text blocks, switch expressions, helpful NullPointerException messages and newer stream and collection APIs, each tied to its JEP number.

When should I use Java 21 Developer Guide for Grails?

Java 21 Developer Guide for Grails fits situations like: writing Java classes that will be used alongside Groovy code; replacing older Java patterns with records, sealed types or pattern matching; migrating Java 8, 11 or 17 code to Java 21 idioms; questions about the module system, performance or security hardening in Java.

How do I install Java 21 Developer Guide for Grails in Claude Code?

Run `npx skills add apache/grails-core --skill java-developer -a claude-code`. Or copy the skill folder (.agents/skills/java-developer in apache/grails-core) into .claude/skills/java-developer in your project. Claude Code loads it when a task matches its description.

How do I install Java 21 Developer Guide for Grails in Codex?

Run `npx skills add apache/grails-core --skill java-developer -a codex`. Or copy the skill folder (.agents/skills/java-developer in apache/grails-core) into .agents/skills/java-developer in your project. Codex loads it when a task matches its description.

Can I use Java 21 Developer Guide for Grails in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add apache/grails-core --skill java-developer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/java-developer, .gemini/skills/java-developer, .github/skills/java-developer and .opencode/skills/java-developer in your project.

What does Java 21 Developer Guide for Grails need to run?

SKILL.md names no scripts, command-line tools or credentials: Java 21 Developer Guide for Grails is instructions for the agent only. Our summary lists: A Java 21 JDK.

Does Java 21 Developer Guide for Grails access the network?

SKILL.md names 2 domains. As links in the text: docs.oracle.com and openjdk.org. This is read from the text; nothing was executed.

Is Java 21 Developer Guide for Grails safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Java 21 Developer Guide for Grails use?

Java 21 Developer Guide for Grails is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Java 21 Developer Guide for Grails use?

About 1.9k tokens (SKILL.md is roughly 7.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Java 21 Developer Guide for Grails?

Skills that share tags, products or a category with Java 21 Developer Guide for Grails: Java (ericrisco/rsc-harness, 156 stars), Cobol Modernization (OpenHands/extensions, 157 stars), Java Idioms (irahardianto/awesome-agv, 157 stars) and Coding (micronaut-projects/micronaut-openapi, 114 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Java 21 Developer Guide for Grails?

apache (a GitHub organization) maintains it in apache/grails-core, which has 2,934 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on October 7, 2026.

Source: apache/grails-core on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.