0124-architecture-patterns

Structure backend code around Clean Architecture, Hexagonal Architecture, and DDD boundaries.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0124-architecture-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0124-architecture-patterns
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0124-architecture-patterns
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0124-architecture-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves tangled dependencies and hard-to-test backend code by providing proven backend architecture patterns that enforce clear boundaries between domain logic, application workflows, and infrastructure concerns.

Core Features & Use Cases

  • Clean Architecture: Separate Entities (domain), Use Cases (application rules), Interface Adapters (translation), and Framework/Drivers (DB, UI, external services) with inward-only dependencies.
  • Hexagonal Architecture: Model the system around ports and adapters so the domain core stays framework-free while infrastructure implementations can be swapped freely.
  • Domain-Driven Design (DDD): Establish bounded contexts plus tactical modeling (entities, value objects, aggregates, repositories, domain events) to keep models coherent and resilient.
  • Testing & Troubleshooting: Enable unit tests without a running database by injecting abstract ports and using in-memory adapters; resolve dependency cycles by enforcing imports that flow inward only.

Quick Start

Ask the AI to refactor your service into Clean/Hexagonal layers by defining domain entities and ports first, then building use cases, and finally wiring adapters (controllers and infrastructure) through dependency injection, while adding an in-memory test repository to keep use-case tests database-free.

Frequently Asked Questions about 0124-architecture-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure backend code using clean architecture and hexagonal architecture?

Clean architecture structures backend code by separating domain logic, use cases, and infrastructure into layers with inward-only dependencies. Hexagonal architecture models the system around ports and adapters so the domain core stays framework-free while infrastructure implementations can be swapped freely.

Why does my backend architecture have dependency cycles between controllers, use cases, and domain?

Dependency cycles occur when code violates inward dependency rules by allowing outer layers to be imported by inner layers. You can resolve these cycles by enforcing imports that flow inward only, ensuring controllers and infrastructure depend on use cases rather than the reverse.

What is the best way to unit test use cases without a running database?

The best way to unit test use cases without a running database is by defining abstract ports for infrastructure access and injecting in-memory adapters. This approach keeps use-case tests database-free while verifying application workflows.

How do I refactor a monolith into bounded contexts using domain-driven design?

Refactoring a monolith into bounded contexts using domain-driven design involves establishing tactical modeling with entities, value objects, aggregates, and repositories. This keeps models coherent and resilient while defining clear boundaries between domain logic and application workflows.

Can I implement ports and adapters when designing a new microservice?

Yes, you can implement ports and adapters when designing a new microservice by modeling the system around hexagonal architecture. This keeps the domain core framework-free while abstract interfaces allow infrastructure implementations to be swapped freely.

When do I need domain-driven design invariants like value objects and aggregates?

You need domain-driven design invariants like value objects and aggregates when modeling complex domain logic to keep models coherent and resilient. These tactical patterns enforce business rules within bounded contexts while preventing tightly coupled, hard-to-test backend layers.