Use this skill when working with Java code, Optional handling, CompletableFuture, records, sealed classes, or virtual threads.
A Conductor skill providing guidance for writing type-safe, concurrent, and modern Java code targeting Java 17+ and Java 21 LTS.
This skill activates when working with Java files and provides guidance on:
The skill automatically activates when:
.java filespom.xml or build.gradle filesjava, optional, completablefuture, record, sealed, virtual thread| Pattern | Description | |---------|-------------| | type-safety | Optional best practices, null safety annotations, defensive coding | | concurrency | CompletableFuture, virtual threads, thread-safe patterns | | modern-features | Records, sealed classes, pattern matching |
// Good - explicit Optional handling
public Optional<User> findUserById(String id) {
return Optional.ofNullable(userRepository.findById(id));
}
// Usage with map/flatMap
String userName = findUserById("123")
.map(User::getName)
.orElse("Unknown");
// Immutable data carrier with automatic equals, hashCode, toString
public record User(String id, String name, String email) {
// Compact constructor for validation
public User {
Objects.requireNonNull(id, "id cannot be null");
Objects.requireNonNull(name, "name cannot be null");
}
}
// Lightweight threads for IO-bound operations
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
List<Future<String>> futures = urls.stream()
.map(url -> executor.submit(() -> fetchUrl(url)))
.toList();
for (Future<String> future : futures) {
System.out.println(future.get());
}
}
npx skills add rbarcante/java-best-practices下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer