Java Coding Standards

Spring Boot 服务的 Java 编码规范:命名、不可变性、Optional 使用、流(streams)、异常、泛型以及项目布局。

2,037 stars 332 forksSoftware Development Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add xu-xiang/everything-claude-code-zh

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add xu-xiang/everything-claude-code-zh --skill java-coding-standards
Manual install
git 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-standards

Personal 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();

// ❌ 避免复杂的嵌套流;为了清晰起见,优先使用循环
```
Read the full skill on GitHub

Details

Skill name
java-coding-standards
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

Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.