Development
源驱动开发
将每一个实现决策都建立在官方文档之上。当你想要权威的、有出处引用的、不含过时模式的代码时使用。
每一个与框架相关的代码决策都必须有官方文档作为支撑。不要凭记忆来实现。
DETECT ──→ FETCH ──→ IMPLEMENT ──→ CITE
│ │ │ │
▼ ▼ ▼ ▼
What Get the Follow the Show your
stack? relevant documented sources
docs patterns
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.
来源层级:
| 优先级 | 来源 | 示例 | |----------|--------|---------| | 1 | 官方文档 | react.dev, docs.djangoproject.com | | 2 | 官方博客 / 变更日志 | react.dev/blog | | 3 | Web 标准参考 | MDN, web.dev | | 4 | 浏览器/运行时兼容性 | caniuse.com |
非权威——绝不引用:
编写与文档所展示内容相符的代码。
当文档与现有代码冲突时:
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?
每个框架相关的模式都要附上出处引用:
// React 19 form handling with useActionState
// Source: https://react.dev/reference/react/useActionState#usage
const [state, formAction, isPending] = useActionState(submitOrder, initialState);
引用规则:
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.
在使用源驱动开发完成实现之后: