/obsidian-brain:retrofrom obsidian-brain
Generates honest session retrospectives analyzing what worked, what didn't, key learnings, and actionable process improvements. Use when: (1) /retro command at end of session, (2) user wants to reflect on session quality and outcomes.
Ships in obsidian-brain. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Analyze the current conversation candidly and save a structured retrospective to the Obsidian vault. The goal is honest reflection — not self-congratulation — so future sessions can improve.
Tools needed: Bash, Read, Write
Follow these steps exactly. Do not skip steps or reorder them.
First find the directory the later steps run from. Run this as a command of its own:
git rev-parse --show-toplevel
If it fails (not a git repo), run pwd instead. Keep the printed path; the steps below call it <REPO_ROOT>. Every block below that runs the plugin's hooks starts with cd '<REPO_ROOT>': paste the literal path, in single quotes (write a ' inside it as '\''). Do not put git inside $(...) on a cd line: a worktree-isolated session refuses that form ("names git in a form too complex to verify", #518).
Then run:
cd '<REPO_ROOT>'
python3 -c '
import sys, os
import glob, json, os, re, sys
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser("~/.claude/plugins/known_marketplaces.json"))).values():
_s = _m.get("source") if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get("source") == "directory"):
continue
_i = _m.get("installLocation") if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, "hooks")
if os.path.isfile(os.path.join(_h, "obsidian_utils.py")):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser("~/.claude/plugins/cache/*/obsidian-brain/*/hooks")) if re.fullmatch("[0-9]+([.][0-9]+)*", _d.split("/")[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split("/")[-2].split(".")], _p), default="hooks")
sys.path.insert(0, _ob_hooks())
from obsidian_utils import load_config
c = load_config()
if not c.get("vault_path"):
print("ERROR: vault_path not configured", file=sys.stderr)
sys.exit(1)
print("VAULT=" + c["vault_path"])
print("SESS=" + c.get("sessions_folder", "claude-sessions"))
print("INS=" + c.get("insights_folder", "claude-insights"))
_w = os.path.expanduser("~/.claude/obsidian-brain")
os.makedirs(_w, mode=0o700, exist_ok=True)
os.chmod(_w, 0o700)
print("WORK=" + _w)
'
Parse each output line as KEY=VALUE, splitting on the first =. WORK is a private (0o700) directory for the note and traces files that Steps 7 and 7.5 write with the Write tool; the steps below call it <WORK>.
If the file does not exist or is invalid JSON, tell the user:
Config not found. Please run
/obsidian-setupfirst to configure your Obsidian vault.
Stop here if config is missing.
Run:
test -d "$VAULT_PATH/$INSIGHTS_FOLDER" && test -w "$VAULT_PATH/$INSIGHTS_FOLDER" && echo "OK" || echo "FAIL"
If FAIL, tell the user:
The insights folder
$VAULT_PATH/$INSIGHTS_FOLDERdoes not exist or is not writable. Run/obsidian-setupto fix this.
Stop here if FAIL.
The active conversation buffer only covers the post-compact half of long sessions. Before drafting the analysis, gather every artifact the active session has already written to the vault.
Detect a compact boundary and recover the prior session id (#184). Before running the helper below:
~/.claude/projects/<project-dir>/<session-id>.jsonl — the basename minus .jsonl IS the prior session id.When a prior id is recovered, pass it as a shell-quoted positional argument after the python3 -c script below, one argument per id — never interpolated into the Python source itself (repo security rule). The script reads them from sys.argv[1:], so it works whether zero or several are recovered.
cd '<REPO_ROOT>'
mkdir -p "$HOME/.claude/obsidian-brain" && chmod 700 "$HOME/.claude/obsidian-brain"
_OB_BUNDLE="$HOME/.claude/obsidian-brain/retro-bundle-$$.json"
_OB_ERR="$HOME/.claude/obsidian-brain/retro-bundle-$$.err"
python3 -c '
import sys, os, json, glob
import glob, json, os, re, sys
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser("~/.claude/plugins/known_marketplaces.json"))).values():
_s = _m.get("source") if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get("source") == "directory"):
continue
_i = _m.get("installLocation") if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, "hooks")
if os.path.isfile(os.path.join(_h, "obsidian_utils.py")):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser("~/.claude/plugins/cache/*/obsidian-brain/*/hooks")) if re.fullmatch("[0-9]+([.][0-9]+)*", _d.split("/")[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split("/")[-2].split(".")], _p), default="hooks")
sys.path.insert(0, _ob_hooks())
_ID_RE = re.compile(r"^[0-9a-fA-F][0-9a-fA-F-]{7,63}$")
_raw_ids = sys.argv[1:]
_also_ids = [a for a in _raw_ids if _ID_RE.match(a)]
_rejected = len(_raw_ids) - len(_also_ids)
if _rejected:
# Loud, never silent: a rejected token (e.g. a leftover placeholder that
# was not stripped) used to just vanish from _also_ids and degrade to
# the empty post-compact bundle #184 exists to eliminate, with no
# signal. Exit non-zero so this routes through the existing crash path
# below into discovery_errors and the "evidence discovery partially or
# fully failed" banner. Never the token itself in the message — this
# is fed straight into the model context via the transcript.
print(f"rejected {_rejected} invalid also-session-id argument(s)", file=sys.stderr)
sys.exit(1)
from obsidian_utils import load_config, get_session_context, gather_session_evidence
try:
from obsidian_utils import resolve_source_session_note
except ImportError:
# Stale hooks predating #330: fall back to the pre-#330 unguarded
# backlink rather than omitting it. Returning an empty string here would
# silently strip source_session_note from every retro on a partial
# upgrade -- the same regression the #330 review caught in the main path.
# NOTE: no apostrophes in this block; it lives inside a single-quoted
# python3 -c argument and one would terminate the shell string.
def resolve_source_session_note(_n="", *_a): return _n
print("WARN: stale obsidian-brain hooks; using the unguarded source_session_note", file=sys.stderr)
c = load_config()
ctx = get_session_context(c["vault_path"], c.get("sessions_folder", "claude-sessions"))
bundle = gather_session_evidence(
c["vault_path"],
c.get("sessions_folder", "claude-sessions"),
c.get("insights_folder", "claude-insights"),
ctx["session_id"], ctx["project"],
also_session_ids=_also_ids,
)
ctx["resolved_source_session_note"] = resolve_source_session_note(
ctx["session_note_name"], ctx["session_id"],
c["vault_path"], c.get("sessions_folder", "claude-sessions"),
)
bundle["_ctx"] = ctx
print(json.dumps(bundle))
' >"$_OB_BUNDLE" 2>"$_OB_ERR"
_OB_RC=$?
if [ $_OB_RC -ne 0 ]; then
_OB_ERRMSG="$([ -f "$_OB_ERR" ] && head -c 500 "$_OB_ERR" || echo "")"
_OB_RC="$_OB_RC" _OB_ERRMSG="$_OB_ERRMSG" python3 -c "
import os, json
rc = os.environ.get('_OB_RC', '?')
errmsg = os.environ.get('_OB_ERRMSG', '')
print(json.dumps({
'session_id': 'unknown',
'session_ids': [],
'snapshots': [],
'insights': [],
'decisions': [],
'error_fixes': [],
'retros': [],
'prior_retro_key': '',
'discovery_errors': [f'evidence helper crashed (exit={rc}): {errmsg[:500]}'],
'_ctx': {'session_id': 'unknown', 'hash': 'unknown', 'project': 'unknown', 'session_note_name': 'unknown', 'resolved_source_session_note': ''},
}))
"
else
cat "$_OB_BUNDLE"
fi
rm -f "$_OB_BUNDLE" "$_OB_ERR"
The canonical block above ships with zero trailing arguments, so the common no-compact-boundary case is correct by copying it verbatim — do not append a literal placeholder string. When a compact boundary IS detected and a prior id recovered, append it as a shell-quoted positional argument after the closing ', one argument per recovered id (per the "Detect a compact boundary" step above); the script rejects any argument that is not a bare hex-and-dash id, so a stray or malformed token fails loudly (see the "Helper crash / partial failure" handling below) rather than being silently dropped.
Parse the JSON output. The bundle has these fields: session_id (the primary id exactly as passed — may be "unknown"), session_ids (the ordered, de-duplicated ids actually scanned — may be non-empty even when session_id is "unknown"), snapshots, insights, decisions, error_fixes, retros, prior_retro_key, discovery_errors, and _ctx (the cached get_session_context() result reused by Step 5).
Unresolved-session fallback. If bundle["session_ids"] == [] AND bundle["discovery_errors"] == [], print:
Note: this session could not be identified (no Claude Code transcript resolves to the current directory), so session-scoped evidence could not be looked up — falling back to active-conversation-only retro. This is not evidence that the vault is empty.
Gate on session_ids, not on the resolver (bundle["_ctx"]["session_id"]): resolver failure and preamble-id recovery are independent. The continuation preamble carrying a prior session id lives in the buffer regardless of whether the transcript resolves, so session_ids can be non-empty even when _ctx["session_id"] is "unknown" — that case is the branch immediately below, not this one.
Recovered-under-prior-id note. If bundle["_ctx"]["session_id"] == "unknown" AND bundle["session_ids"] != [], print:
Note: this session could not be identified, but evidence was recovered under prior session id
<id>(the last entry inbundle["session_ids"]).
Then proceed normally — run the mandatory snapshot pre-pass in Step 3.0 and include ## Evidence Consulted in Step 4 — exactly as if the session had resolved. Only the unresolved-session fallback above and the empty-bundle fallback below skip the pre-pass; this case does not.
Empty-bundle fallback. If the session id IS resolved (bundle["_ctx"]["session_id"] != "unknown"), bundle["discovery_errors"] == [], and snapshots, insights, decisions, error_fixes and retros are all empty, print:
Note: no prior-session evidence found — falling back to active-conversation-only retro.
Keep the three apart. "No evidence found" asserts a fact about the vault ("there is nothing"); an unresolved session id is a fact about the resolver ("I could not identify this session"), and reporting the second as the first is what let a session-resolution failure read as a genuinely fresh session (#260 I4). The unresolved-session and empty-bundle fallbacks behave identically from here — proceed with Step 3 using only the active conversation buffer, and do not include the ## Evidence Consulted section in Step 4 in either case. The recovered-under-prior-id note above is different: evidence exists, so it takes the full evidence-mining path instead.
Helper crash / partial failure. If bundle["discovery_errors"] is non-empty, do not silently fall back to "no prior-session evidence found." Instead emit:
⚠️ Evidence discovery partially or fully failed. Some vault artifacts may be missing from this retro. See the discovery-errors warning surfaced in Step 6 for details.
Then proceed with whatever evidence was collected (possibly none).
Discovery errors. If bundle["discovery_errors"] is non-empty, remember the list — it will be surfaced after the preview in Step 6.
Prior-retro scoping (#285). If bundle["retros"] is non-empty, take the last entry (most recent, ordered by the key named in bundle["prior_retro_key"]: created_at, else date, else filename) and scope this retro to the arc after it — the work this retrospective covers picks up where that prior retro left off. A claude-retro entry is a boundary marker, not evidence: it is deliberately excluded from the "every RELEVANT snapshot must surface in the analysis" coverage rule that governs snapshots in Step 3.0 below. Do not mine a prior retro's own body for content to fold into this one's findings — use it only to know where to stop looking backward.
Be candid, not defensive or self-congratulatory. This retro draws on the current session's pre-compact evidence (the Step 3a bundle — snapshots plus insights/decisions/error-fixes) and the live post-compact conversation. Work the bundle first — mine the snapshots in 3.0 below — then review the live conversation.
When the bundle from Step 3a is non-empty, mine the snapshots BEFORE analyzing the live conversation. The pre-compact snapshot arcs almost always hold more decision points and dead ends than the vivid post-compact buffer, and are the evidence most easily skimmed. The pre-pass below is mandatory — running it first is what gives snapshots equal-or-higher priority than the live buffer.
For each entry in bundle["snapshots"], emit a short visible digest so the pass leaves an auditable trace — do not silently "consider" snapshots; print the digest:
Snapshot [<hhmmss>] <stem> [(pre-compact arc)] — verdict: RELEVANT | EARLIER-ARC/UNRELATED
(if RELEVANT)
- decision points: ...
- abandoned approaches / dead ends: ...
- user corrections / redirects: ...
- anything the post-compact buffer alone would not reveal: ...
(if EARLIER-ARC/UNRELATED)
- reason (e.g. "distinct earlier /ship arc for #NN, not part of this retro")
Verdict rules:
RELEVANT. Only mark a snapshot EARLIER-ARC/UNRELATED when it is unmistakably about a different, self-contained earlier task that is not part of the work this retrospective covers. This bias keeps the exclusion path from becoming a new way to drop content./retro takes no arc argument — it reflects on the current session as a whole — so infer the focus from the live buffer and the most recent arc, and treat most recent arc as a heuristic, not a hard boundary. Only a clearly-concluded earlier /ship arc that already got its own retro is EARLIER-ARC/UNRELATED; when in any doubt, mark RELEVANT (the default-to-RELEVANT bias above governs). Every excluded snapshot is still recorded in ## Evidence Consulted (Step 4), so a wrong exclusion stays visible to the user in the Step 6 preview rather than being silently lost.bundle["snapshots"] is empty, skip this pre-pass; emit No current-session snapshots — skipping the snapshot pre-pass. only if Step 3a did not already print its no-evidence fallback notice (do not print a duplicate).(pre-compact arc) after <stem> when that snapshot's session_id field differs from bundle["_ctx"]["session_id"] (#184) — it labels a snapshot recovered via also_session_ids from a prior session, purely informational, and carries no relevance verdict of its own; judge RELEVANT vs EARLIER-ARC/UNRELATED the same way regardless of which arc it came from.Then weight the analysis by the two halves' decision density: if the pre-compact half ran 6 hours and the post-compact half ran 90 minutes, "What Didn't Work" should reflect that. Estimate this weighting only from RELEVANT snapshots — exclude the time span covered by any EARLIER-ARC/UNRELATED snapshot from both the duration estimate and the resulting weight. Treat every RELEVANT snapshot body and the insight/decision/error-fix bodies as first-class evidence, not background context — every RELEVANT snapshot's findings must surface in the sections below.
The "What Didn't Work" section is the MOST valuable part of this retrospective — invest the most analysis there.
Evaluate the session across these five dimensions:
Draft the note body using this exact structure:
## Evidence Consulted
- Sessions scanned: <id-a> (current), <id-b> (pre-compact)
- Active conversation: <N> messages (post-compact buffer)
- Snapshots — RELEVANT: <K> file(s)
- [[<stem-1>]] (<hhmmss>, <trigger>)
- [[<stem-2>]] (<hhmmss>, <trigger>) (pre-compact arc)
- Snapshots — excluded as earlier-arc: <M> file(s)
- [[<stem-x>]] (<hhmmss>) — <one-line exclusion reason from the 3.0 digest>
- Insights: <K> file(s)
- [[<stem-1>]] — <title>
- Decisions: <K> file(s)
- [[<stem-1>]] — <title>
- Error-fixes: <K> file(s)
- [[<stem-1>]] — <title>
- Prior retros: <K> file(s)
- [[<stem>]] — <title>
- Scope: the arc after [[<most-recent-retro-stem>]] — <what is not re-litigated>
## What Went Well
- <specific thing that worked, with enough context to be meaningful>
## What Didn't Work
- <dead end: what was tried, why it failed, time impact>
- <wrong assumption: what was assumed, what was actually true>
- <user correction: what Claude did wrong, what user redirected to>
## Key Learnings
- <non-obvious insight with enough context to be useful later>
## Process Improvements
- [ ] <specific actionable change for future sessions>
Rules for ## Evidence Consulted:
Snapshots — RELEVANT, list the snapshots marked RELEVANT in the Step 3.0 pre-pass. Under Snapshots — excluded as earlier-arc, list every EARLIER-ARC/UNRELATED snapshot with its one-line reason. The 3.0 digest is console-only, so persisting excluded snapshots here is what keeps an exclusion auditable in the saved note (and catchable by the user in the Step 6 preview) — never rely on the digest alone.RELEVANT snapshot must be represented in the analysis. If a RELEVANT snapshot genuinely yielded no distinct dead-ends beyond the live buffer, say so explicitly in "What Didn't Work" (e.g. - [[stem]]: no distinct dead-ends beyond the live buffer) rather than silently omitting it.Sessions scanned (#184): render this line only when bundle["session_ids"] has more than one entry — omit it entirely for a single-id scan. List each id from bundle["session_ids"] in order, labelling the one matching bundle["_ctx"]["session_id"] (current) and the rest (pre-compact).(pre-compact arc) marker (#184): for each snapshot listed under Snapshots — RELEVANT or Snapshots — excluded as earlier-arc, append (pre-compact arc) when that snapshot's session_id field differs from bundle["_ctx"]["session_id"]; omit the marker when it matches (the common, single-arc case).Prior retros / Scope (#285): these follow the existing zero-count omission rule below, and are not among the two always-rendered Snapshots — lines — omit both when bundle["retros"] is empty. When non-empty, Prior retros lists every entry in bundle["retros"]; Scope names only the last one per the Step 3a prior-retro-scoping rule and states the key: Scope: after [[<stem>]] (most recent by <prior_retro_key>). When bundle["prior_retro_key"] is not created_at, explicitly say that a fallback key was used. Follow this with a short phrase for what is not being re-litigated (e.g. "the auth refactor already covered in that retro").... : 0 file(s) zero-count noise) — except the two Snapshots — lines: whenever bundle["snapshots"] was non-empty, render BOTH lines even at count 0, so an all-excluded session is never indistinguishable from a no-snapshot one.## Evidence Consulted section if the empty-bundle fallback fired in Step 3a.[[stem]]) preserve Obsidian backlinks and round-trip through the FTS index.Important: "What Didn't Work" should have MORE items than "What Went Well." If the session went smoothly with no obvious failures, still find at least one improvement opportunity — there is always something.
Steps 5 to 8 (session ID, preview, write, classification, confirm) save the note. Run them yourself, inline in the main session. They must not be delegated to a subagent or the Agent tool. A subagent's write is invisible to this transcript: when one did the save, the session ended with no proof the note existed (#384). Analysis in Steps 1 to 4 may use helpers; the save may not.
The Step 3a bundle already carries the cached session context as bundle["_ctx"]. Read these fields directly:
SESSION_ID = bundle["_ctx"]["session_id"]HASH = bundle["_ctx"]["hash"]PROJECT = bundle["_ctx"]["project"]SESSION_NOTE = bundle["_ctx"]["resolved_source_session_note"] (not session_note_name — this is already guarded: it is the note name in the normal case (the target either doesn't exist yet — SessionEnd hasn't written it, this is a forward reference just like the PreCompact snapshot backlink — or exists and agrees), and "" ONLY when the target note exists, parses, and its own session_id frontmatter CONTRADICTS SESSION_ID — that is what stops a source_session_note backlink from pointing at a note that disagrees with the stamped source_session (#330))Important: If SESSION_ID is unknown, use unknown for source_session and omit source_session_note entirely. Also omit source_session_note whenever SESSION_NOTE is empty (""), even when SESSION_ID is known — that means the guard above found a genuine contradiction and rejected the link (omit this line entirely when the resolved note is empty; do not write source_session_note: "").
Present the full note to the user including frontmatter:
---
type: claude-retro
date: YYYY-MM-DD
created_at: <ISO-8601-UTC>
source_session: <current-session-id>
source_session_note: "[[<session-note-filename>]]"
project: <project-name>
tags:
- claude/retro
- claude/project/<project-name>
---
# Session Retrospective: <project-name> (<date>)
## Evidence Consulted
...
## What Went Well
...
## What Didn't Work
...
## Key Learnings
...
## Process Improvements
...
Where:
YYYY-MM-DD is today's date<ISO-8601-UTC> is the current UTC timestamp at second precision. Get it via:
python3 -c 'from datetime import datetime, timezone; print(datetime.now(timezone.utc).isoformat(timespec="seconds"))'
Example: 2026-04-24T18:42:11+00:00<current-session-id> and <session-note-filename> are derived from Step 5<project-name> is the PROJECT value from Step 5 (the canonical project name: the main repo's name, also inside a git worktree)source_session_note field creates an Obsidian backlink from the retro to its source sessionAsk the user:
Preview above. Would you like to:
- save as-is
- edit content — tell me what to change
- cancel — discard this note
Wait for the user's response. Apply any requested edits and show the updated preview. Repeat until the user says save or cancel.
Discovery errors. If bundle["discovery_errors"] is non-empty, after the preview but before the save/edit/cancel prompt, emit:
⚠️ file(s) could not be read during evidence discovery:
<basename>:The retro proceeds with the readable evidence.
Each bundle["discovery_errors"] entry has the form "<filename>: <exception>". Split on the first : to separate <basename> from <reason> for the bullet rendering. This is informational only and does not block save.
If cancel, stop here.
Construct the filename:
YYYY-MM-DD (today)retro (fixed — no title slug needed for retrospectives)date +%s | md5 | cut -c1-4date +%s | md5sum | cut -c1-4Final filename: YYYY-MM-DD-retro-<hash>.md
Example: 2026-04-05-retro-a3f2.md
First write the full note (frontmatter + body) with the Write tool to <WORK>/retro-note-<draft-id>.md (<WORK> from Step 1). <draft-id> is 8 random hex characters you pick once per run and reuse in Step 7.5, so two retros started in the same second are very unlikely to share a draft file. Call that path <BODY_FILE>. Then run the note-writer CLI with --body-file. The note text never goes into the Bash command, so a PreToolUse hook that reads command text cannot refuse the save over words the note quotes (#517). note_writer.py creates $INSIGHTS_FOLDER if needed and writes the note atomically at mode 0o600; no mkdir/chmod needed. The HOOKS= line below checks the marketplace-registered directory-source install location FIRST (#278 — on a local checkout that is what loads, not the released cache), and only falls back to the plugin cache, where it sorts versions numerically (a plain max() is lexicographic and picks 3.9.0 over 3.10.0, resolving to a cache with no note_writer.py); the test -f line turns a stale/incomplete cache into the documented ERROR: shape instead of a raw Python can't open file message:
cd '<REPO_ROOT>'
HOOKS=$(python3 -c "
import glob, json, os, re
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser('~/.claude/plugins/known_marketplaces.json'))).values():
_s = _m.get('source') if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get('source') == 'directory'):
continue
_i = _m.get('installLocation') if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, 'hooks')
if os.path.isfile(os.path.join(_h, 'obsidian_utils.py')):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser('~/.claude/plugins/cache/*/obsidian-brain/*/hooks')) if re.fullmatch('[0-9]+([.][0-9]+)*', _d.split('/')[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split('/')[-2].split('.')], _p), default='hooks')
print(_ob_hooks())
")
if ! test -f "$HOOKS/note_writer.py"; then echo "ERROR: note_writer.py not found under $HOOKS - resolution checks the marketplace registered install location first, then falls back to the plugin cache; neither path produced a hooks directory containing it. Verify the obsidian-brain install resolved at $HOOKS is complete (git pull for a directory-source checkout, or run /plugin marketplace update for a cache install), then retry." >&2; exit 1; fi
python3 "$HOOKS/note_writer.py" write "$VAULT_PATH" "$INSIGHTS_FOLDER" "YYYY-MM-DD-retro-<hash>.md" --body-file '<BODY_FILE>'
On success this prints OK: <absolute path>. Keep that absolute path exactly as printed; the steps below call it <NOTE_PATH>. Shell variables do not survive between Bash calls, so wherever <NOTE_PATH> appears, paste the literal path in its place. It always sits inside single quotes, so the shell does not expand a $ or backtick in it; if the path itself contains a ', write each one as '\''. Step 8 confirms against it, not against a path rebuilt from config. After an OK: line, run rm -f '<BODY_FILE>' (the literal path). On failure it prints ERROR: <reason> to stderr and exits non-zero; surface that message to the user, keep <BODY_FILE> and tell the user its path so the note text is not lost, and stop here (do not proceed to arming the classification gate below on a failed write).
If the error is note already exists, the 4-hex filename hash collided with a note written in the same second. Regenerate the hash (Step 7's command), rebuild the filename, and retry the write once. If it fails again for any reason, surface the error and stop — do not loop.
Arm the classification gate. Immediately after writing the note, mark classification as pending. This arms the obsidian_retro_gate.py Stop hook, which blocks the turn from ending until Step 7.5 clears the gate — so classification can no longer be silently skipped:
cd '<REPO_ROOT>'
python3 -c '
import sys, os, glob
import glob, json, os, re, sys
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser("~/.claude/plugins/known_marketplaces.json"))).values():
_s = _m.get("source") if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get("source") == "directory"):
continue
_i = _m.get("installLocation") if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, "hooks")
if os.path.isfile(os.path.join(_h, "obsidian_utils.py")):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser("~/.claude/plugins/cache/*/obsidian-brain/*/hooks")) if re.fullmatch("[0-9]+([.][0-9]+)*", _d.split("/")[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split("/")[-2].split(".")], _p), default="hooks")
sys.path.insert(0, _ob_hooks())
from obsidian_utils import mark_retro_classification_pending
print(mark_retro_classification_pending(sys.argv[1], sys.argv[2]))
' "<current-session-id>" '<NOTE_PATH>'
(<current-session-id> is the value derived in Step 5. <NOTE_PATH> is the path from the OK: line above. The gate is keyed on the session id and fails open on an unusable id: if session_id is empty or "unknown" the gate stays inactive — never blocking the session.)
Check the printed output before continuing. If it starts with Failed:, the gate did NOT arm — print that line to the user in the transcript so the refusal is visible (do not let it scroll past silently). Treat Step 7.5 below as unenforced but still mandatory: nothing will block the turn from ending if you skip it, so you must not skip it anyway. Do not print a "saved" confirmation that implies the classification step is enforced when it is not.
The retro is not done when the file is written. The literal next action after arming the classification gate is to act on what the retro surfaced — do not print the "saved" confirmation until this step is complete. If Step 7's gate armed successfully (the printed output did not start with Failed:), it is a Stop-hook gate that blocks the turn from ending until you clear it here, so this is enforced, not merely advised. If Step 7's gate failed to arm, there is nothing blocking the turn — treat this step as unenforced but still mandatory, per Step 7's own instruction.
cd '<REPO_ROOT>'
HOOKS=$(python3 -c "
import glob, json, os, re
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser('~/.claude/plugins/known_marketplaces.json'))).values():
_s = _m.get('source') if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get('source') == 'directory'):
continue
_i = _m.get('installLocation') if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, 'hooks')
if os.path.isfile(os.path.join(_h, 'obsidian_utils.py')):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser('~/.claude/plugins/cache/*/obsidian-brain/*/hooks')) if re.fullmatch('[0-9]+([.][0-9]+)*', _d.split('/')[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split('/')[-2].split('.')], _p), default='hooks')
print(_ob_hooks())
")
if ! test -f "$HOOKS/retro_trace.py"; then echo "ERROR: retro_trace.py not found under $HOOKS - verify the obsidian-brain install resolved there is complete (git pull for a directory-source checkout, or /plugin marketplace update for a cache install), then retry." >&2; exit 1; fi
python3 "$HOOKS/retro_trace.py" items '<NOTE_PATH>'
It prints one JSON object per item: item (the number), line, checked, text and trace (null until traced). Only - [ ]/- [x] lines in ## Process Improvements are items; Key Learnings are classified below but carry no trace.
2. Classify each item into exactly one bucket:
gh issue create, sub-classified by target repo); otherwise record it wherever the project tracks TODOs.MEMORY.md), add or extend an entry there — prefer an ## Update (date) section on an existing entry over a duplicate; otherwise capture it as a vault insight with /compress.Confirm via an in-turn tool, then file. Surface the proposed classification (each item → bucket → target) and get the user's go-ahead using AskUserQuestion — do not end your turn to ask, because the Step 7 gate will block a turn-end before classification is done. In a non-interactive / auto-run context, file the clear-cut items directly and surface only judgment calls (which repo, which priority) for a one-line confirm; never skip tracking. After filing 2 or more issues, run /github-board:triage-issues (when available) for labels/priority. An item the user declines is still an outcome: it gets the trace skipped: user declined in step 4.
Write each item's tracking back into the note (#470). Build one JSON entry per Process Improvements item whose trace is null:
{"item": N, "kind": "issue", "ref": "owner/repo#123"} (owner, repo and number from the URL gh issue create printed). The item stays - [ ] and the ref goes into the note's tracked_issues frontmatter, so /check-items can offer the tick once the issue closes;{"item": N, "kind": "memory", "stem": "<memory file name without .md>", "note": "new"} (or "note": "Update YYYY-MM-DD" for an ## Update section);{"item": N, "kind": "path", "path": "<path you edited>"};{"item": N, "kind": "skipped", "reason": "<why, citing the artifact>"}.Write {"traces": [...]} with the Write tool to <WORK>/retro-traces-<draft-id>.json (the same <draft-id> as Step 7). Call that path <TRACES_FILE>. Then pass it to apply with --traces-file, so no JSON goes into the Bash command. The file holds one JSON object, for example {"traces": [{"item": 1, "kind": "skipped", "reason": "<why>"}]}:
cd '<REPO_ROOT>'
HOOKS=$(python3 -c "
import glob, json, os, re
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser('~/.claude/plugins/known_marketplaces.json'))).values():
_s = _m.get('source') if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get('source') == 'directory'):
continue
_i = _m.get('installLocation') if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, 'hooks')
if os.path.isfile(os.path.join(_h, 'obsidian_utils.py')):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser('~/.claude/plugins/cache/*/obsidian-brain/*/hooks')) if re.fullmatch('[0-9]+([.][0-9]+)*', _d.split('/')[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split('/')[-2].split('.')], _p), default='hooks')
print(_ob_hooks())
")
if ! test -f "$HOOKS/retro_trace.py"; then echo "ERROR: retro_trace.py not found under $HOOKS - verify the obsidian-brain install resolved there is complete (git pull for a directory-source checkout, or /plugin marketplace update for a cache install), then retry." >&2; exit 1; fi
python3 "$HOOKS/retro_trace.py" apply "$VAULT_PATH" '<NOTE_PATH>' --traces-file '<TRACES_FILE>'
apply checks every entry before it writes anything. Exit 0 prints {"written": true, "untraced": 0, "tracked_issues": [...]}. After exit 0, run rm -f '<TRACES_FILE>'. The note now carries → <trace> on each item, and every item except an issue is ticked - [x]. Exit 2 means an entry was refused (a missing or extra item, an item that already has a trace, a bad ref, or a newline, → or backtick in a value). The note is unchanged; fix the JSON in <TRACES_FILE> from the stderr message (Write tool) and run it again. A traces file that is missing or unreadable is also exit 2, with nothing written. Exit 1 means the note could not be read or written, or was locked or changed on disk. Run it once more. If it fails again, check the note path from Step 7's OK: line and stop: treat it as a cancel and write nothing else.
Cancel is not decline. If the user cancels classification, or apply keeps failing, write nothing: the note stays exactly as Step 7 wrote it and the gate stays armed. The Stop hook then blocks once and clears itself on the re-entry. Never invent a trace to get past the gate.
5. Clear the gate. Once every item is filed and traced (step 4) — or there were no Process Improvements items — clear the gate so the turn can end:
cd '<REPO_ROOT>'
python3 -c '
import sys, os, glob
import glob, json, os, re, sys
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser("~/.claude/plugins/known_marketplaces.json"))).values():
_s = _m.get("source") if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get("source") == "directory"):
continue
_i = _m.get("installLocation") if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, "hooks")
if os.path.isfile(os.path.join(_h, "obsidian_utils.py")):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser("~/.claude/plugins/cache/*/obsidian-brain/*/hooks")) if re.fullmatch("[0-9]+([.][0-9]+)*", _d.split("/")[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split("/")[-2].split(".")], _p), default="hooks")
sys.path.insert(0, _ob_hooks())
from obsidian_utils import clear_retro_classification_pending, retro_gate_untraced
untraced = retro_gate_untraced(sys.argv[1])
if clear_retro_classification_pending(sys.argv[1]):
print("cleared")
elif untraced:
print(f"blocked: {untraced} Process Improvements item(s) have no trace")
else:
print("no-gate")
' "<current-session-id>"
blocked: N ... means step 4 has not traced every item. Run items again, trace the rest, and clear again. The gate does not clear while any item has no trace.
6. Only after the gate is cleared and the filed actions are reflected in the user-facing summary do you proceed to Step 8.
Hard-fail signal: if you are about to print "Retrospective saved!" with the gate still armed, you have skipped this step. The Stop hook will catch it — but classify proactively rather than relying on the block.
Step 7.5 has cleared the gate, so the note is final. Start the lesson update for it in the background. It never asks, never waits and never checks the result: the update judges the new items with Haiku (about 7 seconds each) and rewrites the lesson notes that changed. A held lock makes the background run exit 1 into the log, never block /retro. Replace <NOTE_PATH> with the path from Step 7:
cd '<REPO_ROOT>'
HOOKS=$(python3 -c "
import glob, json, os, re
def _ob_hooks():
try:
for _m in json.load(open(os.path.expanduser('~/.claude/plugins/known_marketplaces.json'))).values():
_s = _m.get('source') if isinstance(_m, dict) else None
if not (isinstance(_s, dict) and _s.get('source') == 'directory'):
continue
_i = _m.get('installLocation') if isinstance(_m, dict) else None
if not (isinstance(_i, str) and os.path.isabs(_i)):
continue
_h = os.path.join(_i, 'hooks')
if os.path.isfile(os.path.join(_h, 'obsidian_utils.py')):
return _h
except Exception:
pass
_c = [_d for _d in glob.glob(os.path.expanduser('~/.claude/plugins/cache/*/obsidian-brain/*/hooks')) if re.fullmatch('[0-9]+([.][0-9]+)*', _d.split('/')[-2])]
return max(_c, key=lambda _p: ([int(_n) for _n in _p.split('/')[-2].split('.')], _p), default='hooks')
print(_ob_hooks())
")
if ! test -f "$HOOKS/retro_rollup.py"; then echo "lesson update skipped: retro_rollup.py not found under $HOOKS"; exit 0; fi
mkdir -p -m 700 "$HOME/.claude/obsidian-brain"
LESSONS=$(python3 -c '
import json, os
c = json.load(open(os.path.expanduser("~/.claude/obsidian-brain-config.json")))
print("off" if c.get("lessons_enabled") is False else "on")
' < /dev/null 2>/dev/null)
if [ "$LESSONS" != "off" ]; then
nohup python3 "$HOOKS/retro_rollup.py" update --note '<NOTE_PATH>' --concurrency 2 < /dev/null >> "$HOME/.claude/obsidian-brain/lessons-update.log" 2>&1 &
echo "lesson update queued"
fi
Print the one line it prints (lesson update queued) and go to Step 8. When lessons_enabled is false it prints nothing: skip silently.
First prove the note exists. Run this in the main session, replacing <NOTE_PATH> with the literal path note_writer.py printed after OK: in Step 7:
ls -l '<NOTE_PATH>'
If ls fails, or Step 7 never printed an OK: line, the note was not saved. Say so, show the error, and do not print the confirmation below. Never print "saved" without this check.
Otherwise print:
Retrospective saved!
- File:
<NOTE_PATH>(the path from note_writer'sOK:line)- Exists:
<the ls -l output line>- Tags:
claude/retro,claude/project/<name>- Filed from Process Improvements / Key Learnings:
<N>GH issue(s),<M>memory entr(ies) (or "none — no actionable items")- Traced:
<T>of<T>Process Improvements item(s) (fromapply'suntraced: 0)- Open in Obsidian to review and track process improvements over time.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub abhattacherjee/obsidian-brain --plugin obsidian-brain21 skills in this plugin
/check-itemsTriage open `- [ ]` items across your Obsidian vault with evidence-grounded AI classification. Auto-closes items shipped by merged PRs, surfaces items needing external action (e.g. `gh issue close`), hides stale items by default. Replaces the old token-overlap heuristic with a two-pass AI pipeline backed by a persistence cache. Use when: (1) sweeping a project for done work, (2) auditing what's still actionable, (3) recovering from /recall deferral fatigue./compressInteractively saves curated insights from the current Claude Code session to the Obsidian vault. Use when: (1) /compress command to save session insights, (2) /compress <topic> to extract a specific topic, (3) user wants to capture decisions, patterns, solutions, or error fixes from the current session./