home / skills / partme-ai / full-stack-skills / ddd-clean-architecture
This skill provides guidance on clean architecture, outlining layer separation, dependency rules, and architectural patterns to structure robust applications.
npx playbooks add skill partme-ai/full-stack-skills --skill ddd-clean-architectureReview the files below or copy the command above to add this skill to your agents.
---
name: ddd-clean-architecture
description: Provides comprehensive guidance for clean architecture including layer separation, dependency rules, and architectural patterns. Use when the user asks about clean architecture, needs to implement clean architecture principles, or structure applications with clean architecture.
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]
## How to use this skill
[待完善:根据具体工具添加使用指南]
## Best Practices
[待完善:根据具体工具添加最佳实践]
## Keywords
[待完善:根据具体工具添加关键词]
This skill provides practical, implementation-focused guidance for applying Clean Architecture principles across application stacks. It explains layer separation, dependency rules, common patterns, and actionable steps to structure code for maintainability and testability. The guidance is language-agnostic but includes Python-centric examples and recommendations.
The skill inspects architecture decisions and suggests layer boundaries (entities, use cases, interfaces/adapters, frameworks) and dependency directions to enforce separation of concerns. It recommends concrete patterns for ports-and-adapters, dependency inversion, and data flow, and outlines folder/module organization and testing strategies. It highlights anti-patterns, migration steps for legacy code, and code-level practices to keep business rules independent from frameworks.
How do I start applying Clean Architecture to an existing codebase?
Start by identifying core business logic and extracting it into domain entities and use-case classes. Introduce interfaces (ports) and move framework-specific code into adapters behind those interfaces. Incrementally replace calls to concrete implementations with interface calls.
Should repositories or ORMs be part of the domain model?
No. Keep persistence concerns in adapter layers. Define repository interfaces in the domain/use-case layer and implement them in an infrastructure adapter that uses the ORM.
How granular should layers and modules be?
Favor small, cohesive modules that reflect business boundaries. Avoid excessive fragmentation; group related use cases and entities logically so navigation and tests remain straightforward.