Use when modeling Domain-Driven Design concepts in a Ruby on Rails codebase. Covers Rails-first mapping of entities, aggregates, value objects, domain services, application services, repositories, and domain events without over-engineering or fighting Rails conventions.
88
85%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Use this skill when the domain concepts are clear enough that the next question is how to model them in Rails.
Core principle: Model real domain pressure, not textbook DDD vocabulary.
| Concept | Rails-first default |
|---|---|
| Entity | ActiveRecord model when persisted identity matters |
| Value object | Plain Ruby object near the domain it supports |
| Aggregate root | The main entry point that guards invariants |
| Domain service | PORO for business behavior that does not belong to one entity |
| Application service | Orchestrator in app/services coordinating a use case |
| Repository | Use only for a real boundary beyond normal ActiveRecord usage |
| Domain event | Explicit object only when multiple downstream consumers justify it |
DO NOT introduce repositories, aggregates, or domain events just to sound "DDD".
DO NOT fight Rails defaults when a normal model or service expresses the domain clearly.
ALWAYS start from domain invariants, ownership, and lifecycle before choosing a pattern.generate-tasks for implementation planning, or to rails-tdd-slices once the first behavior to test is clear.rails-tdd-slices and rspec-best-practices before implementation.| Need | Prefer | Avoid by default |
|---|---|---|
| Persisted concept with identity | ActiveRecord model | Extra wrapper object with no added meaning |
| Small immutable calculation or policy value | PORO value object | Shoving all logic into helpers or primitives |
| Use-case orchestration | Application service in app/services | Fat controller or callback chains |
| Cross-entity business rule | Domain service | Picking an arbitrary model just to hold the code |
| Complex query / persistence abstraction | Repository only if boundary is real | Creating repositories for every query |
| Multi-consumer business signal | Explicit domain event | Callback-driven hidden side effects |
| Modeling choice | Typical home |
|---|---|
| Aggregate / entity | app/models/... |
| Application or domain service | app/services/... |
| Value object | app/models/... or nearby PORO location used by the repo |
| Policy / rule object | app/services/..., app/policies/..., or project convention |
| Domain event object | app/events/... or project-specific namespace if the repo already uses events |
When using this skill, return:
# Money or ReservationWindow carries behavior and invariants
# but does not need its own database identity.# Orders::CreateOrder coordinates inventory, pricing, persistence,
# and follow-up side effects for one use case.app/services/orders/create_order.rb# Bad move:
# Add repositories, command handlers, and domain events
# when a normal model + service already expresses the use case cleanly.| Mistake | Reality |
|---|---|
| Turning every concept into a service | Many behaviors belong naturally on entities or value objects |
| Creating repositories for all reads and writes | ActiveRecord already gives a strong default persistence boundary |
| Treating aggregates as folder names only | Aggregates exist to protect invariants, not to look architectural |
| Adding domain events for one local callback | Events should justify their coordination cost |
| Forgetting Rails conventions entirely | DDD should sharpen Rails design, not replace it wholesale |
| Skill | When to chain |
|---|---|
| ddd-ubiquitous-language | When the terms are not clear enough to model yet |
| ddd-boundaries-review | When the modeling problem is really a context boundary problem |
| generate-tasks | After the tactical design is clear and ready for implementation planning |
| rails-tdd-slices | When the next step is choosing the best first failing spec |
| rails-code-conventions | When validating the modeling choice against Rails simplicity and repo conventions |
ae8ea63
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.