Feature Modification Workflow
A standardized workflow for modifying existing features, ensuring changes are well-founded, controlled, and incremental.
Core Principles
Understand First, Then Modify — Before any feature change, understand the relevant code to ensure the change direction is correct.
Choose Workflow by Scenario — Simple issues get simplified workflow, complex issues get full workflow. No unnecessary overhead.
Check Docs When Needed — Only check latest documentation when dealing with complex technical details or specific API usage. Simple changes don't need this.
Conservative Optimization — Optimize without changing existing flows and core logic. Avoid high-risk large-scale refactoring.
Confirm Before Execute — Complex changes require user confirmation before development begins.
Step 1: Determine Scenario
After receiving a user request, first determine which scenario it falls into, then choose the corresponding workflow:
| Scenario | Characteristics | Workflow |
|---|
| Simple Issue | Change color, text, spacing, config values | Simplified: Read code → Change directly |
| Bug Fix |
Fix errors, exceptions, unexpected behavior | Must analyze cause. Simple bugs use simplified workflow, complex bugs use full workflow |
|
Complex Issue | New features, logic optimization, multi-file changes, architecture involved | Full 5-step workflow |
|
Refactoring | Core flow changes, large-scale code adjustments | Full 5-step workflow |
Scenario 1: Simple Issue (Simplified Workflow)
What Counts as Simple Issue
- - UI adjustments: change color, font size, spacing, borders
- Text modifications: change copy, hints, labels
- Config modifications: change defaults, parameters
- Single-file small changes: doesn't affect other modules
Simplified Workflow
CODEBLOCK0
Example
User: Change the login button color to blue
AI:
- - Read button code → Find color setting → Change to blue → Done
Scenario 2: Bug Fix (Must Analyze Cause)
Core Requirement
Bug fixes must first locate the cause. Don't change code based on guessing.
Simple Bug (Simplified Workflow)
Characteristics: Cause is clear, small change scope, doesn't affect other features
CODEBLOCK1
Complex Bug (Full Workflow)
Characteristics: Cause unclear, involves multiple modules, may affect other features, requires architecture changes
CODEBLOCK2
Judgment Criteria
| Simple Bug | Complex Bug |
|---|
| Clear error message, can locate directly | Cause unclear, needs investigation |
| Small change scope, 1-2 places |
Involves multiple files/modules |
| Doesn't affect other features | May cause chain reactions |
| Doesn't involve core logic | Needs to change core flow |
Scenario 3: Complex Issue (Full 5-Step Workflow)
What Counts as Complex Issue
- - Adding new features
- Optimizing logic/performance
- Changes involving multiple files
- Architecture adjustments
- Requires design proposals
Full Workflow
Step 1: Understand the Project Globally
After receiving a feature change request, don't start coding directly. First do the following:
- 1. Understand project structure
- Use Glob to view directory structure
- Identify core modules and dependencies
- Find relevant config files, entry files
- 2. Read key files
- Project documentation (CLAUDE.md, README.md, etc.)
- Core module implementation files
- Files directly related to the change target
- 3. Understand existing flows
- How data flows
- How modules communicate
- What the user interaction flow is
Output Format:
CODEBLOCK3
Step 2: Analyze Current State
After understanding the project, analyze the current state of the change target:
- 1. Current implementation analysis
- How is current code implemented
- What technologies/patterns are used
- What key design decisions were made
- 2. Identify strengths
- What's good about current implementation
- Which designs are reasonable and worth keeping
- 3. Identify bottlenecks
- Where are performance bottlenecks
- Where are UX bottlenecks
- Where are maintainability bottlenecks
- 4. Identify weaknesses
- Code quality issues
- Design flaws
- Extensibility limitations
Output Format:
CODEBLOCK4
Step 3: Propose Optimization Plan
Based on analysis, propose optimization plan. Key constraint: don't change existing flow
- - Optimization should be incremental, not a rewrite
- Keep core logic and data flow
- Only make local improvements
Output Format:
CODEBLOCK5
Step 4: List Plan and Ask User
Break down the optimization plan into specific steps, list the plan and ask user for confirmation:
Output Format:
CODEBLOCK6
Wait for user response. Don't start development on your own.
Step 5: Execute Step by Step After Confirmation
After user confirms:
- 1. Use TodoWrite to create task list, track progress
- Develop step by step
- Mark completion and inform user after each step
- Report issues promptly, don't bypass problems
During development:
- - Keep communication, ask user for important decisions
- Complete one step before starting next
- If plan needs adjustment, ask user first
Scenario 4: Refactoring (Full 5-Step Workflow)
Refactoring must follow the full workflow because of high risk and large impact scope.
Characteristics of refactoring:
- - Changes to core flow
- Large-scale code adjustments
- Involves multiple modules
- May affect existing features
Conditional Step: Check Documentation
Not all changes need documentation check. Only check in these cases:
When to Check Documentation
- 1. Complex technical details
- Audio processing algorithms (sample rate conversion, silence detection)
- Network protocol details (WebSocket frame format, Protobuf encoding)
- Multi-threading/concurrency issues (thread safety, lock mechanisms)
- 2. Unsure about specific API usage
- Framework API parameter meaning unclear
- Library function best practices
- API changes after version updates
- 3. Involves specifications or standards
- Data format specifications
- Protocol standard documents
- Security/compliance requirements
When NOT to Check Documentation
- - UI layout adjustments (spacing, colors, fonts)
- Simple logic changes (conditionals, parameter adjustments)
- Already familiar API usage
- Similar implementation exists in project for reference
Documentation Check Tools Priority
- 1. Context7 (
mcp__context7__resolve-library-id + mcp__context7__query-docs)
- Latest docs for programming libraries/frameworks
- PySide6, React, numpy, etc.
- 2. WebSearch
- Protocol specifications, technical articles
- WebSocket protocol, best practice articles
Quick Reference
Scenario-Workflow Mapping
| Scenario | Workflow |
|---|
| Simple Issue | Read code → Change directly |
| Simple Bug |
Analyze cause → Fix directly |
| Complex Bug | Full 5 steps |
| Complex Issue | Full 5 steps |
| Refactoring | Full 5 steps |
Full 5 Steps
| Step | Action | Output |
|---|
| 1 | Understand globally | Project overview |
| 2 |
Analyze current state | Strengths/bottlenecks/weaknesses |
| 3 | Propose plan | Optimization points/what not to change |
| 4 | List plan and ask | Step list + confirmation questions |
| 5 | Execute after confirmation | Develop step by step |
Conditional: Check documentation (for complex technical issues)
Remember:
Determine scenario first, then choose workflow. Handle simple issues simply, plan complex issues carefully.
功能修改工作流程
一个标准化的功能修改工作流程,确保变更有理有据、可控且渐进。
核心原则
先理解,再修改 — 在进行任何功能变更前,先理解相关代码,确保变更方向正确。
按场景选择工作流程 — 简单问题使用简化流程,复杂问题使用完整流程。避免不必要的开销。
需要时再查阅文档 — 仅在处理复杂技术细节或特定API用法时查阅最新文档。简单变更无需此步骤。
保守优化 — 在不改变现有流程和核心逻辑的前提下进行优化。避免高风险的大规模重构。
执行前先确认 — 复杂变更需要用户确认后才能开始开发。
第一步:判断场景
收到用户请求后,首先判断属于哪种场景,然后选择对应的工作流程:
| 场景 | 特征 | 工作流程 |
|---|
| 简单问题 | 修改颜色、文本、间距、配置值 | 简化流程:阅读代码 → 直接修改 |
| Bug修复 |
修复错误、异常、非预期行为 | 必须分析原因。简单Bug使用简化流程,复杂Bug使用完整流程 |
|
复杂问题 | 新功能、逻辑优化、多文件修改、涉及架构 | 完整5步工作流程 |
|
重构 | 核心流程变更、大规模代码调整 | 完整5步工作流程 |
场景1:简单问题(简化流程)
什么算简单问题
- - UI调整:修改颜色、字体大小、间距、边框
- 文本修改:修改文案、提示、标签
- 配置修改:修改默认值、参数
- 单文件小改动:不影响其他模块
简化流程
- 1. 阅读相关代码(仅需修改的部分)
- 进行修改
- 告知用户已完成
示例
用户:将登录按钮颜色改为蓝色
AI:
- - 读取按钮代码 → 找到颜色设置 → 改为蓝色 → 完成
场景2:Bug修复(必须分析原因)
核心要求
Bug修复必须先定位原因。不要基于猜测修改代码。
简单Bug(简化流程)
特征:原因明确,修改范围小,不影响其他功能
- 1. 分析当前状态:定位Bug原因
- 直接修复
- 告知用户已完成
复杂Bug(完整流程)
特征:原因不明确,涉及多个模块,可能影响其他功能,需要架构变更
遵循完整5步工作流程
判断标准
| 简单Bug | 复杂Bug |
|---|
| 错误信息明确,可直接定位 | 原因不明确,需要调查 |
| 修改范围小,1-2处 |
涉及多个文件/模块 |
| 不影响其他功能 | 可能引起连锁反应 |
| 不涉及核心逻辑 | 需要修改核心流程 |
场景3:复杂问题(完整5步工作流程)
什么算复杂问题
- - 添加新功能
- 优化逻辑/性能
- 涉及多个文件的修改
- 架构调整
- 需要设计方案
完整工作流程
第一步:全局了解项目
收到功能变更请求后,不要直接开始编码。先执行以下操作:
- 1. 了解项目结构
- 使用Glob查看目录结构
- 识别核心模块和依赖关系
- 找到相关配置文件、入口文件
- 2. 阅读关键文件
- 项目文档(CLAUDE.md、README.md等)
- 核心模块实现文件
- 与变更目标直接相关的文件
- 3. 了解现有流程
- 数据如何流转
- 模块间如何通信
- 用户交互流程是什么
输出格式:
项目概览
- - 项目类型:xxx
- 核心模块:xxx、xxx、xxx
- 数据流:xxx → xxx → xxx
相关模块
- - 模块A:负责xxx
- 模块B:负责xxx
- 依赖关系:A → B → C
第二步:分析当前状态
了解项目后,分析变更目标的当前状态:
- 1. 当前实现分析
- 当前代码如何实现
- 使用了什么技术/模式
- 做了哪些关键设计决策
- 2. 识别优势
- 当前实现好在哪
- 哪些设计合理值得保留
- 3. 识别瓶颈
- 性能瓶颈在哪
- 用户体验瓶颈在哪
- 可维护性瓶颈在哪
- 4. 识别弱点
- 代码质量问题
- 设计缺陷
- 扩展性限制
输出格式:
当前状态分析
当前实现
[描述当前实现]
优势
瓶颈/弱点
第三步:提出优化方案
基于分析,提出优化方案。关键约束:不改变现有流程
- - 优化应是渐进的,而非重写
- 保持核心逻辑和数据流
- 仅做局部改进
输出格式:
优化方案
概述
[简要描述优化方法]
优化点
- 1. xxx:[具体变更、预期效果]
- xxx:[具体变更、预期效果]
不修改的内容
风险评估
- - 变更范围:[大/中/小]
- 受影响模块:xxx、xxx
- 注意事项:xxx
第四步:列出计划并询问用户
将优化方案拆解为具体步骤,列出计划并询问用户确认:
输出格式:
开发计划
步骤列表
- 1. [ ] 步骤1:xxx
- [ ] 步骤2:xxx
- [ ] 步骤3:xxx
确认问题
- - 以上计划是否符合您的预期?
- 是否有需要调整或补充的步骤?
- 是否可以开始执行?
等待用户回复。不要自行开始开发。
第五步:确认后逐步执行
用户确认后:
- 1. 使用TodoWrite创建任务列表,跟踪进度
- 逐步开发
- 每完成一步标记完成并告知用户
- 及时报告问题,不要绕过问题
开发过程中:
- - 保持沟通,重要决策询问用户
- 完成一步后再开始下一步
- 如需调整计划,先询问用户
场景4:重构(完整5步工作流程)
重构必须遵循完整工作流程,因为风险高、影响范围大。
重构的特征:
- - 核心流程变更
- 大规模代码调整
- 涉及多个模块
- 可能影响现有功能
条件步骤:查阅文档
并非所有变更都需要查阅文档。仅在以下情况下需要:
何时查阅文档
- 1. 复杂技术细节
- 音频处理算法(采样率转换、静音检测)
- 网络协议细节(WebSocket帧格式、Protobuf编码)
- 多线程/并发问题(线程安全、锁机制)
- 2. 不确定特定API用法
- 框架API参数含义不明确
- 库函数最佳实践
- 版本更新后的API变更
- 3. 涉及规范或标准
- 数据格式规范
- 协议标准文档
- 安全/合规要求
何时不需要查阅文档
- - UI布局调整(间距、颜色、字体)
- 简单逻辑变更(条件判断、参数调整)
- 已熟悉的API用法
- 项目中有类似实现可参考
文档查阅工具优先级
- 1. Context7(mcpcontext7resolve-library-id + mcpcontext7query-docs)
- 编程库/框架的最新文档
- PySide6、React、numpy等
- 2. WebSearch
- 协议规范、技术文章
- WebSocket协议、最佳实践文章
快速参考
场景-工作流程映射
| 场景 | 工作流程 |
|---|
| 简单问题 | 阅读代码 → 直接修改 |
| 简单Bug |
分析原因 → 直接修复 |
| 复杂Bug | 完整5步 |
| 复杂问题 | 完整5步 |
| 重构 | 完整5步 |
完整5步
分析当前状态 | 优势/瓶颈/弱点 |
| 3 | 提出方案 | 优化点/不修改内容 |
| 4 | 列出计划并询问 | 步骤列表 + 确认问题 |
| 5 | 确认后执行 | 逐步开发 |
条件步骤:查阅文档(针对复杂技术问题)
记住:
先判断场景,再选择工作流程。简单问题简单处理,复杂问题仔细规划。