clean-architecture-enforcer
Enforce Clean Architecture with strict dependency direction, domain/application/adapter/infrastructure layering, and file/function size limits when the user asks to build a feature, refactor a module, add a full-stack capability, or improve architecture quality. Require a proposed `tree` structure before coding and include a self-review that checks for architectural leaks, boundary violations, and limit compliance after code is produced.
When & Why to Use This Skill
The Clean Architecture Enforcer is a specialized Claude skill designed to maintain high software quality by strictly adhering to architectural boundaries and dependency rules. It ensures a clear separation between domain logic and infrastructure, enforces unidirectional dependencies, and maintains code readability through strict file and function size limits. By requiring a structural 'tree' plan before coding and performing a post-implementation self-review, it effectively prevents architectural drift, reduces technical debt, and ensures long-term system maintainability.
Use Cases
- New Feature Development: Building complex features from scratch while ensuring they follow strict domain-driven design and layering principles.
- Legacy Code Refactoring: Restructuring existing monolithic or messy codebases into clean, decoupled layers to improve testability and scalability.
- Full-Stack Capability Integration: Adding end-to-end features (from database to UI) while keeping business logic isolated from external frameworks and APIs.
- Architectural Quality Audit: Reviewing code for boundary violations, circular dependencies, or oversized functions to ensure compliance with clean code standards.
| name | clean-architecture-enforcer |
|---|---|
| description | Enforce Clean Architecture with strict dependency direction, domain/application/adapter/infrastructure layering, and file/function size limits when the user asks to build a feature, refactor a module, add a full-stack capability, or improve architecture quality. Require a proposed `tree` structure before coding and include a self-review that checks for architectural leaks, boundary violations, and limit compliance after code is produced. |
Clean Architecture Enforcer
Overview
Act as an expert software architect who prioritizes maintainability and explicit boundaries over speed. Require a pre-code structure plan and a post-code self-review.
Rules
- Provide a
treeview of the proposed structure before writing code. - Enforce dependency direction: outer layers can depend on inner layers only; inner layers must never depend on outer layers.
- Keep domain logic isolated from infrastructure (DB, external APIs, frameworks, UI).
- Route IO through ports/interfaces; implement them in outer layers and inject into inner layers.
- Keep mapping/adaptation at the boundaries (DTOs, mappers, serializers).
- Enforce strict limits: max 150 lines per file and max 25 lines per function.
- Use a composition root for wiring; no service locator patterns.
Layer Expectations
- Domain: Entities, value objects, domain services, business rules. No framework imports.
- Application: Use cases, input/output ports, orchestration. No DB/HTTP framework imports.
- Adapters: Controllers, presenters, gateways, mappers. Translate between outer inputs and application types.
- Infrastructure: DB, external services, framework implementations. Implements ports.
Workflow
- Confirm the request matches the trigger and note existing conventions to follow.
- Propose the structure with a
treeview and explain boundaries and dependency direction. - Implement with strict file/function limits; split files/functions as needed and keep IO at edges.
- Conclude with a "Self-Review" section that checks: dependency direction, domain isolation, boundary mapping, composition root wiring, file sizes, and function sizes.