Token导航 LogoToken导航TokenDH.com
运维和基础设施只读github未标认证来源可访问clear审计异常

java-devJava DEV 搜索

Agent Skill

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

总安装

955

周安装

39

GitHub Stars

5

下载量

309
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:java-dev(Java DEV 搜索)
来源仓库:https://github.com/story-has-you/skills
仓库路径:skills/java-dev
安装命令:
npx skills add https://github.com/story-has-you/skills --skill java-dev
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/story-has-you/skills --skill java-dev

简介

这项技能确保所有 Java 代码都遵守阿里巴巴的行业标准编码指南。始终优先考虑:

  • 可读性胜过聪明性
  • 安全重于便利
  • 可维护性优于快速修复
  • 标准高于个人喜好
  • 如有疑问,请查阅详细的参考文档以获取具体指导。
  • 每周安装量
  • 39
  • 存储库
  • 故事里有你/技能
  • GitHub 之星
  • 5
  • 第一次看到
  • 2026 年 1 月 22 日
  • 安全审计
  • Gen 代理信任中心失败
  • 套接字通行证
  • 斯尼克通行证

SKILL.md

Java Development - Alibaba Coding Guidelines

Overview

This skill provides comprehensive Java development guidance based on the Alibaba Java Coding Guidelines (Songshan Edition). It ensures all Java code follows industry best practices covering naming conventions, coding standards, concurrency, exception handling, database design, security, testing, and architectural design.

Core Principles

When writing Java code, always follow these fundamental principles:

  1. Code Readability: Write code that is easy to understand and maintain
  2. Consistency: Follow consistent naming and formatting conventions
  3. Safety First: Prevent common pitfalls like NPE, SQL injection, and concurrency issues
  4. Performance Awareness: Consider performance implications of design decisions
  5. Test Coverage: Ensure adequate unit test coverage for critical code

Quick Reference

Naming Conventions

  • Classes: UpperCamelCase (e.g., UserService, OrderController)
  • Methods/Variables: lowerCamelCase (e.g., getUserById, userName)
  • Constants: UPPER_SNAKE_CASE (e.g., MAX_COUNT, DEFAULT_SIZE)
  • Packages: lowercase, single word preferred (e.g., com.company.module)

Common Patterns

  • Abstract classes: Abstract* or Base* prefix
  • Exception classes: *Exception suffix
  • Test classes: *Test suffix
  • Service implementations: *Impl suffix
  • Boolean variables: No is prefix in POJO classes
  • DAO methods: get* (single), list* (multiple), count*, save*, remove*, update*

Critical Rules

  • ❌ Never use magic numbers directly in code
  • ❌ Never catch exceptions without handling them
  • ❌ Never use == to compare wrapper types (use equals())
  • ❌ Never create threads directly (use thread pools)
  • ❌ Never use SELECT * in SQL queries
  • ✅ Always use parameterized queries to prevent SQL injection
  • ✅ Always specify initial capacity for collections when size is known
  • ✅ Always close resources in finally blocks or use try-with-resources
  • ✅ Always validate external inputs

Workflow

1. Before Writing Code

Check the detailed guidelines:

2. Writing Code

Apply the following checks as you write:

Naming

  • Class names use UpperCamelCase
  • Method/variable names use lowerCamelCase
  • Constants use UPPER_SNAKE_CASE
  • Meaningful English names (no pinyin)

Code Structure

  • Methods under 80 lines
  • Single responsibility per class/method
  • Proper access modifiers (private by default)
  • Use @Override for overridden methods

Common Pitfalls to Avoid

// ❌ Wrong: Magic numbers
if (status == 1) { ... }

// ✅ Correct: Named constants
private static final int STATUS_ACTIVE = 1;
if (status == STATUS_ACTIVE) { ... }

// ❌ Wrong: Comparing wrapper types with ==
Integer a = 128;
Integer b = 128;
if (a == b) { ... }  // May fail!

// ✅ Correct: Use equals()
if (a.equals(b)) { ... }

// ❌ Wrong: Empty catch block
try {
    doSomething();
} catch (Exception e) {
    // Silent failure
}

// ✅ Correct: Handle or rethrow
try {
    doSomething();
} catch (Exception e) {
    logger.error("Failed to do something", e);
    throw new BusinessException("Operation failed", e);
}

// ❌ Wrong: Creating threads directly
new Thread(() -> doWork()).start();

// ✅ Correct: Use thread pool
ExecutorService executor = new ThreadPoolExecutor(
    corePoolSize, maxPoolSize, keepAliveTime,
    TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
    new ThreadFactoryBuilder().setNameFormat("worker-%d").build()
);
executor.submit(() -> doWork());

3. Database Operations

Table Design

  • Table names: lowercase with underscores (e.g., user_order)
  • Required fields: id, create_time, update_time
  • Boolean fields: is_* prefix (e.g., is_deleted)
  • Use BIGINT UNSIGNED for IDs
  • Use DECIMAL for monetary values (never FLOAT or DOUBLE)

SQL Best Practices

// ✅ Correct: Parameterized query
String sql = "SELECT id, user_name, email FROM user WHERE id = ?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setLong(1, userId);

// ✅ Correct: MyBatis parameter binding
@Select("SELECT * FROM user WHERE user_name = #{userName}")
User selectByUserName(@Param("userName") String userName);

// ❌ Wrong: String concatenation (SQL injection risk!)
String sql = "SELECT * FROM user WHERE user_name = '" + userName + "'";

4. Exception Handling

Exception Hierarchy

  • Use specific exception types
  • Checked exceptions for recoverable errors
  • Unchecked exceptions for programming errors
  • Always include context in exception messages
// ✅ Correct exception handling
public User getUserById(Long userId) {
    if (userId == null) {
        throw new IllegalArgumentException("userId cannot be null");
    }

    User user = userDao.selectById(userId);
    if (user == null) {
        throw new NotFoundException("User not found: " + userId);
    }

    return user;
}

// ✅ Correct logging with exception
try {
    processOrder(order);
} catch (Exception e) {
    logger.error("Failed to process order, orderId: {}", order.getId(), e);
    throw new BusinessException("订单处理失败", e);
}

5. Concurrency

Thread Safety Rules

  • Use ThreadPoolExecutor instead of Executors
  • Name your threads for debugging
  • Use volatile for visibility, AtomicXxx for atomic operations
  • Avoid SimpleDateFormat in multi-threaded code (use DateTimeFormatter)
  • Clean up ThreadLocal variables
// ✅ Correct: Thread pool with proper configuration
ThreadPoolExecutor executor = new ThreadPoolExecutor(
    10,  // corePoolSize
    20,  // maximumPoolSize
    60L, // keepAliveTime
    TimeUnit.SECONDS,
    new LinkedBlockingQueue<>(100),
    new ThreadFactoryBuilder().setNameFormat("order-processor-%d").build(),
    new ThreadPoolExecutor.CallerRunsPolicy()
);

// ✅ Correct: ThreadLocal cleanup
private static final ThreadLocal<User> USER_CONTEXT = new ThreadLocal<>();

public void processRequest() {
    try {
        USER_CONTEXT.set(getCurrentUser());
        // Process request
    } finally {
        USER_CONTEXT.remove();  // Critical: prevent memory leak
    }
}

6. Security

Input Validation

  • Validate all external inputs
  • Use parameterized queries (never string concatenation)
  • Sanitize HTML output to prevent XSS
  • Implement CSRF protection
  • Mask sensitive data in logs
// ✅ Correct: Input validation
public void createUser(UserCreateRequest request) {
    if (StringUtils.isBlank(request.getUserName())) {
        throw new ValidationException("用户名不能为空");
    }
    if (!ValidationUtils.isValidMobile(request.getMobile())) {
        throw new ValidationException("手机号格式不正确");
    }
    // Process...
}

// ✅ Correct: Sensitive data masking
logger.info("User login, mobile: {}", maskMobile(user.getMobile()));

7. Unit Testing

Testing Standards

  • Test class naming: *Test
  • Test method naming: test*
  • Target coverage: 70% statement coverage minimum
  • Use JUnit 5 + Mockito
  • Follow BCDE principle (Border, Correct, Design, Error)
@ExtendWith(MockitoExtension.class)
public class UserServiceTest {

    @Mock
    private UserDao userDao;

    @InjectMocks
    private UserService userService;

    @Test
    @DisplayName("根据ID获取用户 - 正常情况")
    public void testGetUserById_Success() {
        // Given
        Long userId = 1L;
        User mockUser = new User();
        mockUser.setId(userId);
        mockUser.setUserName("test");
        when(userDao.selectById(userId)).thenReturn(mockUser);

        // When
        User result = userService.getUserById(userId);

        // Then
        assertNotNull(result);
        assertEquals(userId, result.getId());
        verify(userDao, times(1)).selectById(userId);
    }

    @Test
    @DisplayName("根据ID获取用户 - 参数为null")
    public void testGetUserById_NullParameter() {
        assertThrows(IllegalArgumentException.class, () -> {
            userService.getUserById(null);
        });
    }
}

Code Review Checklist

When reviewing Java code, verify:

Naming & Style

  • Class names use UpperCamelCase
  • Method/variable names use lowerCamelCase
  • Constants use UPPER_SNAKE_CASE
  • No magic numbers in code
  • Meaningful English names (no pinyin)

Code Quality

  • Methods under 80 lines
  • Single responsibility principle followed
  • Proper access modifiers used
  • No duplicate code
  • Proper exception handling

Safety

  • No NPE risks (null checks where needed)
  • Wrapper types compared with equals(), not ==
  • Resources properly closed (try-with-resources or finally)
  • Thread-safe if used in concurrent context
  • Input validation for external data

Database

  • Parameterized queries (no SQL injection risk)
  • Specific columns selected (no SELECT *)
  • Proper indexes defined
  • Transaction boundaries correct

Performance

  • Collection initial capacity specified when size known
  • String concatenation uses StringBuilder in loops
  • Appropriate data structures chosen
  • No unnecessary object creation in loops

Testing

  • Unit tests exist for new code
  • Edge cases covered
  • Exception cases tested
  • Mock dependencies properly

Reference Documentation

For detailed guidelines on specific topics, consult these reference documents:

naming-conventions.md

Complete naming rules for classes, methods, variables, packages, and domain models.

coding-standards.md

Detailed coding standards including constants, formatting, OOP rules, date/time handling, collections, and control statements.

concurrency.md

Comprehensive concurrency guidelines covering thread pools, locks, volatile, concurrent collections, and common patterns.

exception-logging.md

Exception handling best practices and logging standards using SLF4J.

database.md

MySQL database design rules, indexing strategies, SQL optimization, and ORM mapping conventions.

security.md

Security guidelines covering input validation, SQL injection prevention, XSS protection, CSRF defense, encryption, and sensitive data handling.

testing.md

Unit testing standards, frameworks (JUnit 5, Mockito), coverage requirements, and testing patterns.

design.md

Design principles, layered architecture, domain models, design patterns, and API design conventions.

Common Scenarios

Scenario 1: Creating a New Service Class

  1. Read naming-conventions.md for service naming rules
  2. Read coding-standards.md for class structure
  3. Read exception-logging.md for error handling
  4. Implement following the patterns shown above
  5. Add unit tests following testing.md

Scenario 2: Database Table Design

  1. Read database.md for table design rules
  2. Ensure required fields: id, create_time, update_time
  3. Use proper data types (DECIMAL for money, BIGINT for IDs)
  4. Add appropriate indexes
  5. Create corresponding DO class following naming conventions

Scenario 3: Implementing Concurrent Processing

  1. Read concurrency.md for thread pool configuration
  2. Use ThreadPoolExecutor with proper parameters
  3. Name threads for debugging
  4. Handle exceptions in worker threads
  5. Clean up ThreadLocal variables

Scenario 4: Security Review

  1. Read security.md for security checklist
  2. Verify input validation exists
  3. Check for SQL injection vulnerabilities
  4. Ensure sensitive data is masked in logs
  5. Verify authentication and authorization

Integration with Development Workflow

This skill integrates seamlessly into your development process:

  1. During Development: Reference quick rules above and detailed guidelines as needed
  2. Code Review: Use the checklist to ensure compliance
  3. Refactoring: Apply guidelines to improve existing code
  4. Onboarding: Use as training material for new team members

Summary

This skill ensures all Java code adheres to Alibaba's industry-standard coding guidelines. Always prioritize:

  • Readability over cleverness
  • Safety over convenience
  • Maintainability over quick fixes
  • Standards over personal preference

When in doubt, consult the detailed reference documents for specific guidance.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.64%
按下载量换算95

Codex

25.08%
按下载量换算77

OpenCode

18.66%
按下载量换算58

Gemini CLI

13.41%
按下载量换算41

trae

7.14%
按下载量换算22

Antigravity

3.54%
按下载量换算11

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills