Pre-protocol
Environment detection
# 检测当前项目信息
PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "unknown")
BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
echo "PROJECT: $PROJECT_ROOT"
echo "BRANCH: $BRANCH"
echo "COMMIT: $COMMIT"
Check whether inside a Git repository
if [ "$PROJECT_ROOT" = "unknown" ]; then echo "WARNING: Not in a Git repository" fi
### 前置技能检查
**dependencies 检查**(无依赖):
此技能无前置依赖,可直接执行。
**工件目录初始化**:
```bash
# 确保工件目录和目标目录存在
mkdir -p memory/artifacts/goal-oriented
mkdir -p memory/goals
User intent confirmation
Determine based on the user message:
Checkpoint:
- Whether the user request contains task characteristics (action instructions, multi-step requirements)
- Whether a new goal needs to be created, an existing goal updated, or a goal verified
- Determine whether it is a pure information query or a task that needs to be executed
Intent classification:
- Create goal: The user proposes a new task, and there is currently no pending goal
- Adjust goal: The user modifies the requirements, and there is currently a pending goal
- Verify goal: The AI believes it is complete, and the goal achievement status needs to be verified
- Query/conversation: Pure information query or simple Q&A, no need to create a goal
Requirement refinement and solution exploration (mandatory) (new)
Trigger timing: After creating the goal file and before executing the task
Mandatory action: Call the pre-skill chain in sequence
Pre-skill chain:
1. prompt-enhancer (requirement refinement + solution exploration)
Trigger conditions:
- The user requirements are vague or incomplete
- Complex task (involving multiple modules/systems)
- Need to explore multiple solutions
Execution steps:
创建目标后 → 调用 prompt-enhancer
↓
需求细化(每个关键点问3-4问题)
↓
方案探索(头脑风暴3-5种方案)
↓
用户选择方案
↓
生成需求方案工件
Artifact location:memory/artifacts/prompt-enhancer/result-{timestamp}.json
Value:
- Avoid misunderstanding
- Fully justify the solution
- Discover hidden requirements
2. planning (implementation planning + plan-review)
Trigger timing: After prompt-enhancer is completed
Mandatory action: Generate an implementation plan and have it confirmed by the user
Execution steps:
读取需求方案工件 → planning
↓
步骤分解(MECE原则)
↓
依赖识别
↓
资源规划
↓
风险评估
↓
生成实施计划
↓
plan-review(用户确认)
↓
生成实施计划工件
Artifact location:memory/artifacts/planning/result-{timestamp}.json
Value:
- Clarify the execution path
- Identify dependencies
- Assess risks in advance
- User confirms the plan
Experience retrieval (mandatory)
Trigger timing: After planning is completed
Mandatory action: Call the experience-manager skill to retrieve historical experience
Execution steps:
-
Extract keywords
从用户原始需求中提取关键词: - 技术关键词:框架、库、工具名称 - 功能关键词:核心功能描述 - 问题关键词:错误类型、问题场景 -
Write to the request artifact
Write( file_path="memory/artifacts/goal-oriented/experience-request.json", content={ "requesting_skill": "goal-oriented", "action": "retrieve", "task_keywords": ["关键词1", "关键词2"], "task_type": "bugfix|feature|refactor", "technologies": ["Technology1", "Technology2"] } ) -
Wait for experience-manager to process
- experience-manager automatically detects the request artifact
- Execute four-level retrieval and generate the result artifact
-
Read the result artifact
result = Read("memory/artifacts/experience-manager/experience-result.json") -
Display to the user
## 📚 历史经验参考 ### ⚠️ 错误预防(来自历史任务) ... ### 🎯 可复用模式 ... ### 💡 改进建议 ...
Value: Avoid repeating mistakes and quickly reuse successful experience.
Experience accumulation (mandatory)
Trigger timing: After the goal is marked as completed
Mandatory action: Call the experience-manager skill to accumulate experience
Execution steps:
-
Collect retrospective data
从目标文件中提取: - 原始需求(用户表述) - SMART 目标(具体、可衡量) - 执行过程(里程碑、调整历史) - 验证结果(完成情况) -
Generate an experience summary
- 做得好的(What Went Well) - 需要改进的(What Could Be Improved) - 错误与修复(Errors & Fixes) - 知识沉淀(Knowledge Gained) - 改进建议(Improvements) -
Write to the request artifact
Write( file_path="memory/artifacts/goal-oriented/experience-save-request.json", content={ "requesting_skill": "goal-oriented", "action": "save", "task_id": "2026-03-24_HHMM_task-keywords", "task_summary": "任务简要描述", "lessons_learned": [...], "errors_fixed": [...], "knowledge_gained": [...] } ) -
Wait for experience-manager to process
- experience-manager automatically detects the request
- Execute four-level accumulation (CLAUDE.md, AGENT.md, MEMORY.md, MCP Memory)
-
Confirm accumulation is complete
result = Read("memory/artifacts/experience-manager/save-result.json") if result.status == "success": print("✅ 经验已沉淀到四层级知识库")
Value: Accumulate knowledge assets and continuously optimize execution strategies.
Milestone Retrospective (Mandatory) (New)
Trigger Timing: When a milestone is completed
Mandatory Action: Invoke the experience-manager skill to conduct a retrospective
Purpose: Keep what works, change what doesn't, and continuously optimize
Execution Steps:
-
Identify milestone completion
当使用 Edit 工具更新里程碑记录时,检测是否为里程碑完成 -
Trigger retrospective request
Write( file_path="memory/artifacts/goal-oriented/milestone-review-request.json", content={ "requesting_skill": "goal-oriented", "action": "review", "task_id": "当前目标ID", "milestone": "里程碑描述", "milestone_status": "completed", "review_type": "milestone" } ) -
Wait for experience-manager to process
- experience-manager analyzes milestone gains and losses
- Keep good practices, change bad practices
- Update the four-level knowledge base
-
Read retrospective results
result = Read("memory/artifacts/experience-manager/review-result.json") 展示给用户: ## 🎯 里程碑复盘结果 ### ✅ 保留好的 - 成功经验1 - 成功经验2 ### ❌ 改掉坏的 - 改进项1 - 改进项2 ### 💡 后续优化建议 - 建议1 - 建议2
Value: Phased retrospectives allow timely strategy adjustments and avoid going too far in the wrong direction.
Overall Retrospective and Reflection (Mandatory) (New)
Trigger Timing: After the overall goal is completed
Mandatory Action: Invoke the experience-manager skill to conduct an in-depth retrospective and reflection
Purpose: Deeply analyze gains and losses, distill wisdom, crown what is good, and correct what is wrong
Execution Steps:
-
Trigger immediately after marking the goal as completed
当目标状态更新为 "completed" 时,自动触发复盘和反思 -
Initiate an in-depth retrospective
Write( file_path="memory/artifacts/goal-oriented/deep-review-request.json", content={ "requesting_skill": "goal-oriented", "action": "review", "task_id": "当前目标ID", "review_type": "project_end", "include_reflection": true, "analyze_milestones": true, "extract_wisdom": true } ) -
Wait for experience-manager in-depth analysis
- Analyze the entire task execution process
- Evaluate the gains and losses of each milestone
- Distill transferable wisdom
- Identify outdated experience that needs reflection
-
Read retrospective and reflection results
result = Read("memory/artifacts/experience-manager/deep-review-result.json") 展示给用户: ## 🏆 任务整体复盘与反思 ### 📊 整体表现 - 执行时长:X小时 - 里程碑数:X个 - 成功率:X% - 经验应用:X次 ### ✅ 保留好的(好则加冕) #### 成功经验 1. **经验1** - 应用效果:... - 推广建议:写入 CLAUDE.md 强制规则 2. **经验2** - 应用效果:... - 推广建议:写入 AGENT.md 标准策略 ### ❌ 改掉坏的(错则改之) #### 失败教训 1. **教训1** - 失败原因:... - 改进方案:... - 预防措施:... 2. **教训2** - 失败原因:... - 改进方案:... - 预防措施:... ### 🔄 需要反思的经验 1. **过时经验** - 原经验:... - 失效原因:技术栈升级 - 更新方案:... 2. **不完整经验** - 原经验:... - 局限性:... - 完善方案:... ### 💡 智慧提炼 **表层经验**: - 具体的技术做法 **深层智慧**: - 方法论层面的思考 - 可迁移的模式 - 通用的原则 ### 📋 后续行动 - [ ] 更新规则(CLAUDE.md) - [ ] 更新策略(AGENT.md) - [ ] 更新知识(MEMORY.md) - [ ] 标记过时经验 - [ ] 编写最佳实践指南 -
Execute the improvement plan
根据复盘结果,立即执行改进: - 更新四层级知识库 - 标记过时经验 - 创建改进任务 - 通知相关技能维护者
Value:
- Deep learning, continuous improvement
- Avoid repeating mistakes
- Accumulate wisdom assets
- Form a positive cycle
Example:
## 🏆 任务整体复盘与反思
**任务**: 优化 methodology-skills 项目的文档结构
### ✅ 保留好的(好则加冕)
1. **三级文档目录结构**
- 应用效果:5次应用,100%成功
- 推广建议:写入 CLAUDE.md 强制规则
- 行动:已完成
2. **README.md 导航文件**
- 应用效果:提升查找效率50%
- 推广建议:写入 AGENT.md 标准策略
- 行动:已完成
### ❌ 改掉坏的(错则改之)
1. **文档命名规范不完善**
- 问题:design-YYYY-MM-DD.md 排序不直观
- 改进:改为 YYYY-MM-DD-design-{title}.md
- 行动:已更新 CLAUDE.md
2. **缺少自动化工具**
- 问题:手动创建文档结构
- 改进:创建文档模板工具
- 行动:本周完成
### 🔄 需要反思的经验
1. **假设用户熟悉 DDD**
- 原经验:使用 DDD 思想划分文档边界上下文
- 问题:部分用户不了解 DDD
- 完善:提供简化的文档分类指南
### 💡 智慧提炼
**表层经验**:
- 文档按功能分类(design/guides/reference)
**深层智慧**:
- 从用户需求出发设计结构
- 简单明了优于复杂完美
- 自动化减少重复劳动
**可迁移模式**:
- 分析本质需求 → 设计分类体系 → 建立导航机制 → 自动化工具支持
Overview
Goal-oriented thinking emphasizes being guided by the ultimate goal, with all actions and decisions serving the achievement of that goal. It focuses on "What result do I want to achieve?" and ensures that the direction is not deviated from during the process.
Core Principle: Begin with the End in Mind
Key Value:
- Avoid task deviation from the goal (Scope Creep)
- Ensure resources are invested in the critical path
- Quickly identify irrelevant work
- Keep the team aligned in direction
When to Use
Applicable Scenarios:
- Need to implement new requirements, new ideas, or new tasks
- Execute medium- and long-term tasks (duration > 1 minute or steps > 1)
- Project planning and management
- Complex tasks that easily deviate from the goal
- Multiple tasks in parallel, requiring priority judgment
- Limited resources, requiring focus
- The user explicitly requests "execute in a goal-oriented manner"
Inapplicable Scenarios:
- Simple, clear small tasks, such as calculating 1+1=?
- Exploratory work where the goal itself is unclear
⚠️ Mandatory Enforcement Rule (Iron Law)
⚡ Core Principle: Continuous Triggering
Every user message must trigger a goal-oriented check, regardless of whether a goal has already been created before.
After triggering, execute the corresponding action according to the current state:
- No goal → Create a goal
- Has pending goal → check user intent (supplement/adjust/restart)
- Has completed goal → check whether it is a new task
At task start (mandatory goal creation)
Detection criteria:
- User message contains action instructions (implement, fix, refactor, optimize, analyze, design, review, etc.)
- Multi-step requirement (requires 1+ steps to complete)
- Involves code writing, file modification, system design, code review
- Currently no pending goal
Mandatory action: Use the Write tool to create the goal file (see "Goal File Operation Guide")
No need to ask the user, execute immediately.
Exceptions:
- Pure information query ("What is XXX", "How to use XXX")
- Simple Q&A (yes/no questions, knowledge consultation)
- User explicitly states "just asking", "just chatting"
- A pending goal already exists(go to the "During task execution" rule)
If the conversation evolves into a task midway, a goal must be created retroactively.
During task execution (mandatory goal adjustment)
Trigger conditions:
- A pending goal already exists
- User continues to provide requirement details
- User explicitly modifies requirements ("never mind", "change it to", "add one", "also need")
- User adds new requirements or constraints
- Environmental changes make the goal infeasible
Mandatory action: Use the Edit tool to adjust the goal file (see "Goal File Operation Guide")
Adjustment principles:
- Immediately synchronize the user's new intent
- Preserve the complete adjustment history (version records)
- Subsequent verification uses the latest version of the goal
Handling when the user says "reimplement", "start over":
- Check the progress of the existing goal
- If the goal has not started execution (no code, no progress) → directly adjust the existing goal
- If the goal has started execution → ask the user:
- "The existing goal already has progress. Create a new goal or adjust the existing goal?"
- Provide: create new goal / adjust existing goal / cancel both options
At task completion (mandatory goal verification)
Trigger timing:
- AI believes it is "done", "finished", "implemented"
- Preparing to commit code, create a PR
- Preparing to end the session
Mandatory action: Use the Read tool to read the goal file and verify (see "Goal File Operation Guide")
Handling of verification results:
- ✅ Goal achieved → can be marked complete, ready to end the session
- ❌ Goal not achieved → must continue executing the missing parts, must not claim "basically complete"
Violations (unacceptable)
- ❌ Executed a task but did not create a goal
- ❌ User adjusted requirements but the goal was not updated
- ❌ Claimed "complete" but did not verify
- ❌ Verification failed but claimed "basically complete"
Any behavior that violates the above rules is unacceptable.
The Process
digraph goal_oriented_with_tools {
rankdir=TB;
"用户首条消息" [shape=box, style=filled, fillcolor="#c8e6c9"];
"AI 判断:是否包含任务?" [shape=diamond, style=filled, fillcolor="#bbdefb"];
"使用 Write 工具创建目标文件" [shape=box, style=filled, fillcolor="#fff9c4"];
"明确最终目标" [shape=box, style=filled, fillcolor="#c8e6c9"];
"定义成功标准" [shape=box, style=filled, fillcolor="#bbdefb"];
"识别关键路径" [shape=box, style=filled, fillcolor="#fff9c4"];
"执行与监控" [shape=box, style=filled, fillcolor="#f8bbd0"];
"里程碑完成检查" [shape=diamond, style=filled, fillcolor="#e1bee7"];
"使用 Edit 工具更新里程碑" [shape=box, style=filled, fillcolor="#ffccbc"];
"用户提出调整?" [shape=diamond, style=filled, fillcolor="#e1bee7"];
"使用 Edit 工具调整目标" [shape=box, style=filled, fillcolor="#ffccbc"];
"AI 判断任务完成?" [shape=diamond, style=filled, fillcolor="#e1bee7"];
"使用 Read 工具验证目标" [shape=box, style=filled, fillcolor="#ffccbc"];
"目标达成验证" [shape=diamond, style=filled, fillcolor="#e1bee7"];
"继续执行缺失部分" [shape=box, style=filled, fillcolor="#f8bbd0"];
"使用 Edit 工具标记完成" [shape=box, style=filled, fillcolor="#81c784"];
"保存工件到 memory/artifacts/" [shape=box, style=filled, fillcolor="#81c784"];
"可结束会话" [shape=doublecircle, style=filled, fillcolor="#81c784"];
"正常对话" [shape=box, style=filled, fillcolor="#f8bbd0"];
"用户首条消息" -> "AI 判断:是否包含任务?";
"AI 判断:是否包含任务?" -> "使用 Write 工具创建目标文件" [label="是"];
"AI 判断:是否包含任务?" -> "正常对话" [label="否"];
"使用 Write 工具创建目标文件" -> "明确最终目标";
"明确最终目标" -> "定义成功标准";
"定义成功标准" -> "识别关键路径";
"识别关键路径" -> "执行与监控";
"执行与监控" -> "里程碑完成检查";
"里程碑完成检查" -> "使用 Edit 工具更新里程碑" [label="是"];
"使用 Edit 工具更新里程碑" -> "用户提出调整?";
"里程碑完成检查" -> "用户提出调整?" [label="否"];
"用户提出调整?" -> "使用 Edit 工具调整目标" [label="是"];
"用户提出调整?" -> "AI 判断任务完成?" [label="否"];
"使用 Edit 工具调整目标" -> "执行与监控";
"AI 判断任务完成?" -> "使用 Read 工具验证目标" [label="是"];
"AI 判断任务完成?" -> "执行与监控" [label="否"];
"使用 Read 工具验证目标" -> "目标达成验证";
"目标达成验证" -> "继续执行缺失部分" [label="未达成"];
"目标达成验证" -> "使用 Edit 工具标记完成" [label="达成"];
"使用 Edit 工具标记完成" -> "保存工件到 memory/artifacts/";
"保存工件到 memory/artifacts/" -> "可结束会话";
"继续执行缺失部分" -> "执行与监控";
}
Step details
Step 1: AI determines whether it contains a task
- Analyze the user's first message
- Detect task characteristics (action instructions, multi-step requirements)
- Decide whether to trigger goal tracking
Step 2: Use the Write tool to create the goal file (mandatory)
- Automatically create the goal file
- Record the user's original requirements
- Extract SMART goals
Step 3: Clarify the final goal
- State the final goal in one sentence
- Ensure the goal conforms to the SMART principle
- Distinguish between "goals" and "means"
Step 4: Define success criteria
- How to determine whether the goal has been achieved?
- Set measurable indicators
- Clarify acceptance conditions
Step 5: Identify the critical path
- Find the necessary path to achieving the goal
- Identify blocking tasks and dependencies
- Determine priorities
Step 6: Execution and monitoring
- Execute according to the critical path
- Continuously monitor progress
- Record deviations and issues
Step 7: Milestone completion check
- Identify phased outcomes
- Trigger milestone updates
Step 8: Use the Edit tool to update milestones (optional)
- Update milestone progress
- Keep progress transparent
Step 9: Did the user propose adjustments? (mandatory)
- Monitor changes in user requirements
- Adjust the goal immediately
Step 10: Use the Edit tool to adjust the goal (mandatory)
- Update SMART goals
- Preserve historical versions
- Synchronize new intent
Step 11: Does the AI judge the task to be complete?
- AI self-assessment
- Trigger mandatory verification
Step 12: Use the Read tool to verify the goal (mandatory)
- Compare the original goal vs. actual completion
- Identify missing items
- Output verification results
Step 13: Goal achievement verification
- Determine whether it has been fully achieved
- Decide follow-up actions
Step 14: Continue executing the missing parts (if not achieved)
- Supplement missing functionality
- Do not claim "basically complete"
Step 15: Use the Edit tool to mark completion
- Update the goal file status
- Record the completion time
- Prepare to end the session
Step 16: Save the artifact to memory/artifacts/
- Generate the artifact JSON file
- Create the latest.json symbolic link
- Record recommended follow-up skills
Goal Decomposition Tool
Use the following checklist to ensure the goal is clear and executable:
- Goal statement: Clearly describe the final goal in one sentence
- Success criteria (SMART):
- Specific: Clearly define what is to be achieved
- Measurable: Has quantitative indicators
- Achievable: Feasible in terms of resources and capabilities
- Relevant: Consistent with the broader goal
- Time-bound: Has a clear deadline
- Key milestones: Break down into 3-5 key nodes
- Potential distractions: Identify risks that may deviate from the goal
- Deviation warning signals: Set thresholds that trigger adjustments
Goal decomposition example:
目标: 重构用户认证模块,提升安全性
成功标准:
- [x] Specific: 重构认证模块,消除安全隐患
- [x] Measurable: 测试覆盖率 > 90%,无高危漏洞
- [x] Achievable: 2人周,技术栈不变
- [x] Relevant: 降低安全事故风险
- [x] Time-bound: 2周内完成
关键里程碑:
- M1: 完成现有代码审计(Day 3)
- M2: 实现核心重构(Day 7)
- M3: 测试通过并上线(Day 10)
潜在干扰因素:
- 新需求插入
- 依赖服务变更
- 团队成员抽调
偏离预警信号:
- 里程碑延期 > 20%
- 新增非核心功能
- 讨论偏离认证安全主题
Goal file operation guide
Goal file location
Storage path:memory/goals/YYYY-MM-DD_HHMM_目标关键词.md
Keyword extraction rules: From smart_specific extract the first 20 non-space characters as the filename
Directory creation: If the memory/goals/ directory does not exist, it must be created first
Operation 1: Create goal (create)
Trigger timing: When the task starts (mandatory)
Execution steps:
-
Extract timestamp
timestamp = "2026-03-23_2005" # 格式:YYYY-MM-DD_HHMM -
Extract keywords
keywords = smart_specific.replace(" ", "")[:20] # 示例:"修复英文页面404错误,确保路由正常工作" → "修复英文页面404错误,确保路由" -
Assemble the file path
file_path = f"memory/goals/{timestamp}_{keywords}.md" -
Use the Write tool to create the file, filling in the following template:
# 目标追踪记录
## 原始需求
{用户原始表述}
## 目标提取(SMART)
- **Specific(具体)**: {具体目标}
- **Measurable(可衡量)**: {衡量标准}
- **Achievable(可实现)**: 待评估
- **Relevant(相关)**: 待说明
- **Time-bound(时限)**: 本次会话
## 创建信息
- 创建时间:{YYYY-MM-DD HH:MM}
- 会话ID:当前会话
- 当前版本:1
## 目标调整历史
### 版本 1({时间})
- **SMART-Specific**: {具体目标}
- **SMART-Measurable**: {衡量标准}
## 验证记录
(待填写)
## 最终状态
- 状态:pending
- 完成时间:-
- 备注:-
Complete example:
用户消息:"现在在中文时候跳转一切正常,但是英文时候全是404,和最开始中文的bug一样"
AI 执行:
1. 提取时间戳:"2026-03-23_2005"
2. 提取关键词:"修复英文页面404错误,确保路由"
3. 文件路径:"memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md"
Write(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
content="""
# 目标追踪记录
## 原始需求
现在在中文时候跳转一切正常,但是英文时候全是404,和最开始中文的bug一样
## 目标提取(SMART)
- **Specific(具体)**: 修复英文页面的404错误,确保路由正常工作
- **Measurable(可衡量)**: 所有英文页面可正常访问,无404错误
- **Achievable(可实现)**: 待评估
- **Relevant(相关)**: 待说明
- **Time-bound(时限)**: 本次会话
## 创建信息
- 创建时间:2026-03-23 20:05
- 会话ID:当前会话
- 当前版本:1
## 目标调整历史
### 版本 1(2026-03-23 20:05)
- **SMART-Specific**: 修复英文页面的404错误,确保路由正常工作
- **SMART-Measurable**: 所有英文页面可正常访问,无404错误
## 验证记录
(待填写)
## 最终状态
- 状态:pending
- 完成时间:-
- 备注:-
"""
)
✅ 输出:"目标已创建:memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md"
Operation 2: Update milestone (update)
Trigger timing: When a phase is completed
Execution steps:
-
Use the Read tool to read the goal file(optional, to confirm the current content)
-
Use the Edit tool to append the milestone content, inserting before
## 验证记录:
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="## 验证记录",
new_string="""### 里程碑:{里程碑描述}
更新时间:{YYYY-MM-DD HH:MM}
## 验证记录"""
)
Complete example:
里程碑描述:"诊断完成,发现英文路由配置问题"
时间:"2026-03-23 20:10"
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="## 验证记录",
new_string="""### 里程碑:诊断完成,发现英文路由配置问题
更新时间:2026-03-23 20:10
## 验证记录"""
)
✅ 输出:"已更新里程碑:诊断完成,发现英文路由配置问题"
Operation 3: Adjust goal (adjust)
Trigger timing: When the user changes requirements (mandatory)
Execution steps:
-
Use the Read tool to read the goal file, and extract the current version number
-
Use the Edit tool to update in sequence:
- Update the version number
- Update the SMART goal
- Append adjustment history
Complete example:
用户消息:"对了,还要优化路由架构,不只是修复404"
AI 执行:
# 步骤1:读取文件,当前版本号为 1
Read(file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md")
# 步骤2:更新版本号(1 → 2)
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="当前版本:1",
new_string="当前版本:2"
)
# 步骤3:更新 SMART-Specific
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="- **Specific(具体)**: 修复英文页面的404错误,确保路由正常工作",
new_string="- **Specific(具体)**: 修复英文页面404错误,并优化路由架构"
)
# 步骤4:更新 SMART-Measurable
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="- **Measurable(可衡量)**: 所有英文页面可正常访问,无404错误",
new_string="- **Measurable(可衡量)**: 所有英文页面正常访问,路由架构清晰,无冗余路由"
)
# 步骤5:追加调整历史
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="## 验证记录",
new_string="""### 版本 2(2026-03-23 20:15)
- **调整原因**: 用户要求优化路由架构
- **SMART-Specific**: 修复英文页面404错误,并优化路由架构
- **SMART-Measurable**: 所有英文页面正常访问,路由架构清晰,无冗余路由
## 验证记录"""
)
✅ 输出:
"目标已调整"
"调整原因:用户要求优化路由架构"
"新版本:2"
Operation 4: Verify goal (verify)
Trigger timing: When the AI considers the task complete (mandatory)
Execution steps:
-
Use the Read tool to read the goal file
-
Extract the SMART goal:
- Specific
- Measurable
-
Compare the AI self-assessment completion status
-
Output the verification result:
- ✅ Goal achieved
- ❌ Goal not achieved + list of missing items
Complete example:
AI 自评:"已修复英文路由配置,优化了路由架构,所有测试通过"
AI 执行:
Read(file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md")
提取目标:
- Specific: 修复英文页面404错误,并优化路由架构
- Measurable: 所有英文页面正常访问,路由架构清晰,无冗余路由
对比分析:
✅ 修复了英文页面404错误
✅ 优化了路由架构
✅ 所有测试通过
验证结果:
📋 原始目标:修复英文页面404错误,并优化路由架构
🔍 实际完成情况:已修复英文路由配置,优化了路由架构,所有测试通过
✅ 目标达成验证通过
Operation 5: Mark complete (complete)
Trigger timing: After the goal verification passes
Execution steps:
Use the Edit tool to update the status and completion time:
Complete example:
完成时间:"2026-03-23 20:20"
# 步骤1:更新状态
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="状态:pending",
new_string="状态:completed"
)
# 步骤2:更新完成时间
Edit(
file_path="memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md",
old_string="完成时间:-",
new_string="完成时间:2026-03-23 20:20"
)
✅ 输出:
"目标已完成"
"完成时间:2026-03-23 20:20"
Operation 6: List all goals (list)
Trigger timing: When viewing all goals of the project
Execution steps:
- Use the Glob tool to find
memory/goals/*.mdfiles - Use the Read tool to read each file's status and goal
- Filter by status (optional)
Complete example:
查看所有 pending 状态的目标:
Glob(pattern="memory/goals/*.md")
输出:
1. memory/goals/2026-03-23_2005_修复英文页面404错误,确保路由.md (pending)
2. memory/goals/2026-03-22_1015_重构用户认证模块.md (completed)
Examples
Case 1: Improve the complete goal-oriented workflow
User message: "Improve the trigger conditions for goal-oriented; whenever the user issues any task, this goal-oriented skills should record it..."
Step 1: The AI detects the task and uses the Write tool to create the goal
Write(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
content="""
# 目标追踪记录
## 原始需求
完善 goal-oriented 的触发条件;只要用户下达了什么任务,这个 goal-oriented skills 就要记录...
## 目标提取(SMART)
- **Specific(具体)**: 实现自动目标追踪和验证机制
- **Measurable(可衡量)**: 任务记录,会话结束前验证,未达成继续执行
- **Achievable(可实现)**: 待评估
- **Relevant(相关)**: 待说明
- **Time-bound(时限)**: 本次会话
## 创建信息
- 创建时间:2026-03-18 09:30
- 会话ID:当前会话
- 当前版本:1
## 目标调整历史
### 版本 1(2026-03-18 09:30)
- **SMART-Specific**: 实现自动目标追踪和验证机制
- **SMART-Measurable**: 任务记录,会话结束前验证,未达成继续执行
## 验证记录
(待填写)
## 最终状态
- 状态:pending
- 完成时间:-
- 备注:-
"""
)
✅ Output:目标已创建:memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md
Step 2: The AI executes the task, using the Edit tool to update the milestone
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="## 验证记录",
new_string="""### 里程碑:Write/Update 「功能」开发完成
更新时间:2026-03-18 10:00
## 验证记录"""
)
✅ Output:已更新里程碑:Write/Update 「功能」开发完成
Step 3: The user adds requirements, using the Edit tool to adjust the goal
User message: "By the way, it also needs to support real-time goal adjustment, to prevent the user from changing their mind in subsequent conversations"
# 更新版本号
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="当前版本:1",
new_string="当前版本:2"
)
# 更新 SMART 目标
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="- **Specific(具体)**: 实现自动目标追踪和验证机制",
new_string="- **Specific(具体)**: 实现自动目标追踪、验证和动态调整机制"
)
# 追加调整历史
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="## 验证记录",
new_string="""### 版本 2(2026-03-18 10:15)
- **调整原因**: 用户补充:需要实时调整目标
- **SMART-Specific**: 实现自动目标追踪、验证和动态调整机制
- **SMART-Measurable**: 任务记录,会话结束前验证,未达成继续执行,实时调整目标
## 验证记录"""
)
✅ Output:目标已调整,新版本:2
Step 4: The AI considers it complete, using the Read tool to verify the goal
Read(file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md")
提取目标:
- Specific: 实现自动目标追踪、验证和动态调整机制
- Measurable: 任务记录,会话结束前验证,未达成继续执行,实时调整目标
AI 自评:"已完成脚本开发、文档更新、支持动态调整"
验证结果:
📋 原始目标:实现自动目标追踪、验证和动态调整机制
🔍 实际完成情况:所有功能已实现并测试通过
✅ 目标达成验证通过
Step 5: Use the Edit tool to mark it as complete
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="状态:pending",
new_string="状态:completed"
)
Edit(
file_path="memory/goals/2026-03-18_0930_完善goal-oriented触发条件.md",
old_string="完成时间:-",
new_string="完成时间:2026-03-18 11:00"
)
✅ Output:目标已完成
Result: The final delivery is completely consistent with the original commitment, with no goal deviation.
Case 2: Goal management for a product development project
Goal: Launch an MVP within 3 months
Success criteria:
- Core features complete
- User testing satisfaction > 4.0/5.0
- No P0-level bugs
- DAU > 1000
Critical path:
- Requirements confirmation (Week 1)
- Core feature development (Week 2-8)
- Testing and optimization (Week 9-10)
- Launch and promotion (Week 11-12)
Execution and monitoring:
- Check progress every Friday
- Found a deviation in Week 6: the team was optimizing non-core features
- Adjust immediately: Remove non-core features and focus on the MVP
Result: Launched on time and achieved the goal
Case 3: Goal-oriented execution of technical debt cleanup
Goal: Reduce code complexity by 30%
Success criteria:
- Cyclomatic complexity < 15 (previously 22)
- Test coverage > 70% (previously 45%)
- Complete documentation
Execution process:
- Check every day: "Does this refactoring reduce complexity?"
- Found a deviation: the team was optimizing performance (not the goal)
- Adjustment: Remind them to focus on complexity; performance optimization will be handled later as a dedicated effort
Result: Complexity reduced to 13, coverage 75%
Common Pitfalls
Pitfall 1: Vague goals that cannot be measured
- Manifestation: "Write the code a bit better", "improve the user experience"
- Correct approach: Use the SMART principle and define clear quantitative metrics
Pitfall 2: Overfocusing on the means and forgetting the purpose
- Manifestation: Obsessing over the technology choice for 2 weeks, forgetting that the goal was only to "launch quickly"
- Correct approach: Regularly ask "Is this means necessary?"
Pitfall 3: Ignoring environmental changes and executing rigidly
- Manifestation: The goal is no longer realistic, but you still execute according to the original plan
- Correct approach: Regularly reassess the reasonableness of the goal
Pitfall 4: Sunk cost fallacy
- Manifestation: "We've already worked on it for 3 weeks, we can't give up"
- Correct approach: If the direction is wrong, adjust immediately, without considering sunk costs
Pitfall 5: Claiming completion without verification
- Manifestation: The AI says "done", "finished", but does not use the Read tool to verify the goal
- Correct approach: When the AI believes it is done, it must use the Read tool to read the target file and verify
Pitfall 6: Verification fails but missing items are skipped
- Manifestation: Verification finds that the goal has not been fully achieved, but the AI says "basically done", "all the core features are there"
- Correct approach: Must continue executing the missing parts until the goal is fully achieved
Pitfall 7: The user adjusts the requirements but the goal is not updated
- Manifestation: The user says "never mind, change it to XXX", but the AI continues executing according to the original goal
- Correct approach: Immediately use the Edit tool to adjust the goal file and sync the user's new intent
Pitfall 8: Executing a task but not creating a goal
- Manifestation: The AI starts executing a multi-step task but does not create a goal file at the start
- Correct approach: When a task is detected at the start of the session, immediately use the Write tool to create a goal file
Post-protocol
Artifact output
Save the goal creation/adjustment result to the artifact file:
# 生成工件文件名
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
ARTIFACT_FILE="memory/artifacts/goal-oriented/result-$TIMESTAMP.json"
# 读取目标文件信息
GOAL_FILE=$(ls -t memory/goals/*.md 2>/dev/null | head -1)
if [ -n "$GOAL_FILE" ]; then
# 提取目标信息
SMART_SPECIFIC=$(grep "^\*\*Specific" "$GOAL_FILE" | sed 's/.*: *//')
SMART_MEASURABLE=$(grep "^\*\*Measurable" "$GOAL_FILE" | sed 's/.*: *//')
GOAL_STATUS=$(grep "状态:" "$GOAL_FILE" | awk '{print $2}')
# 写入工件
cat > "$ARTIFACT_FILE" <<EOF
{
"skill": "goal-oriented",
"version": "2.0.0",
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"project": "$PROJECT_ROOT",
"branch": "$BRANCH",
"commit": "$COMMIT",
"input": {
"user_request": "用户的原始请求"
},
"output": {
"goal_file": "$GOAL_FILE",
"smart_specific": "$SMART_SPECIFIC",
"smart_measurable": "$SMART_MEASURABLE",
"status": "$GOAL_STATUS"
},
"next_skills": [
"first-principles",
"mvp-first",
"pdca-cycle"
]
}
EOF
echo "ARTIFACT SAVED: $ARTIFACT_FILE"
# 创建 latest.json 符号链接
ln -sf "$ARTIFACT_FILE" memory/artifacts/goal-oriented/latest.json
else
echo "No goal file found, skipping artifact generation"
fi
Goal file update
If the goal file exists, record the skill execution:
# 检查是否有 pending 目标
GOAL_FILE=$(ls -t memory/goals/*.md 2>/dev/null | head -1)
if [ -n "$GOAL_FILE" ]; then
# 检查目标状态
GOAL_STATUS=$(grep "状态:" "$GOAL_FILE" | awk '{print $2}')
if [ "$GOAL_STATUS" = "pending" ]; then
echo "GOAL STATUS: $GOAL_STATUS"
echo "GOAL FILE: $GOAL_FILE"
# 可选:使用 Edit 工具添加里程碑记录
# 例如:"goal-oriented 技能执行完成 - {时间}"
fi
fi
Recommended follow-up skills
Based on the goal type, recommend follow-up skills:
Recommended format:
## 后续建议
基于当前目标,建议继续执行:
**推荐技能链**:
1. /first-principles - 从本质思考问题,找到最优解
2. /mvp-first - 如果是复杂系统,进行 MVP 规划
3. /pdca-cycle - 进入 PDCA 循环执行阶段
**根据目标类型选择**:
- **创新问题** → /first-principles
- **复杂系统** → /ddd-strategic-design → /ddd-tactical-design → /mvp-first
- **优化任务** → /pdca-cycle
- **战略分析** → /swot-analysis
是否继续执行?
- A) 执行推荐的技能链
- B) 只执行第一个技能
- C) 不继续,结束当前任务
References
- "The 7 Habits of Highly Effective People" - Begin with the end in mind, never forget your original intention, and you will see it through to the end
- SMART Goals - Peter Drucker
- OKR methodology - John Doerr