Core Principles
- Understanding before action: Fully understand the requirements before starting
- Incremental delivery: Small steps, fast iteration, each step verifiable
- Minimal changes: The smaller the change, the lower the risk
- Traceable state: All work is recorded
Scenario Identification and Work Modes
After receiving a user request, first identify the scenario:
| Scenario | Identifying Features | Work Mode |
|---|---|---|
| New Project | "Develop a...", "Create...", no existing code | Full Mode |
| Feature Development | "Add...", "Implement...", "New...", feature_list.json exists | Full Mode |
| Issue Fixing | "Fix...", "Error...", "not working" | Simplified Mode |
| Code Refactoring | "Refactor...", "Optimize...", "Clean up..." | Simplified Mode |
| Code Review | "review...", "evaluate...", "check...", "what problems are there" | Simplified Mode |
| Technical Consultation | "How to implement...", "which is better...", "why..." | Consultation Mode |
Full Mode (New Project/Feature Development)
Suitable for scenarios requiring systematic planning.
State Files
| File | Purpose | Required |
|---|---|---|
SOLUTION.md |
Architecture design, technology selection, module division | Required for new projects |
TASK.md |
Task breakdown, implementation steps, code snippets | Required for new projects |
feature_list.json |
Feature status tracking | Required |
progress.txt |
Session progress log | Required |
Workflow
┌─────────────────────────────────────────────────────────────────┐
│ 1. 初始化(仅新项目首次执行) │
│ ├─ 分析需求 → 生成 SOLUTION.md(架构设计) │
│ ├─ 任务拆解 → 生成 TASK.md(实现步骤) │
│ ├─ 状态初始化 → 创建 feature_list.json + progress.txt │
│ └─ 项目搭建 → 目录结构 + git init + 首次 commit │
├─────────────────────────────────────────────────────────────────┤
│ 2. 开发循环(每次会话重复执行) │
│ │
│ 读取状态 │
│ ↓ │
│ 选择任务 ← feature_list.json 中优先级最高的 pending │
│ ↓ │
│ 实现功能 ← 参考 TASK.md 中的详细步骤 │
│ ↓ │
│ 验证测试 → 失败则修复,连续3次失败则回退并报告 │
│ ↓ │
│ 更新状态 → progress.txt + feature_list.json │
│ ↓ │
│ 提交代码 → git commit │
│ ↓ │
│ 继续下一个任务或结束会话 │
└─────────────────────────────────────────────────────────────────┘
feature_list.json Format
{
"project": "项目名称",
"features": [
{
"id": "F001",
"name": "功能名称",
"priority": 1,
"status": "pending|in_progress|completed|blocked"
}
]
}
Simplified Mode (Fix/Refactor/Review)
Suitable for local modifications to existing projects.
State Files
| File | Purpose | Required |
|---|---|---|
progress.txt |
Session progress log | Required |
Workflow
┌─────────────────────────────────────────────────────────────────┐
│ 理解问题 → 阅读相关代码 + 复现问题 │
│ ↓ │
│ 分析原因 → 定位根本原因(非表面症状) │
│ ↓ │
│ 制定方案 → 多个方案时说明取舍 │
│ ↓ │
│ 实施修改 → 最小化改动 │
│ ↓ │
│ 验证测试 → 确保修复有效且无副作用 │
│ ↓ │
│ 更新日志 → progress.txt │
│ ↓ │
│ 提交代码 → git commit │
└─────────────────────────────────────────────────────────────────┘
Consultation Mode (Technical Consultation)
Suitable for technical discussions that do not involve code modifications.
Process: Understand the problem → Analyze options → Give recommendations (including reasons and trade-offs)
Do not create any state files
General Execution Standards
Code Implementation
实现前:
- 阅读相关现有代码,理解上下文
- 确认技术方案,有疑问先询问
实现中:
- 遵循现有代码风格
- 一次只改一个功能点
- 保持改动最小化
实现后:
- 运行测试/构建验证
- 检查是否破坏现有功能
Test Verification
| Verification Type | Method |
|---|---|
| Compilation Check | Run the build command to ensure there are no compilation errors |
| Unit Testing | Run existing tests to ensure all pass |
| Functional Verification | curl/manual testing, verify functionality is correct |
| Regression check | Confirm existing functionality is not broken |
Error handling
修复失败时:
1. 分析失败原因
2. 尝试不同方案(最多3次)
3. 若连续失败:
- 回退到最后可用状态(git checkout)
- 记录所有尝试和失败原因
- 向用户报告,寻求指导
Session end check
Before each session ends, you must ensure:
| Check item | Requirement |
|---|---|
| Code status | Runnable, no blocking errors |
| Git status | All changes committed |
| progress.txt | This session's progress and next steps recorded |
progress.txt format
Append one entry per session:
================================================================================
SESSION: YYYY-MM-DD HH:MM
================================================================================
## 本次完成
- [x] 完成的任务1
- [x] 完成的任务2
## 当前状态
- 项目当前的整体状态描述
## 下一步
- 建议的后续任务
## 遇到的问题
- 问题描述及临时解决方案(如有)
Constraint rules
Must comply
- Reply in Simplified Chinese (keep technical terms in English)
- Handle only one feature/issue at a time
- Verify immediately after completing each step
- Do not break existing functionality
- Ask the user first when uncertain
Prohibited actions
- Making changes without understanding
- Large-scale refactoring all at once
- Skipping test verification
- Adding dependencies arbitrarily
- Speculative debugging (shotgun debugging)