java

Standardize Java conventions for Maven or Gradle projects.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/dotBeeps/pantry --skill java-dotbeeps
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java
Source: https://github.com/dotBeeps/pantry/tree/main/morsels/skills/java
Command: npx skills add https://github.com/dotBeeps/pantry --skill java-dotbeeps

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Java conventions to ensure consistent style, safer null handling, and reliable testing across Java projects.

Core Features & Use Cases

  • Enforce local variable type inference using var where the type is obvious from the right-hand side.
  • Encourage records for immutable DTOs and sealed classes for closed hierarchies.
  • Promote Optional for return values and discourage Optional as fields or parameters.
  • Recommend modern patterns like pattern matching for instanceof and concise switch expressions.
  • Testing guidance with JUnit 5 and AssertJ.

Quick Start

Apply these conventions to your Java project to align style, null handling, and testing practices.

Frequently Asked Questions about java

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce Java conventions for immutable DTOs and local variable type inference?

Java conventions for immutable DTOs are enforced by using records, while local variable type inference is standardized by applying var where the type is obvious. This reduces style drift and ensures safer null handling across codebases.

What's the best way to standardize Java testing conventions with JUnit 5?

Standardize Java testing conventions by adopting JUnit 5 with AssertJ for assertions. This combination provides reliable testing practices and expressive assertions, ensuring consistent test coverage and safer null handling across Java projects.

Does this Java convention guide work with both Maven and Gradle projects?

Yes, the Java convention guide applies to both Maven and Gradle projects. It standardizes style, null handling using Optional for return values, and testing practices across your build system without requiring additional dependencies.

When should I use Optional for return values versus fields in Java?

Use Optional for return values to promote safer null handling in Java. The conventions discourage using Optional as fields or parameters, ensuring cleaner API design and reducing style drift across your codebase.

How do I apply sealed classes and pattern matching for closed hierarchies in Java?

Apply sealed classes for closed hierarchies and use pattern matching for instanceof and concise switch expressions. These modern Java patterns standardize conventions and reduce style drift across your codebase.

What are the limitations of using var for local variable type inference in Java?

The limitation of using var for local variable type inference is that it should only be applied where the type is obvious from the right-hand side. Overusing var when the type is unclear reduces code readability and standardization.