Claude Code Plugin
Theclaude-code-sync plugin syncs your Claude Code sessions to OpenSync. It reads session data from Claude Code’s local storage and pushes it to your dashboard in real time.
Source identifier: claude-code
Installation
Install globally with npm:Setup
Generate an API key
Log in to opensync.dev, go to Settings, and click Generate API Key. Copy the key (starts with
osk_).Run login
- Convex URL:
https://polished-penguin-622.convex.cloud(for hosted) or your self-hosted URL - API Key: The key you copied from Settings
Config file
Credentials are stored in~/.claude-code-sync/config.json:
Commands
claude-code-sync login
Prompts for Convex URL and API key, then saves them to the config file.claude-code-sync status
Shows connection info and sync stats:claude-code-sync sync
Force a manual sync of all sessions.Sessions sync automatically. Use manual sync after a network interruption or to catch any missed sessions.
claude-code-sync logout
Clears stored credentials.How syncing works
- Claude Code stores session data in
~/.claude/projects/and related directories. - The plugin scans for new and updated sessions.
- Each session is pushed to the
/sync/sessionendpoint withsource: "claude-code". - Each message is pushed to
/sync/messagewith its role, text content, token counts, and any tool call data. - Deduplication uses
externalId, so re-syncing is safe.
What gets synced
| Data | Description |
|---|---|
| Conversation messages | Full history with role labels (user, assistant, system, tool) |
| Model info | Model name (e.g., “claude-sonnet-4-20250514”) and provider (“anthropic”) |
| Token counts | Prompt and completion tokens per message and per session |
| Cost | Estimated cost based on Anthropic pricing |
| Project path | Working directory associated with the Claude Code session |
| Tool calls | Tool names, arguments, and results |
Session data
Each synced session maps to these database fields:| Plugin data | Database field |
|---|---|
| Session ID from Claude | sessions.externalId |
| First user message | sessions.title (auto-generated) |
| Model name | sessions.model |
| Input tokens | sessions.promptTokens |
| Output tokens | sessions.completionTokens |
| Calculated cost | sessions.cost |
| Project directory | sessions.projectPath, sessions.projectName |
Troubleshooting
Sessions not appearing
- Run
claude-code-sync statusto verify the connection. - Check that Claude Code is active and has sessions in
~/.claude/projects/. - Run
claude-code-sync syncto force a manual push.
Duplicate sessions
Duplicates can occur if Claude Code regenerates session IDs. The plugin usesexternalId for dedup, but if the source ID changes, a new session is created. Contact support if duplicates persist across syncs.
Authentication errors
If you see “Unauthorized” or “Invalid API key”:- Check that your API key is active in the dashboard Settings.
- Re-run
claude-code-sync loginto refresh credentials. - Verify the Convex URL matches your deployment.