Development
源驱动开发
将每一个实现决策都建立在官方文档之上。当你想要权威的、有出处引用的、不含过时模式的代码时使用。
每一个与框架相关的代码决策都必须有官方文档作为支撑。不要凭记忆来实现。
使用场景
- 用户希望代码遵循某个框架当前的最佳实践
- 构建样板代码、起步代码,或将被复制的模式
- 实现那些框架推荐方式很重要的功能
- 任何你即将凭记忆编写框架相关代码的时候
流程
DETECT ──→ FETCH ──→ IMPLEMENT ──→ CITE
│ │ │ │
▼ ▼ ▼ ▼
What Get the Follow the Show your
stack? relevant documented sources
docs patterns
步骤 1:检测技术栈与版本
STACK DETECTED:
- React 19.1.0 (from package.json)
- Vite 6.2.0
- Tailwind CSS 4.0.3
→ Fetching official docs for the relevant patterns.
步骤 2:获取官方文档
来源层级:
| 优先级 | 来源 | 示例 |
|---|---|---|
| 1 | 官方文档 | react.dev, docs.djangoproject.com |
| 2 | 官方博客 / 变更日志 | react.dev/blog |
| 3 | Web 标准参考 | MDN, web.dev |
| 4 | 浏览器/运行时兼容性 | caniuse.com |
非权威——绝不引用:
- Stack Overflow 的回答
- 博客文章或教程
- AI 生成的文档
- 你自己的训练数据
步骤 3:遵循文档化的模式来实现
编写与文档所展示内容相符的代码。
当文档与现有代码冲突时:
CONFLICT DETECTED:
The existing codebase uses useState for form loading state,
but React 19 docs recommend useActionState for this pattern.
(Source: react.dev/reference/react/useActionState)
Options:
A) Use the modern pattern (useActionState)
B) Match existing code (useState)
→ Which approach do you prefer?
步骤 4:引用你的来源
每个框架相关的模式都要附上出处引用:
// React 19 form handling with useActionState
// Source: https://react.dev/reference/react/useActionState#usage
const [state, formAction, isPending] = useActionState(submitOrder, initialState);
引用规则:
- 使用完整 URL,不要使用短链接
- 对于不显而易见的决策,引述相关的段落
- 如果你找不到文档,请明确说明:
UNVERIFIED: I could not find official documentation for this
pattern. This is based on training data and may be outdated.
Verify before using in production.
验证
在使用源驱动开发完成实现之后:
- 框架和库的版本已从依赖文件中识别出来
- 已为框架相关的模式获取了官方文档
- 所有来源都是官方文档
- 代码遵循了当前版本文档中所展示的模式
- 非平凡的决策都包含带完整 URL 的出处引用
- 没有使用任何已废弃的 API
- 文档与现有代码之间的冲突已被提出
- 任何未经验证的内容都已被明确标记