跳到正文
Skillpedia
通用编程48k · #4182

code-polish

它能做什么

这个智能体可以优化代码注释,并进行格式整理等小幅清理工作。它能让代码看起来更专业,同时不改变其功能。

适用场景

  • ✓当你想让代码注释更清晰、更专业时。
  • ✓在与他人分享代码或用于文档之前。
  • ✓当注释含糊、已过时或写得不够正式时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/code-polish/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/code-polish/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“优化这段代码的注释,并把格式整理得更专业。”

每周 5 个新技能,1 分钟读完。

工作原理

它会先通读整段代码,理解上下文。然后逐条检查注释,删除不必要的内容,更新错误信息,并将随意的表述改写得清晰而专业,同时不改动代码逻辑。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Code Polish

A constraint-based protocol for normalizing code comments and performing safe, non-semantic cleanup. This skill exists because human-written code tends to carry casual, outdated, or missing comments, while the goal is professional-grade documentation without touching behavior.

This file is self-contained. Do not require any other skill file to execute this protocol.

Prime Directive

Comments and non-semantic cleanup are the job. Logic is never the job. If a change would alter what the code does — not just what it says or how it's arranged — it is out of scope, no matter how obviously "correct" the fix seems.


When to Use

Apply this skill when:

  • The user asks to "clean up," "professionalize," or "polish" existing code
  • Code is being prepped for code review, handoff, open-sourcing, or documentation
  • A file has a mix of human and AI-written comments and needs one consistent, professional voice
  • Comments are outdated, missing, redundant, or written casually (venting, placeholders, inside jokes)
  • The user wants comments improved but explicitly does not want logic touched

Do not apply this skill when:

  • The user wants a bug fixed or behavior changed (that's a different job — logic edits are out of scope here)
  • The user wants a full rewrite or architectural restructuring
  • The only ask is adding new features or functionality

Phase 0 — Full Read

Before editing anything, read the entire file (or the entire relevant module if the codebase is large — not just the function in question). Do not comment or clean incrementally while still reading. A comment written without full context is a guess, and guesses are how "professional" comments end up wrong.

Identify:

  • The language and its idiomatic comment/docstring convention (JSDoc, Python docstrings, /// for Rust, XML doc comments, etc.)
  • Any existing project comment style already in use elsewhere in the file — match it rather than importing a foreign convention
  • Any comment that encodes real, non-obvious information (race conditions, workarounds for external bugs, "don't reorder this" warnings, business-rule justifications)

Phase 1 — Comment Audit

Classify every existing comment into one of these categories before touching it:

Category Example Action
Junk / venting // wtf is this, // idk why but it works Remove tone, extract any real information underneath, rewrite professionally — or delete if it truly holds zero information
Placeholder // fix later, // TODO hack Convert to a proper TODO: note with the actual concern stated plainly, or remove if stale/resolved
Dead code comments Blocks of commented-out code Remove, unless the surrounding context makes clear it's intentionally preserved (e.g., a documented fallback) — flag these to the user rather than silently deleting
Redundant i++ // increment i Delete — the code already says this
Outdated / wrong Comment describes behavior the code no longer has Rewrite to match current behavior. Flag to the user that it was stale, don't just silently fix it
Valuable but informal // careful, this breaks if you call it twice, learned that the hard way Preserve the information, rewrite the tone. Never delete real warnings just because the phrasing is casual
Missing Complex logic, non-obvious business rules, or public APIs with no docstring Add one. Don't over-comment simple, self-explanatory lines

Phase 2 — Non-Semantic Cleanup

Scope is strictly limited to changes that cannot alter behavior:

  • Consistent indentation and whitespace
  • Consistent brace/bracket style matching the surrounding file
  • Removing truly dead code (unreachable blocks) — only when unambiguous, and flagged in the summary
  • Splitting overly long lines for readability
  • Local variable renaming for clarity is allowed only for private/local-scope names, and only when the improvement is unambiguous — never rename anything exported, public, or referenced across files without calling it out explicitly first

Anything beyond this — reordering logic, extracting functions, changing control flow, altering algorithms — is out of scope for this skill.


Phase 3 — Comment Rewrite / Addition

Apply these standards to every comment touched or added:

…

常见问题

“非语义层面的整理”是什么意思?

指这种整理不会改变代码的含义或运行方式,只调整其呈现形式,例如间距或注释。

它能修复代码中的 bug 吗?

不能,这个智能体只修改注释和格式,不会改变逻辑,也不会修复 bug。

对于包含重要信息但写得不好的注释会怎样?

它会保留其中的重要信息,并将注释改写得清晰专业。

详情

作者的原始描述

Rewrites unprofessional code comments into clear ones and performs non-semantic cleanup. Use to professionalize code without altering logic or behavior.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4182
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能