用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/gugug168/claudecode-tutorial --skill java-coding-standards命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | java-coding-standards |
| description | Spring Boot 服务的 Java 编码标准:命名、不可变性、Optional 使用、streams、异常、泛型和项目布局。 |
Spring Boot 服务中可读、可维护的 Java (17+) 代码标准。
// ✅ 类/Record:帕斯卡命名法 (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;
偏好 record 和 final 字段,只有 getter,没有 setter。
// ✅ 偏好 records 和 final 字段
public record MarketDto(Long id, String name, MarketStatus status) {}
public class Market {
private final Long id;
private final String name;
// 只有 getter,没有 setter
}
// ✅ find* 方法返回 Optional
Optional<Market> market = marketRepository.findBySlug(slug);
// ✅ 使用 map/flatMap 代替 get()
return market
.map(MarketResponse::from)
.orElseThrow(() -> new EntityNotFoundException("Market not found"));
// ✅ 使用 streams 进行转换,保持管道简短
List<String> names = markets.stream()
.map(Market::name)
.filter(Objects::nonNull)
.toList();
// ❌ 避免复杂的嵌套 streams;为了清晰更偏好循环
MarketNotFoundException)catch (Exception ex),除非重新抛出/集中记录throw new MarketNotFoundException(slug);
public <T extends Identifiable> Map<Long, T> indexById(Collection<T> items) { ... }
src/main/java/com/example/app/
config/
controller/
service/
repository/
domain/
dto/
util/
src/main/resources/
application.yml
src/test/java/... (镜像 main 结构)
private static final Logger log = LoggerFactory.getLogger(MarketService.class);
log.info("fetch_market slug={}", slug);
log.error("failed_fetch_market slug={}", slug, ex);
@Nullable;否则使用 @NonNull@NotNull, @NotBlank)记住:保持代码有意向性、类型化和可观察。优化可维护性而非微优化,除非被证明有必要。