ddd-validate
它能做什么
这项技能审核领域驱动的代码库,查找边界泄漏,即一个业务区域导入了另一个区域的内部文件。适合希望保持代码结构清晰的团队。
适用场景
- ✓当你想审核代码库中业务区域之间的泄漏时。
- ✓当你即将合并涉及多个区域的改动时。
- ✓当你希望有自动检查能及早发现边界问题时。
技能链接
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-ddd/skills/ddd-validate/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的代码库,看看是否有代码直接访问其他区域的内部文件。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能找出每个业务区域,扫描其文件中是否有导入进入其他区域内部文件夹的情况,并检查关于实体、事件名称以及仓储位置的规则。然后报告它发现的每个问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Validate domain boundary integrity across all bounded contexts.
Steps
Discover contexts: Scan
src/*/domain/to find all bounded contexts.Check cross-boundary violations:
- For each context, scan all
.tsfiles for import statements - Flag any import that reaches into another context's
domain/directory directly - Allowed: importing from another context's public
index.ts(application layer) - Violation: importing from
src/<other-context>/domain/entities/...directly
# Find cross-boundary imports for ctx in $(find src -maxdepth 2 -name "domain" -type d | sed 's|src/||;s|/domain||'); do grep -rn "from ['\"].*src/" "src/$ctx/" --include="*.ts" | grep -v "src/$ctx/" || true done- For each context, scan all
Check aggregate invariant enforcement:
- Scan aggregate root entities for public setters that bypass validation
- Flag mutable public properties without invariant checks
- Verify that child entities are not directly accessible (must go through aggregate root)
Check event naming conventions:
- Domain events should be past-tense named (e.g.,
OrderCreated, notCreateOrder) - Events should be immutable (no public setters)
- Events should carry the aggregate ID
- Domain events should be past-tense named (e.g.,
Check repository patterns:
- Repository interfaces should exist in
domain/repositories/, notinfrastructure/ - Repository implementations should exist in
infrastructure/, notdomain/ - Each aggregate root should have exactly one repository
- Repository interfaces should exist in
Report findings:
- Output a table of violations with file path, line number, violation type, and suggestion
- Categorize as:
BOUNDARY,INVARIANT,EVENT,REPOSITORY - Exit with summary: total violations, by category, severity
Store results:
npx @claude-flow/cli@latest memory store --key "ddd-validation-TIMESTAMP" --value "RESULTS_SUMMARY" --namespace tasks npx @claude-flow/cli@latest hooks post-task --task-id "ddd-validate" --success true --store-results true
常见问题
什么算是违规?
直接进入其他区域领域文件夹的导入会被标记。从其他区域的公共索引导入是允许的。
它会自己修复问题吗?
这些步骤侧重于发现并报告问题,因此请先查看报告,再决定如何修改。
事件的命名规则是什么?
领域事件应使用过去时命名,例如 OrderCreated,而不是 CreateOrder。
详情
作者的原始描述
Validate domain boundaries -- detect cross-context import violations and aggregate invariant issues. Use when auditing a DDD codebase for leaks between bounded contexts, before merging cross-cutting changes, or as a CI gate to catch boundary erosion early.
repo: ruvnet/ruflo
热度
- GitHub 星标
- 81k
- 排名
- #1616
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-adaptive-coordinator
81k帮你的智能体在工作量变化时拆分和重新平衡一组 AI 智能体,并选择适合任务的分工方式。
agent-agent
81k教你的智能体把一个大目标拆成有顺序的行动计划,并在情况变化时重新规划。
agent-agentic-payments
81k帮你的智能体管理 AI 购物的消费授权,包括消费上限、时间窗口、商户规则和签名审批。
agent-analyze-code-quality
81k帮你的智能体检查代码质量,找出代码异味、技术债务和重构建议,且不改动文件。