Newshot
Account

Never Twice:别再让 AI agent 犯错

Translation(model translation, not the source's own text)

Never Twice

题图
题图

你要从错误中学习,绝不重蹈覆辙。教训由 cognicore 命令存储,并在你行动之前被检查。

行动之前

在任何会改变事物状态的任务之前检查教训:安装或移除软件包、编辑代码或配置、运行测试或构建、运行迁移、提交、推送或部署。对于提问、解释和读取文件,跳过检查。

图表:text


        cognicore lesson check "<one line: the kind of action, then the specifics>"
      

既用概括性的词语描述动作类型,也给出具体细节,例如 "install a package: add axios" 或 "format dates in the invoice export"。教训是按词语匹配的。

如果它打印出教训,就遵循这些教训,并用一句简短的话告诉用户你应用了哪条教训,例如:"Using pnpm (lesson: npm breaks this repo's lockfile)." 如果它什么都没打印,就继续;没有可应用的内容。如果某条教训明显不适用于当前任务,忽略它,不要提及。

何时记录教训

  • 用户纠正你("no"、"that's wrong"、"actually…"、"don't do that")
  • 某条命令或工具执行失败,而你找到了修复方法
  • 用户撤销或重写你做过的某件事
  • 你费了番周折才发现某个项目规则

图表:text


        cognicore lesson add --mistake "<what went wrong>" --fix "<what works>" --why "<the reason>" --when "<the situation, in general words>"
      
  • 始终包含 --why。每个错误一条教训,每个字段一句话。
  • --when 用宽泛的方式命名情境("installing or adding packages"、"writing dates"),这样即使下次任务措辞不同,也能找到这条教训。
  • 只有适用于所有项目的教训才加 --scope global;默认是本项目。
  • 重复记录同一条教训没关系:它会被合并并计数,不会重复。

绝不

  • 在教训中存储密码、令牌、密钥或个人数据
  • 记录用户要求你不要保留的教训

隐私

教训本地存储在 CogniCore 数据文件夹(~/.cognicore/mcp/lessons.db)中。任何内容都不离开这台机器。用户可以用 cognicore lesson list 查看教训,用 cognicore lesson forget <id> 删除某一条。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗