# Clean Architecture

> Use when: structure an app so business logic is independent of frameworks, UI, and databases.

- Skill: `kimtth/clean-architecture` (Agent Skill)
- Install (CLI): `npx skillmds@latest add kimtth/clean-architecture`
- Raw SKILL.md: https://api.skillmd.com/api/skills/kimtth/clean-architecture/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: kimtth (https://skillmd.com/u/kimtth)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/kimtth/clean-architecture

---


Goal: a core domain that does not depend on delivery or infrastructure.

Use for:
- keeping business rules testable and framework-agnostic
- isolating database and UI choices from core logic
- structuring layers and their dependencies

Workflow:
1. Put business rules in a core that imports nothing external.
2. Define ports (interfaces) the core needs.
3. Implement adapters for db, UI, and services at the edges.
4. Point all dependencies inward, toward the core.
5. Pass data across boundaries as plain structures.
6. Test the core without frameworks or a database.

Layers:
- entities and use cases at the center
- interface adapters (controllers, presenters, gateways)
- frameworks and drivers at the outer edge

Rules:
- dependencies point inward only; core knows no framework
- depend on interfaces, inject implementations
- keep framework code out of use cases
- the domain must be testable in isolation

