Automatically recover working context after session compaction or when continuation is implied but context is missing. Works across Discord, Slack, Telegram,...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install context-recovery或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install context-recovery⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/context-recovery/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: context-recovery description: Automatically recover working context after session compaction or when continuation is implied but context is missing. Works across Discord, Slack, Telegram, Signal, and other supported channels. homepage: https://github.com/PSPDFKit-labs/agent-skills repository: https://github.com/PSPDFKit-labs/agent-skills metadata: { "openclaw": { "emoji": "🔄", }, } ---
Automatically recover working context after session compaction or when continuation is implied but context is missing. Works across Discord, Slack, Telegram, Signal, and other supported channels.
Use when: Session starts with truncated context, user references prior work without specifying details, or compaction indicators appear.
---
tag (compaction detected)---
Extract from runtime context:
channel — discord | slack | telegram | signal | etc.channelId — the specific channel/conversation IDthreadId — for threaded conversations (Slack, Discord threads)Initial fetch:
message:read
channel: <detected-channel>
channelId: <detected-channel-id>
limit: 50
Adaptive expansion logic:
newest_timestamp - oldest_timestamp - Fetch additional 50 messages (using before parameter if supported) - Repeat until time span ≥ 2 hours OR total messages ≥ 100
Thread-aware recovery (Slack/Discord):
# If threadId is present, fetch thread messages first
message:read
channel: <detected-channel>
threadId: <thread-id>
limit: 50
# Then fetch parent channel for broader context
message:read
channel: <detected-channel>
channelId: <parent-channel-id>
limit: 30
Parse for:
Use platform/session APIs only (no shell filesystem scans):
# List recent sessions (if tool exists)
sessions_list:
limit: 5
# Pull last messages from likely matching session
sessions_history:
sessionKey: <candidate-session-key>
limit: 80
includeTools: true
If session APIs are unavailable, skip this step and proceed with channel-only evidence.
Only inspect memory if the agent runtime already provides a scoped memory tool/path. Do not run shell glob scans across home directories.
Compile a structured summary:
## Recovered Context
**Channel:** #<channel-name> (<platform>)
**Time Range:** <oldest-message> to <newest-message>
**Messages Analyzed:** <count>
### Active Project/Task
- **Repository:** <repo-name>
- **Branch:** <branch-name>
- **PR:** #<number> — <title>
### Recent Work Timeline
1. [<timestamp>] <action/request>
2. [<timestamp>] <action/request>
3. [<timestamp>] <action/request>
### Pending/Incomplete Actions
- ⏳ "<quoted incomplete action>"
- ⏳ "<another incomplete item>"
### Last User Request
> "<quoted request that may not have been completed>"
Do not write to disk by default. If persistence is useful, ask first:
> "I can cache this recovered context to memory for later continuity. Should I save it?"
Present the recovered context, then prompt:
> "Context recovered. Your last request was [X]. This action [completed/did not complete]. Shall I [continue/retry/clarify]?"
---
channelId from the incoming message metadatathreadId in message metadatachannel parameter with Slack channel IDthreadId — always check for thread context firstmessage:read interface---
---
At session start, scan for compaction indicators:
# Pseudocode for trigger detection
if message contains "<summary>":
trigger_context_recovery()
elif message contains any of ["Summary unavailable", "context limits", "truncated", "compacted"]:
trigger_context_recovery()
elif message matches continuation_patterns:
# "continue", "where were we", "did this happen", etc.
trigger_context_recovery()
Do not wait for user to ask — if compaction is detected, proactively recover and present context.
---
Scenario: Session starts with compaction summary
User message: "<summary>Summary unavailable due to context limits...</summary>"
User message: "did this happen?"
Agent executes:
tagmessage:read channel=discord channelId=1460342116516364533 limit=50> "Context recovered. Your last request was to extract orchestration decisions from Nexus archived sessions for PR #137 (Skills & Agents System). This action did not complete before context was truncated. > > Recovered state: > - PR #137: 15,053 additions, 91 files, CONFLICTING merge state > - Spec location: content/spec-skills-agents-system.md (2,067 lines) > > Shall I proceed with the extraction?"
安装 Context Recovery 后,可以对 AI 说这些话来触发它
Send a Slack message to the #engineering channel about the deployment
Formats and sends the message with relevant context, tagging the right people
Summarize all unread messages in my inbox from today
Reads messages across connected channels and returns a prioritized summary
Draft a reply to this customer complaint and send it for review
Writes an empathetic, professional response and routes it to the approval queue
将技能文件夹放到 ~/.claude/skills/context-recovery/ 目录(个人级,所有项目可用),或 .claude/skills/context-recovery/(项目级)。重启 AI 客户端后,用 /context-recovery 主动调用,或让 AI 根据上下文自动发现并使用。
Context Recovery 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Context Recovery 可免费安装使用。请查阅仓库了解许可证信息。
Automatically recover working context after session compaction or when continuation is implied but context is missing. Works across Discord, Slack, Telegram,...
Context Recovery 属于「Communication」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。