java-conventions

A set of rules for adding or changing Java code in an existing project. It covers modern Java style, immutable data, Spring Boot dependency setup, and JUnit 5 with Mockito tests.

In plain words
What is it for?
Use it when implementing Java tickets, fixing Java builds, designing data classes, handling optional values, or adding unit tests.
Why use it?
It reduces the risk of code that compiles but conflicts with the project's Java version, structure, formatting, or testing habits.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tmj-90/gaffer/java-conventions
Any agent
npx skills add tmj-90/gaffer --skill java-conventions
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,242 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00089 $0.01242
Opus 5 $0.00044 $0.00621
Sonnet 5 $0.00018 $0.00248
Haiku 4.5 $0.00009 $0.00124

Measured yesterday against content hash 557947f285d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java-conventions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/java-conventions/SKILL.md · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Write idiomatic, modern Java

Add Java that uses the current language toolset, models data immutably, and matches the repo's existing idioms — provably correct and conventional, not just compiling.

Steps

  1. Read the lore first. Call search_lore (Memory MCP) for the repo's Java conventions and target version, and respect the build config (pom.xml / build.gradle), the formatter (Spotless / google-java-format), and any architecture ADRs. Match the Java version the project already compiles against — do not assume the newest.
  2. Find a sibling class and copy its patterns — package layout, naming, error handling, how DTOs/entities are modelled, and how tests are organised.
  3. Use modern language features where the version allows. Prefer records for data carriers over hand-written getters/setters or Lombok @Data/@Value/@Builder. Use sealed interfaces + pattern matching and switch expressions to model closed hierarchies exhaustively; use text blocks for multi-line literals.
  4. Discipline with Optional. Represent absence with Optional rather than null; never call .get() without an isPresent() guard — prefer .map(), .orElseThrow(), .orElseGet(). Never use Optional for fields or method parameters.
  5. Favour immutability. Final fields, immutable collections (List.copyOf), defensive copies at boundaries. Prefer composition over inheritance; extract an interface when it improves testability.
  6. Spring Boot idioms (if applicable). Constructor injection (no field @Autowired); keep controllers thin and push logic to services; validate request bodies at the boundary (@Valid + Bean Validation). Log via SLF4J (LoggerFactory.getLogger) — never log secrets, tokens, or PII.
  7. Streams over loops where readability isn't sacrificed; keep methods small and single-purpose.
  8. Test with JUnit 5 + Mockito. Use @ExtendWith(MockitoExtension.class), @Mock/ @InjectMocks, AssertJ-style assertions, and cover happy path, edge cases, and error conditions. Use Testcontainers for integration tests touching real infrastructure.
  9. Verify + evidence. Run the build's test goal, record test_output via the record-evidence skill, and submit for review.

Read the full file on GitHub · 86 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 86 lines · 89 tokens per session scan A 557947f285d9

Subscribe to this mod's changes

java-conventions is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 7d ago), licensed Apache-2.0. It adds 89 tokens to every session and 1,242 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.