技巧

AI 写代码会滚雪球式堆积无用注释,用 /no-comments skill 清理

精选理由

vikingmute 分享了一个很实际的问题:Agent 写代码会把旧注释当模板疯狂复制。用 /no-comments skill 能自动清理垃圾注释,留着架构说明这类有用的。

Lauren(@poteto)指出 AI Agent 倾向于复制代码库中已有的注释,一条解释临时 workaround 的注释会被后续 Agent 反复模仿扩散,导致 TODO、复述代码的英文注释越积越多。她建议删除大部分注释,只保留浏览器兼容性说明、公共 API 接口文档等必要内容。pstack 提供 /no-comments skill,专门清理无用注释并保留有价值的部分,还能从第一性原理出发判断 workaround 是否应通过重构解决。

图片来源 · Viking
原文 · Viking

非常实用,让 AI 写代码的过程中,实际上可以产生非常多的无用注释,因为 Agent 很喜欢复制已有代码和注释,比如一个临时无害的 workround 类型的注释,会影响之后的 agent 的代码生成,滚雪球一样越来越多。 虽然现在根本不怎么代码了,之前抽查,会发现记录代码修改历史记录的注释,TODO的注释,还有把代码用英文重复一遍的注释,而且其他 agent 发现以后,会毫不犹豫的加进去。 所以大部分的注释应该删除,留下好注释,比如一些宏观层次的架构 公共 API/接口说明等等。 OP 的 /no-comment 的这个 skill 做这个工作很不错,而且他还抽象出了他平时的工作流 skill,他自己的用来让 AI coding agent 的工作流,大家可以看看 github.com/backnotprop/ps… lauren @poteto ban and delete most if not all code comments! agents love copying what already exists. a seemingly harmless comment explaining some temporary workaround is one of the worst viruses you can have in your codebase. like a weed it'll spread quickly as a tool for agents to quickly get their job done. before you know it, your codebase is overrun with hacks and stale comments. just one more workaround bro you can use pstack's /no-comments skill as a weedkiller. it'll seek out useless comments while keeping the ones that actually should exist (like explaining a browser quirk), and figure out how to solve them on a first principles basis here's a prompt you can try asking @bot : create a project agent that uses /poteto-mode to spawn a /swarm to use /no-comments and identify useless code comments we can prune in my repo. come back with a high level plan of which of these workarounds would be best solved by refactoring and which we can straight up delete x.ai/bot/plugin/971… 🔗 View Quoted Tweet 💬 0 🔄 0 ❤️ 1 👀 252 ⚡