Skip to content
Back to skills

Clean Architecture

ASecurity

Apply Clean Architecture boundaries to keep domain logic isolated from frameworks and infrastructure.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 9, 2026
ai-agentstypescriptgoapidatabasebackend

Works with

  • api

Security analysis

A100/100

Scanned October 9, 2026

npx -y skills add alisattorov06/ali-kiro --skill clean-architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Clean Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Clean Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alisattorov06-clean-architecture/badge)](https://www.skillsdirectory.com/skills/alisattorov06-clean-architecture)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: clean-architecture
description: Apply Clean Architecture boundaries to keep domain logic isolated from frameworks and infrastructure.
origin: FlowDeck
---

# clean-architecture

## When to Activate
When designing or implementing a new feature or service that needs clear separation of concerns, testability, and independence from frameworks, databases, or UI libraries.

## Steps
1. **Identify the core business logic** - Determine the essential domain rules that would exist even if the application had no UI, database, or external services.
2. **Define the boundary** - Draw a clear boundary between the inner circles (entities, use cases) and outer circles (interfaces, infrastructure).
3. **Place dependencies pointing inward** - Dependencies should always point toward the center. The inner circle knows nothing about the outer circle.
4. **Define ports (interfaces)** - Create interfaces in the domain layer that define how the outside world can interact with it.
5. **Implement adapters** - Create concrete implementations (adapters) for databases, web frameworks, external APIs, etc. in the outer layers.
6. **Wire everything via dependency injection** - Use a composition root or DI container to assemble the application.

## Examples
```typescript
// Domain Layer - Enterprise Business Rules (innermost circle)
class Order {
  constructor(
    private readonly id: string,
    private readonly items: OrderItem[],
    private readonly status: OrderStatus
  ) {}

  get total(): number {
    return this.items.reduce((sum, item) => sum + item.price * item.quantity, 0)
  }

  canBeFulfilled(): boolean {
    return this.status === 'pending' && this.items.length > 0
  }
}

// Application Layer - Application Business Rules
interface OrderRepository {
  findById(id: string): Promise<Order | null>
  save(order: Order): Promise<void>
}

interface NotificationService {
  sendOrderConfirmation(order: Order): Promise<void>
}

class PlaceOrderUseCase {
  constructor(
    private readonly orderRepo: OrderRepository,
    private readonly notifier: NotificationService
  ) {}

  async execute(orderData: OrderData): Promise<Order> {
    const order = new Order(orderData.id, orderData.items, 'pending')

    if (!order.canBeFulfilled()) {
      throw new InvalidOrderError('Order cannot be fulfilled')
    }

    await this.orderRepo.save(order)
    await this.notifier.sendOrderConfirmation(order)

    return order
  }
}

// Infrastructure Layer - Interface Adapters (outermost circle)
class PostgresOrderRepository implements OrderRepository {
  async findById(id: string): Promise<Order | null> {
    // Database implementation
  }

  async save(order: Order): Promise<void> {
    // Database implementation
  }
}

class EmailNotificationService implements NotificationService {
  async sendOrderConfirmation(order: Order): Promise<void> {
    // Email implementation
  }
}
```

## Related Skills
- layered-architecture
- hexagonal-architecture
- ddd-architecture
- backend-patterns

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.