DDD4j Project Creator
When to use this skill
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project, initializing ddd4j project, or setting up ddd4j-boot project.
ALWAYS use this skill when the user mentions:
- Creating a ddd4j project (explicitly mentions "ddd4j")
- Initializing ddd4j-boot project
- Setting up ddd4j project structure
- Creating ddd4j project scaffolding
- 创建 ddd4j 项目 (explicitly mentions "ddd4j")
- 初始化 ddd4j 项目 (initialize ddd4j project)
- ddd4j-boot 项目创建 (create ddd4j-boot project)
Trigger phrases include:
- "创建 ddd4j 项目" (create ddd4j project) - must include "ddd4j"
- "初始化 ddd4j 项目" (initialize ddd4j project) - must include "ddd4j"
- "创建 ddd4j-boot 项目" (create ddd4j-boot project) - must include "ddd4j"
- "使用 ddd4j 创建项目" (create project using ddd4j)
- "ddd4j 项目脚手架" (ddd4j project scaffolding)
DO NOT trigger this skill for:
- Generic DDD projects without mentioning ddd4j
- JPA/Hibernate projects
- Other ORM frameworks
- Generic project initialization without ddd4j context
- "创建 DDD 项目" without "ddd4j" (too generic)
- "初始化项目" without "ddd4j" (too generic)
About DDD4j Boot
DDD4j Boot is a Java microservice development scaffold based on Domain-Driven Design (DDD) principles. It is built with Spring Boot 3.5.x and uses lightweight ddd-4-java and cqrs-4-java libraries to implement Domain-Driven Design, Command Query Responsibility Segregation (CQRS), and Event Sourcing.
Core Design Principles
- Domain-Driven Design (DDD): Strategic design through bounded contexts, tactical design with entities, value objects, aggregates, domain services, repositories, and domain events
- Command Query Responsibility Segregation (CQRS): Separation of read and write models, independent optimization
- Event Sourcing: State changes recorded as event sequences, supporting complete history and state reconstruction
- Diamond Architecture (COLA): Adapter → Application → Domain ← Infrastructure four-layer architecture
Key Features
- Complete DDD layered architecture supporting COLA V5 pattern
- Lightweight DDD implementation based on ddd-4-java and cqrs-4-java
- Technology stack integration: Spring Boot 3.5.x, MyBatis Plus, Jackson, Guava, Swagger, SaToken
- Dual stack support: WebMVC (traditional Servlet) and WebFlux (reactive)
- Domain model base capabilities: BaseEntity, BaseRepository, BaseService
- Domain event support with built-in event publishing mechanism
- Anti-Corruption Layer (ACL) for external service integration
- Unified exception handling mechanism
Project Types Supported
1. Single-Module Monolith (单体单模块)
适用场景: 中小型应用,单个业务领域,团队规模 5-15 人
特点:
- 单一 Maven 模块
- 所有层(interfaces, application, domain, infrastructure)在同一模块内
- 适合快速开发和部署
2. Multi-Module Monolith (单体多模块)
适用场景: 中大型应用,多个业务域,团队规模 15-50 人
特点:
- 多个 Maven 模块,按业务域划分
- 每个业务域包含完整的 DDD 四层架构
- 共享 common 模块
- 统一 BOM 和依赖管理
3. Microservices (单体微服务)
适用场景: 大型电商平台,多个业务域,团队规模 50+ 人
特点:
- 每个服务独立部署
- 服务间通过 RPC 和消息队列通信
- 每个服务内部按 DDD 四层架构组织
- 独立的数据库和配置
How to use this skill
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project. Do NOT trigger for generic DDD project creation requests without ddd4j context.
For New DDD4j Project Creation
Identify the project type from user requirements:
- Single-module monolith →
single-module
- Multi-module monolith →
multi-module
- Microservices →
microservices
Load the appropriate example from the examples/ directory:
examples/single-module.md - Single-module monolith structure
examples/multi-module.md - Multi-module monolith structure
examples/microservices.md - Microservices structure
examples/architecture-patterns.md - DDD, Hexagonal, Clean, COLA V5 patterns
Collect project information:
groupId: Maven group ID (e.g., com.github.hiwepy or io.ddd4j.base)
artifactId: Maven artifact ID (e.g., ddd4j-douyin or my-ddd4j-service)
version: Project version (e.g., 1.0.0-SNAPSHOT)
parentVersion: Parent POM version (e.g., 2023.0.x.20251205-SNAPSHOT or reference to ddd4j-boot-parent)
packageBase: Base package name (e.g., io.ddd4j.douyin or com.example.service)
modules: List of business modules (for multi-module/microservices)
architecture: Architecture pattern (DDD Classic, Hexagonal, Clean, COLA V5)
ddd4jBootVersion: DDD4j Boot version (if using ddd4j-boot-bom)
Generate project structure:
- Create directory structure based on selected type
- Generate
pom.xml files (parent and modules)
- Create
package-info.java files for each module
- Generate
.gitignore, LICENSE, mvnw, mvnw.cmd
- Create basic directory structure with
src/main/java and src/test/java
Save to project directory:
- Default location: Save directly to the command execution directory (same level as the command)
- Directory creation: Automatically create the project directory structure if it doesn't exist
- File naming: Use descriptive names based on project type and module names
For Existing Project Validation
Analyze project structure:
- Scan project directory for Maven modules
- Identify layer structure (interfaces, application, domain, infrastructure)
- Check package naming conventions
- Verify directory organization
Identify project type:
- Single-module: Single
pom.xml at root, all layers in one module
- Multi-module: Parent
pom.xml with multiple modules, each module has complete layers
- Microservices: Multiple services, each with independent structure
Validate against standards:
- Check DDD layer compliance
- Verify dependency direction (interfaces → application → domain ← infrastructure)
- Validate package naming (
{basePackage}.{module}.{layer})
- Check for required directories (
src/main/java, src/test/java)
- Verify
package-info.java files exist
Generate validation report:
- List identified issues
- Provide recommendations
- Suggest fixes for non-compliant structures
Output Format and File Saving
When generating a project structure, follow this response structure:
Save the files first: Create the project structure directly in the command execution directory
- The project will be created at the same level as where the command is executed
- Generate all required files and directories (pom.xml, src/, etc.)
- Use the artifactId as the project root directory name
Inform the user: Tell them where the files were saved
Display the structure: Show the generated directory structure in a code block
Example Response Structure:
- First line: "I've created the DDD project structure and saved it to
./{artifactId}/ in the current directory."
- Then show the structure wrapped in a code block:
- Start with: three backticks +
text + newline
- Then the directory structure
- End with: three backticks + newline
Critical Requirements:
- Always save project files directly to the command execution directory (same level)
- Use artifactId as the project root directory name
- Create the directory structure automatically if it doesn't exist
- Generate complete project structure with all required files
- Follow Maven and DDD conventions strictly
Project Structure Standards
Package Naming Convention
For multi-module projects:
{basePackage}.{moduleName}.{layerName}
Examples:
io.ddd4j.douyin.api.domain - API module, domain layer
io.ddd4j.douyin.api.application - API module, application layer
io.ddd4j.douyin.api.interfaces - API module, interfaces layer
io.ddd4j.douyin.api.infrastructure - API module, infrastructure layer
Required Files
Every module must have:
pom.xml - Maven configuration
src/main/java/{package}/package-info.java - Package documentation
src/test/java/ - Test directory structure
.gitignore - Git ignore rules (at root)
LICENSE - License file (at root)
mvnw, mvnw.cmd - Maven wrapper (at root)
Layer Dependencies
Correct dependency direction:
interfaces → application → domain ← infrastructure
Rules:
- Domain layer must not depend on any other layer
- Infrastructure layer implements domain layer interfaces
- Application layer depends on domain layer
- Interfaces layer depends on application layer
Architecture Patterns
The skill supports four architecture patterns:
DDD Classic Layered Architecture (DDD 经典分层架构)
- Layers: interfaces, application, domain, infrastructure
- Reference:
docs/1、DDD 经典分层架构目录结构.md and examples/architecture-patterns.md#ddd-classic
Hexagonal Architecture (六边形架构)
- Ports and Adapters pattern
- Reference:
docs/2、六边形架构详细目录结构参考.md and examples/architecture-patterns.md#hexagonal
Clean Architecture (整洁架构)
- Entities, Use Cases, Interface Adapters
- Reference:
docs/3、整洁架构详细目录结构参考.md and examples/architecture-patterns.md#clean
COLA V5 (菱形架构)
- Adapter → App → Domain ← Infrastructure
- Reference:
docs/4、COLA V5 架构详细目录结构参考.md and examples/architecture-patterns.md#cola-v5
Validation Rules
When checking existing projects, validate:
Structure Compliance:
- ✓ Correct layer organization
- ✓ Proper module separation
- ✓ Package naming conventions
Dependency Rules:
- ✓ Domain layer has no external dependencies
- ✓ Infrastructure implements domain interfaces
- ✓ Correct dependency direction
File Organization:
- ✓ Required directories exist
- ✓
package-info.java files present
- ✓ Maven configuration correct
Naming Conventions:
- ✓ Package names follow convention
- ✓ Module names are descriptive
- ✓ Layer names are standard
Examples
See the examples/ directory for:
single-module.md - Complete single-module monolith example
multi-module.md - Complete multi-module monolith example (based on ddd4j-douyin structure)
microservices.md - Complete microservices example
architecture-patterns.md - All four architecture patterns with detailed structures
Keywords
English keywords:
ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
Chinese keywords (中文关键词):
ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
IMPORTANT: All keywords must include "ddd4j" to avoid false triggers. Generic terms like "DDD 项目" (DDD project) or "创建项目" (create project) without "ddd4j" should NOT trigger this skill.
1---2name: ddd4j-project-creator3description: A comprehensive skill for creating new ddd4j (Domain-Driven Design for Java) projects based on ddd4j-boot framework. Use ONLY when the user explicitly mentions creating a ddd4j project, initializing ddd4j project, or setting up ddd4j-boot project. Supports three project types: single-module monolith, multi-module monolith, and microservices. Generates project scaffolding based on ddd4j-boot architecture with DDD, Hexagonal Architecture, Clean Architecture, and COLA V5 patterns. Do NOT trigger for generic DDD projects, JPA/Hibernate projects, or other ORM frameworks without explicit ddd4j mention.4license: Complete terms in LICENSE.txt5---6
7# DDD4j Project Creator
8
9## When to use this skill
10
11**CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project, initializing ddd4j project, or setting up ddd4j-boot project.**
12
13**ALWAYS use this skill when the user mentions:**
14- Creating a ddd4j project (explicitly mentions "ddd4j")
15- Initializing ddd4j-boot project
16- Setting up ddd4j project structure
17- Creating ddd4j project scaffolding
18- 创建 ddd4j 项目 (explicitly mentions "ddd4j")
19- 初始化 ddd4j 项目 (initialize ddd4j project)
20- ddd4j-boot 项目创建 (create ddd4j-boot project)
21
22**Trigger phrases include:**
23- "创建 ddd4j 项目" (create ddd4j project) - **must include "ddd4j"**
24- "初始化 ddd4j 项目" (initialize ddd4j project) - **must include "ddd4j"**
25- "创建 ddd4j-boot 项目" (create ddd4j-boot project) - **must include "ddd4j"**
26- "使用 ddd4j 创建项目" (create project using ddd4j)
27- "ddd4j 项目脚手架" (ddd4j project scaffolding)
28
29**DO NOT trigger this skill for:**
30- Generic DDD projects without mentioning ddd4j
31- JPA/Hibernate projects
32- Other ORM frameworks
33- Generic project initialization without ddd4j context
34- "创建 DDD 项目" without "ddd4j" (too generic)
35- "初始化项目" without "ddd4j" (too generic)
36
37## About DDD4j Boot
38
39**DDD4j Boot** is a Java microservice development scaffold based on **Domain-Driven Design (DDD)** principles. It is built with Spring Boot 3.5.x and uses lightweight [ddd-4-java](https://github.com/fuinorg/ddd-4-java) and [cqrs-4-java](https://github.com/fuinorg/cqrs-4-java) libraries to implement Domain-Driven Design, Command Query Responsibility Segregation (CQRS), and Event Sourcing.
40
41### Core Design Principles
42
43- **Domain-Driven Design (DDD)**: Strategic design through bounded contexts, tactical design with entities, value objects, aggregates, domain services, repositories, and domain events
44- **Command Query Responsibility Segregation (CQRS)**: Separation of read and write models, independent optimization
45- **Event Sourcing**: State changes recorded as event sequences, supporting complete history and state reconstruction
46- **Diamond Architecture (COLA)**: Adapter → Application → Domain ← Infrastructure four-layer architecture
47
48### Key Features
49
50- Complete DDD layered architecture supporting COLA V5 pattern
51- Lightweight DDD implementation based on ddd-4-java and cqrs-4-java
52- Technology stack integration: Spring Boot 3.5.x, MyBatis Plus, Jackson, Guava, Swagger, SaToken
53- Dual stack support: WebMVC (traditional Servlet) and WebFlux (reactive)
54- Domain model base capabilities: BaseEntity, BaseRepository, BaseService
55- Domain event support with built-in event publishing mechanism
56- Anti-Corruption Layer (ACL) for external service integration
57- Unified exception handling mechanism
58
59## Project Types Supported
60
61### 1. Single-Module Monolith (单体单模块)
62**适用场景**: 中小型应用,单个业务领域,团队规模 5-15 人
63
64**特点**:
65- 单一 Maven 模块
66- 所有层(interfaces, application, domain, infrastructure)在同一模块内
67- 适合快速开发和部署
68
69### 2. Multi-Module Monolith (单体多模块)
70**适用场景**: 中大型应用,多个业务域,团队规模 15-50 人
71
72**特点**:
73- 多个 Maven 模块,按业务域划分
74- 每个业务域包含完整的 DDD 四层架构
75- 共享 common 模块
76- 统一 BOM 和依赖管理
77
78### 3. Microservices (单体微服务)
79**适用场景**: 大型电商平台,多个业务域,团队规模 50+ 人
80
81**特点**:
82- 每个服务独立部署
83- 服务间通过 RPC 和消息队列通信
84- 每个服务内部按 DDD 四层架构组织
85- 独立的数据库和配置
86
87## How to use this skill
88
89**CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project. Do NOT trigger for generic DDD project creation requests without ddd4j context.**
90
91### For New DDD4j Project Creation
92
931. **Identify the project type** from user requirements:
94 - Single-module monolith → `single-module`
95 - Multi-module monolith → `multi-module`
96 - Microservices → `microservices`
97
982. **Load the appropriate example** from the `examples/` directory:
99 - `examples/single-module.md` - Single-module monolith structure
100 - `examples/multi-module.md` - Multi-module monolith structure
101 - `examples/microservices.md` - Microservices structure
102 - `examples/architecture-patterns.md` - DDD, Hexagonal, Clean, COLA V5 patterns
103
1043. **Collect project information**:
105 - `groupId`: Maven group ID (e.g., `com.github.hiwepy` or `io.ddd4j.base`)
106 - `artifactId`: Maven artifact ID (e.g., `ddd4j-douyin` or `my-ddd4j-service`)
107 - `version`: Project version (e.g., `1.0.0-SNAPSHOT`)
108 - `parentVersion`: Parent POM version (e.g., `2023.0.x.20251205-SNAPSHOT` or reference to `ddd4j-boot-parent`)
109 - `packageBase`: Base package name (e.g., `io.ddd4j.douyin` or `com.example.service`)
110 - `modules`: List of business modules (for multi-module/microservices)
111 - `architecture`: Architecture pattern (DDD Classic, Hexagonal, Clean, COLA V5)
112 - `ddd4jBootVersion`: DDD4j Boot version (if using ddd4j-boot-bom)
113
1144. **Generate project structure**:
115 - Create directory structure based on selected type
116 - Generate `pom.xml` files (parent and modules)
117 - Create `package-info.java` files for each module
118 - Generate `.gitignore`, `LICENSE`, `mvnw`, `mvnw.cmd`
119 - Create basic directory structure with `src/main/java` and `src/test/java`
120
1215. **Save to project directory**:
122 - **Default location**: Save directly to the command execution directory (same level as the command)
123 - **Directory creation**: Automatically create the project directory structure if it doesn't exist
124 - **File naming**: Use descriptive names based on project type and module names
125
126### For Existing Project Validation
127
1281. **Analyze project structure**:
129 - Scan project directory for Maven modules
130 - Identify layer structure (interfaces, application, domain, infrastructure)
131 - Check package naming conventions
132 - Verify directory organization
133
1342. **Identify project type**:
135 - **Single-module**: Single `pom.xml` at root, all layers in one module
136 - **Multi-module**: Parent `pom.xml` with multiple modules, each module has complete layers
137 - **Microservices**: Multiple services, each with independent structure
138
1393. **Validate against standards**:
140 - Check DDD layer compliance
141 - Verify dependency direction (interfaces → application → domain ← infrastructure)
142 - Validate package naming (`{basePackage}.{module}.{layer}`)
143 - Check for required directories (`src/main/java`, `src/test/java`)
144 - Verify `package-info.java` files exist
145
1464. **Generate validation report**:
147 - List identified issues
148 - Provide recommendations
149 - Suggest fixes for non-compliant structures
150
151## Output Format and File Saving
152
153When generating a project structure, follow this response structure:
154
1551. **Save the files first**: Create the project structure directly in the command execution directory
156 - The project will be created at the same level as where the command is executed
157 - Generate all required files and directories (pom.xml, src/, etc.)
158 - Use the artifactId as the project root directory name
159
1602. **Inform the user**: Tell them where the files were saved
161
1623. **Display the structure**: Show the generated directory structure in a code block
163
164**Example Response Structure**:
165- First line: "I've created the DDD project structure and saved it to `./{artifactId}/` in the current directory."
166- Then show the structure wrapped in a code block:
167 - Start with: three backticks + `text` + newline
168 - Then the directory structure
169 - End with: three backticks + newline
170
171**Critical Requirements**:
172- Always save project files directly to the command execution directory (same level)
173- Use artifactId as the project root directory name
174- Create the directory structure automatically if it doesn't exist
175- Generate complete project structure with all required files
176- Follow Maven and DDD conventions strictly
177
178## Project Structure Standards
179
180### Package Naming Convention
181
182For multi-module projects:
183```
184{basePackage}.{moduleName}.{layerName}
185```
186
187Examples:
188- `io.ddd4j.douyin.api.domain` - API module, domain layer
189- `io.ddd4j.douyin.api.application` - API module, application layer
190- `io.ddd4j.douyin.api.interfaces` - API module, interfaces layer
191- `io.ddd4j.douyin.api.infrastructure` - API module, infrastructure layer
192
193### Required Files
194
195Every module must have:
196- `pom.xml` - Maven configuration
197- `src/main/java/{package}/package-info.java` - Package documentation
198- `src/test/java/` - Test directory structure
199- `.gitignore` - Git ignore rules (at root)
200- `LICENSE` - License file (at root)
201- `mvnw`, `mvnw.cmd` - Maven wrapper (at root)
202
203### Layer Dependencies
204
205**Correct dependency direction**:
206```
207interfaces → application → domain ← infrastructure
208```
209
210**Rules**:
211- Domain layer must not depend on any other layer
212- Infrastructure layer implements domain layer interfaces
213- Application layer depends on domain layer
214- Interfaces layer depends on application layer
215
216## Architecture Patterns
217
218The skill supports four architecture patterns:
219
2201. **DDD Classic Layered Architecture** (DDD 经典分层架构)
221 - Layers: interfaces, application, domain, infrastructure
222 - Reference: `docs/1、DDD 经典分层架构目录结构.md` and `examples/architecture-patterns.md#ddd-classic`
223
2242. **Hexagonal Architecture** (六边形架构)
225 - Ports and Adapters pattern
226 - Reference: `docs/2、六边形架构详细目录结构参考.md` and `examples/architecture-patterns.md#hexagonal`
227
2283. **Clean Architecture** (整洁架构)
229 - Entities, Use Cases, Interface Adapters
230 - Reference: `docs/3、整洁架构详细目录结构参考.md` and `examples/architecture-patterns.md#clean`
231
2324. **COLA V5** (菱形架构)
233 - Adapter → App → Domain ← Infrastructure
234 - Reference: `docs/4、COLA V5 架构详细目录结构参考.md` and `examples/architecture-patterns.md#cola-v5`
235
236## Validation Rules
237
238When checking existing projects, validate:
239
2401. **Structure Compliance**:
241 - ✓ Correct layer organization
242 - ✓ Proper module separation
243 - ✓ Package naming conventions
244
2452. **Dependency Rules**:
246 - ✓ Domain layer has no external dependencies
247 - ✓ Infrastructure implements domain interfaces
248 - ✓ Correct dependency direction
249
2503. **File Organization**:
251 - ✓ Required directories exist
252 - ✓ `package-info.java` files present
253 - ✓ Maven configuration correct
254
2554. **Naming Conventions**:
256 - ✓ Package names follow convention
257 - ✓ Module names are descriptive
258 - ✓ Layer names are standard
259
260## Examples
261
262See the `examples/` directory for:
263- `single-module.md` - Complete single-module monolith example
264- `multi-module.md` - Complete multi-module monolith example (based on ddd4j-douyin structure)
265- `microservices.md` - Complete microservices example
266- `architecture-patterns.md` - All four architecture patterns with detailed structures
267
268## Keywords
269
270**English keywords:**
271ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
272
273**Chinese keywords (中文关键词):**
274ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
275
276**IMPORTANT**: All keywords must include "ddd4j" to avoid false triggers. Generic terms like "DDD 项目" (DDD project) or "创建项目" (create project) without "ddd4j" should NOT trigger this skill.