How to Share Context Between Claude.ai and Claude Code
Problem
I brainstorm in Claude.ai’s web interface. Then I switch to Claude Code in my terminal to implement. But Claude Code has no idea what we discussed. I have to re-explain everything.
Each Claude interface keeps its own memory. Nothing transfers between them:
- Claude.ai web: Brainstorming, research, planning
- Claude Code CLI: Coding, debugging, implementation
When I found a bug fix in Claude Code, I had to manually copy it to Claude.ai for future reference. When I made architecture decisions in Claude.ai, I had to restate them in Claude Code.
I wanted Claude to feel like one assistant, not two disconnected ones.
The Core Issue: Siloed Context
Claude operates as two separate products:
+------------------+ +------------------+| Claude.ai | | Claude Code || (Web Chat) | | (Terminal) || | | || Memory: Session | | Memory: Session || only, per chat | | only, per project|+------------------+ +------------------+ | | v v [No connection between them]This siloed approach causes real friction:
- Architecture decisions in Claude.ai don’t carry to implementation in Claude Code
- Bug fixes documented in Claude Code aren’t visible in Claude.ai planning sessions
- Context resets every time you switch interfaces
- You repeat yourself constantly
The Solution: Shared Knowledge Base via MCP
The fix is connecting both interfaces to an external “brain” using MCP (Model Context Protocol). Both interfaces read and write to the same knowledge base.
+------------------+ +------------------+| Claude.ai | | Claude Code || (Web Chat) | | (Terminal) |+--------+---------+ +--------+---------+ | | | MCP Protocol | +--------------------+------------------------+ | v +-------------------------------+ | Knowledge Base MCP Server | | (kb_search, kb_write, etc) | +-------------------------------+ | +------------------+------------------+ | | | v v v +-----------+ +------------+ +------------+ | SQLite | | Obsidian | | Vector | | FTS5 | | Vault | | Index | +-----------+ +------------+ +------------+Now when I write something in Claude.ai, Claude Code can search and read it. When Claude Code captures a bug fix, I can access that knowledge from Claude.ai in my next conversation.
Same brain, different interfaces.
Approach 1: Knowledge Base Server (Recommended)
The most robust solution uses a dedicated knowledge base MCP server. I set up willynikes2/knowledge-base-server which provides these tools:
| Tool | Purpose |
|---|---|
kb_search | Full-text search with BM25 ranking |
kb_search_smart | Hybrid keyword + semantic search |
kb_context | Token-efficient briefing summaries |
kb_write | Write notes to knowledge base |
kb_ingest | Index documents for searching |
kb_capture_session | Record terminal findings |
kb_capture_fix | Document bug fixes |
Configuration for Claude Code
In ~/.claude.json:
{ "mcpServers": { "knowledge-base": { "command": "node", "args": ["/path/to/knowledge-base-server/dist/index.js"], "env": { "KB_VAULT_PATH": "~/claude-vault", "KB_DB_PATH": "~/.knowledge-base/kb.db" } } }}Configuration for Claude.ai (Claude Desktop)
Add the same MCP server in Claude Desktop’s settings. Both interfaces now share the same knowledge base.
The Workflow in Practice
Here’s how the handoff actually works:
- Brainstorm in Claude.ai: Discuss architecture, explore options, make decisions
- Capture insights: Use
kb_writeto save key decisions - Switch to Claude Code: Open terminal, start coding
- Query context: Claude Code searches knowledge base automatically
- Continue thread: Implementation informed by brainstorming
Approach 2: Obsidian Vault with MCP
A simpler approach uses an Obsidian vault as the shared storage. Both interfaces read/write markdown files.
Setup steps:
- Create a dedicated Obsidian vault for Claude context
- Configure MCP filesystem server pointing to the vault
- Use Obsidian’s git plugin for auto-sync and version history
- Both interfaces read/write markdown files
Benefits:
- Human-readable markdown format
- Version control via Git
- Manual curation of knowledge
- Obsidian’s graph view for visualization
Trade-offs:
- No semantic search (just text search)
- Manual organization required
- Less token-efficient than knowledge base server
Approach 3: Memory MCP Server (Simplest)
For basic preferences and simple key-value storage:
{ "mcpServers": { "memory": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"] } }}This is the easiest to set up but has significant limitations: no semantic search, limited to simple preferences, not suitable for rich context.
The Feedback Loop
Once configured, you get a continuous improvement cycle:
Claude.ai (Brainstorm) ---> Knowledge Base ---> Claude Code (Implement) ^ | | | +---------- Capture Bug Fixes -----------------+When Claude Code solves a bug:
kb_capture_fixdocuments the solution- Knowledge base indexes the finding
- Future Claude.ai sessions query past fixes
- Context compounds over time
Practical Example: Architecture Decision
In Claude.ai, I captured an API architecture decision:
await mcp.kb_write({ title: "API Architecture Decision - 2026-03-18", content: `# API Architecture Decision
## DecisionUse REST API with JWT authentication for MVP.
## Rationale- Simpler than GraphQL for our team- JWT provides stateless auth- Faster to implement
## Next Steps- Implement /auth endpoint- Add rate limiting`, tags: ["architecture", "api", "decision"], tier: "hot"});Later, in Claude Code, before implementing:
const context = await mcp.kb_context({ query: "API authentication architecture", maxTokens: 500});Claude Code now has the context from the Claude.ai brainstorming session. No re-explaining required.
Token Optimization Strategy
The kb_context tool provides token-efficient retrieval. Instead of loading all context, it returns summaries first.
Traditional: Load all docs = 50,000 tokensWith kb_context: Summaries first = 500 tokens
Select relevant: Load 2 full docs = 5,000 tokens
Total savings: ~90%Three-tier memory structure:
- Hot: Active project context (frequently accessed)
- Warm: Accumulated project knowledge (periodically relevant)
- Cold: Archived decisions (rarely needed but searchable)
Common Mistakes I Made
Mistake 1: Forgetting to ingest before querying
New documents must be indexed before they’re searchable. I spent hours wondering why my searches returned nothing, only to realize I never ran kb_ingest.
Mistake 2: Single-interface configuration
I initially configured MCP only in Claude Code. Claude.ai couldn’t access the knowledge base. Cross-interface context requires configuring BOTH interfaces.
Mistake 3: Context pollution
I stored everything without tiering. Search results became noisy and irrelevant. Now I use tiers (hot/warm/cold) and clean up old entries periodically.
Mistake 4: No version control
Without Git sync, I lost knowledge when I made mistakes. Git provides history and recovery.
Comparison of Approaches
| Feature | Knowledge Base Server | Obsidian Vault | Memory MCP |
|---|---|---|---|
| Semantic Search | Yes | Via plugin | No |
| Token Efficiency | Excellent | Good | Poor |
| Setup Complexity | Medium | Low | Low |
| Version Control | Optional | Built-in | No |
| Cross-Interface | Excellent | Excellent | Limited |
| Best For | Production workflows | Personal use | Simple preferences |
Summary
In this post, I showed how to share context between Claude.ai and Claude Code using MCP knowledge base servers. The key insight is that both interfaces need an external storage layer they can independently query.
The result: brainstorm in Claude.ai, implement in Claude Code, and context flows seamlessly between them. Bug fixes and decisions compound over time instead of being lost.
The Reddit post that sparked this investigation captured it best: “Same brain, different interfaces.” With proper MCP configuration, what you discover in one interface is immediately available in the other.
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:
- 👨💻 willynikes2/knowledge-base-server
- 👨💻 Reddit: Obsidian + Claude = no more copy paste
- 👨💻 MCP Memory Server
- 👨💻 Model Context Protocol Documentation
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments