doc-driven-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese文档驱动开发规范
Documentation-Driven Development Specification
在生成代码或修复 bug 时,先看官方文档与示例,再动手实现。
When generating code or fixing bugs, consult official documentation and examples first before starting implementation.
⚠️ 核心强制要求
⚠️ Core Mandatory Requirements
必须查文档的场景
Scenarios Where Documentation Must Be Consulted
- 落地新功能、接第三方库 API、或排查 API 报错时,先查官方文档
- 遇到 /
AttributeError/ 版本变更不确定时,必须验证 API 定义与示例TypeError - 对项目自带封装的内部 API,可酌情跳过
- When implementing new features, connecting to third-party library APIs, or troubleshooting API errors, consult official documentation first
- When encountering /
AttributeError/ uncertain version changes, must verify API definitions and examplesTypeError - For internal APIs encapsulated by the project itself, you can skip as appropriate
Agent 执行步骤
Agent Execution Steps
- 停止猜测:明确要查的 API/模块名称和版本
- 查阅文档:优先使用 获取官方文档;若不可用再用
Context7搜索官方来源并二次核验DuckDuckGo - 基于文档实现:依据文档的参数、返回值和示例实现或修复代码
- Stop guessing: Clarify the name and version of the API/module to be queried
- Consult documentation: Prioritize using to obtain official documentation; if unavailable, use
Context7to search for official sources and conduct secondary verificationDuckDuckGo - Implement based on documentation: Implement or fix code according to the parameters, return values and examples in the documentation
MCP 调用基线(文档查阅场景)
MCP Invocation Baseline (Documentation Query Scenarios)
- 文档/API 问题优先使用 ,最新公告或入口信息再使用
Context7DuckDuckGo - 单轮最多调用一种外部服务;确需多工具时串行并说明理由
- 查询保持最小必要(关键词、结果数、时间窗、tokens)
- 发生 429/限流时,退避 20 秒并缩小范围后重试
- 输出中附“工具调用简报”(工具、输入摘要、参数、时间、来源、重试)
- 默认离线优先,不上传敏感信息,遵守 robots/ToS 与隐私约束
- For documentation/API issues, prioritize using , and use
Context7for latest announcements or entry informationDuckDuckGo - Call at most one external service per round; if multiple tools are really needed, call them serially and explain the reasons
- Keep queries as minimal and necessary as possible (keywords, number of results, time window, tokens)
- When 429/rate limiting occurs, back off for 20 seconds and narrow the scope before retrying
- Attach "Tool Call Briefing" in the output (tool, input summary, parameters, time, source, retry)
- Offline first by default, do not upload sensitive information, comply with robots/ToS and privacy constraints
AI Agent 行为要求
AI Agent Behavior Requirements
问题识别
Problem Identification
| 问题类型 | 特征 | 处理方式 |
|---|---|---|
| API 不存在 | | 查找正确的 API |
| 参数错误 | | 查找正确的参数 |
| 行为异常 | 结果不符合预期 | 查找正确的用法 |
| 版本问题 | 某版本后 API 变更 | 查找版本差异 |
| Problem Type | Feature | Handling Method |
|---|---|---|
| API does not exist | | Find the correct API |
| Parameter error | | Find the correct parameters |
| Abnormal behavior | Results do not meet expectations | Find the correct usage |
| Version issue | API changed after a certain version | Find version differences |
收集错误信息
Collect Error Information
必须收集:
- 完整的错误堆栈
- 相关代码片段
- 使用的库/框架版本
Must collect:
- Complete error stack
- Relevant code snippets
- Version of the library/framework used
基于文档实现(禁止猜测)
Implement Based on Documentation (Guessing is Prohibited)
python
undefinedpython
undefined错误:基于猜测实现
错误:基于猜测实现
index.query(question, top_k=10) # 可能参数名不对
index.query(question, top_k=10) # 可能参数名不对
正确:基于文档实现
正确:基于文档实现
查阅文档后确认正确的参数名
查阅文档后确认正确的参数名
index.query(question, similarity_top_k=10)
undefinedindex.query(question, similarity_top_k=10)
undefined修复后验证
Verification After Fix
- 运行测试确认修复
- 检查是否引入新问题
- 验证在不同场景下的表现
- Run tests to confirm the fix
- Check if new problems are introduced
- Verify performance in different scenarios
参考资料
References
- - API 验证流程详细说明(问题识别、文档查阅、实施修复)
references/api-verification.md - - 文档搜索策略与提问指引
references/search-strategy.md - - MCP 调用规则(工具选择、速率限制、安全边界、失败降级与可追溯输出)
references/mcp-usage-rules.md
- - Detailed description of API verification process (problem identification, documentation consultation, implementation of fixes)
references/api-verification.md - - Documentation search strategy and question guidance
references/search-strategy.md - - MCP invocation rules (tool selection, rate limiting, security boundary, failure degradation and traceable output)
references/mcp-usage-rules.md