Context Anchor Skill
Helps agents recover context after compaction by scanning memory files and generating a "here's where you are" briefing.
Why This Exists
Context compaction loses memory. Files survive. But after waking up fresh, you need to:
- 1. Know what you were working on
- See decisions that were made
- Find open loops that need closing
- Get oriented fast
This skill automates that recovery.
Quick Start
CODEBLOCK0
What It Scans
| Source | What It Extracts |
|---|
| INLINECODE0 | Current task status, blockers, next steps |
| INLINECODE1 |
Recent daily logs (last 2 days by default) |
|
context/active/*.md | In-progress task files |
| Daily logs | Decisions (lines with "Decision:", "Decided:", "✅") |
| Daily logs | Open loops (lines with "?", "TODO:", "Blocker:", "Need to") |
Output Format
The script outputs a structured briefing:
CODEBLOCK1
Integration with AGENTS.md
Add to your "Every Session" routine:
CODEBLOCK2
Or use it manually when you feel lost about context.
Customization
Change workspace root
CODEBLOCK3
Change days to scan
CODEBLOCK4
No Dependencies
Pure bash. Uses only:
- -
find, grep, head, tail, date, INLINECODE8 - Works on macOS and Linux
- No external tools required
When to Use
- - Session start: Quick orientation on what's happening
- After compaction: Recover lost context
- Feeling lost: "Wait, what was I doing?"
- Handoff: Show another agent where things stand
- Daily review: See what decisions were made
上下文锚点技能
帮助智能体在压缩后通过扫描记忆文件并生成你当前所在位置简报来恢复上下文。
为何存在
上下文压缩会导致记忆丢失。文件得以保留。但在重新启动后,你需要:
- 1. 了解之前正在处理什么
- 查看已做出的决策
- 找到需要关闭的未完成事项
- 快速定位
本技能可自动完成此恢复过程。
快速开始
bash
完整简报(默认)
./scripts/anchor.sh
仅显示当前任务
./scripts/anchor.sh --task
仅显示活跃上下文文件
./scripts/anchor.sh --active
仅显示近期决策
./scripts/anchor.sh --decisions
显示未完成事项/问题
./scripts/anchor.sh --loops
扫描指定天数
./scripts/anchor.sh --days 3
扫描内容
| 来源 | 提取内容 |
|---|
| memory/current-task.md | 当前任务状态、阻碍、下一步 |
| memory/YYYY-MM-DD.md |
近期每日日志(默认最近2天) |
| context/active/*.md | 进行中的任务文件 |
| 每日日志 | 决策(包含Decision:、Decided:、✅的行) |
| 每日日志 | 未完成事项(包含?、TODO:、Blocker:、Need to的行) |
输出格式
脚本输出结构化简报:
═══════════════════════════════════════════════════════════
上下文锚点
你上次离开的位置
═══════════════════════════════════════════════════════════
📋 当前任务
───────────────────────────────────────────────────────────
[memory/current-task.md的内容或未设置当前任务]
📂 活跃上下文文件
───────────────────────────────────────────────────────────
• context/active/project-name.md(2小时前更新)
└─ 首行预览...
🎯 近期决策(最近2天)
───────────────────────────────────────────────────────────
[2026-01-30] 决策:使用Cloudflare Pages进行托管
[2026-01-30] ✅ 完成邮件捕获设置
❓ 未完成事项
───────────────────────────────────────────────────────────
[2026-01-30] 需要在NAS上启用SFTP
[2026-01-30] TODO:创建Product Hunt账户
═══════════════════════════════════════════════════════════
与AGENTS.md集成
添加到你的每次会话例行程序中:
markdown
每次会话
在执行任何操作之前:
- 1. 运行 ./skills/context-anchor/scripts/anchor.sh 进行定位
- 阅读 SOUL.md — 这是你的身份
- 阅读 USER.md — 这是你正在帮助的对象
...
或者在感觉上下文丢失时手动使用。
自定义
更改工作区根目录
bash
WORKSPACE=/path/to/workspace ./scripts/anchor.sh
更改扫描天数
bash
./scripts/anchor.sh --days 5 # 扫描过去5天
无依赖
纯bash。仅使用:
- - find、grep、head、tail、date、stat
- 适用于macOS和Linux
- 无需外部工具
使用时机
- - 会话开始:快速了解当前情况
- 压缩后:恢复丢失的上下文
- 感到迷茫时:等等,我刚才在做什么?
- 交接时:向其他智能体展示当前状态
- 每日回顾:查看已做出的决策