java-code-standards
Skill0 starsChanged 10 days agoMITView on GitHub
Write and review Java 21: records and immutability, null and Optional handling, domain exception hierarchy with stable ErrorCodes, and pattern matching.
In this repository68 other files it gives its agents.
- skills/web-development/adapters/copilot-instructions.mdCopilot instructions
- accessibility-auditSkill
- agent-handoffSkill
- ai-tool-securitySkill
- api-designSkill
- audit-loggingSkill
- background-jobsSkill
- bulk-reporting-exportSkill
- changelog-generatorSkill
- ci-cdSkill
- codebase-onboardingSkill
- code-reviewSkill
- code-simplificationSkill
- context-engineeringSkill
- context-privacySkill
- data-import-exportSkill
- debuggingSkill
- dependency-auditSkill
- deprecation-and-migrationSkill
- design-tokensSkill
- documentation-and-adrsSkill
- doubt-driven-developmentSkill
- environmental-telemetrySkill
- erp-accountingSkill
- erp-domain-designSkill
- erp-inventorySkill
- erp-procurementSkill
- erp-salesSkill
- feature-flagsSkill
- forms-and-validationSkill
- frontend-stateSkill
- frontend-ui-engineeringSkill
- git-workflowSkill
- identity-access-managementSkill
- incremental-implementationSkill
- java-deliverySkill
- kerangkaSkill
- mcp-builderSkill
- membership-managementSkill
- observabilitySkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- product-analyticsSkill
- quarkus-observabilitySkill
- quarkus-persistenceSkill
- quarkus-securitySkill
- quarkus-serviceSkill
- quarkus-testingSkill
- responsive-layoutSkill
- rest-api-contractSkill
- saas-billingSkill
- saas-multitenancySkill
- saas-onboardingSkill
- security-hardeningSkill
- shipping-and-launchSkill
- skill-creatorSkill
- skill-evaluationSkill
- source-driven-developmentSkill
- spec-driven-developmentSkill
- test-driven-developmentSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Do not argue about formatting in review.
- Very specific: line 53
Do not abbreviate: orderType, not procType.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Java 21 Code Standards
Overview
Full rules: .agents/standards/java/java-code-style.md. This covers the decisions that come up
while writing.
When to use
- Writing a new Java class
- Reviewing a Java diff
- Deciding:
Optionalor exception? Record or class? Checked or unchecked? - Cleaning up code that is hard to read
Formatting is machine-enforced
./mvnw spotless:apply # before committingDo not argue about formatting in review. Spotless has already decided.
Process
- Record by default. Anything carrying data without identity — DTOs, parameter
objects, return values, events — is a
record. A class is for something with identity or mutable state, and you should be able to say which. - Return
Optionalfor an absence the caller must handle; throw for a violated rule.Optionalis a return type, never a field and never a parameter. - Throw a domain exception carrying an
ErrorCode, not a bareRuntimeException. An emptycatchandprintStackTraceare both defects. - Never return
nullfor a collection. Return an empty one. - Early returns over nesting, pattern-matching
switchoverifchains on state, text blocks for SQL. BigDecimalfor money, compared withcompareTo— never==, neverequals, and never adouble.- Log through the logger, never
System.out, and keep sensitive values out of both log lines and exception messages.
Naming
- Identifiers are English.
- The exception is Indonesian statutory order vocabulary with no precise English
equivalent. That glossary lives in the organisation's domain skill under
context/skills/. - Do not abbreviate:
orderType, notprocType. - Booleans read as assertions:
active,approved— notflag,status1.
Red flags
| Item | Threshold | Usually means |
| Method length | > 40 lines | More than one responsibility |
| Parameters | > 4 | Needs a record parameter object |
| Class length | > 400 lines | Needs splitting |
| Nesting | > 3 | Needs early returns |
| "and" in a method name | — | It is two methods |
Verification
- DTOs are
records with no setters - No
nullreturned for a collection Optionalused only as a return type- Domain exceptions with
ErrorCode, not bareRuntimeException - No empty
catchorprintStackTrace - Money uses
BigDecimal, compared withcompareTo - No
System.out - No sensitive data in logs or exception messages
- Every
TODOcarries a ticket ID ./mvnw spotless:checkpasses
References
references/types-and-errors.md- record or class, Optional or exception, which exceptionreferences/expected-patterns.md- early returns, pattern-matching switch, text blocks, money, logging
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.

