Source profileQuality 92/100

ccheney/robust-skills/skills/clean-ddd-hexagonal/SKILL.md

clean-ddd-hexagonal

Proactively apply when designing APIs, microservices, or scalable backend structure. Triggers on DDD, Clean Architecture, Hexagonal, ports and adapters, entities, value objects, domain events, CQRS, event sourcing, repository pattern, use cases, onion architecture, outbox pattern, aggregate root, anti-corruption layer. Use when working with domain models, aggregates, repositories, or bounded contexts. Clean Architecture + DDD + Hexagonal patterns for backend services, language-agnostic (Go, Rust

Source repository stars
57
Declared platforms
0
Static risk flags
1
Last source update
2026-08-15
Source checked
2026-08-25

Decision brief

What it does: where it fits

Backend architecture combining DDD tactical patterns, Clean Architecture dependency rules, and Hexagonal ports/adapters for maintainable, testable systems.

Best for

  • Start simple. Evolve complexity only when needed. Most systems don't need full CQRS or Event Sourcing.

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/ccheney/robust-skills --skill "skills/clean-ddd-hexagonal"
Safe inspection promptEditorial

Inspect the Agent Skill "clean-ddd-hexagonal" from https://github.com/ccheney/robust-skills/blob/0ace9a7f5c20d19cad678b894a717945da2ea8ed/skills/clean-ddd-hexagonal/SKILL.md at commit 0ace9a7f5c20d19cad678b894a717945da2ea8ed. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Implementation Order

    1. Discover the Domain — Event Storming, conversations with domain experts 2. Model the Domain — Entities, value objects, aggregates (no infra) 3. Define Ports — Repository interfaces, external service interfaces 4. Implement Use Cases — Application services coordinating domain…

    Discover the Domain — Event Storming, conversations with domain expertsModel the Domain — Entities, value objects, aggregates (no infra)Define Ports — Repository interfaces, external service interfaces
  2. 02

    Implementation Guides

    Microsoft: DDD + CQRS Microservices

    Microsoft: DDD + CQRS MicroservicesDomain Events — Udi Dahan- Microsoft: DDD + CQRS Microservices - Domain Events — Udi Dahan
  3. 03

    When to Use (and When NOT to)

    Start simple. Evolve complexity only when needed. Most systems don't need full CQRS or Event Sourcing.

    Start simple. Evolve complexity only when needed. Most systems don't need full CQRS or Event Sourcing.
  4. 04

    Pattern Boundaries

    Review the “Pattern Boundaries” section in the pinned source before continuing.

    Review and apply the “Pattern Boundaries” source section.
  5. 05

    CRITICAL: The Dependency Rule

    Dependencies point inward only. Outer layers depend on inner layers, never the reverse.

    Domain importing database/HTTP librariesIn this architecture style, controllers calling repositories directly instead of application use casesEntities depending on application services

Permission review

Static risk signals and limitations

Reads files

low · line 170

The documentation asks the agent to read local files, directories, or repositories.

Read the matching file before doing the task in the left column:

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score92/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars57SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
ccheney/robust-skills
Skill path
skills/clean-ddd-hexagonal/SKILL.md
Commit
0ace9a7f5c20d19cad678b894a717945da2ea8ed
License
MIT
Collected
2026-08-25
Default branch
main
View the original SKILL.md

Clean Architecture + DDD + Hexagonal

Backend architecture combining DDD tactical patterns, Clean Architecture dependency rules, and Hexagonal ports/adapters for maintainable, testable systems.

This skill is an opinionated synthesis of several related architecture traditions. It is not a single canonical architecture model. Use the original source that matches the design question you are answering: DDD for domain modeling, Hexagonal Architecture for ports/adapters, Clean Architecture for dependency direction, Onion Architecture for domain-centered layering, and CQRS/Event Sourcing only for specific read/write or temporal requirements.

When to Use (and When NOT to)

Use WhenSkip When
Complex business domain with many rulesSimple CRUD, few business rules
Long-lived system (years of maintenance)Prototype, MVP, throwaway code
Team of 5+ developersSolo developer or small team (1-2)
Multiple entry points (API, CLI, events)Single entry point, simple API
Need to swap infrastructure (DB, broker)Fixed infrastructure, unlikely to change
High test coverage requiredQuick scripts, internal tools

Start simple. Evolve complexity only when needed. Most systems don't need full CQRS or Event Sourcing.

Pattern Boundaries

PatternPrimary QuestionUse It ForDo Not Treat As
DDDHow do we model a complex business domain?Ubiquitous language, bounded contexts, aggregates, value objectsA folder structure by itself
Hexagonal ArchitectureHow does the application interact with the outside world?Ports, driver adapters, driven adapters, testable application coreA mandate for six sides or one exact package layout
Clean ArchitectureWhich direction should dependencies point?Inward dependency rule, use case boundaries, framework independenceA universal four-folder template
Onion ArchitectureHow do we keep the domain model central?Domain-centered layers and dependency inversionA separate requirement when Clean/Hexagonal already solve the local problem
CQRSDo reads and writes need different models?Bounded contexts with divergent read/write workloadsA default application architecture
Event SourcingDo we need state from a complete event history?Audit, temporal queries, replayable workflowsA persistence default for CRUD systems

CRITICAL: The Dependency Rule

Dependencies point inward only. Outer layers depend on inner layers, never the reverse.

Infrastructure → Application → Domain
   (adapters)     (use cases)    (core)

Violations to catch:

  • Domain importing database/HTTP libraries
  • In this architecture style, controllers calling repositories directly instead of application use cases
  • Entities depending on application services

Design validation: "Create your application to work without either a UI or a database" — Alistair Cockburn. If you can run your domain logic from tests with no infrastructure, your boundaries are correct.

Quick Decision Trees

"Where does this code go?"

Where does it go?
├─ Pure business logic, no I/O           → domain/
├─ Orchestrates domain + has side effects → application/
├─ Talks to external systems              → infrastructure/
├─ Defines HOW to interact (interface)    → port (domain or application)
└─ Implements a port                      → adapter (infrastructure)

Sharp edges — the placements LLMs most often get wrong:

CodeLayerWhy
Business invariant ("order needs items to confirm")Domain (entity method)It's a rule, not orchestration
Input format validation (JSON shape, required fields)Adapter (controller/DTO)Protocol concern, not business rule
Transaction begin/commitApplicationUse case = transaction boundary
ORM entity / table modelInfrastructureMap to domain objects; never let ORM entities BE domain entities
Domain ↔ DB mappingInfrastructure (mapper)Persistence detail
Authorization ("is user allowed?")Application (policy) or adapter middlewareDomain stays auth-agnostic; encode role RULES in domain only if they're business rules
Clock, UUID generationPort in domain/application; adapter in infrastructureKeeps domain deterministic and testable
Reacting to a domain eventApplication (event handler)Side effects = orchestration
Query joining many tables for a screenRead model (application interface, infrastructure impl)Don't force it through aggregates

Litmus test for anemic domain models: if an application service reads state out of an entity, decides, then writes state back (if (order.status === 'draft') order.status = 'confirmed'), move that logic into the entity as order.confirm(). Handlers should read like a script: load aggregate → call one behavior method → save → publish.

"Is this an Entity or Value Object?"

Entity or Value Object?
├─ Has unique identity that persists → Entity
├─ Defined only by its attributes    → Value Object
├─ "Is this THE same thing?"         → Entity (identity comparison)
└─ "Does this have the same value?"  → Value Object (structural equality)

"Should this be its own Aggregate?"

Aggregate boundaries?
├─ Must be consistent together in a transaction → Same aggregate
├─ Can be eventually consistent                 → Separate aggregates
├─ Referenced by ID only                        → Separate aggregates
└─ >10 entities in aggregate                    → Split it

Rule: One aggregate per transaction. Cross-aggregate consistency via domain events (eventual consistency).

Directory Structure

src/
├── domain/                    # Core business logic (NO external dependencies)
│   ├── {aggregate}/
│   │   ├── entity              # Aggregate root + child entities
│   │   ├── value_objects       # Immutable value types
│   │   ├── events              # Domain events
│   │   ├── repository          # DDD repository interface (driven port)
│   │   └── services            # Domain services (stateless logic)
│   └── shared/
│       └── errors              # Domain errors
├── application/               # Use cases / Application services
│   ├── {use-case}/
│   │   ├── command             # Command/Query DTOs
│   │   ├── handler             # Use case implementation
│   │   └── port                # Driver port interface
│   └── shared/
│       └── unit_of_work        # Transaction abstraction
├── infrastructure/            # Adapters (external concerns)
│   ├── persistence/           # Database adapters
│   ├── messaging/             # Message broker adapters
│   ├── http/                  # REST/GraphQL adapters (DRIVER)
│   └── config/
│       └── di                  # Dependency injection / composition root
└── main                        # Bootstrap / entry point

Port placement: This skill defaults to a DDD-centered layout where aggregate repository interfaces live beside the aggregate in domain/. A stricter Hexagonal layout may instead put driven ports under application/ports/driven/. Pick one convention per codebase and keep the dependency rule intact.

Presentation layer: Driver adapters (REST/gRPC/CLI) live under infrastructure/ in this default layout. Some codebases lift them into a fourth top-level presentation/ layer instead (references/LAYERS.md shows that variant). Use one home for controllers, not both.

Event publishing: Saving an aggregate and then publishing its events to a broker are two writes; a crash between them silently drops events. When events must reach other services reliably, write them to an outbox table in the same transaction as the aggregate — see the outbox pattern in references/CQRS-EVENTS.md.

DDD Building Blocks

PatternPurposeLayerKey Rule
EntityIdentity + behaviorDomainEquality by ID
Value ObjectImmutable dataDomainEquality by value, no setters
AggregateConsistency boundaryDomainOnly root is referenced externally
Domain EventRecord of changeDomainPast tense naming (OrderPlaced)
RepositoryPersistence abstractionDomain (port)Per aggregate, not per table
Domain ServiceStateless logicDomainWhen logic doesn't fit an entity
Application ServiceOrchestrationApplicationCoordinates domain + infra

Anti-Patterns (CRITICAL)

Anti-PatternProblemFix
Anemic Domain ModelEntities are data bags, logic in servicesMove behavior INTO entities
Repository per EntityBreaks aggregate boundariesOne repository per AGGREGATE
Leaking InfrastructureDomain imports DB/HTTP libsDomain has ZERO external deps
God AggregateToo many entities, slow transactionsSplit into smaller aggregates
Skipping Use CasesControllers call repositories directly in a use-case architectureRoute through application use cases
CRUD ThinkingModeling data, not behaviorModel business operations
Premature CQRSAdding complexity before neededStart with simple read/write, evolve
Cross-Aggregate TXMultiple aggregates in one transactionUse domain events for consistency

Implementation Order

  1. Discover the Domain — Event Storming, conversations with domain experts
  2. Model the Domain — Entities, value objects, aggregates (no infra)
  3. Define Ports — Repository interfaces, external service interfaces
  4. Implement Use Cases — Application services coordinating domain
  5. Add Adapters last — HTTP, database, messaging implementations

DDD is collaborative. Modeling sessions with domain experts are as important as the code patterns.

Reference Documentation

Read the matching file before doing the task in the left column:

Before you...Read
Write code in any layer, wire dependency injection, or decide 3-layer vs 4-layerreferences/LAYERS.md
Split a system into services/contexts, integrate with a legacy or third-party system (ACL), run Event Stormingreferences/DDD-STRATEGIC.md
Model an entity, value object, aggregate, repository, domain service, or factoryreferences/DDD-TACTICAL.md
Define ports/adapters, name interfaces, or lay out a ports-first structurereferences/HEXAGONAL.md
Add commands/queries, domain vs integration events, outbox, sagas, or evaluate CQRS/Event Sourcingreferences/CQRS-EVENTS.md
Write unit/integration/architecture tests for any layerreferences/TESTING.md
Answer a quick "which pattern/which layer" question without deep-divingreferences/CHEATSHEET.md

Sources

Primary Sources

Primary Pattern References

Implementation Guides

Supplemental Syntheses

Frequently asked questions

What to verify before installation and use

What does the clean-ddd-hexagonal source document cover?

Backend architecture combining DDD tactical patterns, Clean Architecture dependency rules, and Hexagonal ports/adapters for maintainable, testable systems.

How do I install clean-ddd-hexagonal?

The source record exposes this install command: npx skills add https://github.com/ccheney/robust-skills --skill "skills/clean-ddd-hexagonal". Inspect the command and pinned source before running it.

Which permission-related actions were detected?

Static rules flagged read-files in the source; the page lists the matching lines and excerpts.

Alternatives

Compare before choosing

Computed 10045,511

coreyhaines31/marketingskills

ab-testing

When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program

Computed 10029,034

garrytan/gbrain

bulk-ingestion

End-to-end discipline for turning any large data source (audio libraries, email takeouts, document corpora, chat exports, API dumps) into brain pages at scale. The lifecycle spine: SCHEMA → ACCESS → TRIAL → EVALUATE → IMPROVE → CODIFY → TEST → SKILLIFY → BULK → MONITOR. State is tracked in a durable JSON manifest (see MANIFEST-PATTERN.md) so any crash, session boundary, or subagent fan-out resumes from ground truth instead of memory.

Computed 10024,921

alirezarezvani/claude-skills

app-store-optimization

App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist

Computed 1005,241

dotnet/skills

migrate-vstest-to-mtp

Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing