Agent skill
java-best-practices
Java 编码最佳实践与设计模式
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/java-best-practices-leavesfly-jimi
SKILL.md
Java 最佳实践技能包
编码规范
命名规范
- 类名:PascalCase(UserService)
- 方法/变量:camelCase(getUserById)
- 常量:UPPER_SNAKE_CASE(MAX_SIZE)
- 包名:小写(com.example.service)
常用设计模式
单例模式(枚举实现):
public enum Singleton {
INSTANCE;
public void doSomething() {}
}
工厂模式:
public class UserFactory {
public static User createUser(String type) {
return switch (type) {
case "admin" -> new AdminUser();
case "guest" -> new GuestUser();
default -> new RegularUser();
};
}
}
Builder 模式:
User user = User.builder()
.name("张三")
.age(25)
.build();
Stream API
List<String> names = users.stream()
.filter(u -> u.getAge() > 18)
.map(User::getName)
.collect(Collectors.toList());
异常处理
try {
// 业务逻辑
} catch (SpecificException e) {
log.error("Error: {}", e.getMessage(), e);
throw new BusinessException("操作失败");
} finally {
// 清理资源
}
并发编程
ExecutorService executor = Executors.newFixedThreadPool(10);
executor.submit(() -> {
// 异步任务
});
Optional 使用
Optional<User> user = userRepository.findById(id);
return user.orElseThrow(() -> new NotFoundException());
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?