othnielsu15 downloadsBridge selected text to Claude Code CLI for real-time context sharing.
English | 中文
An Obsidian plugin that bridges selected text to Claude Code CLI in real-time.
When you select text in Obsidian, the adjacent terminal running Claude Code automatically shows ⧉ Selected N lines from <file> and includes the selection as context — just like VS Code.
The plugin mimics VS Code's IDE MCP server protocol:
127.0.0.1~/.claude/ide/{port}.lockselection_changed notificationsgit clone https://github.com/othnielsu/obsidian-claude-code-bridge.git
cd obsidian-claude-code-bridge
npm install
npm run build
VAULT="/path/to/your/vault"
mkdir -p "$VAULT/.obsidian/plugins/claude-code-bridge"
cp main.js manifest.json "$VAULT/.obsidian/plugins/claude-code-bridge/"
Then in Obsidian: Settings → Community Plugins → Reload → Enable "Claude Code Bridge"
claude/ide to connect to ObsidianImportant: Claude Code must be started from the vault directory for workspace matching to work.
npm run dev # Watch mode
npm run build # Production build
npm test # Run tests
npm run test:watch # Watch tests
┌─────────────────────┐ WebSocket (JSON-RPC 2.0) ┌──────────────┐
│ Obsidian Plugin │ ◄──────────────────────────────────► │ Claude Code │
│ │ │ CLI │
│ - Selection Listener │ │
│ - WS Server (:port)│ Lock file auto-discovery │ Auto-detect │
│ - Lock file writer │ ────────────────────────────────────► │ & connect │
└─────────────────────┘ ~/.claude/ide/{port}.lock └──────────────┘
| Component | File | Responsibility |
|---|---|---|
| Server | src/server.ts |
WebSocket + MCP protocol handshake |
| Lock File | src/lockfile.ts |
Discovery file management |
| Selection | src/selection.ts |
Debounced selection change detection |
| Main | src/main.ts |
Plugin lifecycle wiring |
MIT