cmd-clean-code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClean Code
整洁代码
Use these rules to improve code readability without altering functionality unless explicitly requested.
使用以下规则在不改动功能的前提下提升代码可读性,除非有明确要求才可变更功能。
Core Principles
核心原则
- Minimize cognitive load for human readers and agents.
- Apply idiomatic best practices where they fit.
- Preserve all business logic unless told otherwise.
- Clarify comments and structure with bullet points where possible.
- 降低人类读者和Agent的认知负担
- 在适配的场景下应用符合语言习惯的最佳实践
- 除非另行告知,否则保留所有业务逻辑
- 尽可能使用项目符号清晰化注释和结构
Accepted Inputs
可接受的输入
- Full source files (,
.proto,.go,.py, etc.)..md - Partial comments: package headers, method docs, inline notes.
- Whole or partial functions.
- Arbitrary code snippets (or any mix of the above).
- 完整源文件(、
.proto、.go、.py等).md - 部分注释:包头、方法文档、内联注释
- 完整或部分函数
- 任意代码片段(或上述内容的任意组合)
Response Requirements
响应要求
- Return the cleaned code wrapped in triple back-ticks.
- Keep all identifiers (fields, params, classes, methods, etc.).
- Add strategic whitespace for readability.
- Convert paragraph-style comments into bullet points when feasible.
- Do not delete or change original content unless asked.
- Favor bullet lists whenever information is list-like.
- 返回整理后的代码,使用三重反引号包裹
- 保留所有标识符(字段、参数、类、方法等)
- 合理添加空白字符提升可读性
- 可行时将段落式注释转换为项目符号列表
- 除非有明确要求,否则不要删除或修改原有内容
- 信息适合列表呈现时优先使用项目符号列表
Team-Specific Edge Cases
团队特定边界情况
- Leave tags untouched.
TODO_???(???) - Preserve callouts like ,
IMPORTANT, etc.DEV_NOTE - Maintain references to GitHub issues/PRs (e.g. "As of #XX ...").
- Keep every link and external reference.
- Retain markers such as ,
CRITICAL,NB,DEV_NOTE; just clean up the following text.NOTE
- 不要修改标签
TODO_???(???) - 保留、
IMPORTANT等标注DEV_NOTE - 保留对GitHub issue/PR的引用(例如 "As of #XX ...")
- 保留所有链接和外部引用
- 保留、
CRITICAL、NB、DEV_NOTE等标记,仅整理标记后续的文本NOTE
Handling Long Snippets
长片段处理
- For grouped code (~5 lines) followed by a blank line, add a brief comment atop the block.
- Keep existing comment hierarchy; just enhance readability.
- 对于成组代码(约5行)后接空行的情况,在代码块顶部添加简短注释
- 保留现有注释层级,仅提升可读性
Nits & Edits
细节调整规则
- Don't create a list with only one item -- write it as plain text.
- Never remove existing links while editing.
- 不要创建仅包含单个项的列表,直接写成普通文本即可
- 编辑过程中绝对不要删除原有链接