java-coding-standards

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

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill java-coding-standards-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: java-coding-standards
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/java-coding-standards
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill java-coding-standards-freedom909

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: Enforces PascalCase classes, camelCase methods, UPPER_SNAKE_CASE constants, and a standard Maven/Gradle package layout (config, controller, service, repository, domain, dto, util). - Immutability and Modern Java: Promotes records, final fields, sealed classes, and pattern matching for Java 17+, plus correct Optional and stream usage. - Exceptions, Logging, and Testing: Guides domain-specific exceptions, SLF4J logging patterns, null handling with Bean Validation, and JUnit 5 + AssertJ + Mockito testing expectations. - Use Case: When 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 that throws a domain-specific MarketNotFoundException. ## Quick Start Review this Spring Boot service class against the Java coding standards and list every violation with a corrected version.

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 coding standards in a Spring Boot project?▼

Apply a written standards guide covering naming, immutability, Optional usage, exceptions, and package layout, then reference it during code reviews. Concrete PASS/FAIL examples for each rule make the conventions unambiguous and easy to apply consistently.

When should I use Optional in Java methods?▼

Return Optional from find* methods that may not produce a result, such as repository lookups by slug. Consume it with map, flatMap, or orElseThrow instead of calling get(), and never use Optional for fields or parameters.

What Java 17 features should Spring Boot code use?▼

Java 17 code should favor records for DTOs, final fields for immutability, and sealed classes with pattern matching where type hierarchies are fixed. These features reduce boilerplate and make domain models safer by default.

Should I 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 (Exception ex) blocks unless logging or rethrowing centrally.

What testing libraries are recommended for Spring Boot services?▼

Use JUnit 5 with AssertJ for fluent assertions and Mockito for mocking, avoiding partial mocks where possible. Tests should be deterministic with no hidden sleeps, and the test source tree should mirror the main package structure.