$ show tawanorg/claude-sync
claude-sync is a Go CLI tool that encrypts and synchronizes Claude Code session files (prompts, agent configs, project contexts) across devices via cloud storage. It uses a pluggable storage backend (S3, R2, GCS, WebDAV), end-to-end encryption with age (X25519 + Argon2id key derivation), gzip compression, and state-based incremental sync. The tool provides commands for push, pull, status, diff, conflict resolution, history rebuild, and auto-sync hooks. It is distributed as an npm package that downloads a platform-specific Go binary. The architecture follows a clean internal separation: storage adapters, crypto, config, paths, syncer, and CLI commands. The code is well-tested (unit + integration) and includes CI/CD pipelines, though there is a Go version mismatch (go.mod requires 1.24, CI uses 1.21) and some security notes (plaintext credentials, no checksum verification in postinstall). The project is actively developed with a mature feature set and offers reusable patterns like the storage interface, cross-device path mapping, and three-way MCP merge.
The LLM identified 5 files worth highlighting for reuse:
Defines a `Storage` interface with methods (Upload, Download, Delete, List, Head, BucketExists) and a factory (`New`) that registers providers via `init()`. Providers (S3, GCS, R2, WebDAV) self-register, making it trivial to add new backends. This is a clean example of the adapter pattern for cloud storage, easily extractable for any Go project needing multi-provider file storage.
Implements deterministic key derivation using Argon2id with a fixed salt (sha256 of 'claude-sync-v1') clamped to X25519, then encrypts with age. Supports passphrase-based encryption that works across devices without sharing keys. Includes random key generation and test helpers. The pattern of deterministic key derivation from a passphrase for cross-device encryption is reusable in any Go application needing portable secrets.
Implements `PathMapper` that replaces absolute paths with portable tokens (e.g., `{HOME}`, `{PROJECTS}`) in Claude session files. Handles username prefix edge cases and content replacement. This solves the common problem of syncing files with machine-specific paths across devices, and the pattern (tokenization, matching, substitution) is reusable for any cross-device sync tool.
Provides a three-way merge algorithm for MCP server configurations (local, remote, baseline). Merges servers by name, reports conflicts for differing transports/arguments. The merge logic (base + local + remote → resolved) is a standalone function that could be extracted for any JSON/YAML config merge task.
The `Push` and `Pull` methods in the syncer use a buffered channel as a worker pool (concurrency=10) to parallelize file uploads/downloads. Progress is reported via a callback. This concurrency pattern is useful for any batch file operation and is cleanly separated from the business logic.