Scripts
Helper scripts for the Claude Code + Obsidian + Graphify setup.
Files
| File | Purpose |
|---|---|
claude_to_obsidian.py |
Process exported Claude chats and import them into your Obsidian vault with frontmatter, auto-tags, and wikilinks |
sync_claude_obsidian.sh |
Automation wrapper: exports Claude Code chats and runs the processor |
Setup
-
Copy both files to
~/scripts/:mkdir -p ~/scripts cp claude_to_obsidian.py ~/scripts/ cp sync_claude_obsidian.sh ~/scripts/ chmod +x ~/scripts/sync_claude_obsidian.sh -
Install the Claude Code extractor:
pip install claude-conversation-extractor -
Edit
sync_claude_obsidian.sh:Open the file and change
VAULT_DIRto point to your Obsidian vault:VAULT_DIR="$HOME/YourVaultName" -
Customize tags (optional):
Open
claude_to_obsidian.pyand edit theKEYWORD_TAG_MAPdictionary at the top. Add keywords specific to your stack and projects:KEYWORD_TAG_MAP = { "my-project": "my-project", "client-name": "client-work", # ... your keywords } -
Test manually:
~/scripts/sync_claude_obsidian.shCheck the log:
tail -f ~/scripts/claude_obsidian_sync.log -
Schedule via cron (daily at 10pm):
(crontab -l 2>/dev/null; echo "0 22 * * * $HOME/scripts/sync_claude_obsidian.sh") | crontab -
How it works
sync_claude_obsidian.shrunsclaude-extractto export all Claude Code conversations as.mdfiles into~/claude-exports/code/- Web chats can be manually exported via the "Export Claude Chat to Markdown" browser extension into
~/claude-exports/web/ claude_to_obsidian.pyprocesses each.md:- Detects origin (Code vs Web)
- Generates auto-tags via keyword matching
- Adds standardized YAML frontmatter
- Inserts
[[wikilinks]]for notes that already exist in your vault
- Files are moved (with
--moveflag) into<vault>/chats/code/or<vault>/chats/web/
CLI options
python3 claude_to_obsidian.py \
--export-dir ~/claude-exports \
--vault-dir ~/ObsidianVault \
--move
| Flag | Description |
|---|---|
--export-dir |
Directory containing exported .md files (required) |
--vault-dir |
Path to your Obsidian vault (required) |
--dry-run |
Preview what would happen without modifying anything |
--move |
Delete originals after copying (default: copy only) |
--origin |
Force origin: code, web, or auto (default: auto) |
--no-wikilinks |
Disable wikilink insertion |
Filter in Obsidian Graph View
After import, use these filters:
tag:chat-import→ only imported chatspath:chats→ all chats by folder-path:chats→ hide all chatstag:python tag:chat-import→ Python-related chats only
Troubleshooting
claude-extract not found:
Install with pip install claude-conversation-extractor. If still not found, check that pip's bin directory is in your $PATH.
Cron job doesn't run on macOS:
Grant Full Disk Access to cron in System Preferences → Privacy & Security → Full Disk Access.
No tags being generated:
Check that KEYWORD_TAG_MAP in claude_to_obsidian.py contains keywords actually present in your chats. Run with --dry-run to debug.
Wikilinks not inserted:
The script only inserts wikilinks for notes that already exist in your vault. Make sure your --vault-dir points to a vault with notes (not an empty folder).