- Java 17+ LTS, records for immutable data, sealed classes for restricted hierarchies, pattern matching.
- A consistent style guide and auto-formatter (e.g., Google Java Style + google-java-format). Static analysis (e.g., Error Prone + SpotBugs).
- Build: Maven or Gradle with wrapper scripts (
mvnw/gradlew). Commit wrapper files. - Testing: JUnit 5 with
@ParameterizedTest, an assertion library (e.g., AssertJ), a coverage tool (e.g., JaCoCo) at 80%+. - Benchmarking: JMH for microbenchmarks — never use
System.nanoTime()loops. - Error handling: specific exceptions only, never
catch (Exception), use try-with-resources forAutoCloseable. varfor obvious types,Optional<T>for returns (never params/fields),finalfields by default.- Prefer constructor injection over field injection for DI. Immutable collections:
List.of(),Map.of(). - Streams for collection transforms,
instanceofpattern matching, switch expressions. - Security: OWASP
dependency-checkMaven/Gradle plugin for CVE scanning. - Dependencies: commit lock files, use BOM for version alignment, avoid
SNAPSHOTin releases. - Anti-patterns: public fields, mutable static state, raw types, checked exceptions in lambdas.
Java Conventions
Java code conventions covering Java 17+ records and sealed classes, formatting/static analysis, Maven/Gradle, JUnit 5, exception handling, constructor injection, streams, and security. Load when writing or reviewing Java code.
Java Conventions by goldziher · 4cf73c7
npx skillmds@latest add goldziher/java-conventions File contents
---name: java-conventionsdescription: Java code conventions covering Java 17+ records and sealed classes, formatting/static analysis, Maven/Gradle, JUnit 5, exception handling, constructor injection, streams, and security. Load when writing or reviewing Java code.---- Java 17+ LTS, records for immutable data, sealed classes for restricted hierarchies, pattern matching.- A consistent style guide and auto-formatter (e.g., Google Java Style + google-java-format). Static analysis (e.g., Error Prone + SpotBugs).- Build: Maven or Gradle with wrapper scripts (`mvnw`/`gradlew`). Commit wrapper files.- Testing: JUnit 5 with `@ParameterizedTest`, an assertion library (e.g., AssertJ), a coverage tool (e.g., JaCoCo) at 80%+.- Benchmarking: JMH for microbenchmarks — never use `System.nanoTime()` loops.- Error handling: specific exceptions only, never `catch (Exception)`, use try-with-resources for `AutoCloseable`.- `var` for obvious types, `Optional<T>` for returns (never params/fields), `final` fields by default.- Prefer constructor injection over field injection for DI. Immutable collections: `List.of()`, `Map.of()`.- Streams for collection transforms, `instanceof` pattern matching, switch expressions.- Security: OWASP `dependency-check` Maven/Gradle plugin for CVE scanning.- Dependencies: commit lock files, use BOM for version alignment, avoid `SNAPSHOT` in releases.- Anti-patterns: public fields, mutable static state, raw types, checked exceptions in lambdas.
goldziher/ai-rulez/tree/main/internal/builtins/languages/java/skills/java-conventions commit 4cf73c7b41
Frequently asked questions
Run npx skillmds@latest add goldziher/java-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Java code conventions covering Java 17+ records and sealed classes, formatting/static analysis, Maven/Gradle, JUnit 5, exception handling, constructor injection, streams, and security. Load when writing or reviewing Java code. It is listed under Security on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
goldziher (@goldziher) published this skill. Their other Agent Skills are listed on their SkillMD profile.