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.
npx agentmods add skills/maxtrezzi/java-best-practices-skills/java-best-practices-modernnpx skills add maxtrezzi/java-best-practices-skills --skill java-best-practices-moderngit clone --depth 1 https://github.com/maxtrezzi/java-best-practices-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/maxtrezzi/java-best-practices-skills/java-best-practices-modern)<a href="https://agentmods.dev/skills/maxtrezzi/java-best-practices-skills/java-best-practices-modern"><img src="https://agentmods.dev/badge/skills/maxtrezzi/java-best-practices-skills/java-best-practices-modern.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00202 | $0.05647 |
| Opus 5 | $0.00101 | $0.02823 |
| Sonnet 5 | $0.00040 | $0.01129 |
| Haiku 4.5 | $0.00020 | $0.00565 |
Grade A, and why
java-best-practices-modern 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 4d ago.
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.
How it starts
The opening of the file, as written. The whole thing — 411 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Java Best Practices — Java 17 and later, version-aware
STEP 0 — RESOLVE THE TARGET VERSION, THEN LOAD ITS PROFILE. Resolve the target in this order:
- Look for the build file — actively, with your tools. Don't wait for it to be "visible": glob for
pom.xml,build.gradle(.kts),gradle.properties,.java-version,.sdkmanrc, then read the one you find for<maven.compiler.release>,JavaLanguageVersion,sourceCompatibility, or a--releaseflag. In a project directory this almost always resolves the question in two tool calls; asking or assuming when the answer is sitting in the repo is the failure mode.- What the user already said in this conversation (e.g. "we're on 21").
- Default to the floor (17), and say which you assumed. Nearly every gap between versions is downgrade-safe: 17-era code compiles and runs on every later version — it is only an older idiom. Writing low and naming the assumption beats guessing high and emitting code that will not compile.
Then load exactly one profile and follow it. Do not re-derive version facts from memory; the profile is the single source of truth for them.
Target Load 17–20 references/profiles/java-17.md21 references/profiles/java-21.md22–24 references/profiles/java-21.md— its "not available" table names what finalised when25 references/profiles/java-25.md26 and later non-LTS references/profiles/java-latest-nonlts.mdThe exception that needs a question, not a default. Final Java APIs stay backward compatible, so the downgrade-safe rule above holds for all of them. Preview APIs are the only ones that can break in both directions — the old spelling fails on the new version and vice versa. Today that is exactly two:
StructuredTaskScope(shape changed in 25, Joiners renamed in 26) andStableValue, which becameLazyConstantin 26. If the task needs either and you do not know the target, ask — there is no safe default.Identical on every supported version (17+) — no profile lookup needed:
- Records (16), sealed interfaces/classes (17), pattern matching for
instanceof(16),switchexpressions with arrow labels (14), text blocks (15),var(10),Stream.toList()(16).Everything else — pattern matching for
switch, record deconstruction, virtual threads, sequenced collections, gatherers,ScopedValue, structured concurrency — arrived in 21 or later. Check the profile before using it.Never generate on any supported version, even if a source claims otherwise:
withexpressions for derived records (obj with { x = 1; }) — not shipped on any version to date. Write an explicit "wither" method calling the canonical constructor, or a copy factory.- Null-restricted types (
String!, the!marker) — not shipped on any version to date. Enforce non-null withObjects.requireNonNullin the compact/canonical constructor and JSpecify@NonNull/@Nullablefor tooling.- String templates (
STR."...",StringTemplate,FormatProcessor) — preview on 21 only, then withdrawn: gone from 23 onward, and absent from 25 even with--enable-preview. A dead end that a 21-era source will still recommend. Useformatted/String.formatwithLocale.ROOT, or a text block.
You are a senior Java engineer. Your job in this skill is to make code that is correct, then clear, then fast — in that order — and to explain the reasoning when it is not obvious. Rules without reasons don't generalize; a junior memorizes rules, a senior knows why each exists and therefore when it bends. Carry that posture into every response.
Two modes. Infer which one applies:
- GENERATE — the user describes something to build. Write the code.
- REVIEW — the user shows existing code and asks about it. Audit it.
What ships with it
18 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/anti-patterns.md 10.0 KB
- references/collections-streams.md 7.5 KB
- references/concurrency.md 7.7 KB
- references/datetime.md 4.0 KB
- references/design-api.md 6.5 KB
- references/exceptions.md 7.2 KB
- references/generate-example.md 7.9 KB
- references/generics.md 3.3 KB
- references/io-resources.md 3.9 KB
- references/language-features.md 7.5 KB
- references/performance.md 6.5 KB
- references/profiles/java-17.md 4.0 KB
- references/profiles/java-21.md 2.5 KB
- references/profiles/java-25.md 2.7 KB
- references/profiles/java-latest-nonlts.md 3.7 KB
- references/review-example.md 4.7 KB
- references/strings-text.md 5.8 KB
- references/testing.md 4.8 KB
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.
- 4d ago First seen · 411 lines · 202 tokens per session scan A 49026533fd11
java-best-practices-modern is a skill published in the GitHub repository maxtrezzi/java-best-practices-skills (1 stars, last pushed 8d ago), licensed MIT. It adds 202 tokens to every session and 5,647 once invoked, about $0.0010 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.
Other skills, from other repositories
setup-agentic-scaffolding
Set up the prerequisites for the Quarkus + LangChain4j agentic stack in the coding agent you are running — detect and (with approval) install the toolchain, register the Quarkus Agents MCP and context7 MCP servers, and write the conventions file into your project. User-invoked only, via /setup-agentic-scaffolding; it…
does-it-work
Проверка, что продукт реально работает, и защита его качества автотестами. Аудит работающего (в т.ч. навайбкоженного) приложения: найти баги, оценить готовность к проду, выдать баг-репорт с severity. Генерация тестовых фреймворков: API-тесты на Python (pytest + httpx + Pydantic + Allure) и Java (JUnit 5 + REST…
language-java
Java idioms — records, sealed types, virtual threads, and JDK 21+ patterns. Auto-load when working with .java files, pom.xml, build.gradle, or when the user mentions Java, JVM, Spring, Maven, Gradle, sealed classes, or virtual threads.
standards-java
Java coding standards for enterprise applications. Includes naming conventions, modern Java features, design patterns, and recommended tooling.
java-development
Build, review, debug, and maintain production Java applications, libraries, services, and APIs. Use for Java, Spring Boot, Jakarta, Maven, Gradle, JUnit, concurrency, JVM performance, persistence, dependency injection, configuration, resilience, or Java security work.
java-best-practices
Java coding best practices. Use when writing or reviewing Java code (17+). Covers modern features, error handling, and patterns.