AgentSkillsCN

clean-architecture

罗伯特·C·马丁的《整洁代码》一书中所倡导的清洁架构原则与最佳实践。在设计软件系统、审查代码结构,或重构应用程序以实现更清晰的职责分离时,应使用此技能。适用于涉及分层、边界、依赖方向、实体、用例,或系统架构的任务。

SKILL.md
--- frontmatter
name: clean-architecture
description: Clean Architecture principles and best practices from Robert C. Martin's book. This skill should be used when designing software systems, reviewing code structure, or refactoring applications to achieve better separation of concerns. Triggers on tasks involving layers, boundaries, dependency direction, entities, use cases, or system architecture.

Clean Architecture Best Practices

Comprehensive guide to Clean Architecture principles for designing maintainable, testable software systems. Based on Robert C. Martin's "Clean Architecture: A Craftsman's Guide to Software Structure and Design." Contains 42 rules across 8 categories, prioritized by architectural impact.

When to Apply

Reference these guidelines when:

  • Designing new software systems or modules
  • Structuring dependencies between layers
  • Defining boundaries between business logic and infrastructure
  • Reviewing code for architectural violations
  • Refactoring coupled systems toward cleaner structure

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Dependency DirectionCRITICALdep-
2Entity DesignCRITICALentity-
3Use Case IsolationHIGHusecase-
4Component CohesionHIGHcomp-
5Boundary DefinitionMEDIUM-HIGHbound-
6Interface AdaptersMEDIUMadapt-
7Framework IsolationMEDIUMframe-
8Testing ArchitectureLOW-MEDIUMtest-

Quick Reference

1. Dependency Direction (CRITICAL)

2. Entity Design (CRITICAL)

3. Use Case Isolation (HIGH)

4. Component Cohesion (HIGH)

5. Boundary Definition (MEDIUM-HIGH)

6. Interface Adapters (MEDIUM)

7. Framework Isolation (MEDIUM)

8. Testing Architecture (LOW-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