---
name: save
description: Distill the current Claude Code session into a concise, linked summary note in the ~/brain second-brain vault, update the project index, clear resolved breadcrumbs, and commit the vault. Use when wrapping up work or when the user says "/save", "save this session", or "checkpoint".
---

# /save — distill this session into the brain vault

Follow these steps exactly. Keep the summary a **distillation**, never a transcript dump.

## 1. Resolve vault + project
- `VAULT = ${BRAIN_VAULT:-$HOME/brain}`.
- `toplevel = git rev-parse --show-toplevel` (run in cwd). If not a git repo, use cwd.
- `slug = basename(toplevel)` lowercased, non-alphanumerics → `-`, trimmed.
- If there is clearly no project (e.g. `$HOME`), tell the user and stop.

## 2. Read the transcript (source of truth)
- First, read any loose breadcrumbs: `$VAULT/Inbox/<slug>/*.md`. If one exists, its
  `transcript:` frontmatter field is the exact transcript path — prefer it.
- Otherwise compute the transcript dir: `$HOME/.claude/projects/<cwd-encoded>`, where
  the encoding replaces every non-alphanumeric character with `-` (Claude Code maps
  `/`, `.`, etc. all to `-`). Compute via:
  `printf '%s' "$(pwd)" | sed 's#[^a-zA-Z0-9]#-#g'` prefixed with `$HOME/.claude/projects/`.
- The current transcript is the **newest** `*.jsonl` there: `ls -t <dir>/*.jsonl | head -1`.
- Read that file with the Read tool. Distill from it — it is full-fidelity even after compaction.

## 3. Write the session note
Path: `$VAULT/Projects/<slug>/sessions/<YYYY-MM-DD>-<short-title-slug>.md`
(use today's date; create dirs as needed). Template:

```markdown
---
date: <YYYY-MM-DD>
project: <slug>
branch: <branch>
tags: [session]
session_id: <id from breadcrumb or transcript>
---

# <Short, specific title>

## Summary
<2–5 sentences: what was done and why.>

## Decisions
- <decision> — link related notes as [[note-name]] where useful.

## Changes
- <files / areas touched, by path>

## Open loops / next steps
- [ ] <what to pick up next>

## Links
- Project: [[index]]
- Plans: [[<relevant mirrored plan filename without .md>]]
```

## 4. Update the project index (map of content)
- File: `$VAULT/Projects/<slug>/index.md`. If missing, create it from the template
  in the `/resume` skill's notes (H1 = friendly project name, sections: Status / next
  steps, Recent sessions, Plans & specs, Key notes).
- Prepend a bullet to **Recent sessions**: `- [[<session-filename-without-.md>]] — <one-line>`.
- Refresh **Status / next steps** from this session's open loops.

## 5. Resolve breadcrumbs + commit
- Delete the breadcrumb(s) you distilled: `rm $VAULT/Inbox/<slug>/<session_id>.md`.
- Commit the vault:
  `git -C "$VAULT" add -A && git -C "$VAULT" commit -m "save(<slug>): <short title>"`.
- Tell the user the session note path and what you recorded.
