Schema 生成
Schema 生成插件允许您使用自然语言描述自动生成符合 cfggen 规范的 .cfg 结构定义文件。通过集成 Claude Code,可以将设计需求快速转换为可执行的 schema 文件。
| 特性 | 说明 |
|---|---|
| 自然语言输入 | 用中文描述配置需求,自动生成 CFG schema |
| ️ 完整语法支持 | 支持 struct、interface、table、外键、元数据等 |
| 智能关联 | 自动识别并生成外键关联关系(-> 单向、=> 多向) |
| 代码注释 | 自动添加清晰的中文注释 |
| 多态支持 | 智能识别需要 interface 的多态场景 |
将 cfgdev/schema-gen-plugin/gen-schema.md 文件复制到项目的 .claude/commands/ 目录:
cp cfgdev/schema-gen-plugin/gen-schema.md .claude/commands//gen-schema <配置需求描述>示例 1:简单数据表
Section titled “示例 1:简单数据表”输入:
/gen-schema 创建一个物品表,包含id、名称、类型、价格、描述生成 item.cfg:
// 物品配置表table item[id] { id:int; // 物品ID name:str; // 物品名称 type:str; // 物品类型 price:int; // 物品价格 description:text; // 物品描述}示例 2:复杂系统
Section titled “示例 2:复杂系统”输入:
/gen-schema 创建一个任务系统:1. 任务表包含任务id、名称、描述、完成条件(接口)、奖励列表2. 完成条件接口支持:击杀怪物、收集物品、与NPC对话3. 奖励包含经验和物品列表生成 task.cfg:
// 任务完成条件接口interface TaskCondition { // 击杀怪物条件 struct KillMonster { monsterid:int ->monster.id; // 怪物ID count:int; // 击杀数量 }
// 收集物品条件 struct CollectItem { itemid:int ->item.id; // 物品ID count:int; // 收集数量 }}
// 任务配置表table task[id] { id:int; // 任务ID name:str; // 任务名称 description:text; // 任务描述 condition:TaskCondition; // 完成条件}示例 3:带关联的配置
Section titled “示例 3:带关联的配置”输入:
/gen-schema 创建商店系统,包含商店表和商品表,商品引用物品配置生成 shop.cfg:
// 商店配置表table shop[id] { id:int; // 商店ID name:str; // 商店名称}
// 商品配置表table shopitem[id] { id:int; // 商品ID shopid:int ->shop.id; // 所属商店 itemid:int ->item.id; // 物品ID price:int; // 价格}