# senapati484/claude-recall architecture

> Architecture diagram of the GitHub repository senapati484/claude-recall, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/senapati484/claude-recall
- Repository: https://github.com/senapati484/claude-recall

## Overview

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: [`scripts/load_context.py`](https://github.com/senapati484/claude-recall/blob/main/scripts/load_context.py) (Load context), [`scripts/save_context.py`](https://github.com/senapati484/claude-recall/blob/main/scripts/save_context.py) (Save context), [`scripts/utils.py`](https://github.com/senapati484/claude-recall/blob/main/scripts/utils.py) (Shared utils), [`install.sh`](https://github.com/senapati484/claude-recall/blob/main/install.sh) (Installer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_claude_code(("Claude Code<br/>runtime"))
  node_local_config[("Claude config<br/>local state")]
end

subgraph group_hooks["Hook scripts"]
  node_load_context["Load context<br/>hook<br/>[load_context.py]"]
  node_save_context["Save context<br/>hook<br/>[save_context.py]"]
  node_recall_update["Recall update<br/>hook helper<br/>[recall_update.py]"]
  node_utils["Shared utils<br/>support<br/>[utils.py]"]
end

subgraph group_storage["Vault storage"]
  node_vault_root[("Vault folder<br/>obsidian storage")]
  node_project_context["Project context<br/>manual memory"]
  node_project_sessions["Session logs<br/>generated history"]
  node_project_index["Project index<br/>aggregate index"]
  node_project_slug{{"Project slug<br/>routing key"}}
end

subgraph group_setup["Setup & docs"]
  node_install_sh["Installer<br/>bootstrap<br/>[install.sh]"]
  node_skill_md["Skill spec<br/>integration doc<br/>[SKILL.md]"]
  node_hook_api["Hook API<br/>protocol doc<br/>[hook-api.md]"]
  node_context_guide["Context guide<br/>format doc"]
  node_readme["README<br/>overview doc<br/>[README.md]"]
end

node_claude_code -->|"prompt start"| node_load_context
node_claude_code -->|"session end"| node_save_context
node_claude_code -->|"uses settings"| node_local_config
node_install_sh -->|"writes config"| node_local_config
node_install_sh -->|"creates skeleton"| node_vault_root
node_load_context -->|"shared logic"| node_utils
node_save_context -->|"shared logic"| node_utils
node_recall_update -->|"shared logic"| node_utils
node_utils -->|"derive slug"| node_project_slug
node_project_slug -->|"routes to"| node_project_context
node_project_slug -->|"routes to"| node_project_sessions
node_project_slug -->|"routes to"| node_project_index
node_load_context -->|"reads"| node_project_context
node_load_context -->|"reads recent"| node_project_sessions
node_load_context -->|"injects context"| node_claude_code
node_save_context -->|"writes note"| node_project_sessions
node_save_context -->|"updates index"| node_project_index
node_project_context -->|"stored in"| node_vault_root
node_project_sessions -->|"stored in"| node_vault_root
node_project_index -->|"stored in"| node_vault_root
node_hook_api -->|"contract"| node_load_context
node_hook_api -->|"contract"| node_save_context
node_context_guide -->|"formats"| node_project_context
node_context_guide -->|"formats"| node_project_sessions
node_skill_md -->|"integration"| node_claude_code
node_readme -->|"documents"| node_install_sh

click node_load_context "https://github.com/senapati484/claude-recall/blob/main/scripts/load_context.py"
click node_save_context "https://github.com/senapati484/claude-recall/blob/main/scripts/save_context.py"
click node_recall_update "https://github.com/senapati484/claude-recall/blob/main/scripts/recall_update.py"
click node_utils "https://github.com/senapati484/claude-recall/blob/main/scripts/utils.py"
click node_install_sh "https://github.com/senapati484/claude-recall/blob/main/install.sh"
click node_skill_md "https://github.com/senapati484/claude-recall/blob/main/SKILL.md"
click node_hook_api "https://github.com/senapati484/claude-recall/blob/main/references/hook-api.md"
click node_context_guide "https://github.com/senapati484/claude-recall/blob/main/references/context-structure.md"
click node_readme "https://github.com/senapati484/claude-recall/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_claude_code,node_local_config toneBlue
class node_load_context,node_save_context,node_recall_update,node_utils toneAmber
class node_vault_root,node_project_context,node_project_sessions,node_project_index,node_project_slug toneMint
class node_install_sh,node_skill_md,node_hook_api,node_context_guide,node_readme toneRose
```

## Components

### Runtime

Claude Code execution boundary

- **Claude Code**: runtime · Invokes hooks with session JSON
- **Claude config**: local state · ~/.claude settings and recall config

### Hook scripts

CLI entrypoints and shared logic

- [Load context](https://github.com/senapati484/claude-recall/blob/main/scripts/load_context.py): hook · Reads vault context for prompt start · `scripts/load_context.py`
- [Save context](https://github.com/senapati484/claude-recall/blob/main/scripts/save_context.py): hook · Writes session notes at stop · `scripts/save_context.py`
- [Recall update](https://github.com/senapati484/claude-recall/blob/main/scripts/recall_update.py): hook helper · Auxiliary update flow · `scripts/recall_update.py`
- [Shared utils](https://github.com/senapati484/claude-recall/blob/main/scripts/utils.py): support · Config, slug, path, and text helpers · `scripts/utils.py`

### Vault storage

Obsidian-backed project memory

- **Vault folder**: obsidian storage · <vault>/claude-recall/ project store
- **Project context**: manual memory · projects/<slug>/context.md
- **Session logs**: generated history · projects/<slug>/sessions/*.md
- **Project index**: aggregate index · projects/<slug>/_index.md
- **Project slug**: routing key · Derived from working directory

### Setup & docs

Install path and protocol references

- [Installer](https://github.com/senapati484/claude-recall/blob/main/install.sh): bootstrap · Installs repo and registers hooks · `install.sh`
- [Skill spec](https://github.com/senapati484/claude-recall/blob/main/SKILL.md): integration doc · Claude skill metadata and instructions · `SKILL.md`
- [Hook API](https://github.com/senapati484/claude-recall/blob/main/references/hook-api.md): protocol doc · Structured stdin/stdout contract · `references/hook-api.md`
- [Context guide](https://github.com/senapati484/claude-recall/blob/main/references/context-structure.md): format doc · Vault layout and note structure · `references/context-structure.md`
- [README](https://github.com/senapati484/claude-recall/blob/main/README.md): overview doc · Repository usage and behavior · `README.md`

## Connections

- 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
