java-coding-standards
Skill1 starsChanged 56 days agoMITView on GitHub
Java language standards for Spring Boot services: naming, Lombok and constructor injection, immutability and records, Optional, streams, exceptions, generics, null safety, SLF4J logging, and Javadoc discipline. Use when you say \"review this Java class\", \"should this be a record\", \"is this Optional usage correct\", \"rename these methods properly\", or \"set up Checkstyle and SpotBugs\". Not for Spring Boot wiring and REST structure, use `springboot-patterns`.
17 other projects use a version of this, 10 of them edited.
Adopted by
Most recently taken up by
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- qingtiandamowang/alibaba-java-guidelines-skillstheir own version, first seen Aug 15, 2026
- SamuelNDCE/claude-super-skill-librarytheir own version, first seen Aug 1, 2026
- JunMystery/Agent-Guidance-Pythontheir own version, first seen Jul 21, 2026
- Snailclimb/AIGuidetheir own version, first seen Jul 7, 2026
- Lukasbrujula/claude-code-frameworkedited, first seen Jul 6, 2026
Used with
Projects with it also use springboot-tdd, django-verification and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
FaisalAlqarniSkillspringboot-tdd
Test-driven development for Spring Boot using JUnit 5, Mockito, MockMvc, Testcontainers, and JaCoCo. Use when adding features, fixing bugs, or refactoring.
Also in 8 projects that use this
FaisalAlqarniSkilldjango-verification
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.
Also in 8 projects that use this
InfopibeSkilleverything-claude-code
Also in 3 projects that use this
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 5 projects that use this
saxon-ySkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 5 projects that use this
johnrtiptonSkilldjango-security
This skill should be used when conducting security reviews, auditing Django applications, hardening security settings, implementing OWASP Top 10 protections, managing secrets, or ensuring multi-tenant security isolation. Provides automated security auditor that scans settings, code, dependencies, and multi-tenant configurations with auto-fix capabilities.
Also in 8 projects that use this
- +3 more from FaisalAlqarni
- +3 more from Infopibe
Other versions17 projects use a version of this.
Word for word · 0
None found.
Edited · 10
- loulanyue/awesome-claude-notes★ 27211% same
- tpavanipradeep/everything-claude-code★ 13411% same
- Jamkris/everything-gemini-code★ 8710% same
- codelably/harmony-claude-code★ 4310% same
- FaisalAlqarni/sp-ecc★ 910% same
- Infopibe/everything-claude-code★ 811% same
- Lukasbrujula/claude-code-framework★ 410% same
- ashutoshrathi0909-oss/everything-claude-code★ 111% same
- royaluniondesign-sys/claude-os★ 111% same
- mryeastcode/ClaudeCode★ 011% same
Wrote their own version · 7
- xu-xiang/everything-claude-code-zh★ 2ksame name
- Snailclimb/AIGuide★ 664same name
- templetongroup/radiant★ 113same name
- yanhaoluo0/AlibabaDevelopmentManualSkills★ 57same name
- JunMystery/Agent-Guidance-Python★ 2same name
- qingtiandamowang/alibaba-java-guidelines-skills★ 1same name
- SamuelNDCE/claude-super-skill-library★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agentic-engineeringSkill
- ai-regression-testingSkill
- angularSkill
- ansibleSkill
- api-designSkill
- architecture-decision-recordsSkill
- ascend-memorySkill
- ascend-web-hunterSkill
- audio-scribeSkill
- automation-inventorySkill
- backend-patternsSkill
- bashSkill
- build-dependency-managementSkill
- code-formatterSkill
- code-reviewerSkill
- coding-standardsSkill
- dart-flutter-patternsSkill
- database-migrationsSkill
- deployment-patternsSkill
- design-systemSkill
- docker-patternsSkill
- e2e-runbooksSkill
- e2e-testingSkill
- embedded-c-arduinoSkill
- frontend-designSkill
- g-code-3d-printingSkill
- github-opsSkill
- git-workflowSkill
- golang-patternsSkill
- hexagonal-architectureSkill
- home-assistantSkill
- jetbrains-ide-opsSkill
- jira-integrationSkill
- keycloak-patternsSkill
- kicadSkill
- markdown-writerSkill
- mongodb-patternsSkill
- nextjs-app-router-patternsSkill
- node-backend-patternsSkill
- observability-and-loggingSkill
- obsidianSkill
- performance-optimizationSkill
- postgres-patternsSkill
- powershellSkill
- project-trackingSkill
- python-patternsSkill
- pytorch-patternsSkill
- react-patternsSkill
- researchSkill
- review-duplicationSkill
- security-reviewSkill
- seoSkill
- soap-webservicesSkill
- springboot-patternsSkill
- tdd-workflowSkill
- unitySkill
- web-accessibilitySkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 12 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 137
Prefer an explicit type over var.
- Very specific: line 167
No raw types. Bound a type parameter when a reusable utility needs a capability from it.
- Very specific: line 194
Use SLF4J as the API, and never import Logback or Log4j2 in business code.
- Distinctive: line 210
Default to none. A Javadoc block is usually a sign that the code failed to explain itself.
- Distinctive: line 215
When one is still genuinely needed, the prose is capped at five lines and is usually one.
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Java Coding Standards
How Java itself is written in a Spring Boot service, from naming through to Javadoc. Java 21 LTS is the minimum and Java 25 LTS, released September 2025, is the recommended target, so records, sealed types, pattern matching, and virtual threads are all available and expected.
When to activate
- Writing or reviewing Java in a Spring Boot project.
- Deciding between a record, a class, and a sealed hierarchy.
- Enforcing naming, immutability, or exception conventions in review.
- Reviewing use of
Optional, streams, or generics. - Structuring packages, or setting up the static analysis that guards this style.
When not to activate
- Spring Boot structure, controllers, DTO contracts, and bean wiring, use
springboot-patterns. - Entity mapping, queries, transaction boundaries, and security wiring, use
springboot-patterns. - Writing the tests, and running the analysis pipeline before a pull request, use
springboot-patterns. - Version catalogs, BOM imports, and dependency admission, use
build-dependency-management. - Ports and adapters layering across a service, use
hexagonal-architecture.
Name things after what they are
Classes and records are PascalCase, methods and fields camelCase, constants UPPER_SNAKE_CASE. A boolean starts with
is, has, or can. A method name is a verb phrase specific enough that a reader does not have to open the body.
Pass:
public record Money(BigDecimal amount, Currency currency) {}
private static final int MAX_PAGE_SIZE = 100;
public List<User> findActiveUsersByTenant(TenantId tenantId) { ... }Fail: getData(), flag, process(), and a constant spelled maxPageSize.
Inject through the constructor, log through Lombok
Lombok removes boilerplate that carries no decisions. @RequiredArgsConstructor for injection, @Slf4j for the
logger, @Builder where construction is genuinely complex, @Value for immutable value objects, and @Getter or
@Setter only where neither a record nor @Value fits.
Pass: final fields, one generated constructor, no annotation on the field.
@Service
@Slf4j
@RequiredArgsConstructor
public class MarketService {
private final MarketRepository marketRepository;
}Fail: field injection, which hides the dependency from every constructor call and from every test.
@Autowired
private MarketRepository marketRepository;Make it immutable unless something has to change
Records for data, final fields elsewhere, and no setter that exists only because a framework once needed one. Immutable objects are safe to share across threads and cannot be half-updated by a failed operation.
Pass:
public record MarketDto(Long id, String name, MarketStatus status) {}Fail: a mutable bean with a no-argument constructor and a setter per field, passed between threads.
Return Optional, never store it
Optional is a return type for a lookup that can legitimately find nothing. It is not a field type, not a
parameter type, and not a collection element.
Pass: map or flatMap the value, and end with orElseThrow.
return marketRepository.findBySlug(slug)
.map(MarketResponse::from)
.orElseThrow(() -> new MarketNotFoundException(slug));Fail: .get() after .isPresent(), or an Optional<String> field on an entity.
Keep stream pipelines short and named
A stream expresses a transformation. When the pipeline needs more than a few stages, or a stage needs a comment, extract it into a method whose name says what the transformation produces.
Pass:
List<String> names = markets.stream()
.map(Market::name)
.filter(Objects::nonNull)
.toList();Fail: a twelve-stage pipeline with a nested flatMap and a lambda spanning six lines. Extract the lambda, or the
whole pipeline, into a named private method.
Write for the next reader
One public top-level type per file. Members in order: constants, fields, constructors, public methods, protected, private. Methods short enough to hold in your head, with helpers extracted. A lambda longer than one line becomes a named private method. Never write a fully qualified class name in code, import it.
Prefer an explicit type over var. The narrow allowance is a right-hand side that already names the type, such as
var list = new ArrayList<String>(). Everywhere else, the type is the documentation.
Pass: MarketResponse response = service.findBySlug(slug);
Fail: var result = service.process(input);, where a reader has to open two methods to learn what result is.
Indent with 2 or 4 spaces, matching the project. Consistency beats preference.
Fail with a domain exception, handle it centrally
Domain errors are unchecked exceptions named after the thing that went wrong. Technical exceptions get wrapped with
context rather than swallowed. One @ControllerAdvice translates them into responses, so business methods stay
free of try-catch blocks.
Pass:
throw new MarketNotFoundException(slug);Fail: catch (Exception ex) { log.error("error", ex); } in the middle of a service method, which turns a failure
into a wrong answer.
Declare your generics
No raw types. Bound a type parameter when a reusable utility needs a capability from it. A raw type turns a
compile-time error into a ClassCastException at runtime.
Pass:
public <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }Fail: public Map indexById(Collection items).
Say where null is allowed
Annotate public API signatures with @NonNull and @Nullable, from JSpecify or jakarta.annotation, and enforce
them with NullAway or the JSpecify processor in CI. Accept @Nullable only where the absence is genuinely part of
the contract. Validate inbound values with Bean Validation so a null never travels deeper than the edge.
Pass: an annotated signature with a CI check that fails on a violation.
Fail: annotations added for documentation with nothing enforcing them, which drift within a release.
Log through SLF4J with structured messages
Use SLF4J as the API, and never import Logback or Log4j2 in business code. Take the logger from @Slf4j. Message
keys are stable tokens with the variable parts as parameters, so a log aggregator can group them.
Pass: log.info("fetch_market slug={}", slug); inside a class annotated @Slf4j.
Fail: log.info("Fetching market " + slug), or a logger built by hand with
LoggerFactory.getLogger(MarketService.class).
Levels: ERROR for unhandled exceptions, WARN for recoverable problems, INFO for significant domain events,
DEBUG for diagnostics. Structured JSON output and the production logging stack belong to
observability-and-logging.
Javadoc
Default to none. A Javadoc block is usually a sign that the code failed to explain itself. Before writing one, extract the unclear block into a well-named method, rename the parameters so they carry their own meaning, and tighten the types. Do that first and most Javadoc blocks have nothing left to say, which is the outcome you want. Code that explains itself cannot go stale, a comment can.
When one is still genuinely needed, the prose is capped at five lines and is usually one. Every tag line is capped at
one line, @param and @return and @throws alike, and only appears when it genuinely adds something: if the note
does not fit on a single line, shorten it or drop the tag. Four rules decide what goes in.
- Prose. One sentence saying what it does, then only what a caller cannot infer from the signature. Nothing more.
@paramonly when the name and the type do not already convey it, meaning units, nullability, a valid range, or who owns the argument afterwards.@param orderId the wholesale order identifieris noise, delete it.@returnonly when it is non-obvious.@throwsalways, for every exception a caller can act on. Unchecked exceptions never appear in the signature, so this one is genuinely contract rather than decoration.
Going past the five-line prose cap is allowed only when the contract genuinely cannot be stated in fewer lines, for example a documented state machine, an ordering requirement, or a concurrency guarantee. It is an exception you justify in review, not a budget to spend. The one-line cap on a tag line has no exception at all: shorten it or delete it.
// GOOD: one sentence, then only what the signature cannot say
/**
* Reserves stock for an order and holds it until the payment window closes.
*
* @param holdFor how long the reservation survives, at most 15 minutes
* @throws InsufficientStockException when the warehouse cannot cover the order
*/
public Reservation reserve(OrderId orderId, Duration holdFor) { ... }
// BAD: restates the signature, and the first tag wraps onto a second line
/**
* Reserves stock.
*
* @param orderId the identifier of the order that stock is being reserved
* against, taken from the inbound request
* @param holdFor the hold duration
* @return the reservation
*/
public Reservation reserve(OrderId orderId, Duration holdFor) { ... }
// BEST: naming and types carry it, no Javadoc needed
public Reservation reserveStockUntilPaymentWindowCloses(OrderId orderId, Duration holdFor) { ... }Reference material
| Open this | For |
| references/concurrency.md | Virtual threads, executors, CompletableFuture composition, and thread-safety documentation. |
| references/serialization-and-config.md | Jackson setup, typed @ConfigurationProperties, and entity to DTO mapping. |
| references/static-analysis.md | Checkstyle, SpotBugs, and PMD wiring, and keeping build output readable. |
| references/project-layout.md | Package structure for a layered project, and the code smells to fix on sight. |
Related skills
| Skill | What it owns |
springboot-patterns | Spring Boot structure, REST contracts, security, JPA, tests, and the analysis pipeline. |
build-dependency-management | Version catalog and BOM discipline for the plugins above. |
hexagonal-architecture | Ports and adapters layering when the project uses it. |
observability-and-logging | Structured log output, metrics, and tracing. |
coding-standards | The cross-language principles this skill applies to Java. |
Checklist
- Names say what the thing is, and booleans read as questions.
- Every dependency arrives through the constructor, and no field carries
@Autowired. - Data types are records or final-field classes, with no setter that nothing needs.
Optionalappears only as a return type, and never after.isPresent()plus.get().- Stream pipelines are short, or extracted into named methods.
- Explicit types instead of
var, except where the right-hand side already names the type. - Domain exceptions are unchecked, named, and handled in one
@ControllerAdvice. - No raw types anywhere.
- Nullability annotations are present on public signatures and enforced in CI.
- Logging goes through
@Slf4jwith parameterised messages, never concatenation. - Javadoc is absent by default, and every surviving block clears the caps above.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

