agentleFS
hi-donwihi-donwi/Donwi-Skills/skills/java-code-standards/SKILL.md

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.

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
  1. Distinctive:

    Do not argue about formatting in review.

    line 29
  2. Very specific:

    Do not abbreviate: orderType, not procType.

    line 53

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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: Optional or exception? Record or class? Checked or unchecked?
  • Cleaning up code that is hard to read

Formatting is machine-enforced

./mvnw spotless:apply     # before committing

Do not argue about formatting in review. Spotless has already decided.

Process

  1. 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.
  2. Return Optional for an absence the caller must handle; throw for a violated rule. Optional is a return type, never a field and never a parameter.
  3. Throw a domain exception carrying an ErrorCode, not a bare RuntimeException. An empty catch and printStackTrace are both defects.
  4. Never return null for a collection. Return an empty one.
  5. Early returns over nesting, pattern-matching switch over if chains on state, text blocks for SQL.
  6. BigDecimal for money, compared with compareTo — never ==, never equals, and never a double.
  7. 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, not procType.
  • Booleans read as assertions: active, approved — not flag, status1.

Red flags

ItemThresholdUsually means
Method length> 40 linesMore than one responsibility
Parameters> 4Needs a record parameter object
Class length> 400 linesNeeds splitting
Nesting> 3Needs early returns
"and" in a method name—It is two methods

Verification

  • DTOs are records with no setters
  • No null returned for a collection
  • Optional used only as a return type
  • Domain exceptions with ErrorCode, not bare RuntimeException
  • No empty catch or printStackTrace
  • Money uses BigDecimal, compared with compareTo
  • No System.out
  • No sensitive data in logs or exception messages
  • Every TODO carries a ticket ID
  • ./mvnw spotless:check passes

References

  • references/types-and-errors.md - record or class, Optional or exception, which exception
  • references/expected-patterns.md - early returns, pattern-matching switch, text blocks, money, logging

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.