本文へスキップ
Skillpedia
APIとサーバー(バックエンド)7.1k · #13512

tactical-ddd

できること

このスキルは、欠けている、または散らばったビジネスルールを探すため、ソフトウェアのモデルをAIがレビューし、ルールがオブジェクトの中にあるようにリファクタリングします。ドメインのコードに、自分のルールを守らせたい開発者向けです。

使う場面

  • ✓ドメインモデルの弱い設計をレビューまたは確認するようAIに頼むとき。
  • ✓ドメインのオブジェクトが単なるデータの入れ物で、ルールが他のサービスにあるとき。
  • ✓コードをエンティティ、値オブジェクト、集約にリファクタリングしたいとき。

スキルのリンク

https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/tactical-ddd/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/tactical-ddd/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私たちの注文と請求書のクラスを確認し、それらが単なるデータの入れ物かどうか、そしてどうすべきかを教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

AIは、まず弱いモデルを検出して点数を付け、次に各クラスにどの設計要素が合うかを決め、あなたが頼めば、ステップごとにリファクタリングします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Tactical DDD — Rich Domain Modeling

Workflow

Determine the user's intent first:

Intent Phases to run
"validate / review / check / is this correct?" Phase 1 + 2 only → report findings, ask before refactoring
"fix / refactor / improve / clean up" Phase 1 + 2 + 3
"how should I design / model this?" Load reference.md directly

Phase 1 — Detect

Load detection.md and scan the target code for anemia signals. Produce a severity score and list of affected classes.

Phase 2 — Assess

For each affected class, determine the correct building block:

Has unique identity tracked over time? Has invariants tying multiple objects? → Building Block
Yes — Entity
No — Value Object
Yes (root) + children with shared invariants Yes Aggregate
Operation spans multiple Aggregates/doesn't belong to any — Domain Service

Prefer Value Objects over Entities. Prefer small Aggregates over large ones.

If intent was validate/review: stop here. Report findings using the output format below. Ask "Would you like me to apply these fixes?" before proceeding.

Phase 3 — Refactor

Load refactoring.md for step-by-step moves. Apply in this order:

  1. Replace setter chains with a single expressive method
  2. Move service logic into the Aggregate that owns it
  3. Add business guards at the top of each method
  4. Publish a Domain Event after each successful state change
  5. Replace primitive types with Value Objects

For deep pattern questions (boundary design, event modeling, service vs. entity decision), load reference.md.


Quick Anemia Signals (scan first)

public setX() / public setY()        → behaviour should be encapsulated
service.doX(entity, ...)              → logic likely belongs in entity
entity.setA(); entity.setB(); ...     → setter chain = missing intent method
no domain methods beyond getters      → pure data bag

Golden Rules

  1. Behaviour with data — Objects own both state and the operations that change it
  2. Ubiquitous Language — Method names come from the domain, not CRUD (commitTo, not setStatus)
  3. Small Aggregates — Root + Value Objects by default; add child Entities only for true invariants
  4. One transaction = one Aggregate — Cross-Aggregate rules use eventual consistency via Domain Events
  5. Reference by ID — Never hold object references to other Aggregates
  6. Value Objects first — Use Entities only when individual identity is essential
  7. Domain Services sparingly — Excessive services → anemic model
  8. Protect invariants — The Aggregate is the last line of defence; never trust the caller

Output Format

When reviewing code, report:

## Anemia Diagnosis: <ClassName>

Severity: [None | Mild | Moderate | Severe]

Issues:
- <description of problem>

Recommended refactoring:
- <specific move from refactoring.md>

When refactoring, show a before/after diff for each class touched.

よくある質問

頼んでいないのにコードを変えますか?

いいえ。レビューを頼むと、AIは所見を報告し、変更の前に待ちます。

貧血モデルとは何ですか?

データを保持するだけで、ビジネスルールは別の場所に置かれたクラスのことです。

値オブジェクトとは何ですか?

お金の額や住所など、独自の同一性を持たない小さなオブジェクトです。

詳細

作者による元の説明

Detects anemic domain models, validates and refactors them into rich domain models, and enforces tactical DDD patterns (Entities, Value Objects, Aggregates, Domain Services, Domain Events). Use when the user asks to validate, review, or check domain models or DDD code; detect anemia; refactor domain objects; improve encapsulation; or mentions terms like "anemic model", "rich domain", "aggregate", "value object", "domain event", "ubiquitous language", "is this good DDD", "does this follow DDD", or "check my domain". Do NOT use for module or service boundary design, architectural decomposition,

repo: tech-leads-club/agent-skills

人気

GitHubのスター
7.1k
ランキング
#13512
ライセンス
—
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル