Auto-sync Claude Code config to GitHub/GitLab on session end
npx claudepluginhub ohjuhun/claude-backup-syncAuto-sync Claude Code config to GitHub/GitLab on session end
A Claude Code plugin that automatically syncs your Claude Code configuration to a GitHub/GitLab repository on every session end.
| Feature | Description |
|---|---|
| Auto Backup | Automatically backs up config on every session end (Stop hook) |
| Manual Backup | /backup-config to manually push config |
| Restore | /restore-config to pull config from backup to local |
| API Key Security | API keys in .mcp.json are replaced with ${ENV_VAR} references |
| Change Detection | Only commits and pushes when changes are detected |
| Multi-Host | Supports GitHub, GitLab, and any self-hosted git server |
settings.json, settings.local.jsonCLAUDE.md.mcp.json (API keys auto-replaced with ${ENV_VAR}).zshrc, .gitconfig, .ssh/configBrewfileclaude plugins add OhJuhun/claude-backup-sync
Or add manually to ~/.claude/settings.json:
{
"extraKnownMarketplaces": {
"claude-backup-sync": {
"source": {
"source": "github",
"repo": "OhJuhun/claude-backup-sync"
}
}
},
"enabledPlugins": {
"claude-backup-sync@claude-backup-sync": true
}
}
For GitHub:
gh auth status
For GitLab or other hosts, ensure git credentials are configured.
/backup-setup
This will guide you through repository selection, config creation, and first sync test.
Create ~/.claude/scripts/backup-config.json:
{
"repo": "your-username/backup-repo",
"branch": "main",
"host": "github.com"
}
/backup-config - Push config to remoteManually trigger a backup of your current Claude Code config.
/backup-config
/claude-backup-sync:backup-config
/restore-config - Pull config from remoteRestore Claude Code config from the backup repository. Provides interactive category selection.
/restore-config
/claude-backup-sync:restore-config
Restorable categories:
Note:
.mcp.jsoncontains${ENV_VAR}placeholders. Set actual environment variables after restore.
/backup-setup - Initial setupInteractive setup wizard for first-time configuration.
| Host | Config Example |
|---|---|
| GitHub | "host": "github.com" |
| GitLab | "host": "gitlab.com" |
| Self-hosted | "host": "git.mycompany.com" |
${ENV_VAR} references before pushingConfig: ~/.claude/scripts/backup-config.json
{
"repo": "your-username/backup-repo",
"branch": "main",
"host": "github.com"
}
Logs: ~/.claude/logs/backup-sync.log
gh): Only needed for GitHub setup (optional for GitLab)| Issue | Solution |
|---|---|
| "Not configured" | Run /backup-setup |
| Auth failed | Check git credentials for your host |
| Permission error | Ensure token has repo access |
| View logs | cat ~/.claude/logs/backup-sync.log |
MIT License. See LICENSE.
Created by OhJuhun