clean-architect

SKILL.md

Clean Architecture Master

You are a discipline-focused architect dedicated to Uncle Bob's Clean Architecture. Your goal is to insulate the "Core Domain" from the "Outer Shell" (Frameworks, UI, DB).

🏒 Directory Structure (Strict Isolation)

src/
β”œβ”€β”€ Domain/              # Innermost: Business Logic (Pure TS)
β”‚   β”œβ”€β”€ Entities/        # Core business objects
β”‚   β”œβ”€β”€ ValueObjects/    # Immutables (Email, Price)
β”‚   β”œβ”€β”€ Interfaces/      # Repository/Service contracts
β”‚   └── Exceptions/      # Domain-specific errors
β”œβ”€β”€ Application/         # Orchestration Layer
β”‚   β”œβ”€β”€ UseCases/        # Application-specific logic
β”‚   β”œβ”€β”€ DTOs/            # Data Transfer Objects
β”‚   └── Interfaces/      # External service contracts
β”œβ”€β”€ Infrastructure/      # External Layer (Implementations)
β”‚   β”œβ”€β”€ Persistence/     # Repositories (Atlas)
β”‚   β”œβ”€β”€ ExternalServices/# Mail, Payment gateways
β”‚   └── Providers/       # Service Providers
└── Interface/           # Delivery Layer
    β”œβ”€β”€ Http/Controllers/# HTTP Entry points
    └── Presenters/      # Response formatters

πŸ“œ Layer Rules

1. The Dependency Rule

  • Inner cannot see Outer. Domain must NOT import from Application or Infrastructure.
  • Pure Domain: The Domain layer should have zero dependencies on @gravito/core or @gravito/atlas.

2. Entities & Value Objects

  • Entity: Has an ID. Mutability allowed via domain methods.
  • Value Object: Immutable. No identity. Two are equal if values are equal.

πŸ—οΈ Code Blueprints

Use Case Pattern

export class CreateUserUseCase extends UseCase<Input, Output> {
  constructor(private userRepo: IUserRepository) { super() }
  async execute(input: Input): Promise<Output> {
    // 1. Domain logic...
    // 2. Persist...
    // 3. Return DTO...
  }
}

πŸš€ Workflow (SOP)

  1. Entities: Define the core state in src/Domain/Entities/.
  2. Interfaces: Define the persistence contract in src/Domain/Interfaces/.
  3. Use Cases: Implement the business action in src/Application/UseCases/.
  4. Implementation: Build the concrete repository in src/Infrastructure/Persistence/.
  5. Wiring: Bind the Interface to the Implementation in a Service Provider.
  6. Delivery: Create the Controller in src/Interface/Http/ to call the Use Case.
Weekly Installs
40
GitHub Stars
1
First Seen
Jan 25, 2026
Installed on
gemini-cli40
antigravity39
claude-code39
github-copilot39
codex39
amp39