yonatankarp/software-design-skills

ddd-aggregate

Use when designing or critiquing aggregate boundaries — phrases like "aggregate", "aggregate root", "should these be one entity or two", "consistency boundary", "transactional consistency", "this aggregate is huge", "should I reference by ID or by object".

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/yonatankarp/software-design-skills --skill ddd-aggregate

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

One-line summary

An aggregate is a cluster of entities and value objects treated as a single unit for data changes — a transactional consistency boundary with one root entity that owns it.

When to use this skill

  • Deciding which entities belong together as one unit.
  • Choosing between "one big object" and "several related objects".
  • Reference rules: "can Order hold a Customer object, or just a customerId?".
  • Performance and locking concerns that trace back to aggregate size.

When NOT to use this skill

  • Within a single entity's behavior — that is ddd-entity territory.
  • Cross-context relationships → ddd-context-mapping.
  • Eventual consistency across aggregates via events → ddd-domain-event.

Core content

An aggregate has one root entity. External code may hold a reference only to the root. Objects inside the aggregate may reference each other freely. Other aggregates are referenced only by ID, never by object reference.

Within one aggregate, invariants are enforced synchronously and transactionally. If a rule must always hold across two entities, those entities belong to the same aggregate. If the rule can lag (eventual consistency is acceptable), the entities can live in separate aggregates and coordinate through domain events.

One transaction touches one aggregate. This is the canonical rule. Loading two aggregates and modifying both in one transaction is a smell — it usually means the aggregate boundaries are wrong, or the work should be split into a command + an event-driven follow-up.

The aggregate root is the only entry point. Code outside the aggregate calls methods on the root; the root delegates to internal entities as needed. The root is responsible for ensuring the aggregate's invariants hold after every operation.

Decision heuristics

  • Prefer small aggregates over large ones. When unsure, split.
  • If two entities don't need to change in the same transaction, they belong to different aggregates.
  • If two entities share an invariant that must always hold synchronously, they belong to the same aggregate.
  • Reference other aggregates by ID only. Holding a Customer object reference inside Order forces eager loading and transactional headaches.

Anti-patterns

  • God aggregates that own half the domain model — every change loads the world, locks become contention, the database transaction balloons.
  • Cross-aggregate object references — pull half the model into memory and tangle persistence.
  • Reaching into an aggregate's internals by passing the root around and letting callers traverse its children.
  • "Repository per entity" instead of "repository per aggregate root" — exposes aggregate internals to callers.

See also

  • ddd-entity — entities are the building blocks of aggregates.
  • ddd-value-object — value objects nest freely inside aggregates.
  • ddd-repository — one repository per aggregate root.
  • ddd-domain-event — cross-aggregate consistency goes through events.
  • ddd-anti-patterns — god aggregates and cross-aggregate references.

References

  • Evans, Domain-Driven Design (2003), Ch. 6 (The Life Cycle of a Domain Object).

관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills
yonatankarp
커뮤니티

arch-adr

Use when recording an architectural decision so future maintainers know why — phrases like "ADR", "architecture decision record", "why did we pick X", "lightweight architecture documentation", "decision log", "should this be an ADR", "tribal knowledge", "we chose this two years ago and now nobody remembers why". Defines the ADR as a short, structured document capturing what was decided, why, alternatives considered, and consequences — written at the time of the decision and kept in the repo.

설치 수
2
GitHub Stars
1
업데이트
5월 19일
yonatankarp
커뮤니티

arch-fitness-functions

Use when enforcing architectural characteristics through automation — phrases like "architecture fitness function", "evolutionary architecture", "architecture tests", "ArchUnit", "dependency rules in CI", "automated architecture checks", "guardrails", "drift detection". Defines fitness functions as automated checks that verify architectural characteristics on every change, catching drift before it accumulates.

설치 수
2
GitHub Stars
1
업데이트
5월 19일
yonatankarp
커뮤니티

arch-microservices

Use when designing or reviewing a microservices architecture — phrases like "microservices", "should we split this service", "service boundaries", "bounded context per service", "API gateway", "backend for frontend", "BFF", "service mesh", "microservices vs monolith", "database per service", "data ownership". Defines microservices as independently deployable services aligned with business capabilities — and the discipline of resisting the style until the monolith proves inadequate.

설치 수
2
GitHub Stars
1
업데이트
5월 19일
yonatankarp
커뮤니티

arch-strangler-fig

Use when migrating a legacy system incrementally — phrases like "strangler fig", "strangler pattern", "incremental migration", "monolith to microservices", "rewrite without big bang", "replace legacy in place", "facade in front of the legacy system", "anticorruption layer". Defines Fowler's Strangler Fig as the migration discipline of gradually replacing legacy functionality behind a stable facade, never doing a big-bang rewrite.

설치 수
2
GitHub Stars
1
업데이트
5월 19일