Skip to content

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's memory problem
+------------------+ +------------------+
| 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:

  1. Architecture decisions in Claude.ai don’t carry to implementation in Claude Code
  2. Bug fixes documented in Claude Code aren’t visible in Claude.ai planning sessions
  3. Context resets every time you switch interfaces
  4. 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.

Shared knowledge base architecture
+------------------+ +------------------+
| 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.

The most robust solution uses a dedicated knowledge base MCP server. I set up willynikes2/knowledge-base-server which provides these tools:

ToolPurpose
kb_searchFull-text search with BM25 ranking
kb_search_smartHybrid keyword + semantic search
kb_contextToken-efficient briefing summaries
kb_writeWrite notes to knowledge base
kb_ingestIndex documents for searching
kb_capture_sessionRecord terminal findings
kb_capture_fixDocument bug fixes

Configuration for Claude Code

In ~/.claude.json:

~/.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:

  1. Brainstorm in Claude.ai: Discuss architecture, explore options, make decisions
  2. Capture insights: Use kb_write to save key decisions
  3. Switch to Claude Code: Open terminal, start coding
  4. Query context: Claude Code searches knowledge base automatically
  5. 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:

  1. Create a dedicated Obsidian vault for Claude context
  2. Configure MCP filesystem server pointing to the vault
  3. Use Obsidian’s git plugin for auto-sync and version history
  4. 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:

~/.claude.json
{
"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:

Cross-interface feedback loop
Claude.ai (Brainstorm) ---> Knowledge Base ---> Claude Code (Implement)
^ |
| |
+---------- Capture Bug Fixes -----------------+

When Claude Code solves a bug:

  1. kb_capture_fix documents the solution
  2. Knowledge base indexes the finding
  3. Future Claude.ai sessions query past fixes
  4. Context compounds over time

Practical Example: Architecture Decision

In Claude.ai, I captured an API architecture decision:

kb_write call in Claude.ai
await mcp.kb_write({
title: "API Architecture Decision - 2026-03-18",
content: `
# API Architecture Decision
## Decision
Use 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:

kb_context call in Claude Code
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.

Token-efficient context retrieval
Traditional: Load all docs = 50,000 tokens
With 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

FeatureKnowledge Base ServerObsidian VaultMemory MCP
Semantic SearchYesVia pluginNo
Token EfficiencyExcellentGoodPoor
Setup ComplexityMediumLowLow
Version ControlOptionalBuilt-inNo
Cross-InterfaceExcellentExcellentLimited
Best ForProduction workflowsPersonal useSimple 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:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments