[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-925":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":35,"readmeContent":36,"aiSummary":37,"trendingCount":16,"starSnapshotCount":16,"syncStatus":38,"lastSyncTime":39,"discoverSource":40},925,"claude-code-memory-setup","lucasrosati\u002Fclaude-code-memory-setup","lucasrosati","Up to 71.5x fewer tokens per session on Claude Code with Obsidian + Graphify. Persistent memory, codebase knowledge graphs, and chat import pipeline. 🇧🇷 PT-BR included.","",null,"Python",757,64,5,1,0,12,139,65.44,"MIT License",false,"main",true,[25,26,27,28,29,30,31,32,33,34],"ai-tools","claude-code","coding-agent","developer-productivity","graphify","knowledge-graph","obsidian","second-brain","token-optimization","zettelkasten","2026-06-11 04:00:34","# Claude Code + Obsidian + Graphify: The Definitive Guide to Token Savings & Persistent Memory\n\n> **71.5x fewer tokens per session** with Graphify + **permanent memory across sessions** with Obsidian Zettelkasten.\n\nA complete setup to turn Claude Code into an agent with long-term memory and full codebase awareness — without wasting tokens re-reading files.\n\n🇧🇷 [Leia em Português](.\u002FREADME.pt-BR.md)\n\n---\n\n## Table of Contents\n\n1. [The Problem](#the-problem)\n2. [The Solution (Overview)](#the-solution-overview)\n3. [Part 1 — Obsidian as Persistent Memory](#part-1--obsidian-as-persistent-memory)\n4. [Part 2 — Chat Import Pipeline](#part-2--chat-import-pipeline)\n5. [Part 3 — Graphify (Codebase Knowledge Graph)](#part-3--graphify-codebase-knowledge-graph)\n6. [Part 4 — Complete Workflow](#part-4--complete-workflow)\n7. [Real Results](#real-results)\n8. [Troubleshooting](#troubleshooting)\n\n---\n\n## The Problem\n\nWhen working with Claude Code, two problems silently eat your tokens:\n\n**Problem 1 — Amnesia between sessions.** Every time you open a new session, you have to re-explain your project: stack, past decisions, current bugs, what's left to do. Claude Code remembers nothing from the previous session.\n\n**Problem 2 — Codebase re-reading.** Claude Code re-reads all your project files every session to understand the structure. A project with ~40 files burns ~20,000 tokens just for Claude to orient itself — before you even ask a question. If you run 10 sessions a day, that's **200,000 wasted tokens**.\n\n---\n\n## The Solution (Overview)\n\nTwo complementary systems, each solving a different problem:\n\n| Layer | Tool | Problem Solved | Cost |\n|-------|------|---------------|------|\n| Project memory | Obsidian Zettelkasten | Amnesia between sessions | Free |\n| Code map | Graphify | Codebase re-reading | Free (AST mode) |\n| Conversation history | Import pipeline | Lost chat insights | Free |\n| Continuity | `\u002Fresume` and `\u002Fsave` commands | Picking up where you left off | Free |\n\nObsidian handles **what was decided** (declarative memory). Graphify handles **how the code is structured** (structural map). Together, Claude Code starts every session knowing everything — without re-reading anything.\n\n---\n\n## Part 1 — Obsidian as Persistent Memory\n\n### Concept\n\nA single, centralized Obsidian vault acts as Claude Code's \"second brain.\" It stores decisions, context, progress, and knowledge for all your projects. Notes follow the Zettelkasten method: atomic (one idea per note), densely interlinked, with standardized metadata.\n\nClaude Code accesses the vault through `CLAUDE.md` and custom skills.\n\n### Recommended Structure\n\n```\n~\u002Fvault\u002F                              # SINGLE vault for all projects\n├── CLAUDE.md                         # global instructions for Claude Code\n├── permanent\u002F                        # consolidated atomic notes\n├── inbox\u002F                            # raw capture (ideas, drafts)\n├── fleeting\u002F                         # quick temporary notes\n├── templates\u002F                        # note templates\n├── logs\u002F                             # global session logs\n├── references\u002F                       # reference material\n├── my-project\u002F                       # MOCs and notes for project X\n│   ├── architecture\u002F                 #   architecture, decisions, conventions\n│   ├── pipeline\u002F                     #   data flows, APIs\n│   ├── data\u002F                         #   schema, data model\n│   ├── features\u002F                     #   planned\u002Fimplemented features\n│   └── logs\u002F                         #   project session logs\n├── another-project\u002F                  # MOCs and notes for project Y\n│   └── ...\n├── chats\u002F                            # imported Claude chats\n│   ├── code\u002F                         #   from Claude Code\n│   └── web\u002F                          #   from Claude Web\u002FApp\n└── graphify\u002F                         # codebase knowledge graphs\n    ├── my-project\u002F                   #   graph notes for project X\n    └── another-project\u002F              #   graph notes for project Y\n```\n\n> **Why a single vault?** Having one vault per project fragments knowledge. With a single vault, a note about \"Supabase Auth\" links to both project A and B. The graph view reveals cross-project connections you didn't expect.\n\n### Step-by-Step Setup\n\n**Prerequisites:**\n- Claude Code installed and authenticated\n- Obsidian installed (free: [obsidian.md](https:\u002F\u002Fobsidian.md))\n\n**1. Create the vault:**\n\nObsidian → \"Create new vault\" → choose a name and location.\n\n**2. Create the folder structure:**\n\n```bash\ncd ~\u002Fvault  # adjust to your path\nmkdir -p permanent inbox fleeting templates logs references\nmkdir -p my-project\u002F{architecture,pipeline,data,features,logs}\n```\n\n**3. Create the CLAUDE.md:**\n\nThis is the file Claude Code reads automatically. Create `CLAUDE.md` at the vault root:\n\n```markdown\n# Vault — Instructions for Claude Code\n\n## What is this vault\nCentralized knowledge base for all projects.\nPersistent memory across sessions.\n\n## Project stacks\n- Project X: React + Supabase\n- Project Y: Python + FastAPI\n(adapt to your projects)\n\n## Zettelkasten Rules\n\n### Note creation\n- Use wikilinks: [[note-name]] (not markdown links)\n- Mandatory YAML frontmatter on every note\n- Filenames in kebab-case: `auth-flow.md`, not `Auth Flow.md`\n- 1 concept per permanent note (atomicity)\n- Minimum 2 wikilinks per note (dense linking)\n\n### Standard frontmatter\n---\ntitle: Note Name\ntags: [project, topic]\ncreated: YYYY-MM-DD\nupdated: YYYY-MM-DD\nstatus: active\ntype: permanent\n---\n\n### Never do\n- Don't delete notes without asking\n- Don't use markdown links for internal notes (use wikilinks)\n- Don't create notes without frontmatter\n- Don't change folder structure without documenting it\n\n## Session Commands\n\n### \u002Fresume\nWhen you receive this command:\n1. Read the 3 most recent session logs in logs\u002F\n2. Read architecture\u002Fdecisions.md for the current project\n3. Summarize current state and what's left to do\n\n### \u002Fsave\nWhen you receive this command:\n1. Create a session log in logs\u002FYYYY-MM-DD-description.md\n2. Record: what was done, decisions made, pending items\n3. Add wikilinks to created\u002Fmodified notes\n4. Run git commit + push if in a repository\n```\n\n**4. Create a note template:**\n\n```bash\ncat > templates\u002Fdefault-note.md \u003C\u003C 'EOF'\n---\ntitle: {{title}}\ntags: []\ncreated: {{date}}\nupdated: {{date}}\nstatus: draft\ntype: permanent\n---\n\n# {{title}}\n\n## Context\n\n## Details\n\n## Related links\nEOF\n```\n\n**5. Recommended Obsidian plugins:**\n\n| Plugin | Purpose | Install method |\n|--------|---------|----------------|\n| BRAT | Install beta plugins | Community Plugins → Browse |\n| 3D Graph | 3D vault visualization | Via BRAT (v2.4.1) |\n| Folders to Graph | Folders as graph nodes | Community Plugins → Browse |\n| Calendar | Daily note navigation | Community Plugins → Browse |\n\n---\n\n## Part 2 — Chat Import Pipeline\n\n### Concept\n\nYour Claude chats (both Code and Web) contain valuable decisions, insights, and context that get lost in the history. This pipeline exports, processes, and imports those conversations as vault notes — with frontmatter, automatic tags, and wikilinks to existing notes.\n\n### Components\n\n```\n~\u002Fscripts\u002F\n├── claude_to_obsidian.py          # processor (frontmatter, tags, wikilinks)\n└── sync_claude_obsidian.sh        # automation (export + process)\n\n~\u002Fclaude-exports\u002F                   # temporary staging area (outside vault)\n├── code\u002F                           # Claude Code exports\n└── web\u002F                            # Claude Web exports\n```\n\n### Setup\n\n**1. Install the Claude Code extractor:**\n\n```bash\npip install claude-conversation-extractor\n```\n\n**2. Create staging directories:**\n\n```bash\nmkdir -p ~\u002Fclaude-exports\u002Fcode ~\u002Fclaude-exports\u002Fweb\n```\n\n**3. Create the post-processing script (`~\u002Fscripts\u002Fclaude_to_obsidian.py`):**\n\nThe script should:\n- Read each exported `.md` file\n- Detect origin (Code vs Web)\n- Generate automatic tags based on content keywords\n- Add standardized YAML frontmatter\n- Insert `[[wikilinks]]` for notes that already exist in the vault\n- Copy to `chats\u002Fcode\u002F` or `chats\u002Fweb\u002F` inside the vault\n\nExample keyword-to-tag mapping:\n\n```python\nKEYWORD_TAG_MAP = {\n    \"python\": \"python\",\n    \"react\": \"react\",\n    \"supabase\": \"supabase\",\n    \"deploy\": \"deploy\",\n    \"bug\": \"debugging\",\n    \"refactor\": \"refactoring\",\n    # add your own\n}\n```\n\n**4. Create the automation script (`~\u002Fscripts\u002Fsync_claude_obsidian.sh`):**\n\n```bash\n#!\u002Fbin\u002Fbash\nEXPORT_DIR=\"$HOME\u002Fclaude-exports\"\nVAULT_DIR=\"$HOME\u002Fvault\"  # adjust to your path\nSCRIPT_DIR=\"$HOME\u002Fscripts\"\nLOG=\"$SCRIPT_DIR\u002Fsync.log\"\n\necho \"[$(date)] Sync started\" >> \"$LOG\"\n\n# Export Claude Code chats\nclaude-extract --all --output \"$EXPORT_DIR\u002Fcode\" 2>> \"$LOG\"\n\n# Process and send to vault\npython3 \"$SCRIPT_DIR\u002Fclaude_to_obsidian.py\" \\\n    --export-dir \"$EXPORT_DIR\" \\\n    --vault-dir \"$VAULT_DIR\" \\\n    --move 2>> \"$LOG\"\n\necho \"[$(date)] Sync completed\" >> \"$LOG\"\n```\n\n**5. Schedule automatic execution:**\n\n```bash\nchmod +x ~\u002Fscripts\u002Fsync_claude_obsidian.sh\n\n# Run daily at 10 PM\n(crontab -l 2>\u002Fdev\u002Fnull; echo \"0 22 * * * $HOME\u002Fscripts\u002Fsync_claude_obsidian.sh\") | crontab -\n```\n\n**6. For Claude Web chats:**\n\nInstall the **\"Export Claude Chat to Markdown\"** browser extension for Chrome\u002FEdge. Do periodic bulk exports, save the `.md` files to `~\u002Fclaude-exports\u002Fweb\u002F`, and the cron job handles the rest.\n\n**7. Add a section to the vault's CLAUDE.md:**\n\n```markdown\n## Chat Import Pipeline\n\n### Structure\n- `chats\u002Fcode\u002F` → imported Claude Code conversations\n- `chats\u002Fweb\u002F` → imported Claude Web\u002FApp conversations\n- All chats get frontmatter with `type: chat` and `chat-import` tag\n\n### Filter in Graph View\n- `tag:chat-import` → chats only\n- `-path:chats` → hide chats\n```\n\n---\n\n## Part 3 — Graphify (Codebase Knowledge Graph)\n\n### Concept\n\n[Graphify](https:\u002F\u002Fgithub.com\u002Fsafishamsi\u002Fgraphify) transforms your codebase into a queryable knowledge graph. Instead of Claude Code re-reading every file, it queries the graph — which is persistent across sessions and costs a fraction of the tokens.\n\n- **Code:** processed 100% locally via tree-sitter AST. No code content leaves your machine.\n- **Cache:** SHA256 — re-runs only process modified files.\n- **Cost:** 0 tokens in default mode (pure AST). `--deep` mode uses LLM for semantic edges.\n- **Languages:** Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, Ruby, C#, Kotlin, Scala, PHP, Swift, Lua, Zig, and more (20 languages via tree-sitter).\n\n### Setup\n\n**1. Install:**\n\n```bash\npip install graphifyy\ngraphify install\n```\n\n`graphify install` creates the skill at `~\u002F.claude\u002Fskills\u002Fgraphify\u002FSKILL.md`.\n\n**2. Generate the graph:**\n\nFrom your project root:\n\n```bash\n# Full pipeline + Obsidian notes in the centralized vault\ngraphify . --obsidian --obsidian-dir ~\u002Fvault\u002Fgraphify\u002Fproject-name\n```\n\nGenerated output:\n\n```\nyour-project\u002F\n└── graphify-out\u002F\n    ├── graph.json          # queryable graph (Claude Code uses this)\n    ├── graph.html          # interactive visualization (open in browser)\n    ├── GRAPH_REPORT.md     # god nodes, connections, metrics\n    ├── wiki\u002F               # Wikipedia-style articles (agent navigation)\n    └── cache\u002F              # SHA256 cache\n\n~\u002Fvault\u002Fgraphify\u002Fproject-name\u002F\n    └── (Obsidian notes)    # each function\u002Fmodule as a node in graph view\n```\n\n**3. Update .gitignore:**\n\n```gitignore\n# Graphify\ngraphify-out\u002Fcache\u002F\n```\n\nKeep `graph.json` and `GRAPH_REPORT.md` versioned — they're useful for the team.\n\n**4. Add to the project's CLAUDE.md:**\n\nAppend to the CLAUDE.md at the repository root:\n\n```markdown\n## Context Navigation (Graphify)\n\n### 3-Layer Query Rule\n1. **First:** query `graphify-out\u002Fgraph.json` or `graphify-out\u002Fwiki\u002Findex.md`\n   to understand code structure and connections\n2. **Second:** query the Obsidian vault for decisions, progress, and project context\n3. **Third:** only read raw code files when editing\n   or when the first two layers don't have the answer\n\n### When to rebuild the graph\n- After structural changes (new modules, major refactors)\n- Command: `graphify . --update` (only processes modified files)\n- The graph is persistent — NO need to rebuild every session\n\n### Do NOT\n- Don't manually modify files inside `graphify-out\u002F`\n- Don't re-read the entire codebase if the graph already has the information\n```\n\n**5. Add to the vault's CLAUDE.md:**\n\n```markdown\n## Graphify (Codebase Maps)\n\n### Structure\n- `graphify\u002Fproject-x\u002F` → knowledge graph for project X\n- Future projects get their own subfolders\n- Notes are auto-generated — do NOT edit manually\n\n### In Graph View\n- Filter by `path:graphify` to see only code nodes\n- Filter by `-path:graphify` to hide code nodes\n```\n\n**6. Git Hook (optional):**\n\nAutomatically rebuilds the graph on every commit:\n\n```bash\ngraphify hook install\n```\n\n**7. Watch Mode (optional):**\n\nAuto-rebuild on file save (run in a separate terminal):\n\n```bash\ngraphify . --watch\n```\n\n### Useful Commands\n\n| Command | Description |\n|---------|-------------|\n| `graphify .` | Full pipeline on current directory |\n| `graphify .\u002Fsrc` | Scan specific folder |\n| `graphify . --update` | Only process modified files |\n| `graphify . --mode deep` | Semantic extraction (uses LLM, costs tokens) |\n| `graphify . --watch` | Auto-rebuild on save |\n| `graphify query \"question\"` | Query the graph directly |\n| `open graphify-out\u002Fgraph.html` | Open interactive visualization |\n\n### Adding New Projects\n\nWith a centralized vault, each project is just a subfolder:\n\n```bash\ncd ~\u002Fanother-project\ngraphify . --obsidian --obsidian-dir ~\u002Fvault\u002Fgraphify\u002Fanother-project\n```\n\nNotes automatically appear in Obsidian's graph view alongside everything else.\n\n---\n\n## Part 4 — Complete Workflow\n\n### Typical session\n\n```\nOpen Claude Code session\n    │\n    ├── \u002Fresume                      ← loads vault context\n    │                                   (recent logs, decisions, progress)\n    │\n    ├── Claude queries graph.json     ← understands code structure\n    │                                   without re-reading all files\n    │\n    ├── Work on code                  ← features, bugs, refactors\n    │\n    ├── \u002Fsave                        ← generates session log in vault\n    │\n    └── git commit                   ← hook rebuilds graph automatically\n```\n\n### Savings per layer\n\n| Layer | Without it | With it |\n|-------|-----------|---------|\n| `\u002Fresume` | Re-explain project every session | Claude already knows the context |\n| Graphify | Re-read ~40 files (~20k tokens) | Query 1 graph (~280 tokens) |\n| Chat pipeline | Insights lost in chat history | Everything indexed and searchable |\n| `\u002Fsave` + logs | Forget what was done | Complete history with wikilinks |\n\n### Graph View Filters\n\n| Filter | What it shows |\n|--------|--------------|\n| `path:permanent` | Only permanent notes (consolidated knowledge) |\n| `path:graphify` | Only codebase nodes (functions, modules, imports) |\n| `tag:chat-import` | Only imported chats |\n| `-path:graphify -path:chats` | Only manual notes (pure vault) |\n\n---\n\n## Real Results\n\nTested on a React + Supabase project with 126 TypeScript files:\n\n| Metric | Value |\n|--------|-------|\n| Graph nodes | 332 |\n| Edges (connections) | 258 |\n| Communities detected | 124 |\n| graph.json size | 172 KB |\n| Obsidian notes generated | 456 |\n| Token reduction per query | **499x** |\n| LLM cost for generation | **0 tokens** (AST mode) |\n| Imported chats in vault | 137 |\n| Accumulated permanent notes | 65+ |\n| Total vault notes | 780+ |\n\n---\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    OBSIDIAN VAULT (single)                   │\n│                                                             │\n│  permanent\u002F  ← consolidated knowledge (Zettelkasten)        │\n│  logs\u002F       ← session logs (\u002Fsave)                         │\n│  chats\u002F      ← imported conversations (cron pipeline)       │\n│  graphify\u002F   ← codebase knowledge graphs                    │\n│  project-x\u002F  ← MOCs, decisions, architecture                │\n│                                                             │\n│  CLAUDE.md   ← global instructions for Claude Code          │\n└─────────────────────────┬───────────────────────────────────┘\n                          │\n                    Claude Code reads\u002Fwrites\n                          │\n┌─────────────────────────┴───────────────────────────────────┐\n│                   PROJECT REPOSITORY                         │\n│                                                             │\n│  src\u002F            ← source code                              │\n│  CLAUDE.md       ← project instructions + Context Nav       │\n│  graphify-out\u002F   ← graph.json, graph.html, report           │\n│  .git\u002Fhooks\u002F     ← post-commit rebuilds the graph           │\n└─────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## Troubleshooting\n\n**Graphify notes don't appear in Obsidian:**\nConfirm the notes are inside the actual vault directory. Obsidian doesn't always point where you think — create a note in Obsidian and run `find ~ -name \"note-name.md\"` to discover the real path. Then move the notes there and Cmd+Q \u002F reopen.\n\n**Graph view empty with filter applied:**\nDisable \"Orphans\" and \"Existing files only\" in the graph filters. Cmd+Q and reopen Obsidian to force reindexing.\n\n**Claude Code doesn't query the graph:**\nCheck that the project's CLAUDE.md has the \"Context Navigation\" section and that `graphify-out\u002Fgraph.json` exists at the repo root.\n\n**Cron doesn't run (macOS):**\nGrant Full Disk Access to your terminal in System Preferences → Privacy & Security.\n\n**Graphify doesn't generate wiki:**\nThe wiki requires semantic edges. In AST-only mode, use `graphify query \"question\"` or run `--mode deep` (costs API tokens).\n\n**Files with parentheses in name:**\nGraphify generates notes like `myFunction().md`. Obsidian may struggle indexing files with `()` in the name. If needed, batch rename:\n```bash\ncd ~\u002Fvault\u002Fgraphify\u002Fproject\nfor f in *\"(\"*; do mv \"$f\" \"$(echo \"$f\" | sed 's\u002F[()]\u002F\u002Fg')\"; done\n```\n**Unknown Command error in graphify:**\nIf an `unknown command '.'` error occurs in the `Generate the graph` step, in newer versions the `update` parameter should be placed immediately after `graphify`, resulting in:\n```bash\ngraphify update . --obsidian --obsidian-dir ~\u002Fvault\u002Fgraphify\u002Fproject-name\n```\n\n---\n\n## Credits & Links\n\n- [Graphify](https:\u002F\u002Fgithub.com\u002Fsafishamsi\u002Fgraphify) — codebase knowledge graphs (MIT)\n- [Obsidian](https:\u002F\u002Fobsidian.md) — PKM and second brain (free)\n- [Claude Code](https:\u002F\u002Fdocs.anthropic.com) — Anthropic's coding agent\n- Inspired by Andrej Karpathy's system and the r\u002FClaudeAI community\n\n---\n\n**If this guide helped you, give the repo a ⭐ and share it with other devs using Claude Code.**\n","该项目通过结合Obsidian和Graphify，显著减少了Claude Code在会话中使用的令牌数量（最高可达71.5倍），并实现了跨会话的持久记忆。其核心功能包括：利用Obsidian作为长期记忆存储，记录项目决策、上下文等信息；Graphify构建代码库知识图谱，避免每次会话重新读取代码文件；以及聊天导入管道，保存对话历史。这些特性使得Claude Code能够以更少的令牌消耗，在每次会话开始时就具备对整个项目的全面了解。适合需要频繁使用AI辅助编码且希望降低令牌成本、提高工作效率的开发者或团队使用。",2,"2026-06-11 02:40:19","CREATED_QUERY"]