/learning-loop:reflectfrom learning-loop
End-of-session consolidation skill that reviews conversations, extracts learnings, and routes them to auto-memory or vault stores. Run after substantial work sessions.
Ships in learning-loop. 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.
Read when SKILL.md points to them.
Structured checkpoint that extracts what was learned in this session and persists it to the right stores. This is how the learning loop closes: without this step, knowledge captured during the session rots.
This skill emits provenance events for pipeline observability. Run each Bash command silently.
At session start:
ll-run provenance-emit.js '{"agent":"reflect","skill":"reflect","action":"session-start"}'
The session-end emit runs in Step 6, coalesced with the completion marker stamp (one final Bash block instead of two).
The PostToolUse hook handles both provenance emission and the per-write tracking that Step 4.6 (Upstream Refinement) consumes. Step 4 only needs to create the new-notes marker once; the hook appends every vault Write/Edit to it until Step 4.6.g removes the marker.
Work through these steps in order. Be concise throughout: the vault voice is Hemingway, not Tolstoy.
Silently review the conversation. Identify:
If the session was purely routine (config change, typo fix, quick lookup), say so and skip to Step 5. Not every session produces learnings.
Identify what was learned. Categories:
| Category | Example | Destination | Confidence |
|---|---|---|---|
| Correction received | "Don't mock the DB in these tests" | Auto-memory (feedback) | strong |
| Preference revealed | "I prefer X approach over Y" | Auto-memory (user/feedback) | strong |
| Decision made | "We chose Postgres over SQLite because..." | Obsidian vault | - |
| Problem solved | "The build failed because X, fixed by Y" | Obsidian vault | - |
| Pattern discovered | "This pagination pattern works across projects" | Obsidian vault | - |
| Domain insight | "Resto Druid HoT uptime benchmarks are..." | Obsidian vault | - |
| Project context | "Auth rewrite is driven by compliance, not tech debt" | Auto-memory (project) | medium |
| Cross-project connection | "Same caching problem exists in Acme and Widget-Co" | Obsidian vault + links | - |
| Implicit pattern | User always runs tests before committing (observed 3+ times, never stated) | Auto-memory (feedback) | weak |
List each learning as a single line. When a learning could fit more than one row, the table's one-destination-per-row is the default, not a hard partition; apply the Route-correctly test (Key Principles) to decide.
Before finalizing, explicitly check the three categories that hide in a fast pass: corrections received mid-session, project-context shifts, and behavior repeated 3+ times but never stated. State present or absent for each. Do NOT invent a weak pattern to fill a slot; "absent" is valid and common.
If any subagent (note-writer, discovery-researcher, literature-capturer) wrote vault notes earlier in this session, the search index may not cover them yet, so the dedup below would miss them. Refresh the index first (incremental; embeds only new or mtime-changed notes):
ll-run vault-search.mjs index
Skip this index refresh if no subagent wrote notes this session (a pure-conversation session). It is also re-run in Step 4.4 after this step's own writes; both passes are incremental and cheap.
Run a single retrieval call for all learnings identified in Step 2. Pass each learning summary as a query:
ll-run vault-search.mjs reflect-scan "learning 1 summary" "learning 2 summary" ... --top 5
MUST use the vault-search.mjs wrapper, not bare ll-search reflect-scan. The wrapper prepends DB_PATH and --config-dir from plugin config; if you call the raw binary, always pass the db path explicitly — a missing DB arg silently corrupts results.
The Step 2.5 reflect-scan and the Step 2.75 episodic search are independent — you MAY issue both in the same turn. Only Step 2.5's output is required before Step 3.
Parse the JSON result. For each query:
top_match_similarity > 0.90: likely duplicate. Read the existing note and update it instead of creating a new one.top_match_similarity 0.70-0.90: related note exists. Consider linking rather than duplicating.top_match_similarity < 0.70: no existing coverage. Create a new note.Review confusable_pairs in the result. If any pairs are found, flag them for the user as potential MERGE or SHARPEN candidates in the Step 5 report.
If the episodic memory MCP tool is available (mcp__plugin_episodic-memory_episodic-memory__search), run one search for the session's primary topic/domain. Extract any relevant prior decisions or unresolved questions. If unavailable, skip silently.
Using the reflect-scan results from Step 2.5:
top_match_similarity > 0.90, read the matched note. If the existing note already captures the insight, skip creating a new one.For auto-memory items:
confidence in frontmatter based on signal strength:
strong: user explicitly stated the preference or correction ("I always want...", "Don't ever...", "No, do it this way")medium: user corrected your output (changed X to Y, rejected an approach) or provided project contextweak: pattern inferred from repeated behavior (observed 3+ times but never explicitly stated by user)medium throughout the systemFor Obsidian vault items:
{{VAULT}}/0-inbox/ using the Write tool4-projects/ if one existsreflect_sid: <SESSION_ID> in the frontmatter of every note you write this session (get the value from ll-paths SESSION_ID, the canonical resolver; the post-tool hook keys this session's marker on the same id). The Step 4.4 sweep uses it to recover sub-agent notes (PostToolUse hooks don't fire on sub-agent writes); the Step 4.6.g cleanup strips it once tracking is done.hooks/modules/reflect-track.mjs) appends every vault Write/Edit's absolute path to that file. Do not echo paths in by hand — the hook is the single writer. The marker lives in plugin-data, not tmp: get its path stem from ll-paths REFLECT_PREFIX (as in the init block below), the same resolver the hook uses, so writer and reader stay in lockstep.# Step 4 init: truncate the new-notes file (the hook handshake marker).
#
# Run this ONCE, before any vault Writes in this step. Do not re-run per
# Write — the post-tool hook does the per-write appends automatically while
# this file exists. Step 4.6.g removes it to end the tracking window.
#
# Every fence runs in its own shell, so 4.4/4.6/4.7 each ask for the prefix
# again. Ask; never rebuild it. REFLECT_PREFIX comes from the same
# DATA_PATHS.reflectPrefix() the hook calls, so writer and reader cannot
# disagree about the dir OR the session key — including across the
# $TMPDIR-split hook/shell boundary, which is why the anchor is plugin-data
# and not tmp.
LL_TMP_PREFIX="$(ll-paths REFLECT_PREFIX)"
mkdir -p "$(dirname "$LL_TMP_PREFIX")"
: > "${LL_TMP_PREFIX}-new-notes.txt"
Sub-agent writes (note-writer, discovery-researcher, literature-capturer) don't fire PostToolUse hooks, so their paths never reach the marker live; Step 4.4's sweep recovers them via the reflect_sid stamp (see that step for the mechanism).
Subagent Write/Edit tool calls bypass PostToolUse hooks. Notes written earlier in this session by note-writer, discovery-researcher, literature-capturer, or any other subagent may have missed the hooks/post-tool.js dispatcher entirely (no suggested backlinks or typed edges), and never reached the reflect new-notes marker (so Step 4.6 refinement would skip them).
Replay the hook chain on two candidate sets, unioned: (1) notes missing structural backlinks (autolink/edge-infer backfill), and (2) every note carrying this session's reflect_sid (the marker backfill — these are the sub-agent notes whose paths the live hook never captured). The replay runs with LL_REFLECT_SID=$SESSION_ID, which routes each replayed Write to this session's marker even under concurrent /reflect runs. Idempotent: safe to run on already-hooked notes (autolink checks for existing links; reflect-track skips a path the marker already holds, so a main-thread note the live hook recorded is not re-appended by the replay).
# This fence runs in its own shell, so re-resolve via --sh. The ll-search shim
# (~/.local/bin/ll-search, installed by /init or the SessionStart hook) handles
# binary location and ORT env vars itself.
VAULT="$(ll-paths VAULT)"
SESSION_ID="$(ll-paths SESSION_ID)"
# Ensure new notes are indexed before the sweep + any downstream similarity queries.
# Incremental by default; only embeds notes that are new or mtime-changed.
ll-search index "$VAULT" "$VAULT/.vault-search/vault-index.db" 2>&1 | tail -1
# Candidate union, then replay, in one node pass (--scan-vault). The walk uses an
# explicit 5-folder ALLOWLIST that excludes 4-projects (free-form indexes), and
# emits each matching note once:
# (1) notes with no [[links]] in the body -> autolink/edge-infer backfill
# (2) notes whose frontmatter reflect_sid == this session's SESSION_ID
# -> marker backfill for sub-agent writes the live hook missed
# LL_REFLECT_SID=$SESSION_ID routes each replayed Write to THIS session's marker
# even under concurrent /reflect runs (see hooks/post-tool.js).
# The walk also strips reflect_sid stamps abandoned by dead /reflect runs; a
# live run's stamps are identified by its marker and left alone.
LL_REFLECT_SID="$SESSION_ID" ll-run sweep-hook-replay.mjs \
--scan-vault "$VAULT" --sid "$SESSION_ID"
The same walk self-heals abandoned reflect_sid stamps. The field is transient — Step 4 writes it, this step reads it, Step 4.6.g strips it — so a run that dies in between leaks it into the vault permanently, since 4.6.g is its only remover. A stamp belonging to another session is stripped when that session's marker file is gone or has sat untouched for six hours; a marker still being written to means that run is live, and its stamps are working state this sweep must not take.
Expected output is a JSON summary {processed, ok, failed, failures, abandonedStripped} (and {processed:0,...} when no candidates). Report failures in Step 5 if any, and abandonedStripped when non-zero. Typical cost: <1s per file, usually 0–5 candidates per session.
After writing new vault captures, scan each new note's body for intention patterns:
If an intention pattern is found, extract to frontmatter:
intentions:
- context: <extracted project/topic>
cue: <the full intention sentence>
status: intentioned
This makes the note reachable by context: ll-run vault-search.mjs intentions "<context>" returns it, and /learning-loop:inbox classifies it as intentioned rather than limbo.
Trigger: either of two conditions fires this step: (1) the reflect new-notes marker created in Step 4 (${LL_TMP_PREFIX}-new-notes.txt) exists and is non-empty, or (2) the deferred refinement queue at $PLUGIN_DATA/refinement-deferred.jsonl is non-empty (overflow pairs parked by a capped /ingest --refine run; this step is their only drain). Check both with one command; refinement.md 4.6.a re-resolves the prefix in its own shell:
PLUGIN_DATA="$(ll-paths PLUGIN_DATA)"
LL_TMP_PREFIX="$(ll-paths REFLECT_PREFIX)"
{ [ -s "${LL_TMP_PREFIX}-new-notes.txt" ] || [ -s "$PLUGIN_DATA/refinement-deferred.jsonl" ]; } && echo RUN || echo SKIP
On RUN, read ${CLAUDE_PLUGIN_ROOT}/skills/reflect/steps/refinement.md and execute it (sub-steps 4.6.a through 4.6.g: candidate pairs + deferred-queue drain, proposer dispatch, validation, confirmation, apply, provenance, cleanup).
On SKIP, skip this entire step: the session wrote no vault notes AND no deferred pairs are queued. A session that wrote nothing still runs this step when the deferred queue is non-empty; otherwise deferred pairs sit indefinitely.
Read ${CLAUDE_PLUGIN_ROOT}/skills/reflect/steps/usage-provenance.md and execute it: list the notes that injection/retrieval surfaced to this session (retrieval-report.mjs --session-surfaced), classify each as used or ignored, and emit one note-usage provenance event per note. Used has two kinds: engaged (read, edited, or linked) and informed (its content reached your output untouched — requires an evidence field naming the claim and where it landed). Surfacing alone — including an injected note body — never counts as used; when unsure, classify as ignored.
Run this step even when Step 4.6 was skipped. Skip it only when nothing was surfaced to the session.
Output a brief summary:
Reflected on [domain/project] session.
Captured: [N items] → [where they went]
Connections: [any cross-project links made]
Merge/Sharpen candidates: [any confusable_pairs flagged, or "none"]
Retrieval usage: [N used / M ignored of K surfaced — omit if nothing surfaced]
Keep it to 2-4 lines. The user can see the diffs if they want details.
Emit the session-end provenance event and write the completion timestamp in one final block. Substitute the real counts for the Ns (vault notes written, auto-memories written this session). Alongside those, include the common outcome shape: items_in (vault notes surfaced this session), items_out (vault_notes plus auto_memories written), items_flagged (0, reflect has no flagging concept), duration_ms. Emit first, stamp last:
ll-run provenance-emit.js '{"agent":"reflect","skill":"reflect","action":"session-end","vault_notes":N,"auto_memories":N,"items_in":N,"items_out":N,"items_flagged":0,"duration_ms":N}'
ll-run marker.mjs stamp last-reflect
Run this at the end of every /reflect invocation, unconditionally — both lines always run, regardless of whether any notes were written or surfaced. The last-reflect marker is what tells the Stop hook reflection already happened; it lives in plugin-data (not tmp) so the Stop hook — which does not inherit this shell's $TMPDIR — reads the same file this command wrote. A non-zero exit on either line is non-fatal: surface the stderr message but do not re-run /reflect.
| Agent | Where | Role |
|---|---|---|
| refinement-proposer | Step 4.6.b (conditional: only when the session wrote new vault notes) | Classifies new-note → upstream-note pairs and proposes refinement edits |
Retrieval itself stays main-thread: it is handled by the reflect-scan binary command, not a subagent.
0-inbox/ without permission.What SKILL.md sets; muted values are Claude Code's defaults
24 skills in this plugin
/deepenStrengthen a single vault note with research. Usage: /learning-loop:deepen "note name" or /learning-loop:deepen (picks shallowest inbox note). Assesses maturity, researches gaps, rewrites in vault voice, promotes when ready./diagramGenerate an Excalidraw diagram for the vault. Usage: /learning-loop:diagram "concept or mechanism" or /learning-loop:diagram (infers from context). Produces .excalidraw.md in vault Excalidraw/ folder./discoveryExplore a topic interactively with web research and vault context. Usage: /learning-loop:discovery "topic" [--style guided|branch|checkpoint] [--tone academic|conversational|persona] [--surf]. --surf skips note creation.npx claudepluginhub robinslange/learning-loop --plugin learning-loopOther plugins' skills for the same job