knowledge-session-state-and-context-session-catalog-fork-rewind-and-export

knowledge-session-state-and-context-session-catalog-fork-rewind-and-export is a skill for Claude Code, Codex from echoVic/blade-code. It costs 140 tokens per session (2,411 once invoked), scanned A, original, MIT.

A session-lifecycle component for finding, resuming, archiving, branching, rewinding, searching, and exporting saved conversations.

In plain words
What is it for?
It is for listing sessions, creating independent forks, undoing a user turn, restoring archived sessions, searching transcripts, and exporting Markdown.
Why use it?
It lets developers manage past sessions safely without losing the original history or mixing workspaces and branches.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/echovic/blade-code/session-catalog-fork-rewind-and-export
Any agent
npx skills add echoVic/blade-code --skill session-catalog-fork-rewind-and-export
Clone the repo
git clone --depth 1 https://github.com/echoVic/blade-code

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for knowledge-session-state-and-context-session-catalog-fork-rewind-and-export

README.md
[![agentmods](https://agentmods.dev/badge/skills/echovic/blade-code/session-catalog-fork-rewind-and-export.svg)](https://agentmods.dev/skills/echovic/blade-code/session-catalog-fork-rewind-and-export)
Your own site
<a href="https://agentmods.dev/skills/echovic/blade-code/session-catalog-fork-rewind-and-export"><img src="https://agentmods.dev/badge/skills/echovic/blade-code/session-catalog-fork-rewind-and-export.svg" alt="Measured on agentmods" height="20"></a>
Per session 140 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,411 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00140 $0.02411
Opus 5 $0.00070 $0.01205
Sonnet 5 $0.00028 $0.00482
Haiku 4.5 $0.00014 $0.00241

Measured 2d ago against content hash 165a004f9a63, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

knowledge-session-state-and-context-session-catalog-fork-rewind-and-export scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.trae/knowledges/session-state-and-context/session-catalog-fork-rewind-and-export/SKILL.md · 70 lines

How it starts

The opening of the file, as written. The whole thing — 70 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Module Structure

该节点负责围绕持久 transcript 构建用户可操作的会话生命周期。所有读取先验证 Session 与 workspace 身份,再从有效事件投影目录、分支、回退结果、搜索命中或导出内容。

Directory Layout

  • packages/cli/src/services/SessionService.ts:会话元数据聚合与生命周期总入口
  • packages/cli/src/services/sessionCatalog.ts:查询规范化、稳定排序和 cursor 编解码
  • packages/cli/src/services/sessionRewind.ts:append-only rewind materialization 与 checkpoint 规划
  • packages/cli/src/services/TranscriptSearch.ts:SQLite FTS 快路径和 JSONL 兼容扫描
  • packages/cli/src/services/SessionMarkdownExporter.ts:可移植 Markdown 安全投影
  • packages/cli/src/services/SessionExportWriter.ts:本地 no-clobber 文件落盘
  • packages/cli/src/slash-commands/:resume、fork、archive、rewind、search 与 export 交互入口

Key Entry Points

  • SessionService.listSessionPage() / listSessions() in packages/cli/src/services/SessionService.ts:分页目录与任务过滤
  • SessionService.forkSession() in packages/cli/src/services/SessionService.ts:从稳定有效历史创建独立 child
  • SessionService.rewindSession() in packages/cli/src/services/SessionService.ts:原子提交回退 marker 并可选恢复 snapshot
  • SessionService.archiveSession() / unarchiveSession() in packages/cli/src/services/SessionService.ts:可恢复归档生命周期
  • SessionService.exportSessionMarkdown() in packages/cli/src/services/SessionService.ts:从 exact-workspace 稳定快照导出

Gotchas

  • Catalog cursor 绑定 cwdincludeSubagentsarchived 查询域;把 active cursor 用于 archived 列表或改变 workspace/filter 会明确拒绝,而不是从近似位置继续 (packages/cli/src/services/sessionCatalog.ts)
  • 排序边界是 lastMessageTime DESC -> projectPath ASC -> sessionId ASC,cursor 还使用 UTF-16 code-unit sort key 对齐 SQLite;改一侧排序却不改另一侧会造成跨页重复或遗漏 (packages/cli/src/services/sessionCatalog.ts, packages/cli/src/services/SessionService.ts)
  • 无 workspace 的 ID 查询只在全局唯一时安全;/resume/fork 和 archive 命令对同名跨工作区 Session 必须拒绝并要求用户选择 (packages/cli/src/slash-commands/resume.ts, packages/cli/src/slash-commands/fork.ts, packages/cli/src/slash-commands/archive.ts)
  • scoped load/delete/fork 不信任转义目录名,必须校验 session_created.data.sessionId 和 committed cwd;目录碰撞不能让另一个 workspace 的 transcript 被读取或删除 (packages/cli/src/services/SessionService.ts, git:f764f682)
  • fork 必须留在源 workspace,并从最多三次 stat/read/stat 一致的稳定快照创建;源在三次读取中持续变化时不产生 child (packages/cli/src/services/SessionService.ts, git:375287f5)
  • fork 复制 materialized 有效历史和 compaction checkpoint,但剥离 token handoff、inbox acknowledgement、pending interaction、review lifecycle 与 task 运行态;这些是父 Session 的恢复权限,不能继承到 child (packages/cli/src/services/SessionService.ts, git:1cacc9eb)
  • fork 的 prompt artifact 必须按 transcript 实际引用复制且重新校验;artifact 复制失败会删除已创建 child transcript 和 child artifact,不能留下只有预览而缺少完整请求的分支 (packages/cli/src/services/SessionService.ts, packages/cli/src/agent/runtime/UserPromptArtifactStore.ts)
  • rewind 不截断 JSONL;conversation/both 模式追加 marker 后由 projector 移除目标 user turn 及后续 conversation 生命周期,code-only 模式则保留 conversation (packages/cli/src/services/sessionRewind.ts, packages/cli/src/services/SessionService.ts)
  • code/both rewind 在 append marker 的 validated 临界区内先检查 snapshot 连续性和写后 hash;任一文件被外部修改时整组拒绝且 transcript 不新增 marker (packages/cli/src/services/SessionService.ts, packages/cli/tests/unit/services/session-service-rewind.test.ts)
  • 归档父 Session 只给根追加 archivedAt,后代状态由 lineage 投影继承;恢复父节点不会解除后代自己直接设置的归档 (packages/cli/src/services/SessionService.ts, docs/reference/session-archive.md)
  • 归档会先按稳定 ID 顺序获取根及全部 fork/subagent 后代的 lease,任一 queued/running 或被占用成员使整次操作零写入失败 (packages/cli/src/services/SessionService.ts, packages/cli/src/agent/runtime/SessionLease.ts)
  • TranscriptSearch 的 SQLite 路径只做 FTS 候选缩减,最终仍执行原 substring/snippet 判断;自定义 storagePath、索引不可用或异常时走 JSONL 扫描 (packages/cli/src/services/TranscriptSearch.ts)
  • SQLite 搜索结果的 lineNumber 为 0,而 JSONL 路径保留物理事件行号;调用方不能把该字段作为所有搜索路径都稳定的定位主键 (packages/cli/src/services/TranscriptSearch.ts)
  • Markdown 导出读取 stable JSONL 并应用 rewind,不从当前 Runtime、Web store 或 SQLite 拼接;否则 archived Session、冷导出和并发 append 会产生不同结果 (packages/cli/src/services/SessionService.ts, packages/cli/src/services/SessionMarkdownExporter.ts)
  • 本地导出使用 exclusive create 和 0600 权限,目标已存在时明确失败;ACP 只允许内联 Markdown 且上限 1 MiB,不能让 remote client 指定宿主路径 (packages/cli/src/services/SessionExportWriter.ts, packages/cli/src/slash-commands/export.ts)
  • exact-path 删除损坏 JSONL 仍保留 legacy 清理行为,当前无法从坏记录证明 committed cwd,且存储键注入性与跨进程锁仍是 storage-v2 债务 (packages/cli/src/services/SessionService.ts)

Read the full file on GitHub · 70 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 70 lines · 140 tokens per session scan A 165a004f9a63

Subscribe to this mod's changes

knowledge-session-state-and-context-session-catalog-fork-rewind-and-export is a skill published in the GitHub repository echoVic/blade-code (178 stars, last pushed yesterday), licensed MIT. It adds 140 tokens to every session and 2,411 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.