save
Save current session transcript to markdown with per-turn token counts, cost breakdown, and context usage.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-12
- Stars
- ★ 3
- Forks
- 4
01 前言 Front Matter
- name
- save
- description
- Save current session transcript to markdown with per-turn token counts, cost breakdown, and context usage.
- allowed-tools
- Bash(*)
- argument-hint
- [output_path]
02 资源文件 3
- 脚本autosave.sh876 B
- 参考文档README.md2.2 KB
- 脚本save.sh5.2 KB
03 SKILL.md 正文
Save the current Claude Code session transcript as a markdown file with token usage, cost stats (/cost), and context window utilization (/context). Never overwrites existing files — appends -1, -2, etc. suffixes.
The user may pass an optional output path as an argument. If provided, use it as OUT. Otherwise default to the current directory.
Steps
- Find the most recent session JSONL. Try exact project key first, then fall back to the most recently modified JSONL across all projects (which is almost certainly this session):
PROJECT_KEY=$(pwd | sed 's|/|-|g')
JSONL=$(ls -t ~/.claude/projects/${PROJECT_KEY}/*.jsonl 2>/dev/null | head -1)
if [[ -z "$JSONL" ]]; then
JSONL=$(find ~/.claude/projects/ -maxdepth 2 -name '*.jsonl' -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -1 | cut -d' ' -f2-)
fi
if [[ -z "$JSONL" ]]; then
echo "No session JSONL found" >&2
exit 1
fi
echo "JSONL: $JSONL"
- Determine output path — use the argument if provided, otherwise save to current directory. If the argument is a directory, create the transcript file inside it:
SESSION_ID=$(basename "$JSONL" .jsonl)
DATE=$(date +%Y-%m-%d)
DEFAULT_NAME="transcript_${SESSION_ID}_${DATE}.md"
if [[ -n "$ARGUMENTS" ]]; then
if [[ -d "$ARGUMENTS" ]]; then
OUT="${ARGUMENTS%/}/${DEFAULT_NAME}"
else
OUT="$ARGUMENTS"
fi
else
OUT="$(pwd)/${DEFAULT_NAME}"
fi
- Find and run the save script relative to the repo root:
SAVE_SCRIPT="$(git rev-parse --show-toplevel 2>/dev/null)/.claude/skills/save/save.sh"
if [[ ! -f "$SAVE_SCRIPT" ]]; then
echo "save.sh not found at: $SAVE_SCRIPT" >&2
exit 1
fi
bash "$SAVE_SCRIPT" "$JSONL" "$OUT"
- Report the output path and total estimated cost.
04 同仓库更多 Skills
tools-spin-sync
Synchronize Spin/Promela models with current source code and re-verify
tools-spin-model
Create a new Spin/Promela formal verification model for a system property
tools-creusot-install
Install the Creusot Rust verification tool
tools-creusot-init
Prepare an existing Cargo project to use Creusot formal verification
tools-creusot-coq-install
Add Coq 8.20 as an additional prover to an existing Creusot installation, for verification conditions that SMT solvers cannot discharge
tools-creusot-annotate-interfaces
Formally verify a component's properties with Creusot and annotate its interface definitions