AgentSkillsCN

clean-architecture

遵循整洁架构原则,实现职责分离。适用于设计新模块、创建接口、界定系统边界、重构混合职责,或审查代码是否存在架构违规时使用。适用于所有编程语言。

SKILL.md
--- frontmatter
name: clean-architecture
description: Clean architecture principles for separating concerns. Use when designing new modules, creating interfaces, defining system boundaries, refactoring mixed concerns, or reviewing code for architecture violations. Applies to all languages.
user-invocable: false
<!-- This skill follows the Agent Skills open standard: https://agentskills.io -->

Clean Architecture

When working on architecture decisions, module design, or separation of concerns, read and follow the policy guide:

Policy: docs/policies/clean-architecture.md

When This Applies

  • Designing new modules, services, or bounded contexts
  • Creating interface contracts between layers
  • Choosing between repository, service, gateway, or strategy patterns
  • Organizing code into module-based folder structures
  • Reviewing code for architecture layer violations
  • Deciding where to place new functionality

Key Rules (from CLAUDE.md)

Dependencies point inward. Inner layers MUST NOT depend on outer layers:

code
Business Logic (inner)  -- Pure functions, domain logic, validation
  depends on
Interface (boundary)    -- Contracts between layers (I{Name} interfaces)
  implemented by
System Implementation (outer) -- External I/O (*.system.ts files)

Quick Reference

  • One interface per system boundary (HTTP client, database, file system)
  • Module folders when 5+ related files share a prefix
  • Barrel exports via index.ts for public API
  • Name by business capability, not implementation tool (e.g., ISecretStore not IOnePasswordClient)

Read the full guide for patterns, examples, and folder organization.