This one gets Claude up to speed on Java 21's three headline features: records for immutable data carriers, sealed types with exhaustive pattern matching, and virtual threads for scalable blocking I/O. You'd reach for it when building modern Java services where you want DTOs validated in compact constructors, closed hierarchies that the compiler can verify, or need to handle thousands of concurrent blocking calls without spinning up platform threads. The examples are clean and show real validation patterns, not toy code. Honestly, if you're still on Java 8 or 11 this will feel like a different language, and that's the point. The anti-patterns section usefully calls out the old habits to drop.

skills.sh installs
328
GitHub stars
665
last updated
Aug 21, 2026

Install

$ npx -y skills add gentleman-programming/gentleman-skills --skill java-21 --agent claude-code

Installs into .claude/skills of the current project.

Files

When to Use

Load this skill when:

  • Writing Java 21 application or library code
  • Designing immutable DTOs or value objects
  • Modeling closed hierarchies with sealed types
  • Using virtual threads for blocking I/O

Critical Patterns

Pattern 1: Records for immutable data

Use records for DTOs and value objects, validate in compact constructors.

Pattern 2: Sealed types + pattern matching

Use sealed interfaces/classes and switch pattern matching for exhaustiveness.

Pattern 3: Virtual threads for I/O

Use virtual threads to handle blocking I/O without large thread pools.

Code Examples

Example 1: Record with validation

package com.acme.user;

public record Email(String value) {
  public Email {
    if (value == null || !value.contains("@")) {
      throw new IllegalArgumentException("Invalid email");
    }
  }
}

Example 2: Sealed hierarchy + switch pattern matching

package com.acme.payment;

public sealed interface Payment permits Card, BankTransfer { }

public record Card(String last4) implements Payment { }
public record BankTransfer(String iban) implements Payment { }

Sponsors

Details

Repository
github.com/gentleman-programming/gentleman-skills
Categories
Documentation, Java & JVM
First seen
Jun 3, 2026

More from gentleman-programming/gentleman-skills

All 13
1pproenca avatarunix-clipproenca/dot-skillsUNIX command-line interface guidelines for building tools that follow POSIX conventions, proper exit codes, stream handling, and the UNIX philosophy. This skill326skills.sh installs
2secondsky avatarswift-best-practicessecondsky/claude-skills| This skill should be used when writing or reviewing Swift code for iOS or macOS projects. Apply modern Swift 6+ best practices, concurrency patterns, API desi326skills.sh installs
3gmh5225 avatargame-hacking-techniquesgmh5225/awesome-game-securityGuide for game-hacking technique taxonomy and threat modeling relevant to game security. Use this skill when researching memory access, code injection, overlays325skills.sh installs
4outscal avatarshorts-script-personalityoutscal/video-generatorGenerates hyper-optimized YouTube Shorts/Instagram Reels scripts with personality-specific styles while enforcing strict anti-AI-slop writing rules325skills.sh installs
5vinayakkulkarni avatarnuxt-best-practicesvinayakkulkarni/vue-nuxt-best-practicesNuxt 4 performance optimization and architecture guidelines (current through Nuxt 4.5) for building fast, maintainable full-stack applications. This skill shoul325skills.sh installs
6anthropics avatarbrand-voiceanthropics/knowledge-work-pluginsApply and enforce brand voice, style guide, and messaging pillars across content. Use when reviewing content for brand consistency, documenting a brand voice, a324skills.sh installs