executar-bugfix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Bug Fix Execution

缺陷修复执行

Procedures

执行流程

Step 1: Context Analysis (Mandatory)
  1. Read the bugs file at
    ./tasks/prd-[feature-slug]/bugs.md
    and extract ALL documented bugs.
  2. Read the PRD at
    ./tasks/prd-[feature-slug]/prd.md
    to understand affected requirements.
  3. Read the Tech Spec at
    ./tasks/prd-[feature-slug]/techspec.md
    to understand relevant technical decisions.
  4. Review project rules for compliance in fixes.
  5. Do NOT skip this step — full context understanding is fundamental for quality fixes.
Step 2: Plan Fixes (Mandatory)
  1. For each bug, generate a planning summary:
    • Bug ID, Severity (High/Medium/Low), Affected Component.
    • Root Cause analysis.
    • Files to modify.
    • Fix strategy description.
    • Planned regression tests (unit, integration, E2E).
  2. Use Context7 MCP to analyze documentation of involved languages, frameworks, and libraries.
Step 3: Implement Fixes (Mandatory)
  1. Fix bugs in severity order: High first, then Medium, then Low.
  2. For each bug follow this sequence: a. Locate and read the affected code. b. Reason about the flow causing the bug. c. Implement the root-cause fix — no superficial workarounds. d. Run
    bun run typecheck
    after each fix. e. Run existing tests to ensure no regressions.
Step 4: Create Regression Tests (Mandatory)
  1. For each fixed bug, create tests that:
    • Simulate the original bug scenario (test must fail if the fix is reverted).
    • Validate the correct behavior with the fix applied.
    • Cover related edge cases.
  2. Choose test type based on bug nature:
    • Unit test: Bug in isolated function/method logic.
    • Integration test: Bug in module communication (e.g., controller + service).
    • E2E test: Bug visible in the UI or full flow.
Step 5: Visual Validation with Playwright MCP (Mandatory for frontend bugs)
  1. For bugs affecting the UI: a. Use
    browser_navigate
    to access the application. b. Use
    browser_snapshot
    to verify page state. c. Reproduce the flow that caused the bug. d. Use
    browser_take_screenshot
    to capture evidence of the fix.
Step 6: Final Test Execution (Mandatory)
  1. Run ALL project tests:
    bun run test
    .
  2. Verify ALL pass with 100% success.
  3. Run type checking:
    bun run typecheck
    .
  4. The task is NOT complete if any test fails.
Step 7: Update bugs.md (Mandatory)
  1. For each fixed bug, append to its entry:
    • Status: Fixed.
    • Applied fix: Brief description.
    • Regression tests: List of created tests.
Step 8: Generate Final Report
  1. Read the report template at
    assets/bugfix-report-template.md
    .
  2. Fill in all sections with actual results.
步骤1:上下文分析(必做)
  1. 读取位于
    ./tasks/prd-[feature-slug]/bugs.md
    的缺陷文件,提取所有已记录的缺陷。
  2. 读取位于
    ./tasks/prd-[feature-slug]/prd.md
    的PRD文档,了解受影响的需求。
  3. 读取位于
    ./tasks/prd-[feature-slug]/techspec.md
    的技术规格文档,明确相关技术决策。
  4. 查阅项目规则,确保修复方案符合规范要求。
  5. 请勿跳过此步骤——完整的上下文理解是高质量修复的基础。
步骤2:制定修复计划(必做)
  1. 为每个缺陷生成计划摘要,包含以下内容:
    • 缺陷ID、严重程度(高/中/低)、受影响组件
    • 根本原因分析
    • 待修改文件
    • 修复策略说明
    • 计划补充的回归测试(单元测试、集成测试、E2E测试)
  2. 使用Context7 MCP分析涉及的编程语言、框架和库的相关文档。
步骤3:执行修复(必做)
  1. 按严重程度顺序修复缺陷:优先修复高优先级,其次中优先级,最后低优先级。
  2. 每个缺陷的修复遵循以下流程: a. 定位并读取受影响的代码 b. 梳理导致缺陷的执行流程 c. 从根本原因层面实现修复,禁止使用表面的临时绕过方案 d. 每次修复后执行
    bun run typecheck
    e. 运行现有测试,确保没有引入回归问题
步骤4:编写回归测试(必做)
  1. 为每个已修复的缺陷编写测试用例,满足以下要求:
    • 模拟原始缺陷场景(如果回滚修复,该测试必须失败)
    • 验证修复应用后功能行为正确
    • 覆盖相关边界场景
  2. 根据缺陷类型选择测试类型:
    • 单元测试:孤立函数/方法逻辑存在的缺陷
    • 集成测试:模块通信层面的缺陷(例如控制器 + 服务层)
    • E2E测试:UI层面或全流程可见的缺陷
步骤5:使用Playwright MCP进行视觉验证(前端缺陷必做)
  1. 针对影响UI的缺陷: a. 使用
    browser_navigate
    访问应用 b. 使用
    browser_snapshot
    验证页面状态 c. 复现导致缺陷的操作流程 d. 使用
    browser_take_screenshot
    捕获修复生效的证据
步骤6:执行最终测试(必做)
  1. 运行项目所有测试:
    bun run test
  2. 验证所有测试100%通过
  3. 执行类型检查:
    bun run typecheck
  4. 如有任何测试失败,视为任务未完成
步骤7:更新bugs.md(必做)
  1. 为每个已修复的缺陷在其条目后追加以下内容:
    • 状态: 已修复
    • 应用的修复方案: 简要说明
    • 回归测试: 新增的测试用例列表
步骤8:生成最终报告
  1. 读取位于
    assets/bugfix-report-template.md
    的报告模板
  2. 使用实际结果填充所有章节

Error Handling

错误处理

  • If bugs.md does not exist, halt and report to the user.
  • If a bug requires significant architectural changes, document the justification before proceeding.
  • If new bugs are discovered during fixes, document them in bugs.md.
  • Begin implementation immediately after planning — do not wait for approval.
  • 如果bugs.md不存在,停止执行并向用户反馈
  • 如果某个缺陷需要大幅修改架构,先记录修改理由再继续执行
  • 修复过程中发现新缺陷时,将其记录到bugs.md中
  • 计划制定完成后立即开始执行,无需等待审批