How to Use Obsidian as a Knowledge Base for Claude Code
I kept losing context between Claude Code sessions. Every time I started a new conversation, I had to re-explain my project structure, re-state my coding preferences, and re-document decisions I’d already made with Claude’s help. It was like starting from zero every single time.
Then I discovered a pattern that changed everything: using Obsidian as a persistent knowledge layer for Claude Code.
The Problem with Ephemeral AI Sessions
Claude Code is powerful, but it has no memory. Close a session, and everything is gone. For long-term projects, this creates several problems:
- Repetitive context-setting - I kept explaining the same project details
- Lost insights - Valuable AI suggestions vanished after sessions ended
- No documentation trail - I couldn’t track why I made certain decisions
- Scattered knowledge - AI-generated content had no central home
I needed a way to make Claude Code’s intelligence accumulate over time.
The Solution: Obsidian as Your AI Memory
The key insight came from a Reddit discussion where users described their Obsidian vault as a “hive mind” for Claude. Instead of just storing notes, the vault becomes a shared workspace where both human and AI contributions compound.
Here’s the workflow that works:
Before Each Session:
- Point Claude Code to your vault directory
- Let it read relevant context files
- Reference existing decisions and patterns
During Session:
- Document decisions in real-time
- Save useful code snippets
- Capture explanations and rationale
After Session:
- Review AI-generated content in Obsidian
- Organize and refine notes
- Commit to git for version history
Setting Up the Vault
I started with a simple directory structure:
~/claude-knowledge-base/|├── .git/ # Version control your knowledge├── .obsidian/ # Obsidian config│ └── plugins/│ ├── dataview/ # Query notes dynamically│ └── templater/ # Consistent templates│├── 00-inbox/ # Quick capture from Claude├── 01-projects/│ └── [project-name]/│ ├── _context.md # Claude reads this first│ ├── sessions/ # Session logs│ ├── decisions/ # Architecture decisions│ └── snippets/ # Code from Claude│├── 02-knowledge/│ ├── patterns/ # Reusable patterns│ ├── commands/ # Useful prompts│ └── references/ # External docs│├── 03-archives/ # Old project knowledge│└── templates/ ├── session.md └── decision.mdThe 00-inbox folder is crucial. During sessions, I tell Claude to dump quick notes there. Later, I process them into proper locations in Obsidian.
The _context.md Pattern
The most powerful pattern I discovered is the _context.md file. At the start of each project folder, I create a context file that Claude reads:
# Project Context: My App
## Tech Stack- Frontend: React + TypeScript- Backend: Node.js + Express- Database: PostgreSQL
## Current Focus- Implementing authentication- Refactoring API layer
## Recent Decisions- [[2024-01-15-auth-strategy]] - Chose JWT over sessions- [[2024-01-10-db-choice]] - PostgreSQL for relational data
## Code PatternsSee: [[patterns/api-error-handling]]When I start a new session, I just tell Claude: “Read ~/claude-knowledge-base/01-projects/my-app/_context.md and use it as context for this session.”
The [[wiki-links]] syntax works beautifully here. Claude can follow those links to get deeper context when needed.
Session Logs That Actually Help
I tried various session logging approaches before settling on this template:
# Session: 2024-01-20 - Auth Refactor
## Context- Project: [[my-app]]- Goal: Refactor authentication to use refresh tokens
## What I Tried1. First approach: Store refresh token in localStorage - Claude flagged: XSS vulnerability risk - Abandoned this path
2. Second approach: HttpOnly cookies - Claude suggested: Use same-site strict attribute - This worked
## Key Decisions1. Use HttpOnly cookies for refresh tokens - Rationale: Prevents XSS token theft - Trade-off: CSRF protection needed
## Code GeneratedSaved to: [[snippets/auth-middleware]]
## Next Steps- [ ] Add CSRF token implementation- [ ] Update API documentation- [ ] Write integration tests
## Related Notes- [[patterns/jwt-security]]- [[decisions/2024-01-15-auth-strategy]]The “What I Tried” section captures the trial-and-error process. This is invaluable - when I encounter a similar problem months later, I can see not just what worked, but what didn’t and why.
The Git Workflow
This almost defeated me. I initially didn’t version control the vault, and I lost several important context updates when I accidentally overwrote files.
Now I commit after every session:
# After each Claude sessioncd ~/claude-knowledge-basegit add -Agit commit -m "Session: [topic] - [brief summary]"git pushThe commit history tells a story of how my project evolved with Claude’s help. I can see exactly what decisions were made and when.
Minimal Plugins, Maximum Value
I made the mistake of installing too many plugins initially. The vault became slow and cluttered. Now I stick to essentials:
| Plugin | Purpose | Why It Matters |
|---|---|---|
| Dataview | Query notes dynamically | Find related sessions/decisions |
| Templater | Consistent templates | Enforce session log format |
| Git | Version control | Never lose context updates |
That’s it. The power comes from the workflow, not the plugins.
A Real Example
Here’s how this worked in practice recently. I was working on a rate limiter implementation:
Session 1: Initial implementation └── Claude helped design token bucket algorithm └── Saved snippet to snippets/rate-limiter.ts └── Logged decision to decisions/2024-01-18-rate-limiter.md
Session 2 (3 days later): Bug fix └── Claude read _context.md + rate limiter decision └── Immediately understood the architecture └── Fixed the bug without re-explaining anything └── Updated session log with fix details
Session 3 (2 weeks later): Scaling issue └── Claude had full context from previous sessions └── Suggested Redis-based distributed rate limiting └── Could explain WHY this was better than current approach └── Referenced previous decision to show trade-offsWithout the Obsidian vault, each session would have started from scratch. With it, Claude had institutional memory.
Common Mistakes I Made
1. Over-engineering the Structure
My first vault had 15 top-level folders, 8 different note types, and a complex tagging system. It collapsed under its own weight.
Fix: Start with inbox/, projects/, and templates/. Add folders only when you feel the pain of not having them.
2. Not Using Git
I lost three weeks of accumulated context because I didn’t version control. Never again.
3. Treating It as Archive, Not Workspace
Initially, I only saved completed work to the vault. Now I save work-in-progress, half-formed ideas, and even failed approaches. The “what didn’t work” notes are often more valuable than the successes.
4. Forgetting to Point Claude to Context
Several times I started sessions without pointing Claude to the vault. The results were generic and unhelpful. Now I have a checklist:
Before starting:1. Open relevant project folder in Obsidian2. Tell Claude: "Read [project-path]/_context.md"3. Confirm Claude has the context by asking a questionWhy This Matters
The real value isn’t in any single session. It’s in the compound effect. After six months of using this approach:
- My vault has 47 project-specific decisions documented
- 120+ code snippets with context
- 30+ recurring patterns identified
- Zero sessions where I had to re-explain project basics
Each session builds on the last. Claude gets smarter about my projects over time, not dumber.
The Cross-Tool Bonus
An unexpected benefit: I also use Claude Cowork for research tasks. Since both tools write to the same git-backed vault:
- Claude Code sessions generate code and technical decisions
- Claude Cowork sessions generate research and documentation
- Everything cross-references via wiki-links
The vault becomes a shared brain across all my AI tools.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Claude Code Documentation
- 👨💻 Obsidian
- 👨💻 Reddit Discussion on Claude + Obsidian
- 👨💻 Dataview Plugin
- 👨💻 Templater Plugin
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments