Agent skill

Java Idioms

by irahardianto in irahardianto/awesome-agv

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

MITAuto-check passedDevelopment

Install Java Idioms

skills CLI
$ npx skills add irahardianto/awesome-agv --skill java-idioms -a claude-code

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

GitHub CLI
$ gh skill install irahardianto/awesome-agv java-idioms --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/irahardianto/awesome-agv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/java-idioms .claude/skills/java-idioms && 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-idioms
GitHub stars
157
Token cost
~1.5k tokens
SKILL.md length
273 words
Files
1
Skills in repo
34
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 5 steps: Records for immutable data carriers → Sealed classes for constrained hierarchies → Pattern matching with switch → …
  • Reviewing Java core logic
  • Calls mvn and gradle
  • Tasks that involve Backend development

What it does

Java Idioms is an agent skill from irahardianto/awesome-agv. Modern Java (17/21+ LTS) idioms: records, sealed classes, pattern matching switch, Optional hygiene, streams, and JUnit 5 testing. Use when writing, refactoring, or reviewing Java core logic, domain models, or libraries. Pair with spring-boot-idioms for Spring services.

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Backend development and Refactoring. It works with Java, JUnit and Spring Boot. The repository describes itself as: Comprehensive sets of standards and practices designed to elevate the capabilities of AI coding agents. The licence is MIT.

When your agent uses it

  • Reviewing Java core logic
  • Tasks that involve Backend development
  • Tasks that involve Refactoring

Example prompts

  • “/java-idioms”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Records for immutable data carriers
  2. Sealed classes for constrained hierarchies
  3. Pattern matching with switch
  4. Text blocks for queries and templates
  5. Virtual threads (21+) for I/O-bound work

What it can do on your machine

Read from SKILL.md and the folder at commit 9e997ba. 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

    Shell commands in SKILL.md call:

    • mvn
    • gradle

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

  • Network

    No URLs in SKILL.md.

    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 Idioms loads about 1.5k tokens when it runs. Until then it costs about 71 tokens; SKILL.md has 273 words of instructions outside code blocks.

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

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 irahardianto/awesome-agv at commit 9e997ba, republished under its MIT licence (© irahardianto). 273 words, ~1,485 tokens.

Download SKILL.mdSave it as .claude/skills/java-idioms/SKILL.md (or your agent's skills folder).
name
java-idioms
description
Modern Java (17/21+ LTS) idioms: records, sealed classes, pattern matching switch, Optional hygiene, streams, and JUnit 5 testing. Use when writing, refactoring, or reviewing Java core logic, domain models, or libraries. Pair with spring-boot-idioms for Spring services.

Java Idioms and Patterns

Java rewards clarity, type safety, and robust ecosystem tooling. Modern Java (17+ LTS) favors records, sealed classes, and pattern matching. Idiomatic Java = clean, readable, framework-aware.

Scope: Java coding idioms. Test naming: .agents/rules/testing-strategy.md. Logging: @.agents/skills/logging-implementation/SKILL.md.

Modern Java Features (17+ LTS)
  1. Records for immutable data carriers:

    java
    // ✅ Concise, immutable, auto-generated equals/hashCode/toString
    public record CreateTaskRequest(String title, Priority priority) {}
    
    // ❌ Verbose boilerplate POJO
    public class CreateTaskRequest { /* getters, setters, equals, hashCode... */ }
  2. Sealed classes for constrained hierarchies:

    java
    public sealed interface TaskResult permits Success, Failure, Pending {}
    public record Success(Task task) implements TaskResult {}
    public record Failure(String reason) implements TaskResult {}
    public record Pending(String taskId) implements TaskResult {}
  3. Pattern matching with switch:

    java
    return switch (result) {
        case Success(var task) -> ResponseEntity.ok(task);
        case Failure(var reason) -> ResponseEntity.badRequest().body(reason);
        case Pending(var id) -> ResponseEntity.accepted().body(id);
    };
  4. Text blocks for queries and templates:

    java
    String query = """
        SELECT t.id, t.title, t.priority
        FROM tasks t
        WHERE t.user_id = ?
        ORDER BY t.created_at DESC
        """;
  5. Virtual threads (21+) for I/O-bound work:

    java
    try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
        executor.submit(() -> fetchUser(userId));
        executor.submit(() -> fetchTasks(userId));
    }
Error Handling
  1. Domain exception hierarchies — never raw Exception:

    java
    public abstract class DomainException extends RuntimeException {
        protected DomainException(String message) { super(message); }
    }
    
    public class NotFoundException extends DomainException {
        private final String resource;
        private final String resourceId;
        public NotFoundException(String resource, String resourceId) {
            super(String.format("%s '%s' not found", resource, resourceId));
            this.resource = resource;
            this.resourceId = resourceId;
        }
    }
  2. Never catch Exception broadly — catch specific exceptions. Never swallow exceptions silently.

  3. Optional for nullable returns — never for parameters:

    java
    // ✅ Return type
    public Optional<Task> findById(String id) { ... }
    
    // ❌ Parameter — use overloading or @Nullable instead
    public void process(Optional<String> filter) { ... }
Interfaces and DI
  1. Program to interfaces, inject via constructor:

    java
    // ✅ Interface in consumer package
    public interface TaskStorage {
        Task getById(String id);
        void save(Task task);
    }
    
    // ✅ Constructor injection (Spring auto-wires)
    @Service
    public class TaskService {
        private final TaskStorage storage;
        public TaskService(TaskStorage storage) { this.storage = storage; }
    }
  2. Prefer constructor injection over @Autowired field injection. No field injection — ever.

Show full SKILL.md (178 more words)Show less
Naming
  1. PascalCase for classes, interfaces, enums, records.
  2. camelCase for methods, fields, local variables.
  3. UPPER_SNAKE_CASE for constants (static final).
  4. No Hungarian notation. TaskService not ITaskService. userId not strUserId.
  5. Package names: lowercase, no underscores. com.example.task not com.example.task_management.
Testing

Test naming, pyramid: .agents/rules/testing-strategy.md. Java-specific tooling below.

  1. JUnit 5 + AssertJ:

    java
    @Test
    void calculateDiscount_returnsZero_whenNoItems() {
        var result = calculator.calculateDiscount(List.of(), coupon);
        assertThat(result).isEqualTo(0.0);
    }
  2. @ParameterizedTest for table-driven tests:

    java
    @ParameterizedTest
    @CsvSource({"low,1", "medium,5", "high,10"})
    void priorityScore_mapsCorrectly(String priority, int expected) {
        assertThat(Priority.score(priority)).isEqualTo(expected);
    }
  3. Mockito for mocking — never PowerMock:

    java
    @ExtendWith(MockitoExtension.class)
    class TaskServiceTest {
        @Mock TaskStorage storage;
        @InjectMocks TaskService service;
    }
  4. TestContainers for integration tests — real DB, no in-memory substitutes for critical paths.

Formatting and Static Analysis

Must pass zero warnings/errors before commit. See .agents/rules/code-idioms-and-conventions.md.

ToolPurposeCommand
google-java-formatCanonical formattinggoogle-java-format --replace src/**/*.java
SpotBugsBug detectionmvn spotbugs:check or gradle spotbugsMain
Error ProneCompile-time bug detectionCompiler plugin
CheckstyleStyle enforcementmvn checkstyle:check
SonarQubeComprehensive analysisCI integration
OWASP Dependency-CheckCVE scanningmvn dependency-check:check
  • Code Idioms and Conventions .agents/rules/code-idioms-and-conventions.md
  • Testing Strategy .agents/rules/testing-strategy.md
  • Error Handling Principles .agents/rules/error-handling-principles.md
  • Dependency Management Principles @.agents/rules/dependency-management-principles.md
  • Logging Implementation @.agents/skills/logging-implementation/SKILL.md

© irahardianto, MIT. 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-idioms of irahardianto/awesome-agv.

Open the folder on GitHubat commit 9e997ba

Compare with similar skills

Java Idioms 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 Idioms compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Java Idioms this skillirahardianto/awesome-agv157—~1.5kAutomated safety check: PassMIT
Javaericrisco/rsc-harness156—~4.6kAutomated safety check: PassMIT
Java Rulessoftspark/ai-toolkit179—~3.1kAutomated safety check: PassApache-2.0
Spring Bootpiomin/claude-ai-spring-boot1.3k—~2kAutomated safety check: PassApache-2.0
Java ArchitectJeffallan/claude-skills12k—~1.5kAutomated safety check: PassMIT
Java TestingHoangNguyen0403/agent-skills-standard570—~1kAutomated safety check: PassMIT

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
  • 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
  • Spring Boot

    piomin/claude-ai-spring-boot

    Spring Boot 3.x development - REST APIs, JPA, Security, Testing, and Cloud-native patterns.

    1.3k GitHub stars~2k tokensUpdated 5 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
  • Java Testing

    HoangNguyen0403/agent-skills-standard

    Testing standards using JUnit 5, AssertJ, Mockito, Cucumber, and Spring Boot integration tests for Java.

    570 GitHub stars~1k tokensUpdated yesterday
    Testing & QAAuto-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
    DevelopmentAuto-check passed

More from irahardianto/awesome-agv

All 34 skills in this repo
  • Distinctive Frontend Design Builder

    irahardianto/awesome-agv

    Commits to one bold aesthetic direction, sets up a CSS token system for it, then builds the interface in Vue or plain HTML using those tokens.

    157 GitHub stars~2.4k tokensUpdated 2 days ago
    Auto-check passed
  • Perf Optimization

    irahardianto/awesome-agv

    Profile-driven performance optimization protocol. An agent skill from irahardianto/awesome-agv.

    157 GitHub stars~4.3k tokensUpdated 2 days ago
    Auto-check passed
  • Angular Idioms and Patterns

    irahardianto/awesome-agv

    Coding conventions for Angular 19 and later: standalone components, signals, OnPush change detection, lazy routes and where RxJS still belongs.

    157 GitHub stars~3.8k tokensUpdated 2 days ago
    Auto-check passed
  • CI/CD Pipeline Principles

    irahardianto/awesome-agv

    Rules for designing CI/CD pipelines in layers: universal lint, test and scan stages, container builds with SBOM attestation, and GitOps for orchestrated deployments.

    157 GitHub stars~2.7k tokensUpdated 2 days ago
    Auto-check: notes
  • Hono Idioms

    irahardianto/awesome-agv

    Hono lightweight web framework patterns: type-safe route handlers, middleware composition, Zod validation, and RPC clients for Cloudflare Workers, Node, or Bun.

    157 GitHub stars~3k tokensUpdated 2 days ago
    Auto-check passed
  • Mobile Testing

    irahardianto/awesome-agv

    Mobile E2E testing patterns — Flutter integrationtest, Patrol, Maestro, golden testing, device matrix, and test data management.

    157 GitHub stars~1.8k tokensUpdated 2 days ago
    Auto-check: notes

Questions about Java Idioms

What does Java Idioms do?

Modern Java (17/21+ LTS) idioms: records, sealed classes, pattern matching switch, Optional hygiene, streams, and JUnit 5 testing. Java Idioms is an agent skill from irahardianto/awesome-agv. Modern Java (17/21+ LTS) idioms: records, sealed classes, pattern matching switch, Optional hygiene, streams, and JUnit 5 testing.

When should I use Java Idioms?

Java Idioms fits situations like: reviewing Java core logic; tasks that involve Backend development; tasks that involve Refactoring.

How do I install Java Idioms in Claude Code?

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

How do I install Java Idioms in Codex?

Run `npx skills add irahardianto/awesome-agv --skill java-idioms -a codex`. Or copy the skill folder (.agents/skills/java-idioms in irahardianto/awesome-agv) into .agents/skills/java-idioms in your project. Codex loads it when a task matches its description.

Can I use Java Idioms 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 irahardianto/awesome-agv --skill java-idioms -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-idioms, .gemini/skills/java-idioms, .github/skills/java-idioms and .opencode/skills/java-idioms in your project.

What does Java Idioms need to run?

Going by SKILL.md and its folder, Java Idioms needs the command-line tools its instructions call (mvn and gradle).

Does Java Idioms access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Java Idioms 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 Idioms use?

Java Idioms is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Java Idioms use?

About 1.5k tokens (SKILL.md is roughly 5.9k 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 Idioms?

Skills that share tags, products or a category with Java Idioms: Java (ericrisco/rsc-harness, 156 stars), Java Rules (softspark/ai-toolkit, 179 stars), Spring Boot (piomin/claude-ai-spring-boot, 1.3k stars) and Java Architect (Jeffallan/claude-skills, 12k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Java Idioms?

irahardianto (a GitHub user) maintains it in irahardianto/awesome-agv, which has 157 GitHub stars. The repository holds 34 skills in this directory. The repository was last updated on October 5, 2026.

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