用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill ddd-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Bun runtime: HTTP server, file I/O, SQLite, test runner, package manager, bundler — all-in-one JS toolchain.
Clerk: Drop-in auth UI, Organizations, User management, JWT templates, webhooks, Next.js middleware integration.
Gelişmiş masaüstü, tarayıcı ve işletim sistemi kontrol yeteneği. Görsel (koordinat tabanlı) fare/klavye otomasyonu, DOM manipülasyonu, pencere yönetimi, gelişmiş dosya, ağ ve süreç yönetimini kapsar.
基于 SOC 职业分类
正在显示 SKILL.md
| name | ddd-patterns |
| description | DDD Patterns: Domain logic, aggregates, value objects, bounded contexts, domain events. |
| triggers | {"keywords":["domain","aggregate","entity","value object","repository","bounded context","domain event","ubiquitous language"]} |
| auto_load_when | Designing domain models or business logic |
| agent | architect |
| tools | ["Read","Write","Bash"] |
Focus: Ubiquitous language, bounded contexts, domain modeling
DDD Tactical Patterns:
├── Entities - identity, mutable
├── Value Objects - immutable, no identity
├── Aggregates - consistency boundary
├── Domain Services - stateless logic
├── Domain Events - something happened
├── Repositories - collection-like access
└── Factories - complex creation
Entity:
├── Has unique ID
├── Mutable state
├── Equality by ID
└── Example: User, Order, Product
Value Object:
├── No ID
├── Immutable
├── Equality by attributes
└── Example: Address, Money, Color
Aggregate Root:
├── Entry point for access
├── Enforces invariants
├── Controls changes
└── Example: Order (contains OrderItems)
Aggregate Rules:
├── One root per aggregate
├── Only root accessible from outside
├── Changes via root only
├── Consistency boundary
└── Transaction scope = aggregate
What is a BC:
├── Explicit boundary
├── Own domain model
├── Own ubiquitous language
└── Own team ownership
How to identify:
├── Different domain vocabularies
├── Different team responsibilities
├── Different scaling needs
└── Different DB schemas
Event structure:
├── Unique ID
├── Occurred at timestamp
├── Event type name
├── Payload (what happened)
When to use:
├── Decouple components
├── Audit trail
├── CQRS read models
└── Event sourcing
Apply DDD when:
├── Complex business domain
├── Ubiquitous language exists
├── Domain experts available
├── Long-term investment
└── Team understands patterns
Avoid when:
├── CRUD-heavy app
├── Simple domain
├── No domain expert
└── Tight timeline
Repository:
├── Collection metaphor
├── Methods: add, remove, getById
├── Query methods (find)
└── Implementation: DB or API
Interface in domain
Implementation in infrastructure
Application Service:
├── Orchestrates use cases
├── Transaction management
├── Coordinates entities
└── Thin, declarative
Domain Service:
├── Pure business logic
├── Stateless
├── Between entities
└── When logic doesn't fit entity
(End of file - 90 lines)
❌ Anemic domain model (entities are just data structs)
✅ Rich entities with behavior — User.changeEmail(), Order.place()
❌ Aggregate that spans too many entities
✅ Keep aggregates small; one transaction = one aggregate
❌ Domain events published synchronously blocking the caller
✅ Collect events in aggregate; dispatch after transaction commits
❌ Business logic in application services or controllers
✅ Logic belongs to entities and domain services
❌ Exposing aggregate internals to the outside
✅ Only aggregate root is accessible from outside; internal objects are private
| Concept | Role | Rule |
|---|---|---|
| Entity | Identity + lifecycle | Mutable; identified by ID |
| Value Object | Describe by value | Immutable; no identity |
| Aggregate | Consistency boundary | One transaction per aggregate |
| Domain Event | Side effect trigger | Immutable; past tense name |
| Repository | Persistence facade | Returns full aggregates |
| Domain Service | Stateless logic | When logic doesn't fit entity |
| Bounded Context | Linguistic boundary | Each team owns its context |