java-coding-standards

Enforces Java 17+ coding standards for Spring Boot services covering naming, immutability, and exceptions.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill java-coding-standards-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-coding-standards
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/java-coding-standards
Command: npx skills add https://github.com/Femad-6/my-skills --skill java-coding-standards-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Java codebases in Spring Boot projects often drift into inconsistent naming, mutable state, poor Optional usage, and unclear exception handling, making reviews slow and maintenance costly. This Skill provides a concrete, example-driven standards reference so code is written and reviewed against one consistent set of rules. ## Core Features & Use Cases - Naming and Structure Conventions: Defines PascalCase classes, camelCase methods, UPPER_SNAKE_CASE constants, and a standard Maven/Gradle package layout (config, controller, service, repository, domain, dto). - Immutability and Modern Java: Promotes records, final fields, sealed classes, and pattern matching for Java 17+ code. - Optional, Streams, and Generics Guidance: Shows correct Optional map/orElseThrow patterns, short stream pipelines, and bounded generics instead of raw types. - Use Case: While reviewing a pull request that returns null from a repository method and catches generic Exception, apply these standards to refactor it into an Optional-returning method throwing a domain-specific MarketNotFoundException. ## Quick Start Review this Java service class against the coding standards and fix any violations of naming, Optional usage, and exception handling.

Frequently Asked Questions about java-coding-standards

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

FAQPage Schema
How do I enforce Java coding standards in a Spring Boot project?

Apply consistent conventions for naming, immutability, and package structure across all code and reviews. Use PascalCase for classes, camelCase for methods, UPPER_SNAKE_CASE for constants, and organize code into config, controller, service, repository, domain, and dto packages.

How should Optional be used in Java repository methods?

Return Optional from find* methods and chain map or flatMap instead of calling get() directly. Convert the result with orElseThrow to raise a domain exception like EntityNotFoundException when the value is absent.

Should Java code use checked or unchecked exceptions for domain errors?

Use unchecked exceptions for domain errors and create domain-specific types such as MarketNotFoundException. Wrap technical exceptions with context and avoid broad catch blocks unless logging centrally or rethrowing.

Does this standard support Java 17 features like records and sealed classes?

Yes, the standards target Java 17+ and actively encourage records for DTOs, final fields for immutability, and sealed classes with pattern matching. Records are the preferred way to define immutable data carriers.

What testing frameworks are recommended for Spring Boot Java code?

Use JUnit 5 with AssertJ for fluent assertions and Mockito for mocking dependencies. Tests should be deterministic, avoid hidden sleeps, and avoid partial mocks where possible.