layered-architecture-design

Define layered architecture responsibilities with enforceable dependency direction rules.

4|Updated May 16, 2026
One-click install
npx skills add https://github.com/machenjie/rd-skills --skill layered-architecture-design-machenjie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: layered-architecture-design
Source: https://github.com/machenjie/rd-skills/tree/main/src/foundation/capabilities/layered-architecture-design
Command: npx skills add https://github.com/machenjie/rd-skills --skill layered-architecture-design-machenjie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill prevents business logic from being accidentally misplaced across controllers, application services, and infrastructure, which otherwise leads to untestable code, leaky dependencies, and inconsistent behavior across delivery mechanisms.

Core Features & Use Cases

  • Define enforceable responsibilities across presentation, application, domain, and infrastructure so each layer owns what it should and rejects what it must not.
  • Codify dependency direction rules (domain inward, never domain→infrastructure) to ensure architecture remains stable even as frameworks and storage technologies change.
  • Specify transaction, validation, and exception boundaries so invariants live in the domain, transactions are orchestrated in the application layer, and infrastructure errors are mapped at the adapter boundary.

Real-world use case: while reviewing a change that adds a new route, handler, repository, or external adapter, apply these rules to move business decisions into domain or application orchestration correctly and to isolate persistence details behind domain ports.

Quick Start

Ask an AI to generate a layered architecture plan for your feature by mapping each new class or file to Presentation, Application, Domain, or Infrastructure and by producing a dependency, transaction, and exception-mapping checklist that matches the non-negotiable rules.

Frequently Asked Questions about layered-architecture-design

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

FAQPage Schema
How do I enforce clean architecture and prevent business logic from leaking into controllers or infrastructure?

Clean architecture is enforced by defining explicit responsibilities across presentation, application, domain, and infrastructure layers, ensuring domain logic never imports infrastructure dependencies.

Where should transaction boundaries and exception mapping be handled in a layered architecture?

In a layered architecture, transaction boundaries are orchestrated within the application layer, while infrastructure-specific errors are mapped to domain exceptions at the adapter boundary.

How do I structure domain invariants and repository ports when adding new cross-layer workflows?

Domain invariants should reside strictly within the domain layer, while repository ports are defined by the domain and implemented by infrastructure adapters to isolate persistence details.

What is the best way to review code for dependency inversion and correct layering in domain-driven design?

Review code by mapping each class to presentation, application, domain, or infrastructure, then verifying that thin controllers orchestrate application services without leaking domain invariants or infrastructure imports.

Can I use CI-enforced dependency checks to maintain strict layering in my software architecture?

Yes, CI-enforced dependency checks validate that dependency directions point inward toward the domain, automatically rejecting changes where domain layers incorrectly import infrastructure modules.

Why does my application orchestration logic contain leaked invariants and how do I fix it?

Application orchestration leaks invariants when business rules bypass the domain layer; fix this by moving validation and business decisions into the domain while keeping application services focused solely on orchestration.