java/java-conventions/SKILL.md
Generic, composable Java 25 code conventions — modern syntax, code style, naming, visibility, structure, methods, streams, exceptions, and documentation rules that apply across all Java contexts (single-file scripts, CLI apps, MicroProfile/Jakarta EE servers, libraries). Technology-neutral within the Java world; meant to be composed with context-specific skills (e.g. `java-cli-script`, `java-cli-app`, `microprofile-server`, `bce`). Use when writing, generating, or reviewing Java code anywhere the composed skill does not already specify style. Triggers on "Java conventions", "Java style", "Java code style", "modern Java", "Java 25", "idiomatic Java", or any request to write or review Java code where context-specific skills do not already cover style.
npx skillsauth add adambien/airails java-conventionsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
bce.java-cli-script, java-cli-app, microprofile-server, zb, etc.--enable-previewvar, records, sealed types, pattern matching, text blocks, switch expressionsvar for local variable declarations where the type is obvious from the right-hand sideimport module java.net.http;) over individual type importsjava.base — it is automatically availablecase X -> ...) over old case X: statements with breakinstanceof — if (o instanceof String s) over cast-and-assignswitch for type-based dispatch<> for generic type inferencevoid main() / void main(String... args) over public static void main(String[] args); instance main, not staticjava.util, java.nio.file, java.net.http, or java.timePath over String, URI over String, Duration over long millis, Instant/LocalDate over Date/longprivate methods (including private static helpers) — prefer package-private (default) so same-package unit tests can exercise them directly, including edge cases, without round-tripping through the public APIprivate fields — prefer package-private so same-package tests can read or seed state without reflection or extra accessorsprivate for genuinely sensitive state (credentials, security tokens, invariants that must never be observed externally); the burden of justification is on private, not on package-privatefinal on fields — exception: static final for constants like LOGGERfinal on local variables or parametersstatic methods over classes with private constructorsstatic over default methods@Produces) instead of instantiating an interface inlineof, from, etc.) in records over passing null to constructors*Impl, *Service, *Manager, *CreatorControlResource for JAX-RS classes, Factory for actual GoF factories, Builder for classes with method chainingget prefix; use the record-style convention — configuration() not getConfiguration()String::strip over s -> s.strip(), this::isSkillFile over p -> p.endsWith("SKILL.md")).filter() calls with multiple &&/|| conditions into chained .filter() callsboolean isEligible() instead of inlining age >= 18 && status.equals("active") && !bannedjava.util.stream.Stream API over for loopsforEach; prefer terminal operations that return valuesStream.of over Arrays.stream for known elements.toList() over .collect(Collectors.toList())List.of / Set.of / Map.of over new ArrayList<>() and array literals for small immutable collectionsStream.gather(...) with a Gatherer (Java 24+) over custom Spliterator or stateful forEach for stream transformations that need to keep state across elements or flush a remainder at end-of-streamList.of(), Set.of(), Map.of()), never nullnull values in collections""") over +-concatenated multi-line stringsString.formatted() (instance) over String.format(...) (static) for readability at the call siteFiles.readString / Files.writeString / Files.lines over BufferedReader/BufferedWriter ceremonythis to reference instance fields when it improves clarity.close() on any AutoCloseable'\n' not 10, define int ESC = '\033' instead of inlining 27Runnable, Consumer, or lambda in a record instead of switching on type externallyif a pure decisionif/elseOptional as a parameter type; use Optional as a return type only when absence is a meaningful part of the contractjava.lang.Exception or RuntimeException directly — throw a specific subclassthrow e adding no value_ for unused catch parameters (catch (IOException _)) instead of named variables like e or ignoredjava.lang.System.Logger instead of System.out statementsjava.util.logging.LoggerLogger fields must be named LOGGER (uppercase) and marked as static finaljava.net.http.HttpClient APIsHttpClient.sendAsync) only when explicitly requestedtest or shouldisEqualTo assertion makes less specific checks (startsWith, isNotNull) obsolete///, JEP 467) over HTML-tagged /** */ blocksjava-cli-script, java-cli-app, microprofile-server, bce, zb)IO.println not System.out.println", "no package declaration in single-file scripts", "JAX-RS resources are boundary classes"), apply it on top of these rules; the composed skill always specializes, never contradictstools
Generic, composable architecture rules for the Boundary-Control-Entity (BCE/ECB) pattern — business components, layer responsibilities, package structure, and cross-component relationships. Technology-neutral; meant to be composed with language- or framework-specific skills (e.g. microprofile-server, web-components, aws-cdk, java-cli-app). Use when creating, generating, scaffolding, writing, or reviewing code organized as business components with boundary/control/entity layers. Triggers on "BCE", "ECB", "Boundary-Control-Entity", "business component", "BC layout", "BC structure", "boundary layer", "control layer", "entity layer", or requests to organize, package, refactor, or review code along BCE lines.
tools
Create zero-dependency, single-file executable Java scripts for system-wide use via PATH. Use when asked to create a single-file Java shell script, system utility, PATH-installed Java tool, or shebang-launched Java program without the .java extension. Triggers on "Java script", "Java utility", "PATH script", "system script", or requests for single-file Java programs installed in /usr/local/bin or similar PATH directories. Not for multi-file Java applications — use java-cli-app for those.
development
Architecture and coding rules for long-running Java MicroProfile / Jakarta EE server applications — BCE layering, business components (BC), JAX-RS resources, CDI, JSON-P, testing (unit/integration/system), and Maven project structure. Use when creating, generating, scaffolding, writing, or reviewing code, resources, entities, boundaries, or business components in MicroProfile server projects. Not for serverless deployments.
tools
Create and maintain multi-file Java 25 CLI applications packaged as executable JARs with zb (Zero Dependencies Builder). Use when asked to create a Java CLI application, a CLI project with multiple source files, or an executable JAR. Triggers on "Java CLI app", "CLI application", "multi-file Java", "executable JAR", "zb build", or requests for Java programs that need multiple source files or JAR packaging. Not for single-file scripts — use java-cli-script for those.