clean-code by pproenca/dot-skills
npx skills add https://github.com/pproenca/dot-skills --skill clean-code基于 Robert C. Martin 的《代码整洁之道:敏捷软件工艺手册》的综合软件工艺指南,其中对 2008 年原始建议中已过时的部分进行了现代化修正。包含 10 个类别共 48 条规则,按影响优先级排序,以指导代码审查、重构决策和新开发。示例主要使用 Java,但原则与语言无关。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 有意义的命名 | 关键 | name- |
| 2 | 函数 | 关键 | func- |
| 3 | 注释 | 高 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
cmt- |
| 4 | 格式 | 高 | fmt- |
| 5 | 错误处理 | 高 | err- |
| 6 | 对象与数据结构 | 中高 | obj- |
| 7 | 边界 | 中高 | bound- |
| 8 | 类与系统 | 中高 | class- |
| 9 | 单元测试 | 中 | test- |
| 10 | 涌现与简单设计 | 中 | emerge- |
name-intention-revealing - 使用能揭示意图的名称name-avoid-disinformation - 避免误导性名称name-meaningful-distinctions - 进行有意义的区分name-pronounceable - 使用可发音的名称name-searchable - 使用可搜索的名称name-avoid-encodings - 避免在名称中使用编码name-class-noun - 对类名使用名词短语name-method-verb - 对方法名使用动词短语func-small - 保持函数短小func-one-thing - 函数应只做一件事func-abstraction-level - 保持单一抽象层级func-minimize-arguments - 最小化函数参数func-no-side-effects - 避免副作用func-command-query-separation - 分离命令与查询func-dry - 不要重复自己cmt-express-in-code - 用代码表达,而非注释cmt-explain-intent - 使用注释来解释意图cmt-avoid-redundant - 避免冗余注释cmt-avoid-commented-out-code - 删除被注释掉的代码cmt-warning-consequences - 使用警告注释说明后果fmt-vertical-formatting - 使用垂直格式以提高可读性fmt-horizontal-alignment - 避免水平对齐fmt-team-rules - 遵循团队格式规则fmt-indentation - 遵守缩进规则err-use-exceptions - 将错误处理与正常路径分离err-write-try-catch-first - 首先编写 try-catch-finallyerr-provide-context - 为异常提供上下文信息err-define-by-caller-needs - 根据调用者需求定义异常err-avoid-null - 避免返回和传递 nullobj-data-abstraction - 将数据隐藏在抽象之后obj-data-object-asymmetry - 理解数据/对象的反对称性obj-law-of-demeter - 遵循德米特法则obj-avoid-hybrids - 避免混合的数据-对象结构obj-dto - 使用 DTO 进行数据传输bound-wrap-third-party - 包装第三方 APIbound-learning-tests - 为第三方代码编写学习测试class-small - 保持类短小class-cohesion - 保持类的内聚性class-organize-for-change - 为变更而组织类class-isolate-from-change - 将类与变更隔离class-separate-concerns - 分离构造与使用test-first-law - 遵循 TDD 三定律test-keep-clean - 保持测试整洁test-one-assert - 每个测试一个概念test-first-principles - 遵循 FIRST 原则test-build-operate-check - 使用构建-操作-检查模式emerge-simple-design - 遵循简单设计的四条规则emerge-expressiveness - 最大化表达力阅读单独的参考文件以获取详细解释和代码示例:
| 文件 | 描述 |
|---|---|
| references/_sections.md | 类别定义和排序 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本和参考信息 |
每周安装次数
144
代码仓库
GitHub 星标数
85
首次出现
2026年1月25日
安全审计
安装于
codex129
opencode125
gemini-cli123
github-copilot120
cursor109
amp105
Comprehensive software craftsmanship guide based on Robert C. Martin's "Clean Code: A Handbook of Agile Software Craftsmanship", updated with modern corrections where the original 2008 advice has been superseded. Contains 48 rules across 10 categories, prioritized by impact to guide code reviews, refactoring decisions, and new development. Examples are primarily in Java but principles are language-agnostic.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Meaningful Names | CRITICAL | name- |
| 2 | Functions | CRITICAL | func- |
| 3 | Comments | HIGH | cmt- |
| 4 | Formatting | HIGH | fmt- |
| 5 | Error Handling | HIGH | err- |
| 6 | Objects and Data Structures | MEDIUM-HIGH | obj- |
| 7 | Boundaries | MEDIUM-HIGH | bound- |
| 8 | Classes and Systems | MEDIUM-HIGH | class- |
| 9 | Unit Tests | MEDIUM | test- |
| 10 | Emergence and Simple Design | MEDIUM | emerge- |
name-intention-revealing - Use names that reveal intentname-avoid-disinformation - Avoid misleading namesname-meaningful-distinctions - Make meaningful distinctionsname-pronounceable - Use pronounceable namesname-searchable - Use searchable namesname-avoid-encodings - Avoid encodings in namesfunc-small - Keep functions smallfunc-one-thing - Functions should do one thingfunc-abstraction-level - Maintain one level of abstractionfunc-minimize-arguments - Minimize function argumentsfunc-no-side-effects - Avoid side effectsfunc-command-query-separation - Separate commands from queriescmt-express-in-code - Express yourself in code, not commentscmt-explain-intent - Use comments to explain intentcmt-avoid-redundant - Avoid redundant commentscmt-avoid-commented-out-code - Delete commented-out codecmt-warning-consequences - Use warning comments for consequencesfmt-vertical-formatting - Use vertical formatting for readabilityfmt-horizontal-alignment - Avoid horizontal alignmentfmt-team-rules - Follow team formatting rulesfmt-indentation - Respect indentation ruleserr-use-exceptions - Separate error handling from happy patherr-write-try-catch-first - Write try-catch-finally firsterr-provide-context - Provide context with exceptionserr-define-by-caller-needs - Define exceptions by caller needserr-avoid-null - Avoid returning and passing nullobj-data-abstraction - Hide data behind abstractionsobj-data-object-asymmetry - Understand data/object anti-symmetryobj-law-of-demeter - Follow the Law of Demeterobj-avoid-hybrids - Avoid hybrid data-object structuresobj-dto - Use DTOs for data transferbound-wrap-third-party - Wrap third-party APIsbound-learning-tests - Write learning tests for third-party codeclass-small - Keep classes smallclass-cohesion - Maintain class cohesionclass-organize-for-change - Organize classes for changeclass-isolate-from-change - Isolate classes from changeclass-separate-concerns - Separate construction from usetest-first-law - Follow the three laws of TDDtest-keep-clean - Keep tests cleantest-one-assert - One concept per testtest-first-principles - Follow FIRST principlestest-build-operate-check - Use Build-Operate-Check patternemerge-simple-design - Follow the four rules of simple designemerge-expressiveness - Maximize expressivenessRead individual reference files for detailed explanations and code examples:
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
144
Repository
GitHub Stars
85
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex129
opencode125
gemini-cli123
github-copilot120
cursor109
amp105
代码安全审查清单:最佳实践与漏洞防范指南(含密钥管理、SQL注入防护)
1,700 周安装
name-class-noun - Use noun phrases for class namesname-method-verb - Use verb phrases for method namesfunc-dry - Do not repeat yourself