agentleFS
sunnysxgsunnysxg/claude_skills/session-log/SKILL.md

session-log

Skill0 starsChanged 3 months agoMITView on GitHub

session 收尾归档:把本次对话的工作摘要归档并生成可检索索引,供以后按项目或关键词找回改过 什么。用户要在结束本次对话前留痕时使用;也在 neat-freak 完成文档与记忆整理之后自动接续。

21 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ml-training-recipe, replication and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • getcompanion-aiSkill

    ml-training-recipe

    Find implementable ML training recipes from papers, datasets, docs, and code. Use when the user wants to fine-tune, train, reproduce, or choose a practical ML method, dataset, hyperparameter setup, or benchmark recipe.

    Also in 3 projects that use this

  • getcompanion-aiSkill

    replication

    Plan a replication of a paper, claim, or benchmark, and execute only after an explicit environment choice. Use when the user asks to replicate results, reproduce an experiment, verify a claim empirically, or build a replication package.

    Also in 3 projects that use this

  • brainbytes-devSkill

    alpha-research

    Also in 3 projects that use this

  • JaimeParkerSkill

    paper-code-audit

    Perform three-way cross-validation of a research paper by comparing the original paper text (via Zotero), official code implementation (via Git), and personal Obsidian notes. Use this skill whenever the user wants to "audit a paper", "verify paper claims against code", "cross-check notes with implementation", "triangulate paper + code + notes", "find discrepancies between paper and code", or mentions wanting a deep, structured comparison of a paper's claims against its implementation and their own notes. Also trigger when the user asks to "analyze this paper thoroughly" with code available, or when they want to systematically reconcile what the paper says, what the code does, and what their notes claim.

    Also in 3 projects that use this

  • JimLiuSkill

    pdf-explore

    Use this skill when the user has attached a PDF, paper, report, or other document and the answer needs content from more than one place in it: summarize the methods or any other section, compare sections, find where a topic is discussed, read a value or label off a figure or chart, or find/list/extract every instance of something across the whole document (datasets, benchmarks, citations, figures, table rows, accession numbers — including appendices). Skip it only for a single lookup of 1–4 pages quoted in your very next response — `read_file(pages=[...])` attaches pages as images that are dropped from context after one turn, so multi-section answers end up re-reading the same ranges repeatedly. Parses the PDF once in the Python kernel: `pdf_pages` (pages as persistent text), `pdf_outline` (TOC), `pdf_scan` (rank pages by relevance), `pdf_map`/`pdf_extract` (per-page summary / structured fields via parallel haiku calls). For PDF creation/manipulation, use reportlab/pypdf directly.

    Also in 3 projects that use this

  • Yusong-EnceladusSkill

    research-review

    Get a deep critical review of research from GPT via Codex MCP. Use when user says "review my research", "help me review", "get external review", or wants critical feedback on research ideas, papers, or experimental results.

    Also in 3 projects that use this

  • +1 more from getcompanion-ai

The file

Files
SKILL.md

Session Log — 关 session 前写摘要

用户要在结束本次 chat 之前留下可检索记录,避免「几天前改过什么但找不到对应 session」。 chat 侧边栏只能按标题/时间浏览,这个归档 + 索引是刻意为之的可搜索层;检索用 session-search,本 skill 只负责写入。

你的任务:回顾当前对话,写一份结构化 session 摘要到全局归档目录,并生成 suggested_chat_title。

平台:时间解析(session_times.py)与 upsert(session_resolve.py)支持 Cursor、 Claude Code 和 Codex;脚本会自动识别 transcript 格式。存量回填(session_backfill.py) 仍仅支持 Cursor。

0. 执行边界与效率

  • session-log 只做归档;不要顺带 commit、补文档或重跑项目测试,除非用户明确同时要求。
  • 第一轮并行收集 transcript 时间、Git 事实、template、index 和已有 target;不要逐项串行读取。
  • session_times.py 返回 fallback: false 时直接采用,不再人工重扫 transcript。
  • resolve 后集中写归档、更新 index、register 映射,避免为每个字段单开工具轮次。

1. 确定项目

按优先级:

  1. 用户 @ 的路径所在项目(含 CLAUDE.md / AGENTS.md 的子目录根)
  2. 从 cwd 向上找最近的 CLAUDE.md、AGENTS.md 或 git 根
  3. 多项目并列时,以主要改动最多的那个为准;不确定则问用户

记为 {PROJECT}(绝对路径)。元信息字段:

字段取值
project项目根目录名 snake_case 化:全小写、- → _(如 quantalpha、factor_infra)
project_path{PROJECT} 的绝对路径(本机实际路径)

日志目录(全局,固定):~/_sxg/llm_session_log/

不存在则创建。归档按机器独立(~ 各自解析),本 skill 只写本机归档。 各项目下的 _sxg/session_log/ 已废弃,勿再写入。

2. 收集事实(先读再写,不要编造)

从当前对话提取:

  • 用户原始目标 / 问题演变
  • 实际完成的工作(含文件路径、行为变化)
  • 关键决策、踩坑、未竟事项
  • 用户明确说「以后再做」的内容

若 {PROJECT} 是 git 仓库,运行:

git -C "{PROJECT}" log --oneline -15
git -C "{PROJECT}" status -sb

把本 session 相关的 commit 写进摘要(hash + 一行说明)。无关的旧 commit 不要堆。

3. 时间与 upsert 解析(必须先跑脚本)

禁止用执行 /session-log 的当前时刻填时间。用户可能隔几小时或几天才来整理归档。

先把适合当前 shell 的 Python 3 调用前缀记为 {PYTHON_CMD},并实际运行 --version 验证; PowerShell 调用绝对路径时前缀包含 &,WindowsApps 占位程序不算可用。Codex Desktop 的 PATH 没有 Python 时,用 workspace dependencies 返回的 bundled Python 绝对路径。脚本只依赖标准库。

3.1 时间 — session_times.py

从当前 SKILL.md 的目录解析为 {SKILL_DIR},不要猜客户端安装根:

{PYTHON_CMD} "{SKILL_DIR}/scripts/session_times.py" --transcript "{当前 session transcript 的绝对路径}" --save-temp

transcript 路径(按优先级):

  1. system 注入的当前 transcript 绝对路径
  2. --uuid {uuid}(Codex 优先用已设置的 CODEX_THREAD_ID)自动查找 Cursor agent-transcripts/、Claude ~/.claude/projects/**/*.jsonl 或 Codex $CODEX_HOME/sessions/**/rollout-*-{uuid}.jsonl

Codex 查找必须按 rollout 文件名精确匹配 UUID,禁止全文 grep;subagent transcript 即使正文带 root UUID 也不能冒充 root session。

保留输出 JSON(含 session_id、date、time、filename_ts、started_at、 last_active_at、logged_at)。--save-temp 让脚本自己把同一份 JSON 写进操作系统临时 目录(Python tempfile,三平台通用),路径在输出的 times_json_path 字段,记为 {TIMES_JSON_PATH}。

{TIMES_JSON_PATH} 只能在操作系统临时目录或 ~/_sxg/llm_session_log/,绝不能写进项目树 或 Git 候选 / worktree:不要用 shell 重定向、Write 工具或手写文件落到 cwd。生产卡的候选里 多出一个未跟踪文件,交付 saga 会判脏树拒绝落位并反复重试(TODOHUB-291 实撞 .tmp_session_times.json,删掉后才自动恢复)。session_resolve.py 对落在 Git 工作树里的 --times-json 直接报 times_json_inside_git_worktree 并退出——撞到就删掉那个文件,改用 --save-temp 重跑。

字段用途
session_idfrontmatter + resolve
datefrontmatter date、index「日期」列(session 开始日;update 不变)
timefrontmatter time(最后活跃;update 刷新)
last_active_at / logged_atfrontmatter
filename_ts仅 create 时用于文件名前缀
fallback: true找不到 transcript;允许用当前时间并在回复说明

3.2 命名(先定 slug,再 resolve)

字段要求示例
session_title5–12 字概括本次工作consistency gate 修复
suggested_chat_title供 chat 标题;建议带开始日前缀260629 consistency+mlflow-slug
slug全小写 snake_case、ASCII、≤40 字符consistency_gate_mlflow_slug

suggested_chat_title 日期前缀用 session 开始日(date 的 YYMMDD)。

3.3 Upsert — session_resolve.py

{PYTHON_CMD} "{SKILL_DIR}/scripts/session_resolve.py" --uuid "{session_id}" --times-json "{TIMES_JSON_PATH}" --project "{project}" --slug "{slug}"
输出含义
mode: create本 chat 首次归档
mode: update已有归档,覆写同一文件
target_file / target_path写入路径(update 时文件名不变)
index_action: insert_rowindex 表头下插入新行
index_action: replace_row替换含 ({target_file}) 的那一行
index_line_matchreplace 时用于 StrReplace 的整行原文

session_resolve.py 读完 --times-json 立即删掉该文件(第一次运行即消费,重跑 resolve 要 先重跑 session_times.py --save-temp);后续步骤用的时间字段取自 3.1 已保留的输出。

session_times.py 会按 transcript 自动区分 Cursor / Claude / Codex; session_resolve.py 的 UUID upsert 逻辑三端共用。若 fallback: true,才允许人工核对并填写时间。

4. 写文件

路径:以 resolve 的 target_path 为准(不要自行拼新文件名)。

create:按 references/template.md 新建;frontmatter 必须含 session_id。

update:

  1. Read 现有 md
  2. 保留 session_id、date(开始日不变)
  3. 更新 time、last_active_at、logged_at、summary、正文各节
  4. 禁止 rename 文件
  5. 文件末尾若有 ## Vault 精选 一节,原样保留在末尾——它由 zettel-distill 维护, session-log 不写、不删、不改(见 references/template.md 末尾说明)

5. 更新 index

index_action操作
insert_row在 index.md 表头下第一行插入
replace_row用 index_line_match 整行 StrReplace,禁止再插一行

行格式:

| {date} | {project} | [{session_title}]({target_file}) | {一行 summary} | `{suggested_chat_title}` |

index「日期」= session 开始日。

6. 登记映射

写入成功后运行:

{PYTHON_CMD} "{SKILL_DIR}/scripts/session_resolve.py" --register --uuid "{session_id}" --file "{target_file}" --started-at "{started_at}" --chat-title "{suggested_chat_title}"

维护 ~/_sxg/llm_session_log/.session_map.json(勿手改)。--chat-title 是 Claude Code Desktop --ccd-pending 补历史遗留标题(见第 7 步)的数据来源,所有客户端都带上,无害。

7. 回复用户

若本次在 Git 候选 / worktree 里收口(尤其生产卡:交付后系统直接落位上线),把卡移入 in_review、或结束会话交给派发器触发交付 saga 之前,先跑 git -C "{候选树}" status --short 确认输出为空;有残留就删掉或 commit 进候选再交付,不留给 saga 撞脏树。

第 4–6 步全部成功后,再用简短中文告知:

  1. 新建或更新同一条,以及路径
  2. date / time 来源;若 fallback 则说明
  3. 检索:~/_sxg/llm_session_log/index.md;不够时 agent 用 session-search
  4. 处理 suggested_chat_title:
    • 宿主提供直接修改当前 task/thread 标题的工具时,调用该工具;Codex Desktop 通常为 codex_app__set_thread_title,省略 threadId 以定位当前 task。工具返回成功后只需告知 用户“任务已重命名为 {suggested_chat_title}”,不要再输出 /rename 或要求用户操作。 Claude Code Desktop 是例外,见下一条。
    • Claude Code Desktop(mcp__ccd_session_mgmt__* 工具可见;deferred 时先用 ToolSearch 加载 set_session_title):调用 set_session_title(session_id="self", title="{suggested_chat_title}") 直接改当前 session(app ≥ 1.32352 支持)。 session_id 必须传字面量 "self":传自己的 local_* id 会被拒("Refusing to rename the current session from within itself"),经 subagent 转发或改 claude-code-sessions 注册 JSON 同样无效,不要再试。成功后告知用户已重命名。 再顺手运行

      {PYTHON_CMD} "{SKILL_DIR}/scripts/session_resolve.py" --ccd-pending --uuid "{session_id}"

      对输出 pending 中的每项调用 set_session_title,补上历史遗留未改名的其他 session(用户手动改过的标题会自动跳过)。

    • 只有当前客户端已明确识别为 Claude、Cursor 或 Codex CLI/TUI,且确认该 surface 支持 /rename 时,才在回复最后一行单独输出 /rename {suggested_chat_title}。 Claude/Cursor 环境若已安装 Stop hook auto_rename_on_stop.py,会经 tmux send-keys 自动执行;Codex CLI/TUI 可由用户执行。
    • Codex Desktop 的工具缺失、失败或结果含糊时,不回滚已成功归档,不输出它不支持的 /rename;明确说未完成重命名,并给出标题供用户在 UI 手动修改。
    • 未知客户端只给标题建议,不假定它支持 slash command;直接标题工具不可见并不能证明 /rename 可用。不得声称已改好。

不要继续写无关代码,除非用户接着提新任务。

8. 与 handoff / 项目 changelog 的边界

工具用途
session-log(本 skill)归档「这次 chat 做了什么」,方便人类回顾、找 session
handoff给下一个 agent 接手的待办与上下文
zettel-distill归档写完后在其末尾「Vault 精选」记候选,用户拍板后写进用户的 Zettelkasten
项目 changelog产品/代码变更史(另议,不在本 skill 范围)

若用户既要关 session 又要交接,先完成 session-log,再询问是否另跑 /handoff。

9. 存量回填(一次性)

脚本 scripts/session_backfill.py:从 Cursor transcript 写入记录反查 uuid,注入 session_id 并生成 .session_map.json。

python3 ~/.cursor/skills/session-log/scripts/session_backfill.py          # 预览
python3 ~/.cursor/skills/session-log/scripts/session_backfill.py --apply  # 写入

同一 chat 重复归档会先合并(见脚本内 MERGE_GROUPS),再回填。

存量 backfill 仅支持并测试 Cursor。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.