用于指导 Claude Code 按阶段规划、测试驱动实现、重构并提交代码。
完整提示词
### 1. 规划与分阶段 将复杂的工作分解为 3-5 个阶段。在 `IMPLEMENTATION_PLAN.md` 中记录: ```text ## 阶段 N: [Name] **目标**: [具体可交付成果] **成功标准**: [可测试的结果] **测试**: [具体的测试用例] **状态**: [未开始|进行中|已完成] ``` * 随着进展更新状态 * 所有阶段完成后删除文件 ### 2. 实现流程 1. **理解** - 研究代码库中的现有模式 2. **测试** - 先编写测试(红色状态) 3. **实现** - 编写最少代码通过测试(绿色状态) 4. **重构** - 在测试通过的前提下清理代码 5. **提交** - 附带明确信息并与计划关联 ### 3. 遇到困难时(尝试了 3 次后) **严重警告**: 每个问题最多尝试 3 次,然后停止。 * **记录失败原因**: * 你尝试了什么 * 具体的错误信息 * 你认为失败的原因 * **研究替代方案**: * 寻找 2-3 个类似的实现 * 记录使用的不同方法 * **反思基本问题**: * 当前的抽象层次是否合适? * 能否拆解为更小的问题? * 是否存在更简单的整体方案? * **尝试不同角度**: * 使用不同的库或框架特性? * 使用不同的架构模式? * 移除抽象而不是增加抽象? ### Technical Standards #### Architecture Principles - Composition over inheritance - Use dependency injection - Interfaces over singletons - Enable testing and flexibility - Explicit over implicit - Clear data flow and dependencies - Test-driven when possible - Never disable tests, fix them #### Code Quality Every commit must: - Compile successfully - Pass all existing tests - Include tests for new functionality - Follow project formatting/linting Before committing: - Run formatters/linters - Self-review changes - Ensure commit message explains "why" #### Error Handling - Fail fast with descriptive messages - Include context for debugging - Handle errors at appropriate level - Never silently swallow exceptions
使用说明
复制全文后,按自己的场景替换占位变量(方括号 / 双花括号包裹的字段)再使用。 部分提示词依赖特定模型或工具(如 GPT / Claude / Copilot),请根据实际情况调整。