save-session

A command for summarising and saving the current coding session to local files. It records progress, decisions, messages, and file changes so the work can be continued later.

In plain words
What is it for?
Use it to save project progress, decisions, planned tasks, edited files, and a searchable session summary across macOS, Windows, and Linux.
Why use it?
It reduces the risk of losing context when a session ends or becomes too long, while keeping a full conversation record for reference.

Command

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 commands/chamherry/claude-code-third-party-plugins/save-session
Clone the repo
git clone --depth 1 https://github.com/ChamHerry/claude-code-third-party-plugins
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,870 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 $0.00011 $0.02870
Opus 5 $0.00005 $0.01435
Sonnet 5 $0.00002 $0.00574
Haiku 4.5 $0.00001 $0.00287

Measured 2d ago against content hash aa62129be236, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

save-session 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.

plugins/session-manager/commands/save-session.md · 401 lines

How it starts

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

智能分析当前会话内容,提取关键信息(项目进度、实施方案、关键决策、文件变更),并保存到分层存储结构中。

核心特性:

  • 📊 智能提取: 自动识别 TodoWrite、AskUserQuestion、文件操作等关键信息
  • 💾 分层存储: 摘要文件 + 完整日志,兼顾查询效率和数据完整性
  • 🔍 防失真: 保留完整对话记录,避免压缩导致信息丢失
  • 🌐 跨平台: 完全兼容 Windows / macOS / Linux

执行步骤

1. 定位当前会话文件

找到 Claude Code 当前会话的 JSONL 文件。

位置~/.claude/projects/ 目录下

匹配规则

  • 项目目录名包含当前工作目录的路径信息
    • 例如:项目在 /Users/user/my-project
    • 对应目录可能是:-Users-user-my-project/
  • 文件名格式:{session-uuid}.jsonl
  • 排除 agent- 开头的文件
  • 选择最新的文件(按修改时间)

如果找不到

  • 输出错误信息
  • 说明可能原因:
    • 当前不在 Claude Code 会话中
    • 会话数据已被清理
    • 项目路径不匹配

提取信息

  • 会话文件的完整路径
  • 会话 UUID(文件名不含扩展名)

2. 读取并解析会话数据

a. 使用 Read 工具读取整个 JSONL 文件

# 读取会话文件
Read tool: $CURRENT_SESSION

b. 解析 JSONL 数据并提取关键信息

  • 使用 Python 脚本处理 JSON 数据(跨平台兼容)
  • 提取以下信息:
    • 第一条用户消息(作为会话标题)
    • 所有用户消息和 AI 响应
    • TodoWrite 工具调用(进度信息)
    • AskUserQuestion 工具调用(关键决策)
    • Write/Edit 工具调用(文件变更)
    • 消息时间戳(开始和结束时间)

c. 解析脚本实现

import json
import sys
from datetime import datetime

# 读取 JSONL 并解析
messages = []
todos = []
decisions = []
file_changes = []

for line in sys.stdin:
    msg = json.loads(line.strip())
    messages.append(msg)

    # 提取 TodoWrite
    if msg.get('type') == 'tool_use' and msg.get('name') == 'TodoWrite':
        todos.append(msg.get('input', {}).get('todos', []))

    # 提取 AskUserQuestion
    if msg.get('type') == 'tool_use' and msg.get('name') == 'AskUserQuestion':
        decisions.append({
            'timestamp': msg.get('timestamp'),
            'questions': msg.get('input', {}).get('questions', []),
            'answers': msg.get('input', {}).get('answers', {})
        })

    # 提取文件操作
    if msg.get('type') == 'tool_use' and msg.get('name') in ['Write', 'Edit']:
        file_changes.append({
            'operation': 'created' if msg.get('name') == 'Write' else 'modified',
            'path': msg.get('input', {}).get('file_path', ''),
            'timestamp': msg.get('timestamp')
        })

# 输出结果
print(json.dumps({
    'messages': messages,
    'todos': todos,
    'decisions': decisions,
    'file_changes': file_changes
}))

Read the full file on GitHub · 401 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 · 401 lines · 11 tokens per session scan A aa62129be236

Subscribe to this mod's changes

save-session is a command published in the GitHub repository ChamHerry/claude-code-third-party-plugins (50 stars, last pushed 9mo ago), licensed MIT. It adds 11 tokens to every session and 2,870 once invoked, about $0.0001 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-08-30.