java-code-style

java-code-style is a skill for Claude Code, Codex from HK-hub/AgentSkills. It costs 115 tokens per session (3,442 once invoked), scanned A, original, MIT.

A Java code-style guide and review workflow for teams working with Java and Spring Boot applications.

In plain words
What is it for?
It supports writing style standards, reviewing Java code, and suggesting small refactors for naming, exceptions, logging, concurrency, database access, and project structure.
Why use it?
It helps turn informal coding preferences into consistent, checkable rules and makes style problems easier to find and fix.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It supports writing style standards, reviewing Java code, and suggesting small refactors for naming, exceptions, logging, concurrency, database access, and project structure.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hk-hub/agentskills/java-code-style
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.

Any agent
npx skills add HK-hub/AgentSkills --skill java-code-style
Clone the repo
git clone --depth 1 https://github.com/HK-hub/AgentSkills

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for java-code-style

README.md
[![agentmods](https://agentmods.dev/badge/skills/hk-hub/agentskills/java-code-style/github.svg)](https://agentmods.dev/skills/hk-hub/agentskills/java-code-style)
Your own site
<a href="https://agentmods.dev/skills/hk-hub/agentskills/java-code-style"><img src="https://agentmods.dev/badge/skills/hk-hub/agentskills/java-code-style/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for java-code-style

Your own site · 80×15
<a href="https://agentmods.dev/skills/hk-hub/agentskills/java-code-style"><img src="https://agentmods.dev/badge/skills/hk-hub/agentskills/java-code-style.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 115 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,442 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00115 $0.03442
Opus 5 $0.00057 $0.01721
Sonnet 5 $0.00023 $0.00688
Haiku 4.5 $0.00012 $0.00344

Measured 9d ago against content hash 05aaafbf1e1e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

java-code-style 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 9d 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.

java-code-style/SKILL.md · 294 lines

How it starts

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

Java Code Style Skill

将个人经验、团队约定与业界规范沉淀为可执行的 Java 代码风格工作流。

Skill Goal

在 Java 后端场景中完成以下任务:

  1. 产出可落地的代码风格规范(不是口号式原则)。
  2. 对现有代码进行结构化风格审查(分级、可追踪、可修复)。
  3. 在不改变业务语义的前提下提供最小改动的重构建议。
  4. 统一团队在命名、异常、日志、边界分层、并发与数据库访问上的实践。

Baseline Reference

优先参考以下资料作为基础规范源:

  • references/阿里巴巴Java开发规范(嵩山版).md

在引用规则时,尽量给出“章节 + 页码段”定位,避免泛化描述。

已知目录主干(来自手册):

  • 编程规约(命名、常量、格式、OOP、日期时间、集合、并发、控制语句、注释、前后端、其他)
  • 异常日志(错误码、异常处理、日志规约)
  • 单元测试
  • 安全规约
  • MySQL 数据库(建表、索引、SQL、ORM)
  • 工程结构(应用分层、二方库依赖、服务器)
  • 设计规约

Operating Mode

默认按以下模式工作:

  1. 先识别任务类型:规范制定 / 代码审查 / 代码改写。
  2. 再识别技术上下文:JDK 版本、Spring Boot 版本、ORM、日志框架、构建工具。
  3. 再应用规则:强制项优先于推荐项。
  4. 最后输出可执行结果:问题清单、改写建议、统一模板。

Required Inputs

在信息不足时,先补齐最小上下文:

  • Java 与 Spring Boot 版本(例如 JDK 17 + Spring Boot 3.x)。
  • 架构风格(分层/DDD/Clean Architecture)。
  • 团队禁用项(如字段注入、通配符导入、System.out.println)。
  • 当前目标(写新代码 / 审查旧代码 / 统一历史代码)。

若用户未提供,先按“通用企业级后端默认值”执行,并在输出中明确假设。

Rule Hierarchy

将规则分成三层:

  • L1 强制(Blocking):违反后必须修改。
  • L2 推荐(Important):建议修改,影响可维护性与协作效率。
  • L3 参考(Nice-to-have):优化项,可在时间允许时处理。

将手册中的【强制 / 推荐 / 参考】映射到上述等级,并保持一致。

Style Dimensions

审查或制定规范时,至少覆盖以下维度:

1) 命名与语义

  • 统一类名、方法名、变量名风格。
  • 禁止歧义缩写与混乱命名。
  • 保证命名可表达业务含义与边界语义。

2) 常量与魔法值

  • 抽离魔法值。
  • 常量命名语义完整。
  • 明确常量作用域(类内/模块内/跨模块)。

3) 代码结构与可读性

  • 方法复杂度不设硬性上限,但必须保证可读性与可维护性。
  • 强制使用卫语句(early return)减少分支金字塔。
  • 工具类保持单一职责,优先复用成熟生态工具(如 Apache Commons Lang3、Commons Collections4、Guava),避免重复造轮子。
  • 简单循环场景优先使用 for / while,禁止使用 stream().forEach(...)
  • 禁止在 Stream 管道中编写复杂业务逻辑或超长 lambda/匿名内部类;复杂逻辑先抽离为具名方法。
  • Service 按 DDD 语义拆分,避免“万能服务类”。

4) OOP 与分层边界

  • 严格区分 DTO / VO / DO / Entity / Command / Query。
  • 实体类优先使用 Lombok 减少样板 getter/setter 代码。
  • Service/DAO 默认采用接口 + Impl 模式。
  • 保留 Manager 层,用于第三方适配、通用能力下沉与多 DAO 组合复用。
  • 禁止跨层泄漏(Controller 直接拼 SQL、Repository 承担业务编排等)。
  • 保持接口契约清晰,避免“万能服务类”。

5) 集合与并发

  • 明确集合类型选择依据。
  • 并发问题优先通过业务流程拆解降低冲突,再考虑锁策略。
  • 优先减少分布式锁使用,避免将锁作为默认方案。
  • JDK >= 21 时,优先评估虚拟线程方案。
  • 明确并发访问场景与线程安全策略,避免无边界并发、隐式共享可变状态。

6) 控制流与防御性编程

  • 强制卫语句,减少深层嵌套。
  • 判空统一优先使用 Objects.isNull / Objects.nonNull
  • 相等判断统一优先使用 Objects.equals
  • 字符串判空/非空统一优先使用 StringUtils.isEmpty / StringUtils.isNotEmpty
  • 集合判空/非空统一优先使用 CollectionUtils.isEmpty / CollectionUtils.isNotEmpty
  • if 判断中禁止直接使用逻辑非 !,布尔判断优先使用 BooleanUtils.isFalse / BooleanUtils.isTrue
  • Optionalnull 不做过度限制,按上下文选择。
  • 对集合型返回(如 DB/RPC 查询 List),无数据或参数不合法时默认返回空列表。
  • 在系统边界进行输入校验。

Read the full file on GitHub · 294 lines

Files

What ships with it

4 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.

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. 9d ago First seen · 294 lines · 115 tokens per session scan A 05aaafbf1e1e

Subscribe to this mod's changes

java-code-style is a skill published in the GitHub repository HK-hub/AgentSkills (6 stars, last pushed 25d ago), licensed MIT. It adds 115 tokens to every session and 3,442 once invoked, about $0.0006 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-09-03.

Related

Other skills, from other repositories

code-review-csharp

Perform structured code reviews of C# source code covering naming conventions, performance, security, readability, and .NET best practices. Trigger phrases include "review this C# code", "check my C# for best practices", "analyze this C# class", "find issues in my C# code".

pnp/copilot-prompts · 66 tokens

solid-principles

SOLID principles checklist with Java examples. Use when a class has too many responsibilities, an abstraction leaks, or a dependency points the wrong way, and when the user asks about Single Responsibility, Open/Closed, Liskov, Interface Segregation or Dependency Inversion. For naming, duplication and method length…

decebals/claude-code-java · 73 tokens

concurrency-review

Review Java concurrency code for thread safety, race conditions, deadlocks, and modern patterns (Virtual Threads, CompletableFuture, @Async). Use when user asks "check thread safety", "concurrency review", "async code review", or when reviewing multi-threaded code.

decebals/claude-code-java · 58 tokens

java-code-review

Systematic code review for Java with null safety, exception handling, concurrency, and performance checks. Use when user says "review code", "check this PR", "code review", or before merging changes.

decebals/claude-code-java · 45 tokens

121-java-object-oriented-design

Use when reviewing, improving, or refactoring Java object-oriented design, including applying SOLID, DRY, or YAGNI; improving classes and interfaces; correcting encapsulation, inheritance, or polymorphism; resolving God Class, Feature Envy, or Data Clumps; and improving object creation, methods, or exception…

jabrena/plinth · 107 tokens

053-design-simple-rules

Use when Java design, refactoring, or implementation tradeoffs should be evaluated with Kent Beck's simple design rules, including passes the tests, reveals intention, has no duplication, and has the fewest elements. This should trigger for requests such as Apply simple design rules; Review this design with Beck's…

jabrena/plinth · 86 tokens