Getting Started
Installation
Install ctx-sync globally via npm:
BASHnpm install -g ctx-sync
Requires **Node.js 18+** and **Git** installed on your system.
Create a Sync Repository
Before running ctx-sync init, create a dedicated private Git repository to store your encrypted context. This is separate from your project repos — it is a single repo that holds encrypted snapshots of all your projects in one place.
- Go to GitHub, GitLab, or your preferred Git host.
- Create a new private repository (e.g.
dev-contextormy-context-sync). - Copy the SSH or HTTPS URL (e.g.
git@github.com:you/dev-context.git).
The sync repository is dedicated to ctx-sync and is separate from your project repos. ctx-sync never modifies your project repositories — it only reads their Git state (branch, remote, uncommitted changes). All your encrypted context is stored in `~/.context-sync/` locally and pushed to this dedicated remote.
First-Time Setup
Run the init command to generate your encryption key and configure your sync repository:
BASHctx-sync init
This will:
- Generate an encryption key pair — Your private key is saved to
~/.config/ctx-sync/key.txtwith secure permissions (600). - Prompt you to back up your private key — Save it to a password manager like 1Password or Bitwarden. You will need this key to restore on another machine.
- Ask for your Git remote URL — Paste the URL of the dedicated private repository you created above. ctx-sync will validate that it uses a secure transport (SSH or HTTPS).
You can press Enter to skip the remote URL during init. ctx-sync will work locally without syncing. To add a remote later, run: `ctx-sync init --remote
Back Up Your Key
Your private key is the **only way** to decrypt your synced context. If you lose it, your data is gone. There is no backdoor by design. ctx-sync will prompt you to back up during init.
- Recommended: Save to 1Password / Bitwarden
- Alternative: Copy to clipboard (auto-clears after 30 seconds)
Track Your First Project
Navigate to any project directory and start tracking:
BASHcd ~/projects/my-app ctx-sync track
ctx-sync will automatically detect:
- Git repository — current branch, remote, uncommitted changes
- .env file — prompts to import environment variables (all encrypted by default)
- docker-compose.yml — prompts to track Docker services
- Mental context — asks what you are currently working on
Use `ctx-sync track --yes` to skip confirmation prompts and accept all defaults.
Sync Your Context
Push your tracked context to your Git remote:
BASHctx-sync sync
All data is encrypted with Age encryption before being committed to Git. Even project names and paths are encrypted — an attacker with access to your Git repo sees only ciphertext.
Restore on a New Machine
On your new machine, install ctx-sync and restore:
BASHnpm install -g ctx-sync ctx-sync init --restore
Paste your private key when prompted. ctx-sync will clone your context repo and decrypt all your state.
Then restore a specific project:
BASHctx-sync restore my-app
This will:
- Show your mental context (what you were working on, blockers, next steps)
- Decrypt and restore environment variables
- Show Docker services and commands for your approval before executing
The entire restore process takes under 10 seconds. You go from a blank machine to knowing exactly where you left off.
Daily Usage
BASH# Track changes to your context ctx-sync track # Add a note about what you are working on ctx-sync note my-app # Sync to remote ctx-sync sync # Check status ctx-sync status
Next Steps
- Full CLI Reference — All available commands
- Security Model — How encryption and key management work
- Team Setup — Share context with your team
- FAQ — Common questions and troubleshooting