java-best-practices
Installation
SKILL.md
Java Best Practices
Guidance for writing type-safe, concurrent, and modern Java code targeting Java 17+ and Java 21 LTS. Covers null safety, concurrency patterns, and modern language features.
Core Principles
- Null safety first: Use Optional for return values, @Nullable/@NonNull for parameters
- Immutability preferred: Use records for data carriers, final fields where possible
- Explicit error handling: Use checked exceptions sparingly, prefer Result patterns
- Modern features: Leverage records, sealed classes, and pattern matching
- Virtual threads for IO: Use virtual threads (Java 21) for IO-bound operations