GuideJuly 21, 20266 min read

Using ConfigSync with GitHub Codespaces

GitHub Codespaces gives you a cloud VM. ConfigSync makes it feel like your laptop. Get your shell, Git config, editor settings, and encrypted secrets in every Codespace automatically.

Codespaces Dotfiles Support Falls Short

GitHub Codespaces has built-in dotfiles support: point it at a dotfiles repository and it clones the repo into every new Codespace. Sounds great in theory. In practice, this approach has significant gaps.

Your dotfiles repo contains plaintext files. SSH keys, API tokens, and cloud credentials either get committed in plaintext (a security risk) or excluded entirely (leaving your Codespace incomplete). There is no encryption, no selective sync, and no way to handle platform differences between your local machine and the Codespace VM.

ConfigSync solves all of these problems. Secrets are encrypted with AES-128. You can filter which modules to pull. And template variables adapt configs to the Codespace environment automatically.

Setting Up ConfigSync in Codespaces

The setup is a one-line addition to your devcontainer configuration. Add ConfigSync to the postCreateCommand in your devcontainer.json:

.devcontainer/devcontainer.json
{ "name": "My Project", "image": "mcr.microsoft.com/devcontainers/typescript-node:20", "postCreateCommand": "npm install -g @inventivehq/configsync && configsync setup --token $CS_TOKEN && configsync pull", "secrets": { "CS_TOKEN": { "description": "ConfigSync API token for environment sync" } } }

The postCreateCommand runs once when the Codespace is created. It installs ConfigSync, authenticates with your token, and pulls your full environment. Every subsequent Codespace gets the same treatment automatically.

Storing Your Token as a Codespace Secret

Your ConfigSync token should never be hardcoded. GitHub Codespaces supports encrypted secrets that are injected as environment variables:

Add your token via GitHub Settings
# Go to: GitHub Settings → Codespaces → Secrets → New Secret # Name: CS_TOKEN # Value: cs_your_api_token_here # Repository access: All repositories (or select specific ones)

Once the secret is stored, every Codespace you create will have $CS_TOKENavailable as an environment variable. The configsync setup command uses it to authenticate and pull your encrypted configs.

Tip: Generate a dedicated API token for Codespaces from your ConfigSync dashboard. If you ever need to revoke Codespace access, you can do so without affecting your other machines.

What Gets Synced

When ConfigSync pulls in a Codespace, you get everything you would have on your local machine: your shell configuration (zsh aliases, functions, prompt), Git settings (identity, signing, aliases), editor preferences (VS Code settings, keybindings, extensions list), and SSH keys for accessing private repositories or servers.

Selective pull for faster startup
# Pull only essentials for faster Codespace creation configsync pull --filter modules:git,modules:zsh,modules:vscode # Or pull everything configsync pull

If your full environment takes too long to set up, use the --filter flag to pull only the modules that matter for Codespace development. Git and shell configs are usually the essentials.

Advanced: Per-Repository Configuration

Different projects may need different environments. You can use ConfigSync profiles to customize what gets pulled per repository:

.devcontainer/devcontainer.json with profile
{ "postCreateCommand": "npm install -g @inventivehq/configsync && configsync setup --token $CS_TOKEN && configsync pull --profile work" }

Your work profile might include corporate proxy settings and internal registry credentials, while a personal project uses your personal Git identity and different SSH keys. Same tool, different configs, automatically applied.

The Result: Identical Environments Everywhere

With ConfigSync in your Codespace setup, opening a new Codespace feels identical to opening a terminal on your laptop. Your aliases work. Your Git commits have the right identity. Your editor looks and behaves the way you expect. And every secret is encrypted in transit and at rest.

No more "let me set up my environment" when switching to Codespaces. No more plaintext dotfiles repos with secrets stripped out. Just your full development environment, everywhere.

Ready to try ConfigSync?

Sync your entire dev environment across machines in minutes. Free forever for up to 3 devices.