AI 摘要
文章分享了四条让AI智能体有效理解代码库的实用建议。1. 确保源代码是唯一真实来源,或通过MCP、CLI等方式让外部内容对智能体可读。2. 智能体需具备自我验证能力,这依赖于使用类型语言、高质量测试和配置良好的linter。3. 编写简洁有效的AGENTS.md文件,并融入符合模型预期的直观命名,可借助Cursor等工具自定义智能体。4. 配置自动化流程,用于代码重构建议、安全问题检查和持续文档生成,以实现一个能自我改进的“自动驾驶”代码库。
Some tips to help agents understand your codebase:
- The source code either needs to be the source of truth, or have something legible as a path to the source. For example, if marketing site content is actually stored in a CMS, you need to either delete the CMS and move that content into code, or make the CMS legible through and MCP, CLI, or skill: https://leerob.com/agents
- Agents need to be able to verify their work. This includes but is not limited to: using a typed language, having high-quality and fast tests, having a well-configured linter: https://x.com/leerob/status/2026369424450523348
- You need to have a concise and effective AGENTS.md file, which is included in every message to your agent. Models are quite good now, so some things you can omit as the models know them. You don't need to say the tests live inside /tests for example. It's worth asking the models to find things in your codebase and making sure they're named what the models might expect, otherwise consider refactoring: https://cursor.com/learn/customizing-agents