mirror of
https://github.com/sweetwisdom/everything-claude-code-zh.git
synced 2026-03-21 22:10:09 +00:00
docs: 完成所有文档的中文翻译并应用到项目
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
# Agent Orchestration
|
||||
# 智能体编排 (Agent Orchestration)
|
||||
|
||||
## Available Agents
|
||||
## 可用智能体 (Available Agents)
|
||||
|
||||
Located in `~/.claude/agents/`:
|
||||
位于 `~/.claude/agents/`:
|
||||
|
||||
| Agent | Purpose | When to Use |
|
||||
| 智能体 (Agent) | 用途 | 适用场景 |
|
||||
|-------|---------|-------------|
|
||||
| planner | Implementation planning | Complex features, refactoring |
|
||||
| architect | System design | Architectural decisions |
|
||||
| tdd-guide | Test-driven development | New features, bug fixes |
|
||||
| code-reviewer | Code review | After writing code |
|
||||
| security-reviewer | Security analysis | Before commits |
|
||||
| build-error-resolver | Fix build errors | When build fails |
|
||||
| e2e-runner | E2E testing | Critical user flows |
|
||||
| refactor-cleaner | Dead code cleanup | Code maintenance |
|
||||
| doc-updater | Documentation | Updating docs |
|
||||
| planner | 实现规划 | 复杂特性、重构 |
|
||||
| architect | 系统设计 | 架构决策 |
|
||||
| tdd-guide | 测试驱动开发 (TDD) | 新特性、Bug 修复 |
|
||||
| code-reviewer | 代码审查 | 代码编写/修改后 |
|
||||
| security-reviewer | 安全分析 | 提交代码前 |
|
||||
| build-error-resolver | 修复构建错误 | 构建失败时 |
|
||||
| e2e-runner | 端到端 (E2E) 测试 | 关键用户流程 |
|
||||
| refactor-cleaner | 冗余代码清理 | 代码维护 |
|
||||
| doc-updater | 文档更新 | 更新文档 |
|
||||
|
||||
## Immediate Agent Usage
|
||||
## 立即调用智能体 (Immediate Agent Usage)
|
||||
|
||||
No user prompt needed:
|
||||
1. Complex feature requests - Use **planner** agent
|
||||
2. Code just written/modified - Use **code-reviewer** agent
|
||||
3. Bug fix or new feature - Use **tdd-guide** agent
|
||||
4. Architectural decision - Use **architect** agent
|
||||
以下情况无需用户提示即可直接调用:
|
||||
1. 复杂特性请求 - 使用 **planner** 智能体
|
||||
2. 刚刚编写/修改的代码 - 使用 **code-reviewer** 智能体
|
||||
3. Bug 修复或新特性 - 使用 **tdd-guide** 智能体
|
||||
4. 架构决策 - 使用 **architect** 智能体
|
||||
|
||||
## Parallel Task Execution
|
||||
## 并行任务执行 (Parallel Task Execution)
|
||||
|
||||
ALWAYS use parallel Task execution for independent operations:
|
||||
对于相互独立的操作,**务必**使用并行任务执行:
|
||||
|
||||
```markdown
|
||||
# GOOD: Parallel execution
|
||||
Launch 3 agents in parallel:
|
||||
1. Agent 1: Security analysis of auth.ts
|
||||
2. Agent 2: Performance review of cache system
|
||||
3. Agent 3: Type checking of utils.ts
|
||||
# 推荐:并行执行
|
||||
并行启动 3 个智能体:
|
||||
1. 智能体 1:对 auth.ts 进行安全分析
|
||||
2. 智能体 2:对缓存系统进行性能审查
|
||||
3. 智能体 3:对 utils.ts 进行类型检查
|
||||
|
||||
# BAD: Sequential when unnecessary
|
||||
First agent 1, then agent 2, then agent 3
|
||||
# 避忌:在不必要时采用串行执行
|
||||
先启动智能体 1,然后智能体 2,最后智能体 3
|
||||
```
|
||||
|
||||
## Multi-Perspective Analysis
|
||||
## 多维度分析 (Multi-Perspective Analysis)
|
||||
|
||||
For complex problems, use split role sub-agents:
|
||||
- Factual reviewer
|
||||
- Senior engineer
|
||||
- Security expert
|
||||
- Consistency reviewer
|
||||
- Redundancy checker
|
||||
针对复杂问题,使用分角色子智能体:
|
||||
- 事实审查员 (Factual Reviewer)
|
||||
- 资深工程师 (Senior Engineer)
|
||||
- 安全专家 (Security Expert)
|
||||
- 一致性审查员 (Consistency Reviewer)
|
||||
- 冗余检查员 (Redundancy Checker)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Coding Style
|
||||
# 代码风格 (Coding Style)
|
||||
|
||||
## Immutability (CRITICAL)
|
||||
## 不可变性 (Immutability)(至关重要)
|
||||
|
||||
ALWAYS create new objects, NEVER mutate:
|
||||
始终创建新对象,严禁修改原对象 (Mutation):
|
||||
|
||||
```javascript
|
||||
// WRONG: Mutation
|
||||
// 错误:修改原对象 (Mutation)
|
||||
function updateUser(user, name) {
|
||||
user.name = name // MUTATION!
|
||||
user.name = name // 直接修改了原对象!
|
||||
return user
|
||||
}
|
||||
|
||||
// CORRECT: Immutability
|
||||
// 正确:不可变性 (Immutability)
|
||||
function updateUser(user, name) {
|
||||
return {
|
||||
...user,
|
||||
@@ -20,17 +20,17 @@ function updateUser(user, name) {
|
||||
}
|
||||
```
|
||||
|
||||
## File Organization
|
||||
## 文件组织
|
||||
|
||||
MANY SMALL FILES > FEW LARGE FILES:
|
||||
- High cohesion, low coupling
|
||||
- 200-400 lines typical, 800 max
|
||||
- Extract utilities from large components
|
||||
- Organize by feature/domain, not by type
|
||||
提倡“多而小”的文件,而非“少而大”的文件:
|
||||
- 高内聚,低耦合
|
||||
- 建议每文件 200-400 行,最大不超过 800 行
|
||||
- 从大型组件中提取工具函数 (Utilities)
|
||||
- 按功能/领域 (Feature/Domain) 组织,而非按类型 (Type) 组织
|
||||
|
||||
## Error Handling
|
||||
## 错误处理
|
||||
|
||||
ALWAYS handle errors comprehensively:
|
||||
始终进行全面的错误处理:
|
||||
|
||||
```typescript
|
||||
try {
|
||||
@@ -42,9 +42,9 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
## Input Validation
|
||||
## 输入校验
|
||||
|
||||
ALWAYS validate user input:
|
||||
始终校验用户输入:
|
||||
|
||||
```typescript
|
||||
import { z } from 'zod'
|
||||
@@ -57,14 +57,14 @@ const schema = z.object({
|
||||
const validated = schema.parse(input)
|
||||
```
|
||||
|
||||
## Code Quality Checklist
|
||||
## 代码质量自检清单
|
||||
|
||||
Before marking work complete:
|
||||
- [ ] Code is readable and well-named
|
||||
- [ ] Functions are small (<50 lines)
|
||||
- [ ] Files are focused (<800 lines)
|
||||
- [ ] No deep nesting (>4 levels)
|
||||
- [ ] Proper error handling
|
||||
- [ ] No console.log statements
|
||||
- [ ] No hardcoded values
|
||||
- [ ] No mutation (immutable patterns used)
|
||||
在标记工作完成之前:
|
||||
- [ ] 代码易读且命名良好
|
||||
- [ ] 函数体量小(<50 行)
|
||||
- [ ] 文件内容聚焦(<800 行)
|
||||
- [ ] 无深度嵌套(>4 层)
|
||||
- [ ] 具备完善的错误处理
|
||||
- [ ] 不存在 console.log 语句
|
||||
- [ ] 不存在硬编码 (Hardcoded) 数值
|
||||
- [ ] 不存在修改原对象 (Mutation) 操作(已采用不可变模式)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Git Workflow
|
||||
# Git 工作流 (Git Workflow)
|
||||
|
||||
## Commit Message Format
|
||||
## 提交信息格式 (Commit Message Format)
|
||||
|
||||
```
|
||||
<type>: <description>
|
||||
@@ -8,38 +8,38 @@
|
||||
<optional body>
|
||||
```
|
||||
|
||||
Types: feat, fix, refactor, docs, test, chore, perf, ci
|
||||
类型 (Types): feat, fix, refactor, docs, test, chore, perf, ci
|
||||
|
||||
Note: Attribution disabled globally via ~/.claude/settings.json.
|
||||
注意:归属归因 (Attribution) 已通过 `~/.claude/settings.json` 全局禁用。
|
||||
|
||||
## Pull Request Workflow
|
||||
## 拉取请求工作流 (Pull Request Workflow)
|
||||
|
||||
When creating PRs:
|
||||
1. Analyze full commit history (not just latest commit)
|
||||
2. Use `git diff [base-branch]...HEAD` to see all changes
|
||||
3. Draft comprehensive PR summary
|
||||
4. Include test plan with TODOs
|
||||
5. Push with `-u` flag if new branch
|
||||
创建 PR 时:
|
||||
1. 分析完整的提交历史(不仅是最近一次提交)
|
||||
2. 使用 `git diff [base-branch]...HEAD` 查看所有变更
|
||||
3. 起草详尽的 PR 摘要
|
||||
4. 包含带有 TODO 的测试计划
|
||||
5. 如果是新分支,使用 `-u` 参数推送
|
||||
|
||||
## Feature Implementation Workflow
|
||||
## 功能实现工作流 (Feature Implementation Workflow)
|
||||
|
||||
1. **Plan First**
|
||||
- Use **planner** agent to create implementation plan
|
||||
- Identify dependencies and risks
|
||||
- Break down into phases
|
||||
1. **规划先行 (Plan First)**
|
||||
- 使用 **planner** 智能体 (Agent) 创建实现计划
|
||||
- 识别依赖关系与风险
|
||||
- 拆分为多个阶段
|
||||
|
||||
2. **TDD Approach**
|
||||
- Use **tdd-guide** agent
|
||||
- Write tests first (RED)
|
||||
- Implement to pass tests (GREEN)
|
||||
- Refactor (IMPROVE)
|
||||
- Verify 80%+ coverage
|
||||
2. **测试驱动开发 (TDD Approach)**
|
||||
- 使用 **tdd-guide** 智能体 (Agent)
|
||||
- 先编写测试 (RED)
|
||||
- 实现功能以通过测试 (GREEN)
|
||||
- 重构 (IMPROVE)
|
||||
- 验证 80% 以上的覆盖率
|
||||
|
||||
3. **Code Review**
|
||||
- Use **code-reviewer** agent immediately after writing code
|
||||
- Address CRITICAL and HIGH issues
|
||||
- Fix MEDIUM issues when possible
|
||||
3. **代码评审 (Code Review)**
|
||||
- 在编写代码后立即使用 **code-reviewer** 智能体 (Agent)
|
||||
- 解决严重 (CRITICAL) 和高 (HIGH) 等级的问题
|
||||
- 尽可能修复中 (MEDIUM) 等级的问题
|
||||
|
||||
4. **Commit & Push**
|
||||
- Detailed commit messages
|
||||
- Follow conventional commits format
|
||||
4. **提交与推送 (Commit & Push)**
|
||||
- 详细的提交信息
|
||||
- 遵循约定式提交 (Conventional Commits) 格式
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
# Hooks System
|
||||
# 钩子系统(Hooks System)
|
||||
|
||||
## Hook Types
|
||||
## 钩子类型(Hook Types)
|
||||
|
||||
- **PreToolUse**: Before tool execution (validation, parameter modification)
|
||||
- **PostToolUse**: After tool execution (auto-format, checks)
|
||||
- **Stop**: When session ends (final verification)
|
||||
- **工具调用前(PreToolUse)**:在工具执行之前(验证、参数修改)
|
||||
- **工具调用后(PostToolUse)**:在工具执行之后(自动格式化、检查)
|
||||
- **会话终止(Stop)**:当会话结束时(最终验证)
|
||||
|
||||
## Current Hooks (in ~/.claude/settings.json)
|
||||
## 当前已配置的钩子(Current Hooks)(位于 ~/.claude/settings.json 中)
|
||||
|
||||
### PreToolUse
|
||||
- **tmux reminder**: Suggests tmux for long-running commands (npm, pnpm, yarn, cargo, etc.)
|
||||
- **git push review**: Opens Zed for review before push
|
||||
- **doc blocker**: Blocks creation of unnecessary .md/.txt files
|
||||
### 工具调用前(PreToolUse)
|
||||
- **tmux 提醒**:针对耗时较长的命令(npm, pnpm, yarn, cargo 等)建议使用 tmux
|
||||
- **git push 审查**:在推送(push)之前打开 Zed 进行代码审查
|
||||
- **文档拦截器(doc blocker)**:拦截不必要的 .md/.txt 文件创建
|
||||
|
||||
### PostToolUse
|
||||
- **PR creation**: Logs PR URL and GitHub Actions status
|
||||
- **Prettier**: Auto-formats JS/TS files after edit
|
||||
- **TypeScript check**: Runs tsc after editing .ts/.tsx files
|
||||
- **console.log warning**: Warns about console.log in edited files
|
||||
### 工具调用后(PostToolUse)
|
||||
- **PR 创建**:记录 PR URL 和 GitHub Actions 状态
|
||||
- **Prettier**:编辑后自动格式化 JS/TS 文件
|
||||
- **TypeScript 检查**:编辑 .ts/.tsx 文件后运行 tsc
|
||||
- **console.log 警告**:对已编辑文件中的 console.log 发出警告
|
||||
|
||||
### Stop
|
||||
- **console.log audit**: Checks all modified files for console.log before session ends
|
||||
### 会话终止(Stop)
|
||||
- **console.log 审计**:在会话结束前检查所有已修改的文件中是否存在 console.log
|
||||
|
||||
## Auto-Accept Permissions
|
||||
## 自动授权许可(Auto-Accept Permissions)
|
||||
|
||||
Use with caution:
|
||||
- Enable for trusted, well-defined plans
|
||||
- Disable for exploratory work
|
||||
- Never use dangerously-skip-permissions flag
|
||||
- Configure `allowedTools` in `~/.claude.json` instead
|
||||
请谨慎使用:
|
||||
- 仅对受信任且定义明确的任务方案启用
|
||||
- 在探索性工作中禁用
|
||||
- 严禁使用 `dangerously-skip-permissions` 标志
|
||||
- 改为在 `~/.claude.json` 中配置 `allowedTools`
|
||||
|
||||
## TodoWrite Best Practices
|
||||
## TodoWrite 最佳实践
|
||||
|
||||
Use TodoWrite tool to:
|
||||
- Track progress on multi-step tasks
|
||||
- Verify understanding of instructions
|
||||
- Enable real-time steering
|
||||
- Show granular implementation steps
|
||||
使用 TodoWrite 工具(Tool)以:
|
||||
- 跟踪多步骤任务的进度
|
||||
- 验证对指令的理解程度
|
||||
- 实现实时引导(steering)
|
||||
- 展示细粒度的实现步骤
|
||||
|
||||
Todo list reveals:
|
||||
- Out of order steps
|
||||
- Missing items
|
||||
- Extra unnecessary items
|
||||
- Wrong granularity
|
||||
- Misinterpreted requirements
|
||||
待办事项列表(Todo list)能够揭示:
|
||||
- 步骤顺序错乱
|
||||
- 遗漏项
|
||||
- 多余的不必要项
|
||||
- 粒度错误
|
||||
- 需求误读
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Common Patterns
|
||||
# 通用模式(Common Patterns)
|
||||
|
||||
## API Response Format
|
||||
## API 响应格式(API Response Format)
|
||||
|
||||
```typescript
|
||||
interface ApiResponse<T> {
|
||||
@@ -15,7 +15,7 @@ interface ApiResponse<T> {
|
||||
}
|
||||
```
|
||||
|
||||
## Custom Hooks Pattern
|
||||
## 自定义 Hook 模式(Custom Hooks Pattern)
|
||||
|
||||
```typescript
|
||||
export function useDebounce<T>(value: T, delay: number): T {
|
||||
@@ -30,7 +30,7 @@ export function useDebounce<T>(value: T, delay: number): T {
|
||||
}
|
||||
```
|
||||
|
||||
## Repository Pattern
|
||||
## 仓储模式(Repository Pattern)
|
||||
|
||||
```typescript
|
||||
interface Repository<T> {
|
||||
@@ -42,14 +42,14 @@ interface Repository<T> {
|
||||
}
|
||||
```
|
||||
|
||||
## Skeleton Projects
|
||||
## 骨架项目(Skeleton Projects)
|
||||
|
||||
When implementing new functionality:
|
||||
1. Search for battle-tested skeleton projects
|
||||
2. Use parallel agents to evaluate options:
|
||||
- Security assessment
|
||||
- Extensibility analysis
|
||||
- Relevance scoring
|
||||
- Implementation planning
|
||||
3. Clone best match as foundation
|
||||
4. Iterate within proven structure
|
||||
在实现新功能时:
|
||||
1. 搜索经过实战检验的骨架项目(Skeleton Projects)
|
||||
2. 使用并行智能体(Parallel Agents)评估备选项:
|
||||
- 安全性评估(Security assessment)
|
||||
- 可扩展性分析(Extensibility analysis)
|
||||
- 相关性评分(Relevance scoring)
|
||||
- 实施计划(Implementation planning)
|
||||
3. 克隆最匹配的项目作为基础
|
||||
4. 在已验证的结构内进行迭代
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
# Performance Optimization
|
||||
# 性能优化(Performance Optimization)
|
||||
|
||||
## Model Selection Strategy
|
||||
## 模型选择策略(Model Selection Strategy)
|
||||
|
||||
**Haiku 4.5** (90% of Sonnet capability, 3x cost savings):
|
||||
- Lightweight agents with frequent invocation
|
||||
- Pair programming and code generation
|
||||
- Worker agents in multi-agent systems
|
||||
**Haiku 4.5**(具备 Sonnet 90% 的能力,节省 3 倍成本):
|
||||
- 频繁调用的轻量级智能体(Agents)
|
||||
- 结对编程与代码生成
|
||||
- 多智能体系统中的执行者智能体(Worker agents)
|
||||
|
||||
**Sonnet 4.5** (Best coding model):
|
||||
- Main development work
|
||||
- Orchestrating multi-agent workflows
|
||||
- Complex coding tasks
|
||||
**Sonnet 4.5**(最佳编程模型):
|
||||
- 主力开发工作
|
||||
- 编排多智能体工作流(Workflow)
|
||||
- 复杂的编程任务
|
||||
|
||||
**Opus 4.5** (Deepest reasoning):
|
||||
- Complex architectural decisions
|
||||
- Maximum reasoning requirements
|
||||
- Research and analysis tasks
|
||||
**Opus 4.5**(最深层的推理能力):
|
||||
- 复杂的架构决策
|
||||
- 极高的推理需求
|
||||
- 研究与分析任务
|
||||
|
||||
## Context Window Management
|
||||
## 上下文窗口管理(Context Window Management)
|
||||
|
||||
Avoid last 20% of context window for:
|
||||
- Large-scale refactoring
|
||||
- Feature implementation spanning multiple files
|
||||
- Debugging complex interactions
|
||||
在以下场景中,避免触及上下文窗口(Context Window)最后 20% 的容量:
|
||||
- 大规模重构
|
||||
- 涉及多个文件的功能实现
|
||||
- 调试复杂的交互逻辑
|
||||
|
||||
Lower context sensitivity tasks:
|
||||
- Single-file edits
|
||||
- Independent utility creation
|
||||
- Documentation updates
|
||||
- Simple bug fixes
|
||||
对上下文敏感度较低的任务:
|
||||
- 单文件编辑
|
||||
- 独立工具函数创建
|
||||
- 文档更新
|
||||
- 简单的 Bug 修复
|
||||
|
||||
## Ultrathink + Plan Mode
|
||||
## Ultrathink + 计划模式(Plan Mode)
|
||||
|
||||
For complex tasks requiring deep reasoning:
|
||||
1. Use `ultrathink` for enhanced thinking
|
||||
2. Enable **Plan Mode** for structured approach
|
||||
3. "Rev the engine" with multiple critique rounds
|
||||
4. Use split role sub-agents for diverse analysis
|
||||
对于需要深度推理的复杂任务:
|
||||
1. 使用 `ultrathink` 以获得增强的思维过程
|
||||
2. 启用 **计划模式(Plan Mode)** 以采用结构化方法
|
||||
3. 通过多轮评审(Critique rounds)来“预热引擎”
|
||||
4. 使用分角色的子智能体(Sub-agents)进行多样化分析
|
||||
|
||||
## Build Troubleshooting
|
||||
## 构建故障排除(Build Troubleshooting)
|
||||
|
||||
If build fails:
|
||||
1. Use **build-error-resolver** agent
|
||||
2. Analyze error messages
|
||||
3. Fix incrementally
|
||||
4. Verify after each fix
|
||||
如果构建失败:
|
||||
1. 使用 **build-error-resolver** 智能体
|
||||
2. 分析错误消息
|
||||
3. 采用增量方式修复
|
||||
4. 每次修复后进行验证
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
# Security Guidelines
|
||||
# 安全指南 (Security Guidelines)
|
||||
|
||||
## Mandatory Security Checks
|
||||
## 强制安全检查 (Mandatory Security Checks)
|
||||
|
||||
Before ANY commit:
|
||||
- [ ] No hardcoded secrets (API keys, passwords, tokens)
|
||||
- [ ] All user inputs validated
|
||||
- [ ] SQL injection prevention (parameterized queries)
|
||||
- [ ] XSS prevention (sanitized HTML)
|
||||
- [ ] CSRF protection enabled
|
||||
- [ ] Authentication/authorization verified
|
||||
- [ ] Rate limiting on all endpoints
|
||||
- [ ] Error messages don't leak sensitive data
|
||||
在任何提交(Commit)之前:
|
||||
- [ ] 无硬编码凭据(API 密钥、密码、令牌/Tokens)
|
||||
- [ ] 所有用户输入均已验证
|
||||
- [ ] 预防 SQL 注入(使用参数化查询)
|
||||
- [ ] 预防 XSS(对 HTML 进行净化处理/Sanitized)
|
||||
- [ ] 已启用 CSRF 保护
|
||||
- [ ] 身份验证/授权已验证
|
||||
- [ ] 所有端点均已设置速率限制(Rate limiting)
|
||||
- [ ] 错误消息不泄露敏感数据
|
||||
|
||||
## Secret Management
|
||||
## 凭据管理 (Secret Management)
|
||||
|
||||
```typescript
|
||||
// NEVER: Hardcoded secrets
|
||||
// 严禁:硬编码凭据
|
||||
const apiKey = "sk-proj-xxxxx"
|
||||
|
||||
// ALWAYS: Environment variables
|
||||
// 推荐:环境变量
|
||||
const apiKey = process.env.OPENAI_API_KEY
|
||||
|
||||
if (!apiKey) {
|
||||
@@ -26,11 +26,11 @@ if (!apiKey) {
|
||||
}
|
||||
```
|
||||
|
||||
## Security Response Protocol
|
||||
## 安全响应协议 (Security Response Protocol)
|
||||
|
||||
If security issue found:
|
||||
1. STOP immediately
|
||||
2. Use **security-reviewer** agent
|
||||
3. Fix CRITICAL issues before continuing
|
||||
4. Rotate any exposed secrets
|
||||
5. Review entire codebase for similar issues
|
||||
如果发现安全问题:
|
||||
1. 立即停止(STOP)
|
||||
2. 使用 **security-reviewer** 智能体(Agent)
|
||||
3. 在继续之前修复严重(CRITICAL)问题
|
||||
4. 轮换任何暴露的凭据
|
||||
5. 审查整个代码库是否存在类似问题
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
# Testing Requirements
|
||||
# 测试要求
|
||||
|
||||
## Minimum Test Coverage: 80%
|
||||
## 最低测试覆盖率:80%
|
||||
|
||||
Test Types (ALL required):
|
||||
1. **Unit Tests** - Individual functions, utilities, components
|
||||
2. **Integration Tests** - API endpoints, database operations
|
||||
3. **E2E Tests** - Critical user flows (Playwright)
|
||||
测试类型(全部必选):
|
||||
1. **单元测试(Unit Tests)** - 独立函数、工具类、组件
|
||||
2. **集成测试(Integration Tests)** - API 终端、数据库操作
|
||||
3. **端到端测试(E2E Tests)** - 关键用户流程 (Playwright)
|
||||
|
||||
## Test-Driven Development
|
||||
## 测试驱动开发(TDD)
|
||||
|
||||
MANDATORY workflow:
|
||||
1. Write test first (RED)
|
||||
2. Run test - it should FAIL
|
||||
3. Write minimal implementation (GREEN)
|
||||
4. Run test - it should PASS
|
||||
5. Refactor (IMPROVE)
|
||||
6. Verify coverage (80%+)
|
||||
强制工作流(MANDATORY workflow):
|
||||
1. 先写测试(红 / RED)
|
||||
2. 运行测试 - 应当失败(FAIL)
|
||||
3. 编写最简实现代码(绿 / GREEN)
|
||||
4. 运行测试 - 应当通过(PASS)
|
||||
5. 重构(优化 / IMPROVE)
|
||||
6. 验证覆盖率(80%+)
|
||||
|
||||
## Troubleshooting Test Failures
|
||||
## 测试失败排查
|
||||
|
||||
1. Use **tdd-guide** agent
|
||||
2. Check test isolation
|
||||
3. Verify mocks are correct
|
||||
4. Fix implementation, not tests (unless tests are wrong)
|
||||
1. 使用 **tdd-guide** 智能体(Agent)
|
||||
2. 检查测试隔离性
|
||||
3. 验证 Mock 是否正确
|
||||
4. 修复实现逻辑,而非测试代码(除非测试代码本身有误)
|
||||
|
||||
## Agent Support
|
||||
## 智能体支持(Agent Support)
|
||||
|
||||
- **tdd-guide** - Use PROACTIVELY for new features, enforces write-tests-first
|
||||
- **e2e-runner** - Playwright E2E testing specialist
|
||||
- **tdd-guide** - 主动用于开发新特性,强制执行“先写测试”原则
|
||||
- **e2e-runner** - Playwright E2E 测试专家
|
||||
|
||||
Reference in New Issue
Block a user