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 skills add HK-hub/AgentSkills --skill java-code-stylegit clone --depth 1 https://github.com/HK-hub/AgentSkillsWrote 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/hk-hub/agentskills/java-code-style)<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.
<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>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.1 | $0.00115 | $0.03442 |
| Opus 5.5 | $0.00046 | $0.01377 |
| Sonnet 5.5 | $0.00023 | $0.00688 |
| Haiku 4.5 | $0.00012 | $0.00344 |
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 3mo 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 — 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 后端场景中完成以下任务:
- 产出可落地的代码风格规范(不是口号式原则)。
- 对现有代码进行结构化风格审查(分级、可追踪、可修复)。
- 在不改变业务语义的前提下提供最小改动的重构建议。
- 统一团队在命名、异常、日志、边界分层、并发与数据库访问上的实践。
Baseline Reference
优先参考以下资料作为基础规范源:
references/阿里巴巴Java开发规范(嵩山版).md
在引用规则时,尽量给出“章节 + 页码段”定位,避免泛化描述。
已知目录主干(来自手册):
- 编程规约(命名、常量、格式、OOP、日期时间、集合、并发、控制语句、注释、前后端、其他)
- 异常日志(错误码、异常处理、日志规约)
- 单元测试
- 安全规约
- MySQL 数据库(建表、索引、SQL、ORM)
- 工程结构(应用分层、二方库依赖、服务器)
- 设计规约
Operating Mode
默认按以下模式工作:
- 先识别任务类型:规范制定 / 代码审查 / 代码改写。
- 再识别技术上下文:JDK 版本、Spring Boot 版本、ORM、日志框架、构建工具。
- 再应用规则:强制项优先于推荐项。
- 最后输出可执行结果:问题清单、改写建议、统一模板。
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。Optional与null不做过度限制,按上下文选择。- 对集合型返回(如 DB/RPC 查询 List),无数据或参数不合法时默认返回空列表。
- 在系统边界进行输入校验。
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.
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.
- 3mo ago First seen · 294 lines · 115 tokens per session scan A 05aaafbf1e1e
java-code-style is a skill published in the GitHub repository HK-hub/AgentSkills (7 stars, last pushed 3mo ago), licensed MIT. It adds 115 tokens to every session and 3,442 once invoked, about $0.0005 per session on Opus 5.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.
java-code-style compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| java-code-styleHK-hub/AgentSkills | Skill | 7 | 3mo ago | MIT | A | 115 | Claude Code, Codex |
| spec-implementmartinffx/atelier | Skill | 53 | today | MIT | A | 63 | Claude Code |
| python-engineering-guidelinesanywhere-labs/Agents-Anywhere | Skill | 3.9k | yesterday | Apache-2.0 | A | 75 | Codex |
| code-review-csharppnp/copilot-prompts | Skill | 914 | 3d ago | MIT | A | 66 | Claude Code, Codex |
| solid-principlesdecebals/claude-code-java | Skill | 781 | 1mo ago | MIT | A | 73 | Claude Code, Codex |
| concurrency-reviewdecebals/claude-code-java | Skill | 781 | 1mo ago | MIT | A | 58 | Claude Code, Codex |
| java-code-reviewdecebals/claude-code-java | Skill | 781 | 1mo ago | MIT | A | 45 | Claude Code, Codex |