java-best-practices

java-best-practices is a skill for Claude Code, Codex from rbarcante/claude-conductor. It costs 30 tokens per session (4,241 once invoked), scanned A, original, Apache-2.0.

Guidance for writing modern, type-safe Java 17 and Java 21 code, including safer handling of missing values and concurrent work.

In plain words
What is it for?
Use it when working with Optional, records, sealed classes, CompletableFuture, or virtual threads, which are Java features for representing data, restricting types, and running tasks.
Why use it?
It helps avoid unclear null values, unsafe shared state, and outdated approaches to Java features and asynchronous programming.

Skill for Claude CodeCodex

Part of the conductor plugin — 7 skills, 9 commands, 6 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/rbarcante/claude-conductor/java-best-practices
Any agent
npx skills add rbarcante/claude-conductor --skill java-best-practices
Clone the repo
git clone --depth 1 https://github.com/rbarcante/claude-conductor

Made for: Claude Code, Codex.

Or install conductor, the plugin that ships this one along with the rest of its 7 skills, 9 commands, 6 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for java-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/rbarcante/claude-conductor/java-best-practices.svg)](https://agentmods.dev/skills/rbarcante/claude-conductor/java-best-practices)
Your own site
<a href="https://agentmods.dev/skills/rbarcante/claude-conductor/java-best-practices"><img src="https://agentmods.dev/badge/skills/rbarcante/claude-conductor/java-best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,241 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.04241
Opus 5 $0.00015 $0.02121
Sonnet 5 $0.00006 $0.00848
Haiku 4.5 $0.00003 $0.00424

Measured 4d ago against content hash c4dc7d9dfd8a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/java-best-practices/SKILL.md · 661 lines

How it starts

The opening of the file, as written. The whole thing — 661 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

  1. Null safety first: Use Optional for return values, @Nullable/@NonNull for parameters
  2. Immutability preferred: Use records for data carriers, final fields where possible
  3. Explicit error handling: Use checked exceptions sparingly, prefer Result patterns
  4. Modern features: Leverage records, sealed classes, and pattern matching
  5. Virtual threads for IO: Use virtual threads (Java 21) for IO-bound operations

Type Safety

Use Optional for Return Values

// Good - explicit absence representation
public Optional<User> findById(String id) {
    User user = userRepository.findById(id);
    return Optional.ofNullable(user);
}

// Bad - null return
public User findById(String id) {
    return userRepository.findById(id); // May return null
}

Never Use Optional as Parameter or Field

// Bad - Optional as parameter
public void processUser(Optional<User> user) { ... }

// Good - use @Nullable annotation or overloading
public void processUser(@Nullable User user) { ... }
public void processUser(User user) { ... } // Overload for non-null

// Bad - Optional as field
private Optional<String> middleName;

// Good - nullable field with annotation
@Nullable
private String middleName;

Use Null Safety Annotations

import org.jspecify.annotations.Nullable;
import org.jspecify.annotations.NonNull;

// Good - explicit null contract
public @NonNull User createUser(@NonNull String name, @Nullable String email) {
    Objects.requireNonNull(name, "name cannot be null");
    return new User(name, email);
}

Defensive Coding with Objects.requireNonNull

public class UserService {
    private final UserRepository repository;
    private final EmailService emailService;

    // Good - fail-fast validation in constructor
    public UserService(UserRepository repository, EmailService emailService) {
        this.repository = Objects.requireNonNull(repository, "repository cannot be null");
        this.emailService = Objects.requireNonNull(emailService, "emailService cannot be null");
    }
}

Read the full file on GitHub · 661 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 661 lines · 30 tokens per session scan A c4dc7d9dfd8a

Subscribe to this mod's changes

java-best-practices is a skill published in the GitHub repository rbarcante/claude-conductor (56 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 30 tokens to every session and 4,241 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

union-type-wrappers

Add typed getters and setters over BinaryData properties that represent TypeSpec union types in generated Java models. Use when generated classes expose BinaryData for union-typed fields and you need ergonomic, type-safe accessors instead.

Azure/azure-sdk-for-java · 49 tokens

run-tests

Run project tests using Maven (mvn). Use when the user asks to run tests.

Azure/azure-sdk-for-java · 21 tokens

search-m2

Search for Java classes inside Maven dependencies in /.m2. Use when the user asks to locate classes or inspect JARs. Cross-reference pom.xml files in the current directory to resolve dependency names/versions.

Azure/azure-sdk-for-java · 46 tokens

dd-code-generation

Use pup CLI for immediate Datadog operations or generate code for integration into applications.

DataDog/pup · 16 tokens

create-package-skill

Interactive wizard that walks service teams through creating a package-specific skill for their Azure SDK package. Scans the package, detects customization patterns, scaffolds a SKILL.md with references, and validates with vally lint. The skill is placed inside the package's .github/skills/ directory so…

Azure/azure-sdk-for-java · 106 tokens

solid-principles

SOLID principles checklist with Java examples. Use when a class has too many responsibilities, an abstraction leaks, or a dependency points the wrong way, and when the user asks about Single Responsibility, Open/Closed, Liskov, Interface Segregation or Dependency Inversion. For naming, duplication and method length…

decebals/claude-code-java · 73 tokens