Java Coding Standards
Spring Boot 服务的 Java 编码规范:命名、不可变性、Optional 使用、流(streams)、异常、泛型以及项目布局。
Install
/plugin marketplace add xu-xiang/everything-claude-code-zhThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add xu-xiang/everything-claude-code-zh --skill java-coding-standardsgit clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh.git /tmp/everything-claude-code-zh
mkdir -p ~/.claude/skills
cp -r /tmp/everything-claude-code-zh/skills/java-coding-standards ~/.claude/skills/java-coding-standardsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Java 编码规范 (Java Coding Standards)
适用于 Spring Boot 服务中可读、可维护的 Java (17+) 代码规范。
## 何时激活 (When to Activate)
- 在 Spring Boot 项目中编写或评审 Java 代码时
- 强制执行命名、不可变性(immutability)或异常处理约定时
- 使用 records、密封类(sealed classes)或模式匹配(pattern matching)(Java 17+)时
- 评审 Optional、流(streams)或泛型(generics)的使用时
- 规划包结构和项目布局时
## 核心原则 (Core Principles)
- 清晰度优先于技巧性
- 默认不可变;尽量减少共享的可变状态
- 快速失败(Fail fast)并提供有意义的异常信息
- 保持命名和包结构的一致性
## 命名 (Naming)
```java
// ✅ 类/Records:大驼峰(PascalCase)
public class MarketService {}
public record Money(BigDecimal amount, Currency currency) {}
// ✅ 方法/字段:小驼峰(camelCase)
private final MarketRepository marketRepository;
public Market findBySlug(String slug) {}
// ✅ 常量:全大写蛇形(UPPER_SNAKE_CASE)
private static final int MAX_PAGE_SIZE = 100;
```
## 不可变性 (Immutability)
```java
// ✅ 优先使用 records 和 final 字段
public record MarketDto(Long id, String name, MarketStatus status) {}
public class Market {
private final Long id;
private final String name;
// 仅提供 getter,不提供 setter
}
```
## Optional 使用 (Optional Usage)
```java
// ✅ find* 方法应返回 Optional
Optional<Market> market = marketRepository.findBySlug(slug);
// ✅ 使用 Map/flatMap 替代 get()
return market
.map(MarketResponse::from)
.orElseThrow(() -> new EntityNotFoundException("Market not found"));
```
## 流最佳实践 (Streams Best Practices)
```java
// ✅ 使用流进行转换,保持流水线简短
List<String> names = markets.stream()
.map(Market::name)
.filter(Objects::nonNull)
.toList();
// ❌ 避免复杂的嵌套流;为了清晰起见,优先使用循环
```Details
- Skill name
java-coding-standards- Repository
- xu-xiang/everything-claude-code-zh
- Path
skills/java-coding-standards/SKILL.md- License
- MIT
- Repo updated
- 5 March 2026
FAQ
What does the Java Coding Standards skill do?
Spring Boot 服务的 Java 编码规范:命名、不可变性、Optional 使用、流(streams)、异常、泛型以及项目布局。
How do I install the Java Coding Standards skill?
Claude Code plugin: /plugin marketplace add xu-xiang/everything-claude-code-zh. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Java Coding Standards popular?
It lives in xu-xiang/everything-claude-code-zh, which has 2,037 GitHub stars and 332 forks.
Related skills
Backend Patterns
2kxu-xiang/everything-claude-code-zh
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
Coding Standards
2kxu-xiang/everything-claude-code-zh
Universal coding standards, best practices, and patterns for TypeScript, JavaScript, React, and Node.js development.
Frontend Patterns
2kxu-xiang/everything-claude-code-zh
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
Plankton Code Quality
2kxu-xiang/everything-claude-code-zh
使用 Plankton 实现编写时代码质量强制执行 —— 通过钩子在每次文件编辑时进行自动格式化、代码检查,并由 Claude 驱动自动修复。
Java Coding Standards
2kxu-xiang/everything-claude-code-zh
Spring Boot服务的Java编码标准:命名、不可变性、Optional用法、流、异常、泛型和项目布局。
Python Patterns
2kxu-xiang/everything-claude-code-zh
Pythonic 惯用法、PEP 8 标准、类型提示,以及构建稳健、高效且可维护 Python 应用的最佳实践。
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.