| name | xml-code-comments |
| argument-hint | <file-or-symbol> |
| description | Use when: 为代码 public 类、struct、字段、属性、方法生成或补全中英文 XML 注释;generate bilingual XML documentation comments for public classes, structs, fields, properties, and methods with Chinese first and English second. |
| user-invocable | true |
| disable-model-invocation | false |
XML Code Comments
Goal
为代码中的 public API 生成准确、简洁、可维护的 XML 注释。
Generate accurate, concise, maintainable XML documentation comments for public APIs.
When to Use
Use this skill when the user asks to:
- 给代码添加 XML 注释。
- 为 public 类、struct、字段、属性、方法补充注释。
- 为 Unity/C# 代码生成中英文说明。
- 检查或改写已有 XML 注释。
- 统一注释格式为“中文在前,英文在后”。
- Generate XML comments for public classes, structs, fields, properties, and methods.
- Add bilingual Chinese/English documentation comments to C# code.
Scope
Only add or update XML comments for public API unless the user explicitly requests otherwise:
public class
public struct
public interface
public enum
public field
public property
public method
public constructor
public event
public delegate
Do not add XML comments to private, protected, internal, or local members unless explicitly requested.
Required Format
All XML comments must put Chinese first and English second.
Summary Format
Parameter Format
Return Format
Type Parameter Format
Exception Format
Only add <exception> when the code explicitly throws the exception or the behavior is obvious from the implementation.
Style Rules
- 中文必须在英文前面。
- 注释必须描述“做什么”和“什么时候用”,不要逐行复述代码。
- 保持简洁,避免过度解释。
- 保留代码标识符原文,不翻译类名、方法名、参数名、字段名。
- 不要编造代码中不存在的行为。
- 如果行为无法从代码确定,使用保守描述。
- 对 Unity API,说明世界坐标、本地坐标、生命周期、运行时/编辑器差异等直接相关约束。
- 对性能敏感 API,必要时说明分配、递归、延迟销毁、平方距离等注意点。
- 不改变原有代码逻辑,除非用户明确要求。
- 不为显而易见的 private 实现细节添加注释。
Procedure
- Identify the target file, selected code, or mentioned symbol.
- Read enough surrounding code to understand the API purpose and dependencies.
- Find public classes, structs, fields, properties, methods, constructors, events, delegates, and enums that lack XML comments or have incomplete comments.
- Add or update XML comments using the required Chinese-first English-second format.
- Preserve existing correct comments when possible.
- If an existing comment is inaccurate, update it to match the implementation.
- Avoid changing formatting unrelated to comments.
- Validate the edited file for syntax errors.
Examples
Public Method
public static bool IsInRange(Vector3 position, Vector3 target, float range)
Public Class
public static class TransformExtension
Public Property
public bool IsEnabled { get; }
Public Field
public float defaultMoveSpeed;
Quality Checklist
Before finishing, verify that:
- All requested public APIs have XML comments.
- Chinese appears before English in every XML comment.
<param> names exactly match method parameters.
<typeparam> names exactly match generic type parameters.
<returns> exists for non-void methods and properties only when appropriate.
- Comments match actual behavior.
- No unrelated code logic was changed.
- The file still compiles or has no new syntax errors.