- TypeScript strict mode
- 优先函数式组件 + hooks
- 文件命名:kebab-case
- 组件命名:PascalCase
- 常量命名:UPPER_SNAKE_CASE
- 优先使用
const 和箭头函数
- 每个组件文件只导出一个主组件
- Props 使用 interface 定义
- 优先使用 shadcn/ui 组件
- 样式使用 Tailwind CSS utility classes
- 不使用 CSS modules 或 styled-components
- API Route 使用 Next.js App Router conventions
- 输入校验使用 Zod schema
- 错误返回统一结构:
{ error: string, code: string }
- SSE 流式使用
ReadableStream
- 不使用 try-catch 包装整个 route,用 next.js error boundary
- 使用 Drizzle ORM 定义 schema
- 所有表必须有
created_at 时间戳
- 查询函数集中在
db/queries.ts
- 不写原始 SQL,除非 Drizzle 无法表达
- 使用 Vercel AI SDK (
ai package)
- 每个角色的 prompt 定义在
prompts.ts 中
- 角色 prompt 必须包含:角色定义、输出格式、字数限制、边界约束
- 流式输出使用
streamText
- 并行调用使用
Promise.all
- 单元测试:vitest
- 组件测试:@testing-library/react
- 测试文件放在
__tests__/ 目录
- 测试命名:
describe('模块名') + it('should ...')