workbuddy-multi-device-sync
Set up automatic configuration sync across multiple Macs using WorkBuddy. Use when the user wants to use WorkBuddy on two or more computers and keep identity, memory, skills, and settings synchronized. Triggers: 多台电脑同步, 双机同步, 两台 Mac 同步 WorkBuddy, sync WorkBuddy across devices, multi-device sync, 换电脑配置同步. Covers Git-based sync via GitHub, auto-sync daemon, and one-click setup for additional machines.
WorkBuddy Multi-Device Sync
Overview
Enable automatic synchronization of WorkBuddy configuration across multiple Macs using a private GitHub repository. After setup, all machines share the same identity (SOUL.md, IDENTITY.md, USER.md), memory (MEMORY.md), skills, and settings — with zero manual commands. A background daemon syncs every 5 minutes.
What Syncs vs What Doesn't
Syncs (via Git)
- Identity files:
SOUL.md,IDENTITY.md,USER.md - Memory:
MEMORY.md(user-level, NOTmemory/daily logs) - Skills:
skills/directory - Config:
mcp.json,settings.json - Setup scripts:
auto-sync.sh,start-sync-daemon.sh,wb-setup-mac-b.sh
Does NOT Sync (machine-specific)
binaries/— 300MB+ platform-specific runtimes, each machine installs its ownworkbuddy.db— SQLite database (automations, runtime state), concurrent sync corrupts it.mcp.json— localhost port numbers differ per machinesessions/,logs/,traces/— runtime data, machine-specificcredentials/— each machine logs in independentlymemory/— daily work logs, project-specificconnectors/,plugins/— marketplace state, machine-specific
Already Synced (server-side, no action needed)
- Conversation history
- Cloud user profile (auto-injected at session start)
Workflow
Phase 1: Set Up Mac A (Primary Machine)
Step 1: Initialize Git in ~/.workbuddy/
# Set git config if not already set
git config --global user.name "$(whoami)"
git config --global user.email "$(whoami)@workbuddy.local"
git config --global init.defaultBranch main
# Initialize repo
cd ~/.workbuddy
git init
Step 2: Create .gitignore
Copy the template from references/gitignore-template to ~/.workbuddy/.gitignore.
This excludes all machine-specific files. Review and adjust as needed.
Key exclusions:
binaries/— runtimesworkbuddy.db/workbuddy.db-*— SQLite.mcp.json— localhost portssessions/,logs/,traces/— runtime datacredentials/— auth tokensmemory/— daily logs.auto-sync.log,.sync-daemon.pid— daemon state
Step 3: Create GitHub Private Repo
Two approaches:
Approach A: GitHub Device Flow (recommended, no SSH needed)
- Initiate device flow to get a verification code:
curl -s -X POST "https://github.com/login/device/code" \
-H "Accept: application/json" \
-d "client_id=178c6fc778ccc68e1d6a&scope=repo,admin:public_key"
Response contains device_code, user_code, and verification_uri.
-
Tell the user to open
verification_uriand enteruser_code. -
Poll for authorization:
curl -s -X POST "https://github.com/login/oauth/access_token" \
-H "Accept: application/json" \
-d "client_id=178c6fc778ccc68e1d6a&device_code=<DEVICE_CODE>&grant_type=urn:ietf:params:oauth:grant-type:device_code"
Repeat every 5 seconds until access_token appears in response.
- Store credentials:
echo "https://<USERNAME>:<TOKEN>@github.com" > ~/.git-credentials
chmod 600 ~/.git-credentials
git config --global credential.helper store
- Create private repo via API:
curl -s -X POST -H "Authorization: token <TOKEN>" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/user/repos" \
-d '{"name":"wb-sync","private":true,"description":"WorkBuddy config sync"}'
Approach B: Manual setup
- User creates a private repo at https://github.com/new (name:
wb-sync, private, no README) - User creates a Personal Access Token at https://github.com/settings/tokens/new (scope:
repo) - Store credentials as shown above
Step 4: Push to GitHub
cd ~/.workbuddy
git remote add origin https://github.com/<USERNAME>/wb-sync.git
git add -A
git commit -m "init: WorkBuddy config from $(hostname)"
git push -u origin main
Step 5: Install Auto-Sync
- Copy
scripts/auto-sync.shto~/.workbuddy/auto-sync.sh - Copy
scripts/start-sync-daemon.shto~/.workbuddy/start-sync-daemon.sh - Make both executable:
chmod +x ~/.workbuddy/auto-sync.sh ~/.workbuddy/start-sync-daemon.sh - Start the daemon:
# Must use dangerouslyDisableSandbox or osascript to escape sandbox
osascript -e 'do shell script "/bin/bash ~/.workbuddy/start-sync-daemon.sh"'
Step 6: Add Terminal Hook
Append to ~/.bash_profile (or ~/.zshrc):
# WorkBuddy 双机同步快捷命令
alias wbsync='cd ~/.workbuddy && git add -A && git commit -m "sync $(date +%m%d-%H%M)" && git push origin main'
alias wbpull='cd ~/.workbuddy && git pull origin main'
# WorkBuddy 自动同步 — 守护进程保活 + 终端打开时即时同步
if [ -f ~/.workbuddy/start-sync-daemon.sh ]; then
bash ~/.workbuddy/start-sync-daemon.sh 2>/dev/null
fi
if [ -t 1 ] && [ -f ~/.workbuddy/auto-sync.sh ]; then
_wb_now=$(date +%s)
_wb_last=$(cat ~/.workbuddy/.last-auto-sync 2>/dev/null || echo 0)
if [ $((_wb_now - _wb_last)) -gt 300 ]; then
bash ~/.workbuddy/auto-sync.sh >/dev/null 2>&1 &
echo $_wb_now > ~/.workbuddy/.last-auto-sync
fi
unset _wb_now _wb_last
fi
Step 7: Commit and Push Everything
cd ~/.workbuddy
git add -A
git commit -m "add: auto-sync scripts + terminal hook"
git push origin main
Phase 2: Set Up Mac B (Additional Machines)
Prerequisites
- WorkBuddy installed and launched once (to create
~/.workbuddy/directory), then quit - Terminal access
- GitHub reachable (directly or via proxy)
One-Liner Setup
Generate a Mac B setup script using scripts/setup-mac-b.sh.template:
- Replace
<GITHUB_USERNAME>,<GITHUB_TOKEN>,<GITHUB_REPO>with actual values - Upload the script to the GitHub repo (commit + push from Mac A)
- On Mac B, run one command:
curl -sSL -H "Authorization: token <TOKEN>" \
"https://raw.githubusercontent.com/<USERNAME>/wb-sync/main/wb-setup-mac-b.sh" | bash
The script automatically:
- Backs up existing Mac B config (if any)
- Stores GitHub credentials
- Clones the repo into
~/.workbuddy/ - Sets up aliases and terminal hook
- Starts the sync daemon
Alternative: AirDrop
If both Macs are nearby:
- AirDrop
wb-setup-mac-b.shfrom Mac A to Mac B - On Mac B:
bash ~/Downloads/wb-setup-mac-b.sh
Phase 3: Verification
# Check daemon is running
cat ~/.workbuddy/.sync-daemon.pid # should show a PID
kill -0 $(cat ~/.workbuddy/.sync-daemon.pid) && echo "ALIVE" || echo "DEAD"
# Check sync log
tail -5 ~/.workbuddy/.auto-sync.log
# Check git status
cd ~/.workbuddy && git log --oneline -3 && git remote -v
Important Notes
- GitHub SSH port 22 may be blocked in China. Use HTTPS + token instead.
- LaunchAgent (
launchctl load) often fails with "Input/output error" on macOS 12+ under sandbox. The Python subprocess daemon approach instart-sync-daemon.shis more reliable. - Automations (scheduled tasks) are stored in
workbuddy.dband do NOT sync. Recreate them on each machine using theautomation_updatetool. - Project workspace memory (
<project>/.workbuddy/memory/) is NOT inside~/.workbuddy/and must be synced separately (via the project's own Git repo or cloud storage). - Token security: The GitHub token is stored in
~/.git-credentials(chmod 600). For shared machines, consider using a token with limited scope and expiration. - Daemon recovery: After a machine reboot, the daemon restarts automatically
when the user opens a terminal (via the
.bash_profilehook) or when WorkBuddy runs any bash command.
Resources
scripts/
auto-sync.sh— Sync script called by the daemon every 5 minutes (pull → commit → push)start-sync-daemon.sh— Daemon launcher with PID dedup and Python auto-detectionsetup-mac-b.sh.template— Mac B one-click setup script template (replace placeholders before use)
references/
gitignore-template— The.gitignorefile to place in~/.workbuddy/sync-architecture.md— Detailed architecture explanation and troubleshooting
- Downloads
- 3kAll time
- Security audit
- Review
- Last updated
- 3mo ago
- Current version
- v0.1.0
- License
- MIT-0
