Modular DDD Architecture

VerifiedSafe

Expert guide for designing and analyzing software architecture using Domain-Driven Design (DDD) and modular architecture principles.

Sby Skills Guide Bot
DevelopmentIntermediate
7/23/2026
Claude CodeCursorWindsurfCopilotCodex
#ddd#modular-architecture#domain-modeling#bounded-contexts#codebase-analysis

Recommended for

Automated summary

Guides the design and analysis of software architecture using strategic Domain-Driven Design and modular architecture principles, operating in either design or analysis mode.

Strengths

  • Two explicit modes (design and analysis) selected from the user's stated intent
  • Language-agnostic, with naming conventions adapted per ecosystem (kebab-case, snake_case, PascalCase)
  • Ships a ready-made module layout (business/api/data/async/integration) plus a decision tree for feature folders
  • Clearly bounds itself by excluding infrastructure, database schema, and API endpoint design

Limitations

  • Relies on bundled reference files (ddd-strategic-design.md, etc.) that must be available for detailed analysis
  • Purely advisory: it generates no code and automates no cohesion checks
  • Domain identification remains a subjective reading of business vocabulary
When to use it

When you need to define bounded contexts and a module structure for a new project, or audit an existing codebase for domain boundaries and cohesion.

When not to use it

For infrastructure/DevOps work, database schema design, or API endpoint design, which the skill explicitly excludes.

Security analysis

Safe
Quality score85/100

This is a pure instructional/guidance skill about Domain-Driven Design and modular architecture. It declares no allowed-tools and contains no executable commands, no shell invocations (no curl|sh, no rm -rf), no network or credential handling, and no obfuscated payloads. It merely directs an agent to read reference files and produce architectural analyses. The text ends abruptly at 'Never a' but this appears to be truncation, not a hidden directive. No meaningful execution risk.

No concerns found

How this analysis is made

Examples

Identify domains in an existing codebase
Analyze this codebase and identify our business domains and bounded contexts. Group the entities, services and handlers by ubiquitous language, then classify each subdomain as core, supporting or generic.
Design a new module
Design the folder structure for a new Billing module in our TypeScript monolith. It has around eight services, so tell me whether to use feature folders and show me the full folder tree with the reasoning behind each decision.
Review cross-module coupling
Review how our modules communicate with each other and flag any place where one module imports another module's concrete implementation instead of an interface. Show me how to apply the Public API Provider pattern to fix it.

name: modular-ddd-architecture description: Expert guide for designing and analyzing software architecture using Domain-Driven Design (DDD) and modular architecture principles. Use when someone asks to design a new module, identify domains, analyze code cohesion, plan folder structure, define bounded contexts, create feature folders, or review architecture. Also use when someone says "analyze this codebase", "what domains do we have", "how should I structure this module", "identify bounded contexts", "create a new module", or asks about modular monolith design. Do NOT use for infrastructure/DevOps, database schema design, or API endpoint design. license: CC-BY-4.0 metadata: author: Luiz Nascimento version: 1.0.0

Modular DDD Architecture

Guide an agent to design new modules or analyze existing codebases using Domain-Driven Design (DDD) strategic principles, modular architecture, and feature folder organization. Language-agnostic.

Modes of Operation

This skill operates in two modes based on user intent:

Design Mode

Trigger: User wants to create a new module, structure a project, or organize code.

Analysis Mode

Trigger: User wants to analyze an existing codebase for domain boundaries, cohesion, or architectural issues.


Instructions

Step 1: Determine the Mode

Ask or infer from context:

  • Design Mode: "create a module", "structure this project", "how should I organize...", "add a new domain"
  • Analysis Mode: "analyze this code", "identify domains", "check cohesion", "review architecture", "what domains exist"

Step 2: Design Mode Workflow

When designing new modules or structuring a project:

  1. Identify the Domain — Determine which business domain the code belongs to. Read references/ddd-strategic-design.md for DDD theory if needed.

  2. Classify the Domain — Is it Core (competitive advantage), Supporting (essential but not differentiating), or Generic (common functionality)?

  3. Define the Module Structure — Apply the layered architecture from references/architecture-guidelines.md:

    module-name/
    ├── business/        # Business logic, services, use cases, models
    ├── api/             # REST/GraphQL/gRPC handlers, DTOs
    ├── data/            # Models, repositories, migrations
    ├── async/           # Queue producers/consumers (optional)
    └── integration/     # External service providers (optional)
    
  4. Apply Feature Folders (if module is complex) — When the module has 5+ services, use vertical slices. Read references/feature-folders-guidelines.md for the decision tree and rules:

    • Each feature folder is JUST a folder (not a separate module/deployment unit)
    • Single module definition registers ALL components
    • Use shared/ only for code used by 3+ features
  5. Define Cross-Module Communication — Use the Public API Provider pattern from references/modular-architecture-principles.md:

    • Define interfaces in shared location
    • Implement in the owning module
    • Inject interfaces, never concrete implementations across modules
  6. Apply Naming Conventions — Choose consistent naming based on language:

    • kebab-case (JavaScript/TypeScript/Ruby)
    • snake_case (Python/Go)
    • PascalCase (Java/C#)
  7. Present the Structure — Show the complete folder tree with explanations for each decision.

Step 3: Analysis Mode Workflow

When analyzing an existing codebase:

  1. Extract Concepts — Scan for entities, services, use cases, and controllers/handlers. Read references/domain-identification-guidelines.md for the full methodology.

  2. Group by Ubiquitous Language — Cluster concepts by business vocabulary (e.g., subscription/plan/invoice = Billing, movie/video/episode = Content).

  3. Identify Domains and Subdomains — Map clusters to domains. Classify each subdomain as Core, Supporting, or Generic.

  4. Measure Cohesion — Score each domain using the 4 metrics:

    • Linguistic Cohesion (0-3): Shared vocabulary
    • Usage Cohesion (0-3): Concepts used together
    • Data Cohesion (0-2): Entity relationships
    • Change Cohesion (0-2): Files changed together
    • Total: X/10 (8-10 High, 5-7 Medium, 0-4 Low)
  5. Detect Low Cohesion Issues — Check for:

    • Linguistic mismatch (different vocabularies in same module)
    • Cross-domain tight coupling (direct service imports between domains)
    • Mixed responsibilities (one service handling multiple domains)
    • Generic concepts in Core Domain
    • Unclear boundaries
  6. Generate Report — Produce:

    • Domain Map (domains, subdomains, types, cohesion scores)
    • Cohesion Matrix (cross-domain relationships)
    • Low Cohesion Issues (with prioritized recommendations)
    • Read references/domain-identification-example.md for a complete worked example.

Step 4: Validate Against Principles

For both modes, validate the architecture against the 10 Modular Architecture Principles from references/modular-architecture-principles.md:

  1. Well-Defined Boundaries — No internal details exposed
  2. Composability — Modules work independently or together
  3. Independence — No tight coupling, interface-based communication
  4. Individual Scale — Each module scales based on its needs
  5. Explicit Communication — All inter-module contracts are explicit
  6. Replaceability — Modules swappable behind interfaces
  7. Deployment Independence — No hard-coded deployment assumptions
  8. State Isolation — Each module owns its database/schema
  9. Testability — Each module testable in isolation
  10. Simplicity — Minimum complexity for current needs

Key Architectural Rules

These rules apply universally regardless of mode:

  1. Domain-based organization, not technical layers — Organize by billing/, content/, identity/, NOT by controllers/, services/, models/.

  2. Business logic independent of frameworks — The business layer has no framework imports.

  3. Repository Pattern for all data access — Never access the database directly from services.

  4. Lean Controllers/Handlers — Handlers only handle request/response, delegate to services or use cases.

  5. Use Cases are optional — Only for complex orchestration across multiple services. Simple operations use services directly.

  6. Cross-module communication via interfaces — Never import another module's internal services. Use the Public API Provider pattern.

  7. Feature Folders are just folders — NOT separate deployment units. One module definition per domain.

  8. shared/ requires 3+ consumers — Don't prematurely abstract. Wait for a 3rd usage before moving to shared.

  9. State isolation — Each module owns its database schema. No shared tables between modules.

  10. Evolutionary design — Start modular monolith, extract microservices only when proven necessary.


Reference Files

Load these on demand based on what the task requires:

| File | When to Load | |------|-------------| | references/architecture-guidelines.md | When designing module structure, layers, naming conventions, or folder organization | | references/modular-architecture-principles.md | When validating architecture, defining cross-module communication, or checking principles | | references/feature-folders-guidelines.md | When a module is complex (5+ services) and needs vertical slice organization | | references/ddd-strategic-design.md | When identifying domains, defining bounded contexts, or understanding DDD theory | | references/domain-identification-guidelines.md | When analyzing an existing codebase for domain boundaries and cohesion | | references/domain-identification-example.md | When you need a complete worked example of domain analysis |


Examples

Example 1: Design a New Module

User says: "I need to create a notifications module"

Actions:

  1. Classify: Notifications is typically a Generic/Supporting subdomain
  2. Design the structure:
    notifications/
    ├── module-definition.*
    ├── business/
    │   ├── services/
    │   │   └── notification-service.*
    │   ├── models/
    │   │   └── notification.*
    │   └── enums/
    │       └── notification-channel-enum.*
    ├── api/
    │   └── rest/
    │       └── handlers/
    │           └── notification-handler.*
    ├── data/
    │   ├── models/
    │   │   └── notification.*
    │   └── repositories/
    │       └── notification-repository.*
    └── integration/
        └── providers/
            ├── email-provider.*
            └── sms-provider.*
    
  3. Define public API interface for other modules to send notifications
  4. No feature folders needed (simple module)

Example 2: Analyze a Codebase

User says: "Analyze this codebase and identify the domains"

Actions:

  1. Scan the codebase for entities, services, use cases, handlers
  2. Group by business vocabulary
  3. Produce domain map with cohesion scores
  4. Identify cross-domain coupling issues
  5. Recommend improvements with priority levels

Example 3: Restructure with Feature Folders

User says: "My billing module has 12 services, how do I organize it?"

Actions:

  1. Read references/feature-folders-guidelines.md
  2. Apply decision tree to each service
  3. Group into features: subscription/, invoice/, credit/, payment/
  4. Move shared utilities to billing/shared/
  5. Keep SINGLE module definition registering all components

Troubleshooting

Problem: Circular dependencies between modules

Cause: Direct service imports between modules instead of interfaces. Solution: Use Public API Provider pattern. Define interface in shared, implement in owning module.

Problem: Unclear which domain a concept belongs to

Cause: The concept may span multiple domains or the boundary is wrong. Solution: Check the Ubiquitous Language — which domain's vocabulary does it use? If ambiguous, it may need to be split or placed at a domain boundary with clear ownership.

Problem: Module too large and hard to navigate

Cause: Domain has grown without internal organization. Solution: Apply Feature Folders (vertical slices) within the module. NOT separate modules — just folders for organization.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/modular-ddd-architecture-mrx3xy8n' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/modular-ddd-architecture-mrx3xy8n/download' --output '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md.part' && mv '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md.part' '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.claude/skills/modular-ddd-architecture'

Cursor
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.cursor/skills/modular-ddd-architecture'

Codex
test -f '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && test -s '.skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/modular-ddd-architecture' && cp -R '.skill-downloads/modular-ddd-architecture-mrx3xy8n' '.agents/skills/modular-ddd-architecture'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/modular-ddd-architecture-mrx3xy8n'

openskills read 'modular-ddd-architecture-mrx3xy8n'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/modular-ddd-architecture-mrx3xy8n/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills