
java-conventions
统一 Java 项目编码规范与注释规范(SLF4J+Lombok 日志、Bean Lombok 注解选择、判空 Objects/Optional、工具类优先级 Spring→Apache Commons→Hutool→Guava、复杂逻辑用设计模式/简单逻辑不拆分、Controller/Service/ServiceImpl/Mapper 注释一致性)。当需要“按 Java 规范重构/Review/补全注释/统一日志/统一工具类使用/补全 JavaDoc”时使用。
- Installs
- 108
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/full-stack-skills/java-skills --skill java-conventions- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads java-conventions automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Java Conventions
用于在 Java 项目中统一编码习惯与注释要求,帮助你在不引入过度设计的前提下保证一致性与可维护性。
使用流程
- 先判断改动范围:仅改动当前涉及的类/方法,不做无关格式化。
- 先统一基础规范:日志、判空、工具类选择、Bean 注解策略。
- 再做注释检查:对象注释、方法注释、逻辑块注释(非简单 CRUD)。
- 最后验证:编译 + 测试通过后再提交。
编码规范
日志规范(必选)
- 统一使用 SLF4J,并结合 Lombok 注解(例如
@Slf4j)。 - 禁止
System.out.println、printStackTrace()。 - 日志内容避免敏感信息与大对象全量输出。
示例:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class UserService {
public void handle(String userId) {
log.info("handle userId={}", userId);
}
}
Bean/Lombok 注解(按场景选择)
- 领域/DTO/VO/BO 等:按需要选
@Getter/@Setter/@Builder/@Data。 - 需要可控 equals/hashCode/toString 时:优先显式选择 Lombok 注解组合,避免一把梭。
- 当对象被序列化/日志输出频繁时:注意
toString的敏感字段与大字段。
判空与防御式编程
- 判空优先使用 JDK 工具:
Objects.requireNonNull、Objects.nonNull、Optional。 - 不要用“全局 try/catch 吞异常”的方式掩盖空指针问题;应在边界处校验输入。
示例:
import java.util.Objects;
public void updateName(String name) {
Objects.requireNonNull(name, "name must not be null");
}
工具类优先级(字符串 / 集合等)
- 优先级:Spring → Apache Commons → Hutool → Guava。
- 在已有依赖满足的前提下,避免为了一个小工具方法引入新依赖。
- 当同类工具同时存在时,统一团队选择,避免到处混用。
设计与拆分
- 复杂逻辑:优先通过设计模式(策略、模板方法、责任链等)提升可扩展性与可测试性。
- 简单逻辑:避免过度设计与过度拆分,保持可读性优先。
- 领域建模:业务规则尽量收敛到领域对象/领域服务,避免贫血模型堆在 ServiceImpl。
注释规范
规则(必选)
- 创建或更新任何对象/方法时,进行注释检查并补全/完善对象注释与方法注释。
- 若方法逻辑不是最简单的 CRUD,需要按逻辑块补充注释说明关键意图与边界条件。
- Controller、Service、ServiceImpl、Mapper 均需要注释,保持注释与代码一致(不写过期注释)。
建议模板
- 类:说明职责边界、输入输出、关键约束。
- 方法:说明做什么、关键参数含义、异常/返回约定。
更完整的注释模板与检查清单见 references/api_reference.md。
输出要求(用于 Review/改造时的交付)
- 列出:已调整的规范点(日志/判空/工具类/注释)。
- 附带:受影响文件清单与验证方式(编译/测试)。
常见陷阱 (Gotchas)
- 版本兼容性:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异
- 配置文件格式:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查
- 环境变量:确保所有必要的环境变量已正确设置,敏感信息不要硬编码
- 依赖冲突:多版本共存时注意依赖冲突,使用 lock 文件锁定版本
- 性能陷阱:大数据量场景下注意性能优化,避免 N+1 查询等常见问题
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
FAQ
What does the java-conventions skill do?
统一 Java 项目编码规范与注释规范(SLF4J+Lombok 日志、Bean Lombok 注解选择、判空 Objects/Optional、工具类优先级 Spring→Apache Commons→Hutool→Guava、复杂逻辑用设计模式/简单逻辑不拆分、Controller/Service/ServiceImpl/Mapper 注释一致性)。当需要“按 Java 规范重构/Review/补全注释/统一日志/统一工具类使用/补全 JavaDoc”时使用。
How do I install java-conventions?
Run npx skills add https://github.com/full-stack-skills/java-skills --skill java-conventions in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/java-conventions/ (personal) or .claude/skills/java-conventions/ (project).
Which AI agents can use java-conventions?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is java-conventions safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains java-conventions?
It is published by full-stack-skills in full-stack-skills/java-skills. It has 108 recorded installs.
More from full-stack-skills/java-skills
mybatis-plus-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
java-code-comments
full-stack-skills/java-skills
Provides comprehensive guidance for adding Java code comments following industry standards and best practices. This skill helps add class-level comments, method-level comments, and field-level comments to Java code. Use when the user wants to add comments to Java code, needs to document Java classes/methods/fields, wants to improve code documentation, or needs to generate JavaDoc comments. This skill covers Controller, Service, ServiceImpl, Mapper, Model, Entity, BO (Business Object), DTO, VO, and other common Java component types. The skill follows a systematic workflow: scan codebase, identify components, create todo list, and add comments in order (class comments → method comments → field comments).
mybatis-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
mapstruct-patterns
full-stack-skills/java-skills
MapStruct 最佳实践模式。从官方 Reference Guide 提炼,覆盖 Mapper 三种定义方式(接口/抽象类/default方法)、Spring 注入策略(CONSTRUCTOR推荐/SETTER解决循环依赖)、嵌套映射模式(显式子方法 dot notation 一次性配置)、@Qualifier @Named 的安全选择、Lombok 集成规则、@MappingComposition 谨慎使用。 纠正 LLM 最常见的错误:用反射 BeanUtils 而非编译期 MapStruct、嵌套映射全写在一个方法、不知 SETTER 解决循环依赖。
java-development-manual
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
redis-redisson-patterns
full-stack-skills/java-skills
Open the skill to read its SKILL.md instructions.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.