name: java-code-comments description: | Provides comprehensive guidance for adding Java code comments following industry standards and best practices. This skill helps add class-level comments, method-level comments, and field-level comments to Java code. Use when the user wants to add comments to Java code, needs to document Java classes/methods/fields, wants to improve code documentation, or needs to generate JavaDoc comments. This skill covers Controller, Service, ServiceImpl, Mapper, Model, Entity, BO (Business Object), DTO, VO, and other common Java component types. The skill follows a systematic workflow: scan codebase, identify components, create todo list, and add comments in order (class comments → method comments → field comments).
ALWAYS use this skill when the user mentions:
Trigger phrases include:
Component types this skill handles:
CRITICAL: This skill should be triggered when the user wants to add comments to Java code, regardless of the component type or complexity.
This skill follows a systematic 4-step workflow:
CRITICAL: Before adding any comments, you MUST:
Scan all Java files in the project:
.java files in the current directory and subdirectoriesRead related documentation:
Understand the context:
Identify patterns:
Output: A summary of your understanding of the codebase, including:
CRITICAL: You MUST ask the user to confirm which component types need comments.
Present a checklist of common Java component types and ask the user to select:
请确认需要进行代码注释的分类(可多选):
- [ ] Controller(控制器)
- [ ] Service(服务接口)
- [ ] ServiceImpl(服务实现)
- [ ] Mapper(数据访问层)
- [ ] Model(数据模型)
- [ ] Entity(实体类)
- [ ] BO(业务对象)
- [ ] DTO(数据传输对象)
- [ ] VO(视图对象)
- [ ] DAO(数据访问对象)
- [ ] Repository(仓储)
- [ ] Configuration(配置类)
- [ ] Component(组件类)
- [ ] Utility(工具类)
- [ ] Exception(异常类)
- [ ] 其他(请 specify)
Also ask about comment types:
Wait for user confirmation before proceeding to the next step.
CRITICAL: After user confirms component types, create a detailed todo list.
For each component type selected by the user:
Scan the codebase to find all matching classes:
*Controller.java, *Service.java)For each class, identify:
Generate a structured todo list in the following format:
## Todo List: Java Code Comments
### Controller 层
- [ ] UserController
- [ ] 类注释
- [ ] createUser() - 方法注释
- [ ] updateUser() - 方法注释
- [ ] deleteUser() - 方法注释
- [ ] userId - 属性注释
### Service 层
- [ ] UserService
- [ ] 类注释
- [ ] findUserById() - 方法注释
- [ ] saveUser() - 方法注释
### ServiceImpl 层
- [ ] UserServiceImpl
- [ ] 类注释
- [ ] findUserById() - 方法注释
- [ ] saveUser() - 方法注释
### Mapper 层
- [ ] UserMapper
- [ ] 类注释
- [ ] selectById() - 方法注释
### Model/Entity 层
- [ ] User
- [ ] 类注释
- [ ] id - 属性注释
- [ ] username - 属性注释
- [ ] email - 属性注释
Important:
CRITICAL: Add comments in the specified order and update todo list after each completion.
Order of execution:
For each item in the todo list:
Process one class at a time:
Class-level comment format (Standard JavaDoc):
/**
* [Class description]
*
* <p>This class [purpose and responsibility]
*
* @author [Author name if available]
* @since [Version or date if available]
*/
public class UserController {
Class-level comment format (Java Coding Standards - strict):
/**
* <p>[Class description]</p>
*
* <p>This class [purpose and responsibility]</p>
*
* @author [Author name if available]
* @since [Version or date if available]
*/
public class UserController {
Method-level comment format (Standard JavaDoc):
/**
* [Method description]
*
* @param [paramName] [parameter description]
* @return [return value description]
* @throws [ExceptionType] [exception description]
*/
public UserDTO createUser(@RequestBody UserCreateRequest request) {
Method-level comment format (Java Coding Standards - strict):
/**
* <p>[Method description]</p>
*
* <p>[Detailed description]</p>
*
* @param [paramName] [paramType] [parameter description]
* @return [returnType] [return value description]
* @exception [full.package.ExceptionType] [exception description]
*/
public UserDTO createUser(@RequestBody UserCreateRequest request) {
Field-level comment format (Standard JavaDoc):
/**
* [Field description]
*/
private Long userId;
Field-level comment format (Java Coding Standards - strict):
/**
* <p>[Field description]</p>
*
* <p>[Detailed description if needed]</p>
*/
private Long userId;
[x]Example progress update:
## Progress Update
✅ Completed: UserController
- [x] 类注释
- [x] createUser() - 方法注释
- [x] updateUser() - 方法注释
- [x] deleteUser() - 方法注释
- [x] userId - 属性注释
🔄 In Progress: UserService
- [x] 类注释
- [ ] findUserById() - 方法注释
- [ ] saveUser() - 方法注释
IMPORTANT: Comment Format Standards
This skill follows two standards:
The Java Coding Standards require:
<p> tags: <p>description</p>@param paramName paramType description@return returnType description@exception java.lang.Exception descriptionClass Comments Should Include:
<p> tags if following Java Coding Standards)Method Comments Should Include:
<p> tags if following Java Coding Standards)Field Comments Should Include:
<p> tags if following Java Coding Standards)For different component types, use appropriate templates from the templates/ directory:
templates/controller-comment-template.md - Controller class commentstemplates/service-comment-template.md - Service interface commentstemplates/serviceimpl-comment-template.md - Service implementation commentstemplates/mapper-comment-template.md - Mapper commentstemplates/entity-comment-template.md - Entity class commentstemplates/dto-comment-template.md - DTO class commentsWhen to use Java Coding Standards format:
<p> tags for descriptionsSee the examples/ directory for complete examples:
examples/controller-example.md - Controller commenting exampleexamples/service-example.md - Service commenting exampleexamples/entity-example.md - Entity commenting exampleexamples/full-workflow-example.md - Complete workflow exampleEnglish keywords: java, code comments, javadoc, documentation, class comments, method comments, field comments, code annotation, code documentation, java documentation, add comments, generate comments, document code, code comments java, java code comments, controller comments, service comments, mapper comments, entity comments, dto comments
Chinese keywords (中文关键词): Java 代码注释, 添加注释, 生成注释, 代码注释, 文档注释, JavaDoc, 类注释, 方法注释, 属性注释, 字段注释, 给代码添加注释, 代码文档, Java 文档, 注释生成, 一句话添加注释, Controller 注释, Service 注释, Mapper 注释, Entity 注释, DTO 注释, 代码注解