Logo di Architecture Domain Driven Design

Architecture Domain Driven Design

Community
j4flmao
architecture-domain-driven-design

Use this skill when the user says 'DDD', 'domain-driven design', 'bounded context', 'aggregate', 'aggregate root', 'ubiquitous language', 'context map', 'anti-corruption layer', 'event storming', 'value object'. Applies strategic DDD (subdomains, bounded contexts, context maps) and tactical DDD (aggregates, entities, value objects, domain events, repositories) to model complex business logic. Do NOT use for: simple CRUD apps where DDD adds ceremony, service decomposition mechanics (architecture/system-design/microservices-patterns), or layering/folder structure only (backend/universal/clean-architecture).

Panoramica

Pubblicato daj4flmao
Repositoryagent-skills
Nome della skillarchitecture-domain-driven-design
Stelle
41
Fork
6
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da j4flmao su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Architecture Domain Driven Design in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/system-design/domain-driven-design
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/architecture/system-design/domain-driven-design .claude/skills/architecture-domain-driven-design
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Architecture Domain Driven Design in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Architecture Domain Driven Design non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Architecture Domain Driven Design non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Domain-Driven Design

Purpose

DDD aligns software structure with the business: a shared language inside explicit boundaries, models that enforce business invariants, and deliberate translation where contexts meet. Use it where domain complexity is the main risk (pricing, underwriting, logistics, billing). For simple CRUD, plain layered code is cheaper.

Agent Protocol

Trigger

"DDD", "bounded context", "aggregate", "aggregate root", "entity vs value object", "domain event", "context map", "anti-corruption layer", "ubiquitous language", "event storming".

Input Context

  • Business capabilities and processes; domain experts' vocabulary.
  • Current pain: tangled models, inconsistent rules, overloaded terms.
  • Team structure (contexts usually map to team ownership).
  • Persistence and integration constraints.

Output Artifact

Strategic map (subdomains, contexts, relationships) and/or tactical model (aggregates with invariants, value objects, events, repository interfaces).

Response Format

Subdomains: {core|supporting|generic}: {name}
Contexts: {name} owns {terms}; team {x}
Context map: {upstream} -> {downstream} [{pattern}]
Aggregate: {Root} invariants: {list}; references others by id
Events: {PastTenseName}(fields)

Completion Criteria

  • Each term defined per context (no global "User"/"Product" model).
  • Every aggregate lists the invariants it protects.
  • One aggregate modified per transaction; others updated via events.
  • Context relationships named with a context-map pattern.

Strategic Design

Subdomains: core (competitive advantage: invest, custom build), supporting (needed, specific: build simply), generic (commodity: buy/SaaS, e.g. auth, payments).

Bounded context: a boundary within which a model and its language are consistent. "Product" in Catalog (description, images), Inventory (SKU, quantity, location), and Pricing (price lists, discounts) are different models that share an identifier.

Context map patterns

PatternRelationship
PartnershipTwo teams coordinate releases jointly
Shared KernelSmall shared model owned by both (keep tiny)
Customer/SupplierDownstream needs influence upstream's roadmap
ConformistDownstream adopts upstream model as-is
Anti-Corruption Layer (ACL)Downstream translates upstream model into its own terms
Open Host Service + Published LanguageUpstream offers a stable, documented API/schema for many consumers
Separate WaysNo integration; duplicate where cheaper

Event Storming (Brandolini): domain experts and engineers place domain events (orange) on a timeline, then commands, actors, policies, and aggregates; clusters suggest context boundaries.

Tactical Design

Building blockIdentityMutabilityExample
EntityHas id; equality by idMutable via methodsOrder
Value objectNo id; equality by valueImmutableMoney, Address, DateRange
AggregateCluster with one root; consistency boundaryChanged only through rootOrder + OrderLine
Domain eventImmutable factImmutableOrderPlaced
RepositoryLoads/saves whole aggregatesn/aOrderRepository
Domain serviceLogic not belonging to one entityStatelessPricingService

Aggregate rules (Vernon)

  1. Protect true invariants inside the boundary.
  2. Design small aggregates.
  3. Reference other aggregates by identity only.
  4. Use eventual consistency (domain events) outside the boundary; modify one aggregate per transaction.

Example (TypeScript)

typescript
export class Money {
  private constructor(readonly cents: number, readonly currency: string) {}
  static of(cents: number, currency: string): Money {
    if (!Number.isInteger(cents) || cents < 0) throw new RangeError(`invalid amount: ${cents}`);
    return new Money(cents, currency);
  }
  add(other: Money): Money {
    if (other.currency !== this.currency) {
      throw new Error(`currency mismatch: ${this.currency} vs ${other.currency}`);
    }
    return new Money(this.cents + other.cents, this.currency);
  }
}

type OrderStatus = "draft" | "placed" | "cancelled";
export type OrderEvent =
  | { type: "OrderPlaced"; orderId: string; customerId: string; totalCents: number; at: Date };

interface OrderLine { readonly sku: string; readonly qty: number; readonly unitPrice: Money }

export class Order {
  private lines: OrderLine[] = [];
  private status: OrderStatus = "draft";
  private pending: OrderEvent[] = [];

  constructor(readonly id: string, readonly customerId: string, private readonly currency: string) {}

  addLine(sku: string, qty: number, unitPrice: Money): void {
    if (this.status !== "draft") throw new Error(`order ${this.id} is ${this.status}; cannot add lines`);
    if (qty <= 0) throw new RangeError(`qty must be positive, got ${qty}`);
    if (unitPrice.currency !== this.currency) throw new Error("line currency differs from order");
    if (this.lines.length >= 100) throw new Error("max 100 lines per order");   // invariant
    this.lines.push({ sku, qty, unitPrice });
  }

  total(): Money {
    return this.lines.reduce((sum, l) => sum.add(Money.of(l.unitPrice.cents * l.qty, this.currency)),
                             Money.of(0, this.currency));
  }

  place(now: Date): void {
    if (this.status !== "draft") throw new Error(`order ${this.id} already ${this.status}`);
    if (this.lines.length === 0) throw new Error("cannot place an empty order");
    this.status = "placed";
    this.pending.push({ type: "OrderPlaced", orderId: this.id, customerId: this.customerId,
                        totalCents: this.total().cents, at: now });
  }

  pullEvents(): OrderEvent[] {
    const events = this.pending;
    this.pending = [];
    return events;
  }
}

export interface OrderRepository {
  get(id: string): Promise<Order>;
  save(order: Order): Promise<void>;   // persists state + pulled events (outbox) in one transaction
}

Application service: load aggregate → call one method → save (state + events via outbox) in one transaction. Other contexts (Inventory, Billing) react to OrderPlaced asynchronously, translating through their own ACL.

Anti-Corruption Layer

typescript
// Shipping context translating a legacy ERP customer into its own model
export function toRecipient(erp: { CUST_NM: string; ADDR1: string; CNTRY_CD: string }): Recipient {
  if (!erp.ADDR1) throw new Error(`ERP customer ${erp.CUST_NM} has no address`);
  return { name: erp.CUST_NM.trim(), street: erp.ADDR1.trim(), country: mapCountry(erp.CNTRY_CD) };
}

The ACL keeps upstream naming, quirks, and changes from leaking into the downstream model.

Anti-Patterns

  • Anemic domain model: entities as property bags, rules spread through services.
  • Giant aggregates (Customer containing all orders): lock contention and slow loads.
  • One enterprise-wide model for core concepts.
  • Repositories per table instead of per aggregate.
  • DDD ceremony on CRUD subdomains.
  • Bounded contexts that ignore team boundaries (Conway's law will win).

Checklist

  • Subdomains classified; investment matches type.
  • Bounded contexts with glossary and owning team.
  • Context map with explicit patterns; ACL where upstream model is foreign.
  • Aggregates small, invariants listed and enforced in methods.
  • Value objects immutable with validation.
  • Domain events published via outbox; consumers idempotent.
  • Unit tests on aggregates without infrastructure.

References

  • Evans, "Domain-Driven Design" (2003); Vernon, "Implementing Domain-Driven Design" (2013) and "Effective Aggregate Design" essays.
  • Brandolini, "Introducing EventStorming"; Khononov, "Learning Domain-Driven Design" (2021).

Domande frequenti

Cosa fa la skill IA Architecture Domain Driven Design?

Use this skill when the user says 'DDD', 'domain-driven design', 'bounded context', 'aggregate', 'aggregate root', 'ubiquitous language', 'context map', 'anti-corruption layer', 'event storming', 'value object'. Applies strategic DDD (subdomains, bounded contexts, context maps) and tactical DDD (aggregates, entities, value objects, domain events, repositories) to model complex business logic. Do NOT use for: simple CRUD apps where DDD adds ceremony, service decomposition mechanics (architecture/system-design/microservices-patterns), or layering/folder structure only (backend/universal/clean...

Perché usare Architecture Domain Driven Design su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Architecture Domain Driven Design è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Architecture Domain Driven Design in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/system-design/domain-driven-design. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Architecture Domain Driven Design?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Architecture Domain Driven Design?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Architecture Domain Driven Design: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Architecture Domain Driven Design è gratuita?

Sì. È pubblicata su GitHub da j4flmao con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇