Back to list
malston

clean-architecture

by malston

1🍴 0📅 Jan 24, 2026

SKILL.md


name: clean-architecture description: Clean Architecture principles for maintainable, testable applications. Use when designing application structure or refactoring.

Clean Architecture

Layer Structure

┌─────────────────────────────────────────────┐
│ FRAMEWORKS & DRIVERS (Web, DB, External)    │
│ ┌─────────────────────────────────────────┐ │
│ │ INTERFACE ADAPTERS (Controllers, Repos) │ │
│ │ ┌─────────────────────────────────────┐ │ │
│ │ │ APPLICATION (Use Cases)             │ │ │
│ │ │ ┌─────────────────────────────────┐ │ │ │
│ │ │ │ DOMAIN (Entities)               │ │ │ │
│ │ │ └─────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────┘

Dependency Rule

Dependencies point inward only.

  • Domain knows nothing about outer layers
  • Use Cases know Domain, nothing else
  • Adapters know Use Cases + Domain
  • Frameworks know everything

Layers

Domain (Entities)

  • Business objects with behavior
  • Validation rules
  • No framework dependencies
  • No I/O operations

Application (Use Cases)

  • Orchestrates domain objects
  • One use case = one action
  • Defines repository interfaces
  • Input/Output DTOs

Interface Adapters

  • Controllers: HTTP → Use Case
  • Repositories: Use Case → Database
  • Presenters: Use Case → Response format

Frameworks & Drivers

  • Web framework (Express, FastAPI, Fiber)
  • Database clients
  • External APIs
  • Configuration

Folder Structure

src/
├── domain/
│   └── entities/
├── application/
│   ├── use-cases/
│   └── interfaces/      # Repository interfaces
├── infrastructure/
│   ├── repositories/    # Interface implementations
│   └── external/        # API clients
└── interfaces/
    ├── http/            # Controllers, routes
    └── cli/             # CLI handlers

Key Patterns

Dependency Injection

UseCase depends on RepositoryInterface (not implementation)
Controller injects concrete Repository into UseCase

Use Case Structure

1. Validate input
2. Load entities via repository
3. Execute domain logic
4. Persist via repository
5. Return output DTO

Repository Interface

Defined in: application/interfaces/
Implemented in: infrastructure/repositories/

When to Apply

Use Clean Architecture when:

  • Application will grow/evolve
  • Multiple entry points (API, CLI, queue)
  • Team needs clear boundaries
  • Testing is priority

Skip for:

  • Simple CRUD apps
  • Prototypes/MVPs
  • Scripts/tools

Common Mistakes

  • Entities depending on ORM/framework
  • Use cases calling HTTP directly
  • Business logic in controllers
  • Skipping the interface layer
  • Over-engineering simple apps

Testing Strategy

LayerTest TypeMocks
DomainUnitNone
Use CasesUnitRepositories
AdaptersIntegrationExternal services
E2ESystemNone

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon