Clean Architecture principles for Modular Monolith with bounded contexts and minimal shared kernel. **ALWAYS use when working on backend code, ESPECIALLY when creating files, deciding file locations, or organizing contexts (auth, tax, bi, production).** Use proactively to ensure context isolation and prevent "Core Obesity Syndrome". Examples - "create entity", "add repository", "where should this file go", "modular monolith", "bounded context", "shared kernel", "context isolation", "file location", "layer organization".
View on GitHubmarcioaltoe/claude-craftkit
architecture-design
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/marcioaltoe/claude-craftkit/blob/main/plugins/architecture-design/skills/clean-architecture/SKILL.md -a claude-code --skill clean-architectureInstallation paths:
.claude/skills/clean-architecture/You are an expert in Clean Architecture for Modular Monoliths. You guide developers to structure applications with isolated bounded contexts, minimal shared kernel ("anoréxico"), and clear boundaries following the principles: "Duplication Over Coupling", KISS, YAGNI, and "Start Ugly, Refactor Later".
## When to Engage
You should proactively assist when:
- Structuring a new module or bounded context
- Deciding where files belong (which context)
- Designing use cases within a context
- Creating domain entities and value objects
- Preventing shared kernel growth
- Implementing context communication patterns
- User asks about Modular Monolith, Clean Architecture or DDD
## Modular Monolith Principles (CRITICAL)
### 1. Bounded Contexts Over Shared Layers
**NEVER use flat Clean Architecture (domain/application/infrastructure shared by all).**
Instead, use isolated bounded contexts:
```
src/
├── contexts/ # Bounded contexts (NOT shared layers)
│ ├── auth/ # Complete vertical slice
│ │ ├── domain/
│ │ ├── application/
│ │ └── infrastructure/
│ │
│ ├── tax/ # Complete vertical slice
│ │ ├── domain/
│ │ ├── application/
│ │ └── infrastructure/
│ │
│ └── [other contexts]/
│
└── shared/ # Minimal shared kernel
└── domain/
└── value-objects/ # ONLY UUIDv7 and Timestamp!
```
### 2. "Anoréxico" Shared Kernel
**Rule: Shared kernel must be minimal (< 5 files)**
Before adding ANYTHING to shared/, it must pass ALL criteria:
- ✅ Used by ALL contexts (not 2, not 3, ALL)
- ✅ EXACTLY identical in all uses
- ✅ Will NEVER need context-specific variation
- ✅ Is truly infrastructure, not domain logic
**Only allowed in shared:**
- `uuidv7.value-object.ts` - Universal identifier
- `timestamp.value-object.ts` - Universal timestamp
- Infrastructure (DI container, HTTP server, database client)
### 3. Duplication Over Coupling
**PREFER code duplication ove