mcpField
C
clean-architect

clean-architect

github.com/gravito-frameworkDevelopment248 installsUpdated 27w ago
Repository

About clean-architect

Architecture guidance based on Uncle Bob's Clean Architecture for developers building applications with Gravito and TypeScript. It emphasizes dependency direction, domain isolation, and a layered implementation flow from entities to HTTP controllers.

Key features

  1. 01Defines Domain and Application layers
  2. 02Enforces inward-only dependencies
  3. 03Distinguishes entities from value objects
  4. 04Organizes logic around use cases
  5. 05Binds contracts to concrete implementations

Use cases

  1. 01Plan a Clean Architecture project structure
  2. 02Keep the core domain separate from frameworks and databases
  3. 03Build a flow from domain models to HTTP controllers

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/gravito-framework/gravito --skill clean-architect

After installing, type/clean-architectin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

assets/
.keep
references/
.keep
scripts/
.keep

Details

From the project README

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.

Comments

Markdown supported