How senapati484/claude-recall works
1. What this repo is
- claude-recall is a local integration layer between Claude Code and an Obsidian vault.
- It is not a web service; it is a CLI hook-based utility that runs on the user’s machine and persists memory across Claude sessions.
2. Primary runtime boundary
- The repo is installed into ~/.claude/skills/claude-recall/ and configured through ~/.claude/settings.json.
- Runtime state lives outside the repo in two places:
- ~/.claude/claude-recall.json for configuration
- the user’s Obsidian vault for stored context and session notes
3. Main execution paths
- There are two hook-driven flows:
- Session start / first prompt: scripts/load_context.py
- Session end / stop: scripts/save_context.py
- These scripts are the core architecture: one reads from Obsidian and injects context, the other writes session history back.
4. Claude Code integration model
- Claude Code invokes the hooks with structured JSON input through stdin, per the hook contract documented in references/hook-api.md.
- The load hook feeds context into Claude’s prompt/system context.
- The save hook consumes session metadata and transcript information to produce a Markdown note.
5. Obsidian vault data model
- The vault contains a dedicated folder, defaulting to <vault>/claude-recall/.
- Per project, the layout is:
- projects/<slug>/context.md for durable human-edited memory
- projects/<slug>/sessions/*.md for auto-generated session logs
- _index.md as an aggregate project index
- This separation is important: manual knowledge vs. generated history.
6. Project identity and routing
- The active project is derived from the current working directory using slug logic in scripts/utils.py.
- That slug determines which vault subfolder is loaded/saved.
- This is the key routing mechanism that maps a Claude working directory to an Obsidian project record.
7. Context-loading pipeline
- load_context.py pulls together:
- the project’s context.md
- a configurable number of recent session notes
- It applies a token budget (max_context_tokens) and optional behavior such as load_on_every_prompt.
- The output is meant for Claude consumption, so this path is optimized for context injection, not persistence.
8. Session-saving pipeline
- save_context.py reads the session transcript and extracts session metadata such as:
- first prompt
- files mentioned
- session statistics
- timestamped note content
- It writes a dated Markdown file into the project’s sessions/ folder and may update the project index.
- This path is the persistence boundary from transient chat history into durable documentation.
9. Shared support layer
- scripts/utils.py holds cross-cutting logic used by both hooks:
- config loading
- path/slug helpers
- truncation/token budgeting
- common Markdown or file utilities
- This keeps the hook scripts thin and makes their behavior consistent.
10. Installer and bootstrap
- install.sh is the deployment entrypoint.
- It:
- asks for the vault path
- writes ~/.claude/claude-recall.json
- clones/updates the repo under ~/.claude/skills/claude-recall/
- registers both hooks in Claude Code settings
- creates the vault folder skeleton
- Architecture-wise, this is the only place that mutates Claude’s local config.
11. Documentation and protocol references
- references/hook-api.md defines the hook I/O contract that the scripts must satisfy.
- references/context-structure.md defines the note formats and vault layout.
- SKILL.md packages the skill instructions/metadata for Claude Code.
- These files are part of the integration boundary, not the runtime data plane.
12. Operational characteristics
- The system is local-only, zero-config after install, and non-invasive to the project repo.
- It depends on:
- Python 3.8+
- Claude Code hooks
- Obsidian vault files on disk
- No external network service is required during normal operation; persistence is file-based.
13. Useful diagram split
- For an architecture diagram, separate the system into:
- Claude Code runtime
- claude-recall hook scripts
- local Claude config
- Obsidian vault storage
- Then show the two flows:
- prompt start → load context → inject into Claude
- session stop → parse transcript → write Markdown notes
Main entry points: load_context.py Load context · save_context.py Save context · utils.py Shared utils · install.sh Installer
Components 16
Runtime
Claude Code execution boundary
- Claude Code · Invokes hooks with session JSON
- Claude config · ~/.claude settings and recall config
Hook scripts
CLI entrypoints and shared logic
- Load context · Reads vault context for prompt start
scripts/load_context.py - Save context · Writes session notes at stop
scripts/save_context.py - Recall update · Auxiliary update flow
scripts/recall_update.py - Shared utils · Config, slug, path, and text helpers
scripts/utils.py
Vault storage
Obsidian-backed project memory
- Vault folder · <vault>/claude-recall/ project store
- Project context · projects/<slug>/context.md
- Session logs · projects/<slug>/sessions/*.md
- Project index · projects/<slug>/_index.md
- Project slug · Derived from working directory
Setup & docs
Install path and protocol references
- Installer · Installs repo and registers hooks
install.sh - Skill spec · Claude skill metadata and instructions
SKILL.md - Hook API · Structured stdin/stdout contract
references/hook-api.md - Context guide · Vault layout and note structure
references/context-structure.md - README · Repository usage and behavior
README.md
Connections 26
- Claude Code → Load context: prompt start · Claude Code calls the load hook at session start
- Claude Code → Save context: session end · Claude Code calls the save hook when stopping
- Claude Code → Claude config: uses settings · Hooks and vault path are configured in local Claude files
- Installer → Claude config: writes config · Installer creates ~/.claude/claude-recall.json and registers hooks
- Installer → Vault folder: creates skeleton · Installer prepares the vault folder structure
- Load context → Shared utils: shared logic · Load path depends on common helpers
- Save context → Shared utils: shared logic · Save path depends on common helpers
- Recall update → Shared utils: shared logic · Auxiliary update flow uses the same support layer
- Shared utils → Project slug: derive slug · Maps current working directory to a project key
- Project slug → Project context: routes to · Slug selects the project memory folder
- Project slug → Session logs: routes to · Slug selects the session log folder
- Project slug → Project index: routes to · Slug selects the per-project index
- Load context → Project context: reads · Loads durable manual context for the current project
- Load context → Session logs: reads recent · Pulls recent session notes into prompt context
- Load context → Claude Code: injects context · Produces prompt-ready context for Claude consumption
- Save context → Session logs: writes note · Persists a dated Markdown session log
- Save context → Project index: updates index · May refresh the project summary index
- Project context → Vault folder: stored in · Project memory lives inside the vault folder
- Session logs → Vault folder: stored in · Generated session logs live inside the vault folder
- Project index → Vault folder: stored in · Aggregate index lives inside the vault folder
- Hook API → Load context: contract · Defines hook input/output expectations
- Hook API → Save context: contract · Defines hook input/output expectations
- Context guide → Project context: formats · Defines note structure and vault layout
- Context guide → Session logs: formats · Defines note structure and vault layout
- Skill spec → Claude Code: integration · Packages the skill for Claude Code
- README → Installer: documents · Explains installation and usage