Token导航 LogoToken导航

Agent Skill · 开发规范

java-best-practices-code-review(Java 最佳实践代码审查)

用于辅助 Java 项目开发、面向对象设计、Spring 生态、Maven 或 Gradle 依赖和后端工程实践。它适合让 Agent 分析类结构、设计接口、整理服务分层、生成测试或检查常见代码坏味道。使用时需要结合项目已有架构、包结构和依赖版本,不应只按通用教程改代码;涉及数据库、事务、并发或框架配置时,应先确认运行环境和回归测试范围。

java-best-practices-code-review 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在开发规范类的 1,265 个 Skill 里排第 1,214。

总安装 192周安装 8GitHub Stars 1下载 64核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:java-best-practices-code-review(Java 最佳实践代码审查)
来源仓库:https://github.com/dawiddutoit/custom-claude
仓库路径:skills/java-best-practices-code-review
安装命令:
npx skills add https://github.com/dawiddutoit/custom-claude --skill java-best-practices-code-review
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dawiddutoit/custom-claude --skill java-best-practices-code-review

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

用于辅助 Java 项目开发、面向对象设计和 Spring 生态集成。适合分析类结构、设计接口、整理服务分层或生成测试代码。使用时需结合项目已有架构、包结构和依赖版本,避免仅按教程修改代码。涉及数据库、事务或并发配置时,应先确认运行环境和回归测试范围。

java-best-practices-code-review 属于开发规范类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/java-best-practices-code-review

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dawiddutoit/custom-claude --skill java-best-pr…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

java-best-practices-code-review 怎么安装?

在终端执行 npx skills add https://github.com/dawiddutoit/custom-claude --skill java-best-practices-co…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

java-best-practices-code-review 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

java-best-practices-code-review 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

java-best-practices-code-review 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

java-best-practices-code-review 用的人多吗?

公开数据是累计安装 192 次,近一周安装 8 次,下载 64 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

java-best-practices-code-review 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
java-best-practices-code-review

Java 最佳实践代码审查 · 本页

1921接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Works with.java files, Spring components, and Java projects of any size.

Java Code Review

Table of Contents

Purpose

Performs comprehensive code reviews of Java code against industry best practices, SOLID principles, and modern Java idioms. Provides actionable feedback to improve code quality, maintainability, and security.

When to Use

Use this skill when you need to:

  • Review Java files for code quality issues
  • Analyze SOLID principle compliance
  • Evaluate exception handling patterns
  • Assess thread safety in concurrent code
  • Audit resource management (try-with-resources usage)
  • Check naming conventions and coding standards
  • Review Stream API and Optional usage
  • Verify modern Java features adoption (Java 8+ idioms)
  • Conduct PR reviews for Java projects
  • Identify refactoring opportunities

Quick Start

Point to any Java file or directory and receive immediate feedback on code quality issues:

# Review a single file
Review src/main/java/com/example/UserService.java

# Review all Java files in a package
Review all Java files in src/main/java/com/example/service/

Instructions

Step 1: Identify Target Scope

Determine what needs to be reviewed:

  • Single Java class file
  • Package directory (all.java files)
  • Specific component type (controllers, services, repositories)
  • Entire src tree

Use Glob to find Java files if not explicitly specified:

**/*.java                    # All Java files
src/main/java/**/*Service.java  # All service classes

Step 2: Read and Analyze Code

For each Java file, perform multi-dimensional analysis:

SOLID Principles Assessment:

  • Single Responsibility: Does class have one clear purpose?
  • Open/Closed: Is class extensible without modification?
  • Liskov Substitution: Are inheritance hierarchies sound?
  • Interface Segregation: Are interfaces focused and minimal?
  • Dependency Inversion: Does code depend on abstractions?

Code Quality Checks:

  • Naming conventions (camelCase, PascalCase, UPPER_SNAKE_CASE)
  • Method length (flag methods over 50 lines)
  • Class cohesion (related methods grouped together)
  • Magic numbers and strings (should be constants)
  • Code duplication (DRY principle violations)

Exception Handling:

  • Proper exception types (checked vs unchecked)
  • No empty catch blocks
  • No catching generic Exception unless necessary
  • Meaningful error messages
  • Proper exception chaining (throw new CustomException(e))

Resource Management:

  • try-with-resources for AutoCloseable resources
  • Proper Stream/File/Connection closing
  • No resource leaks

Modern Java Patterns:

  • Stream API usage (prefer streams over loops where appropriate)
  • Optional instead of null returns
  • Records for data classes (Java 14+)
  • Switch expressions (Java 14+)
  • Text blocks for multi-line strings (Java 15+)

Thread Safety:

  • Proper synchronization if needed
  • Immutability where possible
  • Thread-safe collection usage
  • Avoid shared mutable state

Security Concerns:

  • No hardcoded credentials
  • Proper input validation
  • SQL injection prevention (use PreparedStatement)
  • Path traversal vulnerabilities
  • Sensitive data logging

Step 3: Generate Structured Review Report

Organize findings by severity:

CRITICAL - Must fix immediately:

  • Security vulnerabilities
  • Resource leaks
  • Thread safety violations in concurrent code

HIGH - Should fix soon:

  • SOLID principle violations
  • Poor error handling
  • Significant code smells

MEDIUM - Improve when possible:

  • Code duplication
  • Naming convention issues
  • Missing modern Java features

LOW - Nice to have:

  • Code style inconsistencies
  • Minor optimizations
  • Documentation improvements

Step 4: Provide Actionable Recommendations

For each issue identified:

  1. Specify exact location (file, line number)
  2. Explain the problem clearly
  3. Show code example of the issue
  4. Provide corrected code example
  5. Explain why the change improves code quality

Examples

Example 1: Review Single Service Class

Input:

public class UserService {
    private UserRepository userRepository = new UserRepository();

    public User getUser(String id) {
        User user = userRepository.findById(id);
        if (user == null) {
            return null;
        }
        return user;
    }
}

Review Output:

CRITICAL Issues:
- Line 2: Dependency Inversion violation - direct instantiation of UserRepository
  Fix: Inject UserRepository via constructor

HIGH Issues:
- Line 7: Returns null instead of Optional<User>
  Fix: Return Optional.ofNullable(user)

MEDIUM Issues:
- Class lacks @Service annotation (assuming Spring)
- No logging for diagnostic purposes

Recommended Refactoring:

@Service @RequiredArgsConstructor public class UserService { private final UserRepository userRepository; private static final Logger log = LoggerFactory.getLogger(UserService.class);

public Optional<User> getUser(String id) { log.debug("Fetching user with id: {}", id); return Optional.ofNullable(userRepository.findById(id)); } }

Example 2: Review Controller with Multiple Issues

Input:

public class UserController {
    @GetMapping("/users/{id}")
    public User getUser(@PathVariable String id) {
        try {
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/db", "root", "password");
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE id = " + id);
            if (rs.next()) {
                return new User(rs.getString("name"), rs.getString("email"));
            }
        } catch (Exception e) {
            // ignore
        }
        return null;
    }
}

Review Output:

CRITICAL Issues:
1. Line 7: SQL Injection vulnerability - concatenating user input into query
   Fix: Use PreparedStatement with parameters

2. Line 5: Hardcoded database credentials in code
   Fix: Externalize to application.properties and use Spring's DataSource

3. Lines 5-10: Resource leak - Connection, Statement, ResultSet not closed
   Fix: Use try-with-resources or Spring JdbcTemplate

4. Line 11-13: Empty catch block silently swallows exceptions
   Fix: Log exception and throw appropriate response exception

HIGH Issues:
5. Architecture violation: Controller directly accessing database
   Fix: Use Service layer and Repository pattern

6. Line 14: Returns null instead of proper HTTP 404
   Fix: Throw ResponseStatusException or return ResponseEntity

MEDIUM Issues:
7. Missing @RestController annotation
8. No input validation on id parameter
9. No API documentation (@Operation, @ApiResponse)

Recommended Architecture:

@RestController @RequiredArgsConstructor @Validated public class UserController { private final UserService userService;

@GetMapping("/users/{id}") @Operation(summary = "Get user by ID") public ResponseEntity<User> getUser( @PathVariable @NotBlank String id) { return userService.getUser(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } }

@Service @RequiredArgsConstructor public class UserService { private final UserRepository userRepository;

public Optional<User> getUser(String id) { return userRepository.findById(id); } }

@Repository public interface UserRepository extends JpaRepository<User, String> { }

Example 3: Review Stream API Usage

Input:

List<String> activeUserNames = new ArrayList<>();
for (User user : users) {
    if (user.isActive()) {
        activeUserNames.add(user.getName());
    }
}
Collections.sort(activeUserNames);

Review Output:

MEDIUM Issues:
- Lines 1-6: Imperative loop should use Stream API for clarity
- Line 7: Mutating list instead of using sorted stream

Recommended Refactoring:

List<String> activeUserNames = users.stream() .filter(User::isActive) .map(User::getName) .sorted() .toList();


Benefits:

- More declarative and readable
- Immutable result (.toList() returns unmodifiable list)
- Potential for parallel processing if needed
- Method reference usage (User::isActive)

Requirements

  • Java 8+ knowledge for Stream API, Optional, lambda expressions
  • Java 11+ awareness for var, String methods, Collection.toArray()
  • Java 14+ familiarity with records, switch expressions, text blocks
  • Java 17+ understanding of sealed classes, pattern matching
  • Understanding of SOLID principles and design patterns
  • Familiarity with Spring Framework conventions (if reviewing Spring code)
  • Knowledge of common security vulnerabilities (OWASP Top 10)

Review Checklist

Use this checklist to ensure comprehensive coverage:

Design & Architecture:

  • [ ] SOLID principles followed
  • [ ] Proper layer separation (Controller/Service/Repository)
  • [ ] Dependency injection used correctly
  • [ ] Interfaces used for abstraction
  • [ ] Design patterns applied appropriately

Code Quality:

  • [ ] Methods are focused and under 50 lines
  • [ ] No code duplication (DRY)
  • [ ] Clear, descriptive naming
  • [ ] No magic numbers or strings
  • [ ] Proper visibility modifiers (private, protected, public)

Error Handling:

  • [ ] Appropriate exception types used
  • [ ] No empty catch blocks
  • [ ] Meaningful error messages
  • [ ] Exception chaining preserved
  • [ ] Resources cleaned up in finally or try-with-resources

Modern Java:

  • [ ] Stream API used where appropriate
  • [ ] Optional used instead of null returns
  • [ ] Records used for DTOs (Java 14+)
  • [ ] Switch expressions used (Java 14+)
  • [ ] Text blocks for multi-line strings (Java 15+)

Thread Safety:

  • [ ] Shared mutable state identified
  • [ ] Proper synchronization if needed
  • [ ] Immutable objects preferred
  • [ ] Thread-safe collections used

Security:

  • [ ] No hardcoded credentials
  • [ ] Input validation present
  • [ ] SQL injection prevention (PreparedStatement)
  • [ ] No path traversal vulnerabilities
  • [ ] Sensitive data not logged

Performance:

  • [ ] No premature optimization
  • [ ] Efficient algorithms used
  • [ ] Proper use of collections
  • [ ] Stream operations optimized
  • [ ] Database N+1 queries avoided

Output Format

Always structure review output as:

# Java Code Review: [ClassName or Package]

## Summary
- Files reviewed: X
- Critical issues: X
- High priority issues: X
- Medium priority issues: X
- Low priority issues: X

## Critical Issues (Fix Immediately)
[List with file:line, description, fix]

## High Priority Issues (Fix Soon)
[List with file:line, description, fix]

## Medium Priority Issues (Improve When Possible)
[List with file:line, description, fix]

## Low Priority Issues (Nice to Have)
[List with file:line, description, fix]

## Positive Findings
[Call out well-written code and good practices]

## Overall Assessment
[Summary paragraph with key recommendations]

Error Handling

If review cannot be completed:

  1. File Not Found: Verify path and use Glob to search for Java files
  2. Cannot Parse Code: Note syntax errors preventing analysis
  3. Incomplete Context: Request additional files for proper review (e.g., parent classes, interfaces)
  4. Ambiguous Requirements: Ask for specific focus areas (security, performance, etc.)

Always fail-fast with clear error messages rather than providing incomplete reviews.

平台分布

Codex

34.1%
按下载量换算22

Claude

28.85%
按下载量换算18

Cursor

19.25%
按下载量换算12

Gemini CLI

9.16%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills