跳到正文
cccskills
免费在 GitHub 公开

ddd

Strategic DDD guide for this project. Use to split the domain into bounded contexts, define ubiquitous language, create new business modules, or analyze context boundaries. Tactical patterns follow Clean Architecture (see architecture skill).

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md5.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Domain-Driven Design - Strategic Guide

Persona

Read .claude/roles/architect.md — adopt this profile and follow all its rules.

Activation

This skill activates for high-level domain decisions:

  • Splitting into Bounded Contexts
  • Defining the Ubiquitous Language
  • Creating a new business module
  • Analyzing relationships between contexts

Important clarification

Clean Architecture definitions take precedence over DDD tactical definitions.

We use DDD only at the strategic level (domain splitting, language). Tactical patterns (Entities, Use Cases, Gateways, Presenters) follow Clean Architecture.

What we take from DDDWhat we do NOT take
Bounded ContextsAggregates
Ubiquitous LanguageRepositories (we have Gateways)
Context MappingDomain Events
Module splittingComplex Value Objects

Bounded Context

"A Bounded Context delimits the applicability of a particular model." — Eric Evans

A Bounded Context = a module in modules/<context-name>/

Each BC is an autonomous package with its own public API.

Identifying a Bounded Context

Signs that a new BC is needed:

  • The same term has different meanings depending on context
  • A different team could manage this part
  • The model is becoming too complex
  • Business rules are diverging

ReviewFlow example:

Bounded ContextResponsibility
reviewCode review orchestration and result handling
trackingMR/PR assignment tracking and follow-up
webhookInbound webhook processing (GitLab/GitHub)
mcpModel Context Protocol server and tools
dashboardReview statistics and visualization
securitySecret detection and access control

Communication between Bounded Contexts

BCs communicate via their public APIs, like two independent packages.

// modules/tracking/index.ts (public API)
export { TrackAssignmentUseCase } from "./application/usecases/trackAssignment.usecase"
export { createTrackedMr } from "./domain/factories/trackedMrFactory"
export type { TrackingGateway } from "./application/ports/gateways/trackingGateway"

// modules/review/ imports from the public API
import { TrackAssignmentUseCase } from "@/modules/tracking"

Communication rules

AllowedForbidden
Import from another BC's index.tsDirectly import an internal file
Pass data (DTO, primitives)Share mutable entities
Call an exposed Use CaseAccess internal state

Concrete example

// modules/review/application/usecases/triggerReview.usecase.ts
import { TrackAssignmentUseCase } from "@/modules/tracking"  // Public API

export const triggerReview = async (data) => {
  const trackAssignment = new TrackAssignmentUseCase(trackingGateway);
  // ...
}
// FORBIDDEN - internal import
import { parseTrackingData } from "@/modules/tracking/domain/validators/trackingValidator"

Ubiquitous Language

"Use the model as the backbone of a language." — Eric Evans

Business vocabulary must be:

  • Consistent: same term = same concept within a given context
  • Explicit: no ambiguity
  • Shared: understood by devs AND business stakeholders

In code

// Ubiquitous Language respected
class ReviewContext { ... }
class TrackedMr { ... }
function triggerReview() { ... }
function trackAssignment() { ... }

// Technical or ambiguous vocabulary
class Data { ... }           // "Data" is not a business term
class ReviewRequest { }      // "Request" vs "ReviewContext"?
function doReview() { }      // "do" vs "trigger"?

Language documentation

Each BC maintains its glossary in /docs/business/glossary/<context>.md

# Glossary - Review

| Term | Definition |
|------|------------|
| ReviewContext | The full context for a code review (diff, MR metadata, threads) |
| TrackedMr | A merge request being tracked for review assignments |
| ReviewAction | An action to perform on the platform (comment, resolve, reply) |
| DiffMetadata | Parsed metadata from a merge request diff |

Workflow: Creating a new Bounded Context

Step 1: Identify the domain

DDD - Identification

New domain identified: [name]

Questions to validate:
1. What business problem does it solve?
2. What are the specific terms?
3. What are the main entities?
4. Which existing BCs will use it?

Shall we explore these questions?

Step 2: Define the language

DDD - Ubiquitous Language

Proposed glossary for [context]:

| Term | Definition |
|------|------------|
| ... | ... |

Are these terms aligned with the business vocabulary?

Step 3: Define the public API

DDD - Public API

Planned exports for [context]:

Entities: [list]
Use Cases: [list]
Types: [list]

Which other BCs will consume this API?

Step 4: Create the structure

DDD - Structure

I will create:
modules/[context]/
├── index.ts           # Public API
├── entities/
├── use-cases/
├── interface-adapters/
└── testing/

+ Glossary: docs/business/glossary/[context].md

Shall we create this structure?

After validation -> Switch to the Architecture skill for tactical details.


Anti-patterns to avoid

  • A single catch-all "domain" module
  • Mixing vocabulary from multiple contexts
  • Circular dependencies between contexts
  • Importing internal files from another BC
  • Naming modules by technical aspect ("services", "models")

References

  • Domain-Driven Design (Eric Evans, 2003) - Chapters 1-4 (strategic)
  • For tactical patterns -> see architecture skill (Clean Architecture)

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Guide for creating optimized Claude Code agents. Use to design a new specialized agent, a swarm sub-agent, or a multi-agent workflow. Follows the Skill → Agent (preloaded skills) → Skill orchestration pattern.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

Anti-overengineering guide based on YAGNI. Use before adding an architectural pattern, during code review, or to challenge an overly complex implementation.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

Clean Architecture (Uncle Bob) guide for this project. Use when creating modules, entities, use cases, presenters, controllers, gateways, guards, services. Contains tactical patterns and structure conventions.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

Audit documentation for duplication, staleness, language issues, and verbosity. Read-only — produces an actionable report.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

Local auto-review of modified code (no GitLab/GitHub). Runs 5 sequential audits and generates a local report. Ideal for validating code before creating a MR/PR.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

Clean Code (Robert C. Martin) guide to produce and challenge code that is readable, durable, simple, and consistent. Covers naming, functions, comments, smells, and refactor heuristics. Complements `/solid` (SOLID principles) and `/anti-overengineering` (YAGNI/KISS). Activate during the REFACTOR phase of the TDD cycle and during implementation self-review.

中文简介正在准备中。当前显示原文说明。

DGouron/review-flow442026年10月18日 更新

查看 DGouron 的全部技能

报告此技能的问题