Mate New Module
Developmentmate-new-moduleMate New Module is an Agent Skill for development published in the mateaix/matecloud repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
在 MateCloud 新建业务模块 (mate-{name}) 时使用。约束 DDD 四层结构、命名后缀、错误码、端口分配、领域纯净,避免手搓出不合规范的模块。当用户说"新建模块""加一个 mate-xxx 服务""scaffold a module"时触发。
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/mateaix/matecloud/blob/HEAD/.claude/.harness/skills/mate-new-module/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/mate-new-module, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
新建 MateCloud 业务模块
目标:产出一个符合 DDD 四层 + 项目约定的新模块,而不是随手摆几个包。
完整规则见 .claude/.harness/rules/01-architecture.md 与 02-conventions.md。
第一步:优先用 CLI 脚手架(别手搓)
java -jar mate-cli/target/mate-cli.jar new module mate-{name} --port {port}
端口按段分配(见 coding-standards §1.3):9030-9039 系统 / 9040-9049 后台 / 9050-9059 通知 / 9060+ 业务扩展。新模块端口递增,别撞已用端口。
CLI 不可用时才手动建,且必须补齐:
mate-biz/mate-{name}/pom.xml引入所需 starter(core7 必备)。application.yml(~15 行):端口 + 应用名 +spring.config.import引 Nacos。Mate{Name}Application.java:@SpringBootApplication+@EnableDubbo。- DDD 四层包:
trigger / application / domain / infrastructure / types。 - 在根
pom.xml和mate-biz/pom.xml各加一行<module>。
第二步:四层落位(包根 vip.mate.{name})
trigger/controller(/api/v1/...+@SaCheckLogin/@SaCheckPermission) · rpc · event · jobapplication/command(写,@Transactional) · query(读,接口+impl) · convertor(MapStruct)domain/model{aggregate,entity,valobj} · service · adapter{repository,port}(接口) · eventinfrastructure/adapter 实现 · dao + dao/po(PO) · seed · configtypes/exception(ErrorCode 枚举) · constant · security(Perms)
约束清单(提交前逐条自查)
- 领域纯净:
domain/model/**零框架 import(框架注解只在 PO)。 - CQRS:Command 与 Query 不混在一个类;Command 标
@Transactional(rollbackFor=Exception.class)。 - 仓储接口在 domain,实现在 infrastructure;application 不直接碰 DAO。
- 所有对象转换用 MapStruct,不用
BeanUtils.copyProperties。 - 错误码
{MODULE}{TYPE}{SEQ}(如ORDB001;A=参数 B=业务 C=RPC D=DB E=外部)。 - 表
mate_前缀,必备deleted/lock_version/created_at/updated_at。 - API 统一
/api/v1/,返回Result<T>;权限用Perms常量不硬编码。 - 无内联 FQN,import 按 IntelliJ 默认分组(见 rules/02)。
第三步:建完即自检
bash .claude/.harness/checks/run-all.sh
阻断级必须全绿。代码生成可用 mate-cli gen code --table {table} --module mate-{name} --service {svc}。