simplify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/simplify
/simplify
Refactor and clean up code after tests pass.
测试通过后重构并清理代码。
Usage
使用方法
/simplify
/simplify src/openenv/core/client.py/simplify
/simplify src/openenv/core/client.pyWhen to Use
适用场景
- After makes tests pass
/implement - When code is correct but could be cleaner
- Before creating a PR (optional polish step)
- 在使测试通过之后
/implement - 代码逻辑正确但可以更简洁时
- 创建PR之前(可选的优化步骤)
When NOT to Use
不适用场景
- Tests are failing (fix tests first)
- You want to add new functionality (use first)
/write-tests - Code is already clean and simple
- 测试失败时(先修复测试)
- 你想要添加新功能时(先使用)
/write-tests - 代码已经简洁明了时
What It Does
功能说明
- Runs tests to ensure they pass (baseline)
- Identifies opportunities for simplification
- Refactors while keeping tests green
- Runs tests after each change to verify nothing broke
- 运行测试确保全部通过(基准验证)
- 识别可简化的优化点
- 在保持测试通过的前提下进行重构
- 每次修改后运行测试,确保没有引入问题
Philosophy
设计理念
This is TDD's third phase: Red → Green → Refactor.
The goal is NOT to add features or change behavior. The goal is to make the code:
- Easier to read
- Easier to maintain
- More consistent with project patterns
- Less duplicated
这是TDD(测试驱动开发)的第三个阶段:红 → 绿 → 重构。
目标不是添加功能或改变行为,而是让代码:
- 更易读
- 更易维护
- 与项目模式更一致
- 减少重复代码
Guidelines
指导原则
Good Simplifications
合理的简化操作
- Extract helper functions to reduce duplication
- Rename variables for clarity
- Remove dead code
- Simplify complex conditionals
- Use more Pythonic idioms
- 提取辅助函数以减少重复
- 重命名变量提升可读性
- 删除死代码
- 简化复杂条件判断
- 使用更符合Python风格的写法
NOT Simplifications (Avoid)
非简化操作(需避免)
- Adding new features
- Changing public APIs
- "Improving" code that works and is readable
- Adding abstractions for hypothetical future needs
- 添加新功能
- 修改公共API
- “优化”原本运行正常且可读性良好的代码
- 为假设性的未来需求添加抽象层
Completion Criteria
完成标准
- All tests still pass
- Code is cleaner/simpler than before
- No new functionality was added
- Changes follow project patterns (see PATTERNS.md)
- 所有测试仍能通过
- 代码比之前更简洁
- 未添加任何新功能
- 变更符合项目模式(参考PATTERNS.md)
Integration with TDD Workflow
与TDD工作流的集成
/write-tests → create failing tests (Red)
↓
/implement → make tests pass (Green)
↓
/simplify → clean up code (Refactor)
↓
/pre-submit-pr → validate before PR/write-tests → 创建失败的测试(红阶段)
↓
/implement → 使测试通过(绿阶段)
↓
/simplify → 清理代码(重构阶段)
↓
/pre-submit-pr → PR提交前验证