feat: 初始化AI-Native研发流程模板
- 创建项目基础结构和说明文档 - 实现 project-onboarding 和 feature-development 技能 - 添加6个核心子代理(requirement/design/code-gen/test/code-review/analyzer) - 配置 Claude Code 插件系统 - 完善README和使用文档 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
commit
c4cb7ac6cf
20 files changed
+18925
No files matched your search
@@ -0,0 +1,899 @@
|
||||
---
|
||||
name: feature-development
|
||||
description: 完整的功能开发流程,从需求到上线的全自动化工作流
|
||||
version: 1.0.0
|
||||
author: AI-Native Dev Template
|
||||
tags: [development, workflow, automation, tdd]
|
||||
---
|
||||
|
||||
# 功能开发技能 (Feature Development Skill)
|
||||
|
||||
这个技能提供完整的功能开发流程,从需求分析到代码实现、测试、审查、部署的全链路自动化。
|
||||
|
||||
## 使用方式
|
||||
|
||||
```bash
|
||||
# 在 Claude Code 中
|
||||
/feature-dev
|
||||
|
||||
# 或者描述需求
|
||||
请帮我开发一个用户注册功能
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 开发流程总览
|
||||
|
||||
```
|
||||
需求输入
|
||||
→ 需求分析 (requirement-agent)
|
||||
→ 方案设计 (design-agent)
|
||||
→ 代码实现 (code-gen-agent)
|
||||
→ 测试编写 (test-agent)
|
||||
→ 代码审查
|
||||
→ 部署上线
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 阶段 1: 需求分析
|
||||
|
||||
### 1.1 需求收集
|
||||
|
||||
**请描述你的需求**:
|
||||
```
|
||||
示例:
|
||||
"我需要一个用户注册功能
|
||||
- 用户可以通过邮箱和密码注册
|
||||
- 需要邮箱验证
|
||||
- 密码强度要求: 至少8位,包含大小写字母和数字
|
||||
- 注册成功后自动登录"
|
||||
```
|
||||
|
||||
### 1.2 需求解析
|
||||
|
||||
我将使用 `requirement-agent` 分析需求,生成:
|
||||
|
||||
**用户故事**:
|
||||
```markdown
|
||||
作为 用户
|
||||
我想要 通过邮箱注册账号
|
||||
以便 使用系统的各项功能
|
||||
|
||||
验收标准:
|
||||
- 提供邮箱和密码可以完成注册
|
||||
- 邮箱格式需要验证
|
||||
- 密码需要满足强度要求
|
||||
- 注册后收到验证邮件
|
||||
- 验证邮箱后自动登录
|
||||
```
|
||||
|
||||
**功能分解**:
|
||||
```markdown
|
||||
## 功能点
|
||||
|
||||
### 1. 注册表单
|
||||
- 邮箱输入框 (带格式验证)
|
||||
- 密码输入框 (显示强度指示器)
|
||||
- 确认密码输入框
|
||||
- 注册按钮
|
||||
|
||||
### 2. 后端验证
|
||||
- 邮箱格式验证
|
||||
- 密码强度验证
|
||||
- 邮箱唯一性检查
|
||||
- 创建用户记录
|
||||
|
||||
### 3. 邮箱验证
|
||||
- 生成验证token
|
||||
- 发送验证邮件
|
||||
- 验证链接处理
|
||||
- 激活账号
|
||||
|
||||
### 4. 自动登录
|
||||
- 生成登录token
|
||||
- 设置session
|
||||
- 跳转到首页
|
||||
```
|
||||
|
||||
**边界条件**:
|
||||
```markdown
|
||||
## 异常情况
|
||||
|
||||
1. 邮箱已被注册
|
||||
→ 提示: "该邮箱已被注册,请直接登录或使用其他邮箱"
|
||||
|
||||
2. 密码强度不足
|
||||
→ 提示: "密码至少8位,需包含大小写字母和数字"
|
||||
|
||||
3. 邮箱发送失败
|
||||
→ 允许注册,提供"重发验证邮件"按钮
|
||||
|
||||
4. 验证链接过期
|
||||
→ 提示: "验证链接已过期,请重新获取"
|
||||
```
|
||||
|
||||
### 1.3 需求确认 ⭐ 重要
|
||||
|
||||
**需求文档已生成**: `docs/requirements/{feature-name}-requirements.md`
|
||||
|
||||
**请确认以下内容**:
|
||||
|
||||
1. ✅ 用户故事是否准确?
|
||||
2. ✅ 功能分解是否完整?
|
||||
3. ✅ 边界条件是否覆盖?
|
||||
4. ✅ 是否有遗漏的需求?
|
||||
|
||||
**请回复**:
|
||||
- **"确认"** - 进入设计阶段
|
||||
- **"修改 [具体内容]"** - 修改需求
|
||||
- **"查看文档"** - 查看完整需求文档
|
||||
|
||||
⚠️ **只有在你确认后,我才会进入设计阶段**
|
||||
|
||||
---
|
||||
|
||||
## 阶段 2: 技术方案设计
|
||||
|
||||
### 2.1 进入设计模式
|
||||
|
||||
使用 `design-agent` 和 EnterPlanMode 进行方案设计。
|
||||
|
||||
### 2.2 数据模型设计
|
||||
|
||||
**User 模型**:
|
||||
```typescript
|
||||
interface User {
|
||||
id: string; // UUID
|
||||
email: string; // 唯一索引
|
||||
passwordHash: string; // bcrypt加密
|
||||
emailVerified: boolean; // 邮箱验证状态
|
||||
emailVerificationToken?: string; // 验证token
|
||||
emailVerificationExpiry?: Date; // token过期时间
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
```
|
||||
|
||||
**数据库 Schema** (以 PostgreSQL 为例):
|
||||
```sql
|
||||
CREATE TABLE users (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
email_verified BOOLEAN DEFAULT FALSE,
|
||||
email_verification_token VARCHAR(255),
|
||||
email_verification_expiry TIMESTAMP,
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_users_email ON users(email);
|
||||
CREATE INDEX idx_users_verification_token ON users(email_verification_token);
|
||||
```
|
||||
|
||||
### 2.3 API 接口设计
|
||||
|
||||
**POST /api/auth/register**
|
||||
```typescript
|
||||
// Request
|
||||
{
|
||||
email: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
}
|
||||
|
||||
// Response (Success - 201)
|
||||
{
|
||||
message: "注册成功,请查收验证邮件";
|
||||
user: {
|
||||
id: string;
|
||||
email: string;
|
||||
}
|
||||
}
|
||||
|
||||
// Response (Error - 400)
|
||||
{
|
||||
error: "邮箱已被注册" | "密码强度不足" | ...;
|
||||
}
|
||||
```
|
||||
|
||||
**GET /api/auth/verify-email?token=xxx**
|
||||
```typescript
|
||||
// Response (Success - 200)
|
||||
{
|
||||
message: "邮箱验证成功";
|
||||
token: string; // JWT登录token
|
||||
}
|
||||
|
||||
// Response (Error - 400)
|
||||
{
|
||||
error: "验证链接无效或已过期";
|
||||
}
|
||||
```
|
||||
|
||||
### 2.4 前端组件设计
|
||||
|
||||
**组件层级**:
|
||||
```
|
||||
RegisterPage
|
||||
├── RegisterForm
|
||||
│ ├── EmailInput (带验证)
|
||||
│ ├── PasswordInput (带强度指示器)
|
||||
│ ├── ConfirmPasswordInput
|
||||
│ └── SubmitButton
|
||||
└── VerificationNotice
|
||||
```
|
||||
|
||||
**状态管理**:
|
||||
```typescript
|
||||
interface RegisterState {
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
showVerificationNotice: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
### 2.5 实现计划
|
||||
|
||||
**文件修改清单**:
|
||||
```markdown
|
||||
## 后端
|
||||
|
||||
### 新增文件
|
||||
- src/services/auth.service.ts # 认证服务
|
||||
- src/services/email.service.ts # 邮件服务
|
||||
- src/controllers/auth.controller.ts # 认证控制器
|
||||
- src/types/auth.types.ts # 类型定义
|
||||
|
||||
### 修改文件
|
||||
- src/app.ts # 添加路由
|
||||
- database/migrations/xxx_create_users_table.ts # 数据库迁移
|
||||
|
||||
## 前端
|
||||
|
||||
### 新增文件
|
||||
- src/views/Register.vue # 注册页面
|
||||
- src/components/RegisterForm.vue # 注册表单
|
||||
- src/components/PasswordStrength.vue # 密码强度组件
|
||||
- src/api/auth.ts # API调用
|
||||
|
||||
### 修改文件
|
||||
- src/router/index.ts # 添加路由
|
||||
- src/stores/auth.ts # 添加注册action
|
||||
|
||||
## 测试
|
||||
|
||||
### 新增文件
|
||||
- tests/unit/auth.service.test.ts # 服务单元测试
|
||||
- tests/integration/register.test.ts # 注册集成测试
|
||||
- tests/e2e/user-registration.spec.ts # E2E测试
|
||||
```
|
||||
|
||||
### 2.6 风险评估
|
||||
|
||||
**技术风险**:
|
||||
1. 邮件服务可能失败 → 使用队列重试机制
|
||||
2. 高并发注册 → 添加邮箱唯一索引
|
||||
3. 邮箱验证token泄露 → 设置短过期时间
|
||||
|
||||
**时间估算**:
|
||||
- 后端实现: 4小时
|
||||
- 前端实现: 3小时
|
||||
- 测试编写: 2小时
|
||||
- 总计: 约1个工作日
|
||||
|
||||
### 2.7 设计确认 ⭐ 重要
|
||||
|
||||
**设计文档已生成**: `docs/designs/{feature-name}-design.md`
|
||||
|
||||
**请确认以下内容**:
|
||||
|
||||
1. ✅ 数据模型设计是否合理?
|
||||
2. ✅ API接口设计是否符合需求?
|
||||
3. ✅ 前端组件设计是否清晰?
|
||||
4. ✅ 技术选型是否合适?
|
||||
5. ✅ 实施计划是否可行?
|
||||
|
||||
**请回复**:
|
||||
- **"确认"** - 开始代码实现和测试编写
|
||||
- **"调整 [具体内容]"** - 调整设计方案
|
||||
- **"查看文档"** - 查看完整设计文档
|
||||
|
||||
⚠️ **只有在你确认后,我才会开始代码实现**
|
||||
|
||||
---
|
||||
|
||||
## 阶段 3: 代码实现
|
||||
|
||||
### 3.1 测试驱动开发 (TDD)
|
||||
|
||||
**先写测试**:
|
||||
|
||||
使用 `test-agent` 生成测试用例:
|
||||
|
||||
```typescript
|
||||
// tests/unit/auth.service.test.ts
|
||||
describe('AuthService', () => {
|
||||
describe('register', () => {
|
||||
it('should create user with valid data', async () => {
|
||||
const data = {
|
||||
email: 'test@example.com',
|
||||
password: 'Passw0rd!'
|
||||
};
|
||||
|
||||
const user = await authService.register(data);
|
||||
|
||||
expect(user.email).toBe(data.email);
|
||||
expect(user.emailVerified).toBe(false);
|
||||
expect(user.passwordHash).not.toBe(data.password);
|
||||
});
|
||||
|
||||
it('should throw error if email already exists', async () => {
|
||||
// 先创建一个用户
|
||||
await authService.register({
|
||||
email: 'existing@example.com',
|
||||
password: 'Passw0rd!'
|
||||
});
|
||||
|
||||
// 尝试使用相同邮箱注册
|
||||
await expect(
|
||||
authService.register({
|
||||
email: 'existing@example.com',
|
||||
password: 'Passw0rd!'
|
||||
})
|
||||
).rejects.toThrow('邮箱已被注册');
|
||||
});
|
||||
|
||||
it('should throw error if password is weak', async () => {
|
||||
await expect(
|
||||
authService.register({
|
||||
email: 'test@example.com',
|
||||
password: '123' // 弱密码
|
||||
})
|
||||
).rejects.toThrow('密码强度不足');
|
||||
});
|
||||
});
|
||||
|
||||
describe('verifyEmail', () => {
|
||||
it('should verify email with valid token', async () => {
|
||||
// 创建用户
|
||||
const user = await authService.register({
|
||||
email: 'test@example.com',
|
||||
password: 'Passw0rd!'
|
||||
});
|
||||
|
||||
// 验证邮箱
|
||||
const result = await authService.verifyEmail(
|
||||
user.emailVerificationToken!
|
||||
);
|
||||
|
||||
expect(result.emailVerified).toBe(true);
|
||||
expect(result.token).toBeDefined(); // JWT token
|
||||
});
|
||||
|
||||
it('should throw error if token is invalid', async () => {
|
||||
await expect(
|
||||
authService.verifyEmail('invalid-token')
|
||||
).rejects.toThrow('验证链接无效或已过期');
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**运行测试确认失败**:
|
||||
```bash
|
||||
npm test
|
||||
# ✗ 所有测试都失败(因为还没实现)
|
||||
```
|
||||
|
||||
### 3.2 实现功能
|
||||
|
||||
使用 `code-gen-agent` 按照设计实现代码:
|
||||
|
||||
#### 后端实现
|
||||
|
||||
**auth.service.ts**:
|
||||
```typescript
|
||||
import bcrypt from 'bcrypt';
|
||||
import crypto from 'crypto';
|
||||
import { sendVerificationEmail } from './email.service';
|
||||
|
||||
export async function register(data: {
|
||||
email: string;
|
||||
password: string;
|
||||
}): Promise<User> {
|
||||
// 验证邮箱格式
|
||||
if (!isValidEmail(data.email)) {
|
||||
throw new Error('邮箱格式无效');
|
||||
}
|
||||
|
||||
// 验证密码强度
|
||||
if (!isStrongPassword(data.password)) {
|
||||
throw new Error('密码强度不足');
|
||||
}
|
||||
|
||||
// 检查邮箱是否已存在
|
||||
const existing = await db.user.findUnique({
|
||||
where: { email: data.email }
|
||||
});
|
||||
if (existing) {
|
||||
throw new Error('邮箱已被注册');
|
||||
}
|
||||
|
||||
// 加密密码
|
||||
const passwordHash = await bcrypt.hash(data.password, 10);
|
||||
|
||||
// 生成验证token
|
||||
const verificationToken = crypto.randomBytes(32).toString('hex');
|
||||
const verificationExpiry = new Date(Date.now() + 24 * 60 * 60 * 1000); // 24小时
|
||||
|
||||
// 创建用户
|
||||
const user = await db.user.create({
|
||||
data: {
|
||||
email: data.email,
|
||||
passwordHash,
|
||||
emailVerificationToken: verificationToken,
|
||||
emailVerificationExpiry: verificationExpiry,
|
||||
emailVerified: false
|
||||
}
|
||||
});
|
||||
|
||||
// 发送验证邮件
|
||||
await sendVerificationEmail(user.email, verificationToken);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
export async function verifyEmail(token: string): Promise<{
|
||||
user: User;
|
||||
token: string;
|
||||
}> {
|
||||
// 查找用户
|
||||
const user = await db.user.findFirst({
|
||||
where: {
|
||||
emailVerificationToken: token,
|
||||
emailVerificationExpiry: {
|
||||
gt: new Date() // token未过期
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new Error('验证链接无效或已过期');
|
||||
}
|
||||
|
||||
// 更新用户状态
|
||||
const updated = await db.user.update({
|
||||
where: { id: user.id },
|
||||
data: {
|
||||
emailVerified: true,
|
||||
emailVerificationToken: null,
|
||||
emailVerificationExpiry: null
|
||||
}
|
||||
});
|
||||
|
||||
// 生成JWT token
|
||||
const jwtToken = generateJWT({ userId: user.id });
|
||||
|
||||
return {
|
||||
user: updated,
|
||||
token: jwtToken
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### 前端实现
|
||||
|
||||
**Register.vue**:
|
||||
```vue
|
||||
<template>
|
||||
<div class="register-page">
|
||||
<h1>用户注册</h1>
|
||||
|
||||
<RegisterForm
|
||||
v-if="!showVerificationNotice"
|
||||
@submit="handleRegister"
|
||||
:loading="loading"
|
||||
:error="error"
|
||||
/>
|
||||
|
||||
<VerificationNotice v-else :email="registeredEmail" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { registerUser } from '@/api/auth';
|
||||
import RegisterForm from '@/components/RegisterForm.vue';
|
||||
import VerificationNotice from '@/components/VerificationNotice.vue';
|
||||
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
const showVerificationNotice = ref(false);
|
||||
const registeredEmail = ref('');
|
||||
|
||||
async function handleRegister(data: {
|
||||
email: string;
|
||||
password: string;
|
||||
}) {
|
||||
loading.value = true;
|
||||
error.value = null;
|
||||
|
||||
try {
|
||||
await registerUser(data);
|
||||
registeredEmail.value = data.email;
|
||||
showVerificationNotice.value = true;
|
||||
} catch (e: any) {
|
||||
error.value = e.message || '注册失败,请稍后重试';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
### 3.3 运行测试验证
|
||||
|
||||
```bash
|
||||
npm test
|
||||
# ✓ 所有测试通过
|
||||
```
|
||||
|
||||
### 3.4 代码质量检查
|
||||
|
||||
```bash
|
||||
# 类型检查
|
||||
npm run typecheck
|
||||
# ✓ No errors
|
||||
|
||||
# 代码规范检查
|
||||
npm run lint
|
||||
# ✓ No issues
|
||||
```
|
||||
|
||||
### 3.5 代码实现确认 ⭐ 重要
|
||||
|
||||
**代码已实现完成**
|
||||
|
||||
**请确认以下内容**:
|
||||
|
||||
1. ✅ 功能是否按设计实现?
|
||||
2. ✅ 测试是否全部通过?
|
||||
3. ✅ 类型检查是否通过?
|
||||
4. ✅ 代码规范是否符合要求?
|
||||
5. ✅ 是否可以进入集成测试?
|
||||
|
||||
**请回复**:
|
||||
- **"确认"** - 进入集成测试阶段
|
||||
- **"修复 [具体问题]"** - 修复代码问题
|
||||
- **"查看代码"** - 查看实现的代码
|
||||
|
||||
⚠️ **只有在你确认后,我才会进入集成测试阶段**
|
||||
|
||||
---
|
||||
|
||||
## 阶段 4: 集成测试
|
||||
|
||||
### 4.1 API 测试
|
||||
|
||||
```typescript
|
||||
// tests/integration/register.test.ts
|
||||
describe('POST /api/auth/register', () => {
|
||||
it('should register user successfully', async () => {
|
||||
const response = await request(app)
|
||||
.post('/api/auth/register')
|
||||
.send({
|
||||
email: 'newuser@example.com',
|
||||
password: 'Passw0rd!',
|
||||
confirmPassword: 'Passw0rd!'
|
||||
});
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.body.message).toBe('注册成功,请查收验证邮件');
|
||||
expect(response.body.user.email).toBe('newuser@example.com');
|
||||
});
|
||||
|
||||
it('should return 400 for duplicate email', async () => {
|
||||
// 先注册一次
|
||||
await request(app)
|
||||
.post('/api/auth/register')
|
||||
.send({
|
||||
email: 'duplicate@example.com',
|
||||
password: 'Passw0rd!',
|
||||
confirmPassword: 'Passw0rd!'
|
||||
});
|
||||
|
||||
// 尝试再次注册
|
||||
const response = await request(app)
|
||||
.post('/api/auth/register')
|
||||
.send({
|
||||
email: 'duplicate@example.com',
|
||||
password: 'Passw0rd!',
|
||||
confirmPassword: 'Passw0rd!'
|
||||
});
|
||||
|
||||
expect(response.status).toBe(400);
|
||||
expect(response.body.error).toBe('邮箱已被注册');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 4.2 E2E 测试
|
||||
|
||||
```typescript
|
||||
// tests/e2e/user-registration.spec.ts
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('User Registration Flow', () => {
|
||||
test('should complete full registration flow', async ({ page }) => {
|
||||
// 访问注册页面
|
||||
await page.goto('/register');
|
||||
|
||||
// 填写表单
|
||||
await page.fill('input[name="email"]', 'e2e@example.com');
|
||||
await page.fill('input[name="password"]', 'Passw0rd!');
|
||||
await page.fill('input[name="confirmPassword"]', 'Passw0rd!');
|
||||
|
||||
// 提交表单
|
||||
await page.click('button[type="submit"]');
|
||||
|
||||
// 验证成功提示
|
||||
await expect(page.locator('text=请查收验证邮件')).toBeVisible();
|
||||
|
||||
// TODO: 自动化邮件验证流程(需要配置测试邮箱)
|
||||
});
|
||||
|
||||
test('should show error for weak password', async ({ page }) => {
|
||||
await page.goto('/register');
|
||||
|
||||
await page.fill('input[name="email"]', 'test@example.com');
|
||||
await page.fill('input[name="password"]', '123'); // 弱密码
|
||||
|
||||
// 密码强度指示器应显示"弱"
|
||||
await expect(page.locator('.password-strength.weak')).toBeVisible();
|
||||
|
||||
await page.click('button[type="submit"]');
|
||||
|
||||
// 应显示错误提示
|
||||
await expect(page.locator('text=密码强度不足')).toBeVisible();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 4.3 集成测试确认 ⭐ 重要
|
||||
|
||||
**测试报告已生成**: `docs/test-reports/{feature-name}-test-report.md`
|
||||
|
||||
**请确认以下内容**:
|
||||
|
||||
1. ✅ API 测试是否全部通过?
|
||||
2. ✅ E2E 测试是否覆盖核心流程?
|
||||
3. ✅ 测试覆盖率是否达标?
|
||||
4. ✅ 是否发现需要修复的问题?
|
||||
5. ✅ 是否可以进入代码审查?
|
||||
|
||||
**请回复**:
|
||||
- **"确认"** - 进入代码审查阶段
|
||||
- **"补充测试"** - 补充测试用例
|
||||
- **"查看报告"** - 查看完整测试报告
|
||||
|
||||
⚠️ **只有在你确认后,我才会进入代码审查阶段**
|
||||
|
||||
---
|
||||
|
||||
## 阶段 5: 代码审查
|
||||
|
||||
### 5.1 创建 Pull Request
|
||||
|
||||
```bash
|
||||
# 创建功能分支
|
||||
git checkout -b feature/user-registration
|
||||
|
||||
# 提交代码
|
||||
git add .
|
||||
git commit -m "feat: 添加用户注册功能
|
||||
|
||||
- 实现邮箱密码注册
|
||||
- 添加邮箱验证功能
|
||||
- 实现自动登录
|
||||
- 完整的测试覆盖
|
||||
|
||||
Closes #123"
|
||||
|
||||
# 推送到远程
|
||||
git push origin feature/user-registration
|
||||
```
|
||||
|
||||
### 5.2 自动审查
|
||||
|
||||
使用 `code-review` 技能进行自动审查:
|
||||
|
||||
```bash
|
||||
/code-review
|
||||
```
|
||||
|
||||
审查报告:
|
||||
```markdown
|
||||
## 代码审查报告
|
||||
|
||||
### ✅ 通过检查
|
||||
- [x] 所有测试通过 (100% 覆盖率)
|
||||
- [x] 类型检查通过
|
||||
- [x] 代码规范检查通过
|
||||
- [x] 无安全漏洞
|
||||
- [x] API文档已更新
|
||||
- [x] CHANGELOG已更新
|
||||
|
||||
### ⚠️ 建议改进
|
||||
1. **性能优化**
|
||||
- 建议为 users.email 添加索引
|
||||
- 位置: database/migrations/xxx.ts:10
|
||||
|
||||
2. **错误处理**
|
||||
- 建议为邮件发送失败添加重试机制
|
||||
- 位置: src/services/email.service.ts:25
|
||||
|
||||
3. **用户体验**
|
||||
- 建议添加密码可见性切换
|
||||
- 位置: src/components/PasswordInput.vue:15
|
||||
|
||||
### 📊 代码质量指标
|
||||
- 复杂度: 低 (平均 cyclomatic complexity: 3)
|
||||
- 重复代码: 无
|
||||
- 测试覆盖率: 100%
|
||||
- 文档覆盖率: 95%
|
||||
|
||||
### 总结
|
||||
代码质量优秀,建议合并。
|
||||
建议改进项可以在后续迭代中优化。
|
||||
```
|
||||
|
||||
### 5.3 人工审查
|
||||
|
||||
等待团队成员审查并反馈。
|
||||
|
||||
### 5.4 代码审查确认 ⭐ 重要
|
||||
|
||||
**审查报告已生成**: `docs/reviews/{feature-name}-review-{date}.md`
|
||||
|
||||
**请确认以下内容**:
|
||||
|
||||
1. ✅ 代码质量是否达标?
|
||||
2. ✅ 是否有需要立即修复的问题?
|
||||
3. ✅ 安全性检查是否通过?
|
||||
4. ✅ 性能是否符合要求?
|
||||
5. ✅ 是否可以合并代码?
|
||||
|
||||
**请回复**:
|
||||
- **"确认合并"** - 合并代码并部署上线
|
||||
- **"修复问题"** - 修复审查中发现的问题
|
||||
- **"查看报告"** - 查看完整审查报告
|
||||
|
||||
⚠️ **只有在你确认后,我才会合并代码并部署上线**
|
||||
|
||||
---
|
||||
|
||||
## 阶段 6: 部署上线
|
||||
|
||||
### 6.1 合并代码
|
||||
|
||||
```bash
|
||||
# 审查通过后合并到主分支
|
||||
git checkout main
|
||||
git merge feature/user-registration
|
||||
git push origin main
|
||||
```
|
||||
|
||||
### 6.2 CI/CD 自动部署
|
||||
|
||||
GitHub Actions 自动触发:
|
||||
```yaml
|
||||
# .github/workflows/deploy.yml
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
- name: Build
|
||||
run: npm run build
|
||||
- name: Deploy to production
|
||||
run: npm run deploy
|
||||
```
|
||||
|
||||
### 6.3 发布验证
|
||||
|
||||
**冒烟测试**:
|
||||
```bash
|
||||
# 测试注册功能
|
||||
curl -X POST https://api.example.com/auth/register \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"email": "smoke-test@example.com",
|
||||
"password": "Passw0rd!",
|
||||
"confirmPassword": "Passw0rd!"
|
||||
}'
|
||||
|
||||
# 预期返回 201
|
||||
```
|
||||
|
||||
**监控验证**:
|
||||
- 检查日志是否有错误
|
||||
- 检查注册成功率
|
||||
- 检查邮件发送成功率
|
||||
|
||||
---
|
||||
|
||||
## 阶段 7: 文档更新
|
||||
|
||||
### 7.1 更新 API 文档
|
||||
|
||||
```markdown
|
||||
## POST /api/auth/register
|
||||
|
||||
注册新用户账号。
|
||||
|
||||
### 请求
|
||||
\`\`\`json
|
||||
{
|
||||
"email": "user@example.com",
|
||||
"password": "Passw0rd!",
|
||||
"confirmPassword": "Passw0rd!"
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
### 响应
|
||||
\`\`\`json
|
||||
{
|
||||
"message": "注册成功,请查收验证邮件",
|
||||
"user": {
|
||||
"id": "uuid",
|
||||
"email": "user@example.com"
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
### 错误码
|
||||
- 400: 邮箱已被注册 / 密码强度不足 / 邮箱格式无效
|
||||
- 500: 服务器错误
|
||||
```
|
||||
|
||||
### 7.2 更新 CHANGELOG
|
||||
|
||||
```markdown
|
||||
## [1.1.0] - 2026-01-04
|
||||
|
||||
### Added
|
||||
- 用户注册功能 (#123)
|
||||
- 邮箱密码注册
|
||||
- 邮箱验证
|
||||
- 自动登录
|
||||
- 密码强度校验
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 总结
|
||||
|
||||
通过这个技能,你完成了:
|
||||
|
||||
✅ **需求分析** - 清晰的用户故事和验收标准
|
||||
✅ **方案设计** - 完整的技术方案
|
||||
✅ **测试驱动** - 先写测试,后写代码
|
||||
✅ **代码实现** - 高质量的代码
|
||||
✅ **质量保证** - 完整的测试覆盖
|
||||
✅ **代码审查** - 自动和人工审查
|
||||
✅ **自动部署** - CI/CD自动化
|
||||
✅ **文档更新** - 完整的文档记录
|
||||
|
||||
---
|
||||
|
||||
**现在,请告诉我你要开发什么功能?**
|
||||
Reference in new issue
Block a user