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-codeInstalls 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
