clean-architecture-enforcer

MohamedChaibMyQCM's avatarfrom MohamedChaibMyQCM

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.

⭐0stars🔀0forks📁View on GitHub🕐Updated Jan 4, 2026

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.
nameclean-architecture-enforcer
descriptionEnforce 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

  1. Provide a tree view of the proposed structure before writing code.
  2. Enforce dependency direction: outer layers can depend on inner layers only; inner layers must never depend on outer layers.
  3. Keep domain logic isolated from infrastructure (DB, external APIs, frameworks, UI).
  4. Route IO through ports/interfaces; implement them in outer layers and inject into inner layers.
  5. Keep mapping/adaptation at the boundaries (DTOs, mappers, serializers).
  6. Enforce strict limits: max 150 lines per file and max 25 lines per function.
  7. 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

  1. Confirm the request matches the trigger and note existing conventions to follow.
  2. Propose the structure with a tree view and explain boundaries and dependency direction.
  3. Implement with strict file/function limits; split files/functions as needed and keep IO at edges.
  4. Conclude with a "Self-Review" section that checks: dependency direction, domain isolation, boundary mapping, composition root wiring, file sizes, and function sizes.