Agent skill

Groovy 5 Developer Guide

by apache in apache/grails-core

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

Apache-2.0Auto-check passedDevelopment

Install Groovy 5 Developer Guide

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

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

GitHub CLI
$ gh skill install apache/grails-core groovy-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/groovy-developer .claude/skills/groovy-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
groovy-developer
GitHub stars
2.9k
Token cost
~3k tokens
SKILL.md length
427 words
Files
1
Skills in repo
9
Repo updated
First seen
Licence
Apache-2.0

At a glance

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

  • Writing or debugging Groovy classes in a Grails application
  • SKILL.md covers What I Do, When to Use Me, Groovy 5 Key Features and Static Compilation, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Building or fixing Gradle build scripts for a Groovy project

What it does

This guide equips the agent for Groovy 5.1 development. It covers core language features such as closures, traits, GStrings, operators and Groovy Truth, metaprogramming at runtime (categories, ExpandoMetaClass, extension modules) and at compile time through AST transformations like @Immutable, @Builder, @Delegate, @Singleton, @Log and @Memoized. It also helps with DSLs built on MarkupBuilder, JsonBuilder and configuration builders.

Other areas are Spock specifications for unit and integration tests, JSON and XML handling, Groovy SQL and collection processing, and integration with Java 21 through joint compilation, Gradle builds, Grails and Spring Boot. For speed it recommends @CompileStatic, @TypeChecked and @GrailsCompileStatic. Typical tasks include Grails domain classes, controllers, services and taglibs, build.gradle scripts, GORM criteria queries, and moving code from Groovy 2.x, 3.x or 4.x to 5.1.

When your agent uses it

  • Writing or debugging Groovy classes in a Grails application
  • Building or fixing Gradle build scripts for a Groovy project
  • Writing Spock specifications for unit and integration tests
  • Migrating code from an older Groovy version to 5.1

Example prompts

  • “Add a Grails service that groups orders by customer, using @CompileStatic.”
  • “Write a Spock spec with a data table for the discount calculator.”
  • “Migrate this Groovy 3 utility class to Groovy 5.1 and tell me what changed.”
  • “Build a small DSL for defining validation rules with a closure delegate.”

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 groovy).

    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):

    • groovy-lang.org
    • grails.apache.org
    • spockframework.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

Groovy 5 Developer Guide loads about 3k tokens when it runs. Until then it costs about 43 tokens; SKILL.md has 427 words of instructions outside code blocks.

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

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). 427 words, ~2,957 tokens.

Download SKILL.mdSave it as .claude/skills/groovy-developer/SKILL.md (or your agent's skills folder).
name
groovy-developer
description
Expert guide for Groovy 5 development, covering concise syntax, closures, DSLs, metaprogramming, static compilation, and integration with Java 21 and Grails
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 deep expertise in Groovy 5.1, including core language features: syntax, closures, traits, GStrings, operators, and Groovy Truth.
  • Guide metaprogramming techniques: runtime (categories, ExpandoMetaClass, extension modules) and compile-time (AST transformations like @Immutable, @Builder, @Delegate, @Singleton, @Log, @Memoized).
  • Assist with DSL creation and usage (MarkupBuilder, JsonBuilder, builders for configuration).
  • Support testing with Spock Framework (BDD, data-driven tests, mocking) and built-in power assertions.
  • Help integrate Groovy with Java 21: joint compilation, Gradle builds, Grails, and Spring Boot.
  • Cover data handling: JSON/XML parsing and building, Groovy SQL, collection processing.
  • Advise on performance: @CompileStatic, @TypeChecked, @GrailsCompileStatic for optimal execution.

When to Use Me

Activate this skill for any Groovy-related task, including:

  • Writing or debugging Groovy classes in Grails domain, controllers, services, or taglibs.
  • Building or enhancing Gradle build scripts (build.gradle).
  • Creating DSLs for configuration, testing, or business rules.
  • Writing Spock specifications for unit and integration tests.
  • Migrating from older Groovy versions (2.x/3.x/4.x) to 5.1.
  • Performance optimization with static compilation.
  • Working with JSON/XML data, GORM criteria queries, or builders.

Groovy 5 Key Features

Concise Syntax
groovy
// No semicolons required
def name = 'Grails'

// Optional parentheses for method calls
println 'Hello World'
list.each { println it }

// Optional return keyword
String greet(String name) {
    "Hello, $name"  // Last expression is returned (GString needs double quotes)
}
GStrings (String Interpolation)
groovy
def user = "Alice"
def count = 42

// Simple interpolation
println "User: $user"

// Expression interpolation
println "Items: ${count * 2}"

// Lazy GStrings (evaluated when accessed)
def lazy = "Count is ${ -> counter }"

// Multi-line strings
def sql = """
    SELECT * FROM users
    WHERE name = '$user'
    ORDER BY created_at
"""
Closures
groovy
// Basic closure
def greet = { name -> "Hello, $name" }
println greet("World")

// Implicit 'it' parameter
def twice = { it * 2 }
println [1, 2, 3].collect(twice)

// Closure with delegate (for DSLs)
def configure = {
    name = "MyApp"
    version = "1.0"
}
configure.delegate = new Config()
configure.resolveStrategy = Closure.DELEGATE_FIRST
configure()

// Method references
def upper = String.&toUpperCase
println ["a", "b"].collect(upper)
Safe Navigation and Elvis Operator
groovy
// Safe navigation - returns null if any part is null
def city = user?.address?.city

// Elvis operator - default value if null
def name = user?.name ?: "Anonymous"

// Safe method calls
def length = text?.length() ?: 0

// Combine with collections
def firstTitle = books?.first()?.title ?: "No books"
Ternary Operator
groovy
// Use ternary operators only for simple conditions.
// Split long ternary expressions into multiple lines.
// Align `?` and `:` branches for readability.
String message = condition
        ? "Value when true"
        : "Value when false"
Spread Operator
groovy
// Spread operator for collections
def names = users*.name  // Same as users.collect { it.name }

// Spread for method arguments
def args = [1, 2, 3]
someMethod(*args)

// Spread in list literals
def combined = [*list1, *list2]
Collection Literals and Methods
groovy
// List literal
def list = [1, 2, 3, 4, 5]

// Map literal
def map = [name: "Grails", version: 7]

// Range
def range = 1..10
def exclusive = 1..<10

// Powerful collection methods
list.find { it > 3 }           // First match: 4
list.findAll { it > 3 }        // All matches: [4, 5]
list.any { it > 3 }            // true
list.every { it > 0 }          // true
list.groupBy { it % 2 }        // [0:[2,4], 1:[1,3,5]]
list.collectEntries { [it, it * 2] }  // [1:2, 2:4, ...]

// Sorting
list.sort { a, b -> b <=> a }  // Descending
list.sort { -it }              // Descending (numeric)
Groovy Truth
groovy
// Falsy values: null, empty string, empty collection, 0, false
if (list) { }      // True if not null and not empty
if (string) { }    // True if not null and not blank
if (number) { }    // True if not 0

// Useful in conditionals
def items = getItems() ?: []  // Default to empty list
Records
groovy
// Immutable data class
record Point(int x, int y) {}

def p = new Point(10, 20)
println p.x()  // 10
println p      // Point[x=10, y=20]
Traits
groovy
trait Auditable {
    Date dateCreated
    Date lastUpdated

    def beforeInsert() {
        dateCreated = new Date()
    }

    def beforeUpdate() {
        lastUpdated = new Date()
    }
}

class Book implements Auditable {
    String title
}

Static Compilation

@CompileStatic

Enables static type checking and compilation for better performance:

groovy
import groovy.transform.CompileStatic

@CompileStatic
class BookService {
    List<Book> findByAuthor(String author) {
        Book.findAllByAuthor(author)
    }

    int calculateTotal(List<Integer> prices) {
        prices.sum() as int
    }
}
@TypeChecked

Type checking without full static compilation:

groovy
import groovy.transform.TypeChecked

@TypeChecked
void process(String input) {
    println input.toUppercase()  // Compile error: method not found
}
@GrailsCompileStatic

Grails-aware static compilation that understands dynamic finders:

groovy
import grails.compiler.GrailsCompileStatic

@GrailsCompileStatic
class BookController {
    def show(Long id) {
        respond Book.findByIdAndActive(id, true)  // Dynamic finder works with @GrailsCompileStatic
    }
}

AST Transformations

@Immutable
groovy
import groovy.transform.Immutable

@Immutable
class Person {
    String name
    int age
}

def p = new Person(name: "Alice", age: 30)
// p.name = "Bob"  // Error: read-only
@Builder
groovy
import groovy.transform.builder.Builder

@Builder
class Email {
    String to
    String subject
    String body
}

def email = Email.builder()
    .to("user@example.com")
    .subject("Hello")
    .body("Content here")
    .build()
@Delegate
groovy
import groovy.lang.Delegate

class EnhancedList<T> {
    @Delegate List<T> list = []

    T secondLast() {
        list[-2]
    }
}

def enhanced = new EnhancedList<String>()
enhanced.add("a")  // Delegated to list
enhanced.add("b")
println enhanced.secondLast()  // "a"
@Singleton
groovy
import groovy.lang.Singleton

@Singleton
class ConfigManager {
    Map settings = [:]
}

ConfigManager.instance.settings['key'] = 'value'
@Memoized
groovy
import groovy.transform.Memoized

class Calculator {
    @Memoized
    BigInteger fibonacci(int n) {
        if (n <= 1) return n
        fibonacci(n - 1) + fibonacci(n - 2)
    }
}
@Log Variants
groovy
import groovy.util.logging.Slf4j

@Slf4j
class BookService {
    def save(Book book) {
        log.info "Saving book: ${book.title}"
        // ...
    }
}

Builders and DSLs

JsonBuilder
groovy
import groovy.json.JsonBuilder

def builder = new JsonBuilder()
builder {
    name "Grails"
    version 7
    features(["GORM", "GSP", "Plugins"])
    metadata {
        author "Grails Team"
        license "Apache 2.0"
    }
}
println builder.toPrettyString()
JsonSlurper
groovy
import groovy.json.JsonSlurper

def json = '{"name": "Grails", "version": 7}'
def data = new JsonSlurper().parseText(json)
println data.name  // Grails
MarkupBuilder (XML/HTML)
groovy
import groovy.xml.MarkupBuilder

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.books {
    book(id: 1) {
        title "Grails Guide"
        author "Team"
    }
}
println writer.toString()
Custom DSL Example
groovy
class HtmlBuilder {
    def html(@DelegatesTo(HtmlBuilder) Closure c) {
        c.delegate = this
        c.resolveStrategy = Closure.DELEGATE_FIRST
        "<html>${c()}</html>"
    }

    def body(String content) {
        "<body>$content</body>"
    }
}

def builder = new HtmlBuilder()
def result = builder.html {
    body "Hello World"
}

Testing with Spock

Basic Specification
groovy
class BookServiceSpec extends Specification {

    def service = new BookService()

    def "should find book by title"() {
        given: "a book title"
        def title = "Grails Guide"

        when: "searching for the book"
        def book = service.findByTitle(title)

        then: "the book is found"
        book != null
        book.title == title
    }
}
Data-Driven Tests
groovy
@Unroll
def "max of #a and #b is #expected"() {
    expect:
    Math.max(a, b) == expected

    where:
    a | b || expected
    1 | 3 || 3
    7 | 4 || 7
    0 | 0 || 0
}
Show full SKILL.md (180 more words)Show less
Mocking
groovy
def "should call repository when saving"() {
    given:
    def repo = Mock(BookRepository)
    def service = new BookService(repo)
    def book = new Book(title: "Test")

    when:
    service.save(book)

    then:
    1 * repo.save(book)
}
Exception Testing
groovy
def "should throw exception for invalid input"() {
    when:
    service.process(null)

    then:
    thrown(IllegalArgumentException)
}

Groovy SQL

groovy
import groovy.sql.Sql

def sql = Sql.newInstance(dataSource)

// Query
sql.eachRow("SELECT * FROM books WHERE author = ?", [authorName]) { row ->
    println "${row.title} by ${row.author}"
}

// Insert
sql.execute("INSERT INTO books (title, author) VALUES (?, ?)",
            [title, author])

// With GString (auto-parameterized)
sql.execute("INSERT INTO books (title) VALUES ($title)")

Best Practices

Performance
  • Use @CompileStatic or @GrailsCompileStatic in production code.
  • Avoid runtime metaprogramming in hot paths.
  • Prefer collect/findAll over manual loops.
  • Use @Memoized for expensive computations.
Code Style
  • Use safe navigation (?.) instead of null checks.
  • Prefer Elvis operator (?:) for default values.
  • Use GStrings for string interpolation.
  • Prefer traits over inheritance for mixins.
  • Use explicit types for public APIs, def for local variables.
  • Always use parentheses in method calls for clarity.
Grails-Specific
  • Use @GrailsCompileStatic instead of @CompileStatic in Grails artefact classes if needed.
  • Leverage GORM dynamic finders and where queries.
  • Use command objects for form binding and validation.
  • Follow convention over configuration.

Common Pitfalls

  • == vs is: == calls equals(), use is for identity comparison (same as Java).
  • GString in maps: GStrings don't work as map keys; use "key$idx".toString() if needed.
  • Closure scope: Understand delegate, owner, and this in closures.
  • Optional parentheses: Can cause ambiguity; always use parentheses for clarity.
  • Static imports: Always use explicit imports for statically imported methods.

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/groovy-developer of apache/grails-core.

Open the folder on GitHubat commit 3d6db18

Compare with similar skills

Groovy 5 Developer Guide 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.

Groovy 5 Developer Guide compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Groovy 5 Developer Guide this skillapache/grails-core2.9k—~3kAutomated safety check: PassApache-2.0
Java Rulessoftspark/ai-toolkit179—~3.1kAutomated safety check: PassApache-2.0
Javaericrisco/rsc-harness156—~4.6kAutomated safety check: PassMIT
Progensivaprasadreddy/sivalabs-agent-skills187—~2.7kAutomated safety check: NotesMIT
Starter Domain Revieweraxelixlabs/axelix147—~3.3kAutomated safety check: PassLGPL-3.0
Spring Mvc To Boot MigratorArabelaTso/Skills-4-SE253—~2.2kAutomated safety check: PassApache-2.0

Similar skills

  • 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
  • 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
  • Progen

    sivaprasadreddy/sivalabs-agent-skills

    A skill your agent uses when the user wants to create/generate/scaffold a new Spring Boot project (Maven or Gradle, REST API / Web App / Spring Boot + Angular full stack).

    187 GitHub stars~2.7k tokensUpdated 2 days ago
    Backend & APIsAuto-check: notes
  • Starter Domain Reviewer

    axelixlabs/axelix

    Reviews changes in sbs/starter-domain for technology-agnostic domain logic, forbidden production dependencies, and Java 11+ compatibility.

    147 GitHub stars~3.3k tokensUpdated yesterday
    Backend & APIsAuto-check passed
  • Spring Mvc To Boot Migrator

    ArabelaTso/Skills-4-SE

    Automatically migrate Spring MVC applications to Spring Boot.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Backend & APIsAuto-check passed
  • Java Architect

    Jeffallan/claude-skills

    Builds Spring Boot 3.x services on Java 21 with domain-driven design, WebFlux, JPA tuning and Spring Security using OAuth2 and JWT, verified by Maven or Gradle builds.

    12k GitHub stars~1.5k tokensUpdated 4 days ago
    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
  • 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
  • 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.

    2.9k GitHub stars~1.9k 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

Questions about Groovy 5 Developer Guide

What does Groovy 5 Developer Guide do?

Guidance for Groovy 5 work in Grails projects: syntax, closures, traits, DSLs, metaprogramming, Spock tests, static compilation and Java 21 integration. 1 development. It covers core language features such as closures, traits, GStrings, operators and Groovy Truth, metaprogramming at runtime (categories, ExpandoMetaClass, extension modules) and at compile time through AST transformations like @Immutable, @Builder, @Delegate, @Singleton, @Log and @Memoized.

When should I use Groovy 5 Developer Guide?

Groovy 5 Developer Guide fits situations like: writing or debugging Groovy classes in a Grails application; building or fixing Gradle build scripts for a Groovy project; writing Spock specifications for unit and integration tests; migrating code from an older Groovy version to 5.1.

How do I install Groovy 5 Developer Guide in Claude Code?

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

How do I install Groovy 5 Developer Guide in Codex?

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

Can I use Groovy 5 Developer Guide 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 groovy-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/groovy-developer, .gemini/skills/groovy-developer, .github/skills/groovy-developer and .opencode/skills/groovy-developer in your project.

What does Groovy 5 Developer Guide need to run?

SKILL.md names no scripts, command-line tools or credentials: Groovy 5 Developer Guide is instructions for the agent only.

Does Groovy 5 Developer Guide access the network?

SKILL.md names 3 domains. As links in the text: groovy-lang.org, grails.apache.org and spockframework.org. This is read from the text; nothing was executed.

Is Groovy 5 Developer Guide 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 Groovy 5 Developer Guide use?

Groovy 5 Developer Guide 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 Groovy 5 Developer Guide use?

About 3k tokens (SKILL.md is roughly 12k 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 Groovy 5 Developer Guide?

Skills that share tags, products or a category with Groovy 5 Developer Guide: Java Rules (softspark/ai-toolkit, 179 stars), Java (ericrisco/rsc-harness, 156 stars), Progen (sivaprasadreddy/sivalabs-agent-skills, 187 stars) and Starter Domain Reviewer (axelixlabs/axelix, 147 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Groovy 5 Developer Guide?

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.