Auto-Context — Situational Awareness Protocol (Meta-Skill)
Before you act, understand where you are. This skill ensures the AI loads critical project context automatically before any major action, preventing wasted effort, duplicate work, and misaligned implementations.
Installation
OpenClaw / Moltbot / Clawbot
CODEBLOCK0
When to Activate
This skill triggers automatically based on the current action. Do not wait for the user to ask — proactively load context when any of these conditions are met.
| Trigger | Why | Minimum Context |
|---|
| Starting a new task | Understand priorities, avoid conflicts | Critical + High |
| Implementing a feature |
Know the plan, constraints, recent changes | Critical + High |
| Refactoring code | Understand what changed recently, what's planned | Critical + High + Medium |
| Debugging an issue | Check recent changes, known issues, discoveries | Critical + High + Medium |
| Planning or scoping work | Full picture of roadmap, backlog, progress | All levels |
| Session start or resume | Rebuild mental model from last session state | Critical + High |
| Before a handoff | Ensure nothing is missed in transition | All levels |
Context Files to Read
Read these files in priority order. Stop early if the task is narrow and lower-priority files are clearly irrelevant.
| Priority | File | Purpose | Read When |
|---|
| Critical | INLINECODE0 | Current tasks, backlog, and priorities | Always |
| Critical |
roadmap.md | Phase status, milestones, project direction | Always |
| High |
task_plan.md | Active task breakdown and implementation plan | File exists |
| High |
.cursor/handoffs/*.md | Recent handoff notes (read last 3 by date) | File exists |
| Medium |
findings.md | Research results, discoveries, decisions made | Relevant to task |
| Medium |
CHANGELOG.md | Recent changes and their rationale | Relevant to task |
| Low |
.cursor/sessions/*.md | Session summaries (read last 2 by date) | Planning or debugging |
Alternate Locations
Some projects use different paths. Check these fallbacks if primary paths are empty:
| Primary | Fallback |
|---|
| INLINECODE7 | INLINECODE8 , INLINECODE9 |
| INLINECODE10 |
docs/roadmap.md,
ROADMAP.md |
|
task_plan.md |
docs/task_plan.md,
.cursor/task_plan.md |
|
findings.md |
docs/findings.md,
.cursor/findings.md |
Context Loading Strategy
Step 1: Load Critical Files (Always)
CODEBLOCK1
If either critical file is missing, warn the user:
"No TODO.md found. Consider creating one to track tasks."
Step 2: Load High-Priority Files (If They Exist)
CODEBLOCK2
Step 3: Load Medium/Low Files (If Relevant)
Only read these when the current task benefits from historical context:
- - Debugging? — Read
findings.md and INLINECODE20 - Planning? — Read everything including session files
- Quick fix? — Skip medium and low entirely
Step 4: Synthesize and Present
After loading, produce a context summary (see format below) before proceeding with the task.
Staleness Detection
Check modification dates on all loaded files. Flag files that may contain outdated information.
| Age | Status | Action |
|---|
| < 24 hours | Fresh | Use as-is |
| 1-7 days |
Current | Use as-is, note the age |
| 7-30 days | Stale | Warn: "{file} last updated {N} days ago — verify before relying on it" |
| > 30 days | Outdated | Warn: "{file} is {N} days old and may no longer reflect project state" |
To check file ages on macOS:
CODEBLOCK3
On Linux:
CODEBLOCK4
Context Summary Format
After loading context, present a concise summary using this template. Keep it tight — the goal is awareness, not repetition.
CODEBLOCK5
If no context files exist at all, output:
CODEBLOCK6
Integration Points
This skill connects to other workflow commands and should run as a precursor.
| Command | How Auto-Context Integrates |
|---|
| INLINECODE21 | Loads full context before beginning work; populates task plan |
| INLINECODE22 |
Reads roadmap and TODO to validate intent against project direction |
|
/workflow | Provides the "understand" phase of any workflow automatically |
|
/progress | Uses TODO.md and task_plan.md to assess completion status |
|
/handoff-and-resume | Reads last handoff to rebuild state on resume |
|
/session-summary | Cross-references loaded context with session actions for accuracy |
Execution Order
CODEBLOCK7
Quick Reference
CODEBLOCK8
NEVER Do
- 1. NEVER skip critical files to save time — leads to duplicate work and conflicting implementations
- NEVER load every file regardless of task — wastes tokens and dilutes focus with irrelevant info
- NEVER ignore staleness warnings — stale context causes decisions based on outdated assumptions
- NEVER read files without summarizing — raw file dumps overwhelm; always synthesize first
- NEVER assume context from memory alone — sessions are stateless; always re-read files
- NEVER silently proceed when no context exists — user should know they're operating blind
- NEVER read handoffs/sessions beyond the limit — last 3 handoffs and last 2 sessions are sufficient
技能名称: auto-context
详细描述:
Auto-Context — 情境感知协议(元技能)
在行动之前,先了解你所处的位置。此技能确保AI在任何重大行动前自动加载关键项目上下文,避免精力浪费、重复工作和实施偏差。
安装
OpenClaw / Moltbot / Clawbot
bash
npx clawhub@latest install auto-context
何时激活
此技能根据当前操作自动触发。不要等待用户询问——当满足以下任一条件时,主动加载上下文。
| 触发条件 | 原因 | 最低上下文级别 |
|---|
| 开始新任务 | 了解优先级,避免冲突 | 关键 + 高 |
| 实现功能 |
了解计划、约束和近期变更 | 关键 + 高 |
| 重构代码 | 了解近期变更和计划内容 | 关键 + 高 + 中 |
| 调试问题 | 检查近期变更、已知问题和发现 | 关键 + 高 + 中 |
| 规划或界定工作范围 | 全面了解路线图、待办事项和进度 | 所有级别 |
| 会话开始或恢复 | 从上次会话状态重建心智模型 | 关键 + 高 |
| 交接前 | 确保交接过程中无遗漏 | 所有级别 |
需读取的上下文文件
按优先级顺序读取这些文件。如果任务范围狭窄且低优先级文件明显不相关,可提前停止。
| 优先级 | 文件 | 用途 | 读取时机 |
|---|
| 关键 | TODO.md | 当前任务、待办事项和优先级 | 始终 |
| 关键 |
roadmap.md | 阶段状态、里程碑、项目方向 | 始终 |
| 高 | task_plan.md | 活跃任务分解和实施计划 | 文件存在时 |
| 高 | .cursor/handoffs/*.md | 近期交接记录(按日期读取最近3个) | 文件存在时 |
| 中 | findings.md | 研究结果、发现、已做决策 | 与任务相关时 |
| 中 | CHANGELOG.md | 近期变更及其理由 | 与任务相关时 |
| 低 | .cursor/sessions/*.md | 会话摘要(按日期读取最近2个) | 规划或调试时 |
备用路径
有些项目使用不同路径。如果主路径为空,检查这些备用路径:
| 主路径 | 备用路径 |
|---|
| TODO.md | docs/TODO.md, ai/TODO.md |
| roadmap.md |
docs/roadmap.md, ROADMAP.md |
| task
plan.md | docs/taskplan.md, .cursor/task_plan.md |
| findings.md | docs/findings.md, .cursor/findings.md |
上下文加载策略
步骤 1:加载关键文件(始终执行)
读取 TODO.md → 提取:当前任务、下一优先级、阻塞项
读取 roadmap.md → 提取:当前阶段、活跃里程碑、即将到来的截止日期
如果任一关键文件缺失,警告用户:
未找到 TODO.md。建议创建一个以跟踪任务。
步骤 2:加载高优先级文件(如果存在)
读取 task_plan.md → 提取:实施步骤、验收标准
全局搜索 .cursor/handoffs/*.md → 按修改日期读取最近3个
步骤 3:加载中/低优先级文件(如果相关)
仅当当前任务受益于历史上下文时读取这些文件:
- - 调试中? — 读取 findings.md 和 CHANGELOG.md
- 规划中? — 读取所有文件,包括会话文件
- 快速修复? — 完全跳过中低优先级文件
步骤 4:综合并呈现
加载后,在继续任务之前生成上下文摘要(见下方格式)。
过时检测
检查所有已加载文件的修改日期。标记可能包含过时信息的文件。
当前 | 直接使用,注明时间 |
| 7-30天 | 过时 | 警告:{文件} 上次更新于 {N} 天前——使用前请验证 |
| > 30天 | 陈旧 | 警告:{文件} 已存在 {N} 天,可能不再反映项目状态 |
在 macOS 上检查文件时间:
bash
stat -f %m %N TODO.md roadmap.md task_plan.md findings.md CHANGELOG.md 2>/dev/null
在 Linux 上:
bash
stat -c %Y %n TODO.md roadmap.md task_plan.md findings.md CHANGELOG.md 2>/dev/null
上下文摘要格式
加载上下文后,使用此模板呈现简洁摘要。保持紧凑——目标是提供认知,而非重复。
markdown
上下文已加载
当前阶段: {来自 roadmap 的阶段}
活跃里程碑: {里程碑及进度}
当前任务: {来自 TODO.md 或 task_plan.md}
- - 状态:{进行中 / 被阻塞 / 未开始}
- 阻塞项:{任何阻塞项,或无}
近期变更:
- - {来自 CHANGELOG 或交接记录的最近 2-3 项}
相关发现:
过时警告:
如果完全不存在上下文文件,输出:
markdown
上下文已加载
未找到项目上下文文件。在没有历史上下文的情况下运行。
建议创建 TODO.md 和 roadmap.md 以启用上下文感知辅助。
集成点
此技能连接到其他工作流命令,并应作为前置步骤运行。
| 命令 | Auto-Context 如何集成 |
|---|
| /start-task | 在开始工作前加载完整上下文;填充任务计划 |
| /intent |
读取路线图和待办事项,验证意图是否符合项目方向 |
| /workflow | 自动提供任何工作流的理解阶段 |
| /progress | 使用 TODO.md 和 task_plan.md 评估完成状态 |
| /handoff-and-resume | 读取上次交接记录以在恢复时重建状态 |
| /session-summary | 将加载的上下文与会话操作交叉引用以确保准确性 |
执行顺序
用户触发操作
→ Auto-Context 激活(此技能)
→ 呈现上下文摘要
→ 主要技能/命令在完全感知的情况下执行
快速参考
上下文加载检查清单:
1. 读取 TODO.md(关键)
2. 读取 roadmap.md(关键)
3. 读取 task_plan.md(如果存在)
4. 读取最近 3 个交接记录(如果存在)
5. 检查文件过时情况
6. 读取发现/变更日志(如果相关)
7. 呈现上下文摘要
8. 继续执行任务
绝对禁止
- 1. 绝对不要为节省时间跳过关键文件 — 导致重复工作和冲突实施
- 绝对不要不论任务如何加载所有文件 — 浪费令牌并用无关信息稀释焦点
- 绝对不要忽略过时警告 — 过时上下文导致基于过时假设的决策
- 绝对不要读取文件而不做摘要 — 原始文件转储令人不知所措;始终先综合
- 绝对不要仅凭记忆假设上下文 — 会话是无状态的;始终重新读取文件
- 绝对不要在无上下文时默默继续 — 用户应知道他们正在盲目操作
- 绝对不要读取超出限制的交接记录/会话 — 最近 3 个交接记录和最近 2 个会话已足够