engineering-workflow / rules
Cursor rule0 starsChanged 36 days agoMITView on GitHub
本规则对所有涉及代码的项目生效。agent 在设计和实现模块时必须遵循以下架构约束。 本规则对所有涉及代码的项目生效,但根据项目类型有不同强度: 当项目为纯工具/配置类(如本模板项目本身),agent 不应强制要求话题通信架构,仅保持日志和 MD5 留痕即可。 所有模块间数据传递统一使用话题机制,禁止直接函数调用传数据(内部纯计算除外)。 无论哪种方案,必须满足: - 话题可枚举(有 topic registry) - 消息可回放(有持久化或日志) - 订阅关系可查(运行时可 dump) 结构化数据为 JSON,至少包含:触发源、变更前后值、关联 trace_id。 对以下对象维护 MD5 校验记录: MD5 日志格式(append-only): 存储位置:项目根目录 .trace/integrity.log
In this repository11 other files it gives its agents.
- .cursor/rules/00-workflow-entry.mdCursor rule
- .cursor/rules/01-first-principles.mdCursor rule
- .cursor/rules/02-ask-before-act.mdCursor rule
- .cursor/rules/03-goal-alignment.mdCursor rule
- .cursor/rules/04-changelog.mdCursor rule
- .cursor/rules/05-must-complete-mode.mdCursor rule
- .cursor/rules/07-dialogue-execute-mode.mdCursor rule
- project-indexSkill
- project-surveySkill
- tts-notifySkill
- version-backupSkill
The file
Files
话题通信 + 全量溯源(强制架构约束)
本规则对所有涉及代码的项目生效。agent 在设计和实现模块时必须遵循以下架构约束。
作用域
本规则对所有涉及代码的项目生效,但根据项目类型有不同强度:
| project-profile.type | 话题通信 | 全量日志 | MD5 完整性 |
| web-frontend / web-backend / mobile / desktop | 强制 | 强制 | 强制 |
| library / cli-tool / other | 可选(模块 ≥3 时建议启用) | 强制 | 强制 |
| 纯脚本/配置项目(无 modules 或 modules ≤2) | 不要求 | 建议 | 建议 |
当项目为纯工具/配置类(如本模板项目本身),agent 不应强制要求话题通信架构,仅保持日志和 MD5 留痕即可。
模块间通信:话题(Topic / Pub-Sub)
所有模块间数据传递统一使用话题机制,禁止直接函数调用传数据(内部纯计算除外)。
话题模型
Publisher → Topic(name, schema) → Subscriber(s)
每条消息结构:
{
topic: string, // 话题名,如 "order.created", "sensor.imu"
timestamp: ISO8601, // 发布时间
source: string, // 发布者模块标识
payload: any, // 业务数据
trace_id: string, // 链路追踪 ID(贯穿整条调用链)
seq: number // 该话题上的序列号
}实现选择(按项目需求选型)
| 场景 | 推荐方案 |
| 机器人/嵌入式/多进程 | ROS 2 topic(直接用 rclpy/rclcpp) |
| Web/微服务 | Redis Pub/Sub / NATS / Kafka |
| 单进程多模块 | 内置 EventBus(自实现,≤50 行) |
| 桌面/CLI 工具 | 基于文件的 topic log(append-only) |
无论哪种方案,必须满足:
- 话题可枚举(有 topic registry)
- 消息可回放(有持久化或日志)
- 订阅关系可查(运行时可 dump)
全量日志:一切留痕
必须记录的事件
| 类别 | 内容 | 示例 |
| 状态变更 | 任何状态机跳转 | order.status: pending → paid |
| 数据变更 | CRUD 操作 | user.email updated, old=x, new=y |
| 话题消息 | 每条 pub/sub 消息 | topic log 本身 |
| 文件变更 | 文件创建/修改/删除 | 路径 + 操作 + MD5 |
| 外部调用 | API/DB/第三方 | request + response 摘要 |
| 错误 | 所有 catch 到的异常 | stack + context |
日志格式
[timestamp] [level] [module] [trace_id] message {structured_data}结构化数据为 JSON,至少包含:触发源、变更前后值、关联 trace_id。
MD5 完整性日志
对以下对象维护 MD5 校验记录:
- 所有配置文件 — 启动时计算 + 变更时重算
- 构建产物 — 构建完成时记录
- 数据文件 — 写入/导入时记录
- 部署包 — 发布时记录
MD5 日志格式(append-only):
[timestamp] [event] [path] [md5] [operator]存储位置:项目根目录 .trace/integrity.log
溯源基础设施
每个项目必须包含:
.trace/
├── topics.registry.json # 话题注册表(名称 + schema + publisher + subscribers)
├── integrity.log # MD5 完整性日志
└── events/ # 事件日志(按日期分文件)
└── YYYY-MM-DD.jsonlagent 实施要求
- 新建项目时:自动创建
.trace/目录结构和 topic registry - 新增模块时:检查其对外通信是否走话题,不走则要求重构
- 新增状态时:确保状态变更有日志记录
- 修改文件时:更新 integrity.log 中的 MD5
- 代码审查时:检查是否有"暗通道"(模块直接调用传数据绕过话题)
禁止行为
- 禁止模块间通过全局变量/单例共享状态(必须通过话题)
- 禁止状态变更不写日志
- 禁止文件操作不记录 MD5
- 禁止删除或截断
.trace/下的日志文件
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

