Skip to main content

smart-clear

Intelligent context clearing: analyzes conversation, extracts key info into summary, saves to file, then guides user to /clear with SessionStart hook for auto-restore. Use when user mentions clear context, clean conversation, context too long, /smart-clear, 清理上下文, 对话太长, 清除对话, 上下文清理.

Source facts

Repository
zunyiqingfeng-code/skills
Last source activity
August 21, 2026 at 14:34
Detected SKILL.md language
Chinese
Stars
2
Forks
0

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
smart-clear
description
Intelligent context clearing: analyzes conversation, extracts key info into summary, saves to file, then guides user to /clear with SessionStart hook for auto-restore. Use when user mentions clear context, clean conversation, context too long, /smart-clear, 清理上下文, 对话太长, 清除对话, 上下文清理.
user-invocable
true
model
sonnet
trigger-keywords
["smart-clear","智能清理","清理上下文","清空对话","上下文太长","context too long","压缩对话"]
# Smart Clear - 智能上下文清理 ## 触发条件 用户提到"清理上下文"、"对话太长"、"上下文超限"等,或主动输入 /smart-clear。 ## 执行流程 ### Step 1: 分析对话内容 扫描当前对话中的所有内容,按以下分类标记: **必须保留(KEEP)**: - 文件路径和行号引用 - 关键决策和结论(如"选择方案A因为...") - 未完成的任务和待办事项 - 用户明确表达的偏好或要求 - 已修改/创建的文件列表 - 重要的代码片段或配置 - 错误及其根因分析结果 **可以丢弃(DISCARD)**: - 中间的文件读取操作(Read/Grep 结果) - 失败的尝试和调试过程 - 重复的搜索操作 - 工具调用的原始输出 - 已解决的问题的中间分析过程 ### Step 2: 生成摘要 将 KEEP 类内容整理为结构化摘要,格式如下: ```markdown # 上下文摘要 {timestamp} ## 活跃任务 - [任务描述和状态] ## 关键文件 - [文件路径]: [修改内容摘要] ## 重要决策 - [决策]: [原因] ## 用户偏好 - [偏好项] ## 待办/未完成 - [事项] ## 代码片段 - [关键代码] ``` ### Step 3: 保存摘要 将摘要保存到 `~/.claude/context-summaries/` 目录: - 文件名: `{YYYYMMDD-HHmmss}.md` - 同步更新 `latest.md` 为最新摘要的符号链接或副本 ### Step 4: 通知用户 输出简短通知: ``` 摘要已保存。请执行 /clear 清空上下文。 新会话将自动恢复以上摘要。 ``` ### Step 5: 同步到桌面 将摘要文件同时复制一份到桌面 `~/Desktop/context-summary-{timestamp}.md`。 ## 限制 - 不自动执行 /clear,需要用户确认 - 摘要文件保留最近 10 份,自动清理旧文件 - 如果对话中无明显可保留内容,直接建议 /clear 无需生成摘要
View on GitHub