skills/cc-session-cleaner/SKILL.md
清理当前项目的 Claude Code 会话:列出 ~/.claude/projects 下最近会话,按序号或 sessionId 选择,经二次确认后删除对应 .jsonl 与同名附件目录。Trigger words: 清理 cc 会话, 删除历史会话, cc resume 会话, clean cc sessions, cc session cleaner
npx skillsauth add shiqkuangsan/oh-my-daily-skills tooyoung:cc-session-cleanerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
清理 Claude Code ~/.claude/projects/<project-slug>/ 下不再需要的会话文件。默认不是按标题自动删除,而是先列出当前项目最近会话,让用户挑选后再删除。
每个 CC 会话在 ~/.claude/projects/<project-slug>/ 下通常对应两类路径:
<session-id>.jsonl ← 会话消息流(可能含 custom-title 行)
<session-id>/ ← 同名子目录:附件、shell snapshot 等
cc resume 列表里的标题来自 .jsonl 中的 custom-title 行:
{ "type": "custom-title", "customTitle": "xxx", "sessionId": "<session-id>" }
用户说出以下任一意图即触发:
默认走交互挑选模式:
~/.claude/projects/<project-slug>/。.jsonl,按 mtime 倒序排列;用户明确要求"全部"/all 时展示全部会话。删除 1 3 8 或 删除 abc def。.jsonl 与同名子目录;如果用户选中当前会话,保留在提示中但标记为不可删除并剔除。.jsonl 与同名目录均不存在。预览表必须包含:
| 字段 | 说明 |
| -------------------- | -------------------------------------------------------------------- |
| # | 本次预览序号,用于用户选择 |
| current | 当前会话标记;匹配显式 current session id 时显示 CURRENT,否则为空 |
| sessionId | .jsonl 文件名去掉后缀 |
| title | 最近一条 custom-title,没有则为空 |
| mtime | .jsonl 修改时间 |
| size | .jsonl 大小,按 B/KB/MB/GB 自动切换 |
| first user prompt | 首条非 caveat 的 user prompt,截断 80 字 |
| recent user prompt | 最近一条非 caveat 的 user prompt,截断 80 字 |
预览和删除复述都必须优先使用 Markdown 表格,避免用散乱项目符号代替关键清单:
#、current、sessionId、title、mtime、size、first user prompt、recent user prompt。sessionId、jsonl path、attachment dir、status。status 必须标为 不可删除:当前会话,且不得传入删除脚本。| 用户口谕 | 行为 |
| ----------------------------- | ------------------------------------------ |
| "清理一下 cc 会话" | 列出当前项目最近 30 条会话,等待选择 |
| "列出最近 50 条会话" | 列出当前项目最近 50 条会话 |
| "列出全部会话" / "list all" | 列出当前项目全部会话 |
| "删除 1 3 8" | 复述序号 1、3、8 对应会话,等待 确认删除 |
| "删除 sid=abc sid=xyz" | 复述指定 sessionId,等待 确认删除 |
| "看看 title 是 待删除 的会话" | 严格筛选 customTitle == "待删除" 后展示 |
任何形态的删除一律走两步,即便用户首条口谕已显含"删除"语义:
Step 1. AI 列表/解析选择 → 复述将删除的路径 → 询问:「是否执行删除?请回复『确认删除』或『取消』。」
Step 2. AI 等待 → 仅当用户回复强确认词才执行删除。
视为有效的强确认:
确认删除 / 确认清理confirm delete / yes delete不视为确认:
好 / 嗯 / ok / 行 / 知道了 / 继续 / 执行 / 删这些是什么时候的? / 能恢复吗?用户说"直接删"、"不用预览"、"不用确认"也不能绕过预览和二次确认。CC 会话删除后不可由本 skill 恢复。
CC 把每个项目的会话存在 ~/.claude/projects/<slug>/,但 slug 规则随 CC 版本演进,磁盘上可能多代命名并存:
| 路径片 | 旧规则 | 新规则 |
| --------------------------- | ------ | ------ |
| / | - | - |
| .(隐藏目录如 .config) | 保留 | - |
| 空格 | 保留 | - |
没有可靠的 $CLAUDE_PROJECT_DIR 环境变量可直接使用,必须自行推导。
derive_projdir() {
local cwd="${1:-$PWD}"
local base="$HOME/.claude/projects"
local c1="$base/$(printf '%s' "$cwd" | sed 's|/|-|g')"
local c2="$base/$(printf '%s' "$cwd" | sed -e 's|/|-|g' -e 's|\.|-|g')"
local c3="$base/$(printf '%s' "$cwd" | sed -e 's|/|-|g' -e 's|\.|-|g' -e 's| |-|g')"
for cand in "$c1" "$c2" "$c3"; do
[ -d "$cand" ] && { echo "$cand"; return 0; }
done
return 1
}
候选全空时,列出 ~/.claude/projects/ 目录请用户确认,不要擅自模糊匹配。
按 Agent Skills 标准结构,长脚本应拆到 skill 目录下的 scripts/:
skills/cc-session-cleaner/
├── SKILL.md
└── scripts/
├── preview_sessions.py
└── delete_sessions.py
scripts/preview_sessions.py:列出会话,输出 Markdown 表格数据。scripts/delete_sessions.py:仅在强确认后删除指定 sessionId 的 .jsonl 与同名目录。SKILL.md 只保留流程、参数约定、安全红线和展示要求。PROJDIR="${1:-$(derive_projdir)}" || { echo "无法定位项目目录,请显式指定" >&2; exit 1; }
LIMIT="${2:-30}"
MARK="${3:-}"
CURRENT_SESSION_ID="${4:-${CLAUDE_SESSION_ID:-}}"
python3 skills/cc-session-cleaner/scripts/preview_sessions.py "$PROJDIR" --limit "$LIMIT" --mark "$MARK" --current-session-id "$CURRENT_SESSION_ID"
当前会话说明:每个 Claude Code 会话都有 sessionId;如果 shell 中没有 $CLAUDE_SESSION_ID,只表示脚本没有拿到当前会话 id,不表示当前会话没有 id。若用户从 /status 或其它可靠来源提供当前 sessionId,应作为 --current-session-id 传入并用于 CURRENT 标记。
删除 1 3 8。删除 abc123 def456。current 列;如果拿到显式 current session id(例如用户从 /status 提供,或环境变量 $CLAUDE_SESSION_ID 可用),匹配行显示 CURRENT。cc resume 中看到的完整候选集。$CLAUDE_SESSION_ID 为空只表示脚本没拿到当前会话 id,不表示当前会话没有 id。$CLAUDE_SESSION_ID 识别当前会话,必须在 current 列标记为 CURRENT。PROJDIR="$HOME/.claude/projects/<slug>"
python3 skills/cc-session-cleaner/scripts/delete_sessions.py "$PROJDIR" sid1 sid2 sid3
customTitle == MARK 严格相等。.jsonl 会话。.jsonl 与同名附件目录。memory/MEMORY.md 等)。.jsonl 建索引的插件,删除前提醒:相关 observations / corpus 引用可能指向已删除原文,但记忆数据本身仍在。development
Show OpenAI Codex release highlights in Chinese. Fetch GitHub release notes, summarize feature-level changes, skip bug-fix/chore noise by default, and append a mandatory highlights section. Trigger words: Codex updates, Codex features, Codex 新功能, Codex 更新, OpenAI Codex releases
development
Create simple Three.js web apps with scene setup, lighting, geometries, materials, animations, OrbitControls, particles, and responsive rendering. Use for Three.js scenes, WebGL demos, 3D showcases, and interactive 3D web content. Trigger: threejs, Three.js, 3D scene, WebGL, 三维展示, 3D showcase, interactive 3D
development
为 Claude Code 定义个性化身份风格(人设)。触发词:定义人设、创建身份、persona、角色设定、CLAUDE.local.md
data-ai
将 vless+reality 等新协议配置转换为带 GEOSITE 规则的配置文件,支持 11 地区分组 + AI/媒体/游戏分流,可直接上传 OpenClash 使用。触发词:合并 OpenClash、转换订阅、Clash 配置