Keeping a record: working across many sessions
说明与用途
建立了一个系统,用于在 Claude Code 会话之间保存和恢复上下文:命名约定、索引、自动化钩子和元数据,使工作能够轻松继续而不丢失信息。
问题
Maintaining continuity across multiple Claude Code sessions without losing decisions or context.
结果
A robust, repeatable workflow that preserves session continuity, enabling the author to write posts and manage work across many sessions without losing context.
工作流
- Define a naming format YYYYMMDD-VNN_name for each session.
- Create an index file docs/sessions.md with a Markdown table of sessions.
- Add a closing hook script that updates end time and status when Claude finishes.
- Determine the session UUID by selecting the most recent file in Claude’s internal sessions directory.
- Create a per-session file with metadata header and fixed sections (goal, decisions, work done, next steps).
- Implement list_sessions.py to read headers and display sessions ordered by activity.
- Add a start hook that injects data (tickets, long‑open sessions, alerts) and prompts to resume or start a new session.
- Move the closing hook into each project’s folder so it travels with the project.
- Apply the same template across all projects to keep naming and structure consistent.
- Iteratively patch and refine the system as new edge cases arise.
证据
A naming format, YYYYMMDD-VNN_nombre: the date, a counter that restarts at V01 every day, and a goal in two or three words.
An index, docs/sessions.md, a Markdown table.
A closing hook —a script Claude Code runs on its own every time the model finishes responding— that updates the end time and the status.
list_sessions.py appeared, which reads those headers and shows the sessions ordered by activity.
- 记录日期: 2026-09-18T05:45:18.181Z