AgentSkillsCN

clean-code

在编写、审查或重构代码时,为提升代码的可维护性和可读性而使用此技能。适用于代码审查、命名讨论、函数设计、错误处理,以及测试编写等场景。该技能基于罗伯特·C·马丁的《整洁代码》手册。

SKILL.md
--- frontmatter
name: clean-code
description: Use when writing, reviewing, or refactoring code for maintainability and readability. Triggers on code reviews, naming discussions, function design, error handling, and test writing. Based on Robert C. Martin's Clean Code handbook.

Robert C. Martin (Uncle Bob) Clean Code Best Practices

Comprehensive software craftsmanship guide based on Robert C. Martin's "Clean Code: A Handbook of Agile Software Craftsmanship". Contains 45 rules across 8 categories, prioritized by impact to guide code reviews, refactoring decisions, and new development.

When to Apply

Reference these guidelines when:

  • Writing new functions, classes, or modules
  • Naming variables, functions, classes, or files
  • Reviewing code for maintainability issues
  • Refactoring existing code to improve clarity
  • Writing or improving unit tests

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Meaningful NamesCRITICALname-
2FunctionsCRITICALfunc-
3CommentsHIGHcmt-
4FormattingHIGHfmt-
5Objects and Data StructuresMEDIUM-HIGHobj-
6Error HandlingMEDIUM-HIGHerr-
7Unit TestsMEDIUMtest-
8Classes and SystemsMEDIUMclass-

Quick Reference

1. Meaningful Names (CRITICAL)

2. Functions (CRITICAL)

3. Comments (HIGH)

4. Formatting (HIGH)

5. Objects and Data Structures (MEDIUM-HIGH)

6. Error Handling (MEDIUM-HIGH)

7. Unit Tests (MEDIUM)

8. Classes and Systems (MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information