全部技能 / 基础工具与工作流 / read-claude-code-history
基础工具与工作流 · daymade/claude-code-skills

read-claude-code-history

Reads, searches, and exports local Claude Code history without resuming work. Covers recent session inventory, exact session timelines, verbatim human input including queued mid-turn prompts, full-event keyword search, hybrid recall when wording changed, end-state triage, and deleted-file recovery across active Claude homes plus registered archives. Use whenever the user asks what they or Claude said, wants a Claude Code session ID or original context, remembers prior work vaguely, needs an old file from a transcript, or must prove what a Claude session contained before continuing it. Also owns the only Kimi CLI surface, via its Kimi inventory and search flags. For Codex history use read-codex-history; when the request names no platform at all or spans providers, start at local-conversation-history.

风险提醒:黄色 · 留意使用AI 侦查报告
作者 daymadeGitHub daymade/claude-code-skills ↗Stars 1385许可 MIT(仓库根 LICENSE:'MIT License / Copyright (c) 2025 daymade';GitHub API spdx MIT)commit d5c4678cb5
agent 宿主通常会约束 skill 执行权限;风险提醒为 AI 侦查观点,不构成质量或安全保证。第三方 skill 仅作拆解与展示,安装使用风险自负,版权归原作者。

1实现原理 · 为什么它能做到

功能载体是 6 个本地 Python CLI(list_local_history / read_claude_session / extract_user_messages / analyze_sessions / history_index / recover_content),各自对应 inventory、精确会话重建、人工输入导出、关键词检索、混合召回、triage、文件恢复;agent 按 SKILL 路由表调用,明确禁止恢复旧进程。

daymade-claude-code/read-claude-code-history/SKILL.md
| Recent Claude Code sessions, titles, dates, or IDs | `scripts/list_local_history.py --source claude` |
注:SKILL.md 把『用户想要什么结果』映射到具体脚本+参数;guardrails 同时写死 'Do not run `claude --resume` or `claude --continue`',保证这是只读证据层,读取完把证据交给 continue-claude-code-work 才能动手。

『找不到』是昂贵答案:跨多 home 全量发现是正确性根基。homes.py 枚举 CLAUDE_CONFIG_DIR、~/.claude、~/.claude-profiles/* 与 ~/.claude-* 兄弟 home;sources.py 再并入 ~/.claude/history-sources.json 注册的归档;按 Session ID 去重、以记录内时间戳而非 mtime 排序。

daymade-claude-code/read-claude-code-history/scripts/_core/homes.py
# CLAUDE_CONFIG_DIR wins first when set, then the default home.
注:模块 docstring 点出动机:'A tool that only looks at ~/.claude silently misses every conversation held under a profile, which is the #1 reason a real session is wrongly reported as not found'——即多 home 发现直接决定『没找到』这个结论是否可信。

对 Claude 记录做语义而非字面处理:storage label(type: user)不等于作者;忙碌期间的排队指令藏在 attachment.queued_command.prompt(origin.kind: human),只读 user 记录会丢修正。

daymade-claude-code/read-claude-code-history/SKILL.md
Treat Claude's record labels as storage metadata, not authorship proof.
注:SKILL 用整段约束:顶层 type: user 记录可能装命令信封/hook 样板/整段粘贴文档/agent 口吻文本/系统占位;配套 references/session_file_format.md 讲 schema、sidechain、附件、compaction、file-history 快照。

可选『混合召回』路径(history_index.py recall):中文分词 FTS5(wangfenjin/simple libsimple,固定版本 v0.7.1 + SHA256 校验下载)+ Qwen3 嵌入向量(Apple Silicon MLX),BM25/向量融合,解决『措辞变了』的语义召回;不属于默认只读路径。

daymade-claude-code/read-claude-code-history/scripts/history_index.py
EMBEDDING_MODEL_ID = "Qwen/Qwen3-Embedding-0.6B"
注:同文件 SIMPLE_VERSION = v0.7.1;引用文档 hybrid_history_recall.md 明确分工:'You remember the meaning but not the wording | `history_index.py recall` | Ranked candidate sessions',精确取证仍走 analyze_sessions.py search。安装/下载在 SKILL 里被描述为一次性 setup。

文件恢复(recover_content.py)走『报告-批准-写入』三段门禁:先对精确 Session 文件出恢复报告,人工审阅每个目标路径后才写;且禁止直接覆盖当前项目树。

daymade-claude-code/read-claude-code-history/SKILL.md
First run the recovery report against the exact Session file, review every proposed destination, then write only after the user asked to recover content. Never restore directly over the current project tree.
注:恢复的是 Claude file-history 记录里保存的被删/被覆写文件;把『写盘』从常规读取中隔离出来单独立规矩。

Kimi CLI 历史是该 skill 的活表面:inventory 走 list_local_history.py --source kimi,全文检索走 analyze_sessions.py search --kimi,解析 ~/.kimi-code 下的 state.json/wire JSONL(home 优先级 --kimi-home > KIMI_HOME > ~/.kimi-code)。

daymade-claude-code/read-claude-code-history/scripts/_core/kimi.py
Kimi CLI (kimi-code) stores conversations under ``~/.kimi-code/`` (override with ``KIMI_HOME``).
注:SKILL.md:'Kimi CLI is a live surface of this Skill, not a legacy one. It has no reader of its own'——若用 Claude 数据回答 Kimi 问题会产出假的 never happened;shared _core 说明该包是跨 read-*-history 技能捆绑复制的单一实现(SSOT 在 _conversation_core/)。

2核心能力

01跨所有 Claude home/归档的最近会话清单(含 profile 隔离会话、子代理标记、来源诊断)
02按 Session ID 精确重建时间线证据简报(compaction 边界、user/assistant 交替、排队指令、end reason、未决调用、subagent 状态、文件/记忆/工作区)
03全事件关键词检索(消息/思考/工具入出/压缩摘要/附件/队列/文件快照),默认排除 agent prompt 与当前会话自匹配
04人工输入导出为 Markdown/HTML:剥离存储污染、保留排队 prompt、去重保序不擅自主题分类
05措辞变化时的语义混合召回(可选 libsimple FTS5 + Qwen3 向量)
06triage:按时间窗/项目归类会话如何结束(interrupted/net-error/stuck-on-tool/done)
07从 file-history 快照恢复被删/被覆写文件(先报告、批准后写入)
08Kimi CLI 清单与全文检索(仓库内唯一活表面)

3外部依赖

类型依赖
cligit
clirg/grep(可选路径预过滤)
networkgithub.com 发布物下载(wangfenjin/simple libsimple,固定版本+SHA256 校验,仅混合索引 setup)
networkHugging Face 模型(Qwen/Qwen3-Embedding-0.6B,仅 --download-model 经 mlx_embeddings.load)
package可选 Python 依赖 chonkie/transformers(分块)与 mlx-embeddings/mlx(Apple Silicon 向量)

4风险提醒 风险提醒:黄色 · 留意使用

风险提醒:黄色 · 留意使用
  • 数据面=可能含凭据的全部本地会话历史 — 脚本无凭证读取,但历史内容可含 API key/私密业务上下文;误分享或误用即泄漏——SKILL 靠 guardrail 与用户批准门禁约束,非技术强制。
  • 可选混合索引引入第三方二进制与模型供应链 — libsimple 从第三方 GitHub release 下载(sha256 固定+zip 防护);HF 模型下载对象随库实现;不走默认路径则无此面。
  • 原生扩展加载 — libsimple 以 SQLite FTS5 tokenizer 扩展形式在进程内加载执行(下载内容=原生代码执行面),校验链依赖发布方仓库与 sha 固定。
  • 大 --full briefing 的临时物化 — SKILL 指示大简报先物化私有临时文件,若 agent 未清理或路径不当会遗留含历史摘要的临时文件。
风险提醒:黄色,留意使用。默认读取路径零外发、纯本地只读(JSONL 只读、sqlite mode=ro),按准则属 blue 面;取黄色的依据是存在真实的网络外发代码路径(非默认触发):history_index.py setup 从 github.com/wangfenjin/simple releases 下载原生 libsimple(版本固定 v0.7.1、sha256 校验、zip-slip 防护)并在进程内作为 FTS5 扩展加载,--download-model 时再经 mlx_embeddings 下载 HF 模型 Qwen/Qwen3-Embedding-0.6B;外发对象可预期(公开源)、不碰凭证、需用户显式触发,故 yellow 而非更高档。数据面为可能含凭据的本地全量会话历史,SKILL 自带分享门禁。

5第二遍独立确认

  • [ok] libsimple 下载(github.com/wangfenjin/simple)调用点 — history_index.py url 构造 + urlopen;sha256 校验与 _safe_extract_zip 穿越防护真实存在。
  • [ok] 无其他网络调用(排除 requests/curl/wget/其他 urlopen) — 全目录扫描仅 history_index.py 引入 urllib.request;其余脚本零网络 import。
  • [ok] Kimi 表面真实存在且只读 — list_local_history.py argparse choices 含 kimi;analyze_sessions.py search 有 --kimi/--kimi-home;_core/kimi.py 只解析 state.json/wire.jsonl,无 kimi CLI 调用。
  • [ok] read-only 承诺与写盘面核对 — SKILL guardrails 禁止 resume/continue;写盘仅 extract_user_messages(用户给输出基址)、recover_content(报告后批准)、history_index(可选索引库)。
  • [unlocatable] Qwen 嵌入模型网络端点 — 静态证据止于 EMBEDDING_MODEL_ID + mlx_embeddings.load(...) 与 ~/.cache/huggingface 路径;HF 实际网络端点由 mlx-embeddings 库行为决定,源码未直写,未运行验证。
  • [ok] 能力声明夸大检查(exact timelines/verbatim input/full-event search) — read_claude_session.py 严格解析含 compaction 前记录、extract_user_messages 去噪逻辑(NOISE_USER_PATTERNS/IMG_TOKEN_RE)、analyze_sessions 预算超时显式失败——均有代码与测试佐证。

6结论

  • 默认路径纯本地只读,且用多 home+归档发现解决『假性 not found』
  • 对 Claude 存储语义理解深:storage label≠作者、queued_command 修正、compaction 标记、file-history 快照均有专门处理与 reference
  • 写盘/恢复路径设报告-批准门禁,读与写物理隔离
  • 工程完整度高:flag 齐全、pytest 覆盖、evals 验收对、异常路径(预算超时/畸形 JSONL/副本分歧)显式失败不装完整
  • 适合:适合需要『证明 Claude 会话里到底说过/做过什么』的场景:找回 Session ID、逐字人工输入、被删文件恢复、跨 profile/归档的完整检索;适合作为继续工作前的证据层(与 continue-claude-code-work 配对),以及把『本地历史可信检索』当基础设施的深度用户。
    不适合:不适合需要恢复旧进程继续干活或改动旧项目的请求(那是 continue-claude-code-work);不适合无本地 Claude Code 历史的环境;不需要语义级『忘了措辞』召回的用户不必启用 history_index(省去下载与 MLX 依赖);Kimi/Codex 问题请走对应表面,本 skill 不替代。
    安装 agent 直装可复制
    ① 本站镜像 更新 2026-09-09
    方式 A · 人下载镜像包下载 read-claude-code-history.tar.gz
    sha256: 646d5ca94bdfe86a…
    方式 B · JSON 格式安装指南,复制给 agent
    安装指南
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② 上游 GitHub · 原始来源
    能访问 GitHub?直接去上游安装(实时版,可能已更新)GitHub 原始 ↗
    本页镜像锁定 commit d5c4678cb5;上游为实时仓库。
    来源信息 GitHub 原始
    作者 / 仓库daymade / daymade/claude-code-skills
    Stars1385
    最近推送2026-09-09
    本 skill commitd5c4678cb5
    许可MIT(仓库根 LICENSE:'MIT License / Copyright (c) 2025 daymade';GitHub API spdx MIT)
    本站信息
    收录日期2026-09-06
    分类基础工具与工作流
    侦查报告AI 侦查 · 2 遍 · 2026-09-06
    本站镜像与 GitHub 原始是不同来源:本站锁定 commit 快照经 /r2 分发;GitHub 为实时上游,内容可能已更新。
    同分类邻近