意图-协作振动编码的简单意图跟踪
跟踪为什么编写代码以及使用Cursor或Claude code时代码是如何演变的。
安装
在存储库根目录下运行:
npx setup-intention脚本将:
- 检测您使用的AI助手
- 将意图跟踪说明添加到其配置文件中
- 创建一个
.intents用于跟踪的文件夹
工作原理
设置后,每当编码代理创建或修改文件时,它也会在中创建相应的文件 .intents/ 记录:
- 什么 被请求(提示)
- 当 它发生了(时间戳)
- 为什么 已完成(摘要)
- 谁 请求它(如果可用)
示例
当你问:“在app.js中创建Express服务器”
编码代理创建:
app.js-您的Express服务器.intents/app.js.json-创建原因的文档
{
"intents": [{
"id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2024-11-05T10:30:00Z",
"action": "create",
"prompt": "Create an Express server in app.js",
"summary": "Created Express server with basic routing and middleware setup"
}]
}支持的AI助手
- 光标 -
.cursorrules - 克劳德代码 -
.claude/instructions.md(桌面IDE)
查看意向历史记录
# See all tracked files
find .intents -name "*.json"
# View specific file history
cat .intents/src/app.js.json | python -m json.tool
# Count changes per file
for f in .intents/**/*.json; do
echo "$f: $(grep -c '"id"' $f) changes"
done版本控制
重要提示: 这 .intents 文件夹应该提交到您的存储库中。这使您的团队能够:
- 了解编写代码的原因
- 观察人工智能辅助变革的演变
- 审查人工智能决策
- 保持问责制
不添加 .intents 到 .gitignore -这是为了合作。
为什么要跟踪意图?
- 了解决策 -知道为什么代码是以某种方式编写的
- 团队协作 -分享人工智能辅助变革的背景
- 代码考古学 -了解历史决策
- 质量保证 -更有效地审查AI生成的代码
- 知识转移 -新团队成员更快地理解代码库
