360 Secure SkillHub
360 安全技能中心

Workspace Sync

用零 token 的 bash 脚本在多台机器间同步 Agent 工作区(skills、memory、配置文件):sync-all 先提交并推送 Git 共享仓库,再经 rsync 同步到树莓派,可选同步 Mac;支持 --dry-run 预览、按清单排除机密与大文件、Cron 或 pre-commit 触发;冲突需手动解决,不含自动备份。

h-mascot
h-mascot
热度 22.88
最近更新 2026-06-04 00:18:08
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / 工作流 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add ec-workspace-sync
Metadata
name
workspace-sync
description
Sync agent workspaces (skills, memory, config) across machines using Git or rsync. Use when you need to synchronize agent workspaces between Ada, Spock, and Scotty across local machines, Pi, and Mac environments. Zero-token bash scripts for selective sync with secrets exclusion.

Workspace Sync

Synchronize agent workspaces across multiple machines using zero-token bash scripts. Supports Git-based and rsync-based workflows with selective file exclusion.

Architecture

Agents:

  • Ada - Primary agent (ada-gateway)
  • Spock - Research agent (spock workspace)
  • Scotty - Operations agent (scotty workspace)

Sync Targets:

  • Local machines (ada-gateway, spock, scotty)
  • Pi (Raspberry Pi)
  • Mac (macOS machine)

Shared Repository: henrino3/clawd (Git-based sync backbone)

What Gets Synced

  • skills/ - Custom skills and scripts
  • memory/ - Daily memory files
  • memory.md - Long-term memory
  • AGENTS.md, SOUL.md, IDENTITY.md - Agent configuration
  • TOOLS.md - Tool notes

What Gets Excluded

See config/sync-exclude.txt for the full list:

  • Secrets and credentials (.env, *.key, *.pem)
  • Large files (*.mp4, *.zip, *.tar.gz)
  • System files (.DS_Store, node_modules/)
  • Local runtime files (logs/, *.pid)

Usage

Sync to Pi

Push current workspace to Pi:

./scripts/sync-to-pi.sh

Options:

  • -n, --dry-run - Preview changes without applying
  • -h, --host HOSTNAME - Override Pi hostname (default: pi@raspberrypi.local)

Sync from Pi

Pull workspace from Pi to local:

./scripts/sync-from-pi.sh

Options:

  • -n, --dry-run - Preview changes without applying
  • -h, --host HOSTNAME - Override Pi hostname

Sync All

Synchronize across all configured machines:

./scripts/sync-all.sh

This script:

  1. Commits local changes to Git
  2. Pushes to henrino3/clawd
  3. Syncs to Pi via rsync
  4. Optionally syncs to Mac (if configured)

Git Workflow

The shared repository provides version control and conflict resolution:

# On any machine:
cd ~/clawd
git pull                    # Get latest changes
# Make modifications
git add .
git commit -m "Update"
git push                    # Share with other machines

Rsync vs Git

Use Git for:

  • Tracked changes with history
  • Conflict resolution
  • Collaboration across multiple agents

Use rsync for:

  • Fast one-way sync to Pi
  • Selective sync with exclusions
  • Backup without version control

Conflict Resolution

When conflicts occur:

  1. Git conflicts - Resolve manually in affected files, commit
  2. Rsync conflicts - Newer files overwrite older (use --dry-run first)

Setup Requirements

Pi SSH Access

Ensure SSH key authentication is configured:

ssh-copy-id pi@raspberrypi.local

Git Configuration

Clone the shared repository on each machine:

git clone https://github.com/henrino3/clawd.git ~/clawd
cd ~/clawd
git config user.name "Your Name"
git config user.email "your@email.com"

Environment Variables

Optional overrides in ~/.bashrc or ~/.zshrc:

export CLAWD_PI_HOST="pi@192.168.1.100"  # Override Pi hostname
export CLAWD_MAC_HOST="mac@macmini.local"  # Mac sync target

Automation

Cron Jobs

Sync automatically every hour:

0 * * * * cd ~/clawd/skills/workspace-sync && ./scripts/sync-all.sh >> ~/clawd/logs/sync.log 2>&1

Pre-commit Hook

Auto-sync on workspace changes:

# ~/clawd/.git/hooks/pre-commit
#!/bin/bash
cd ~/clawd/skills/workspace-sync
./scripts/sync-all.sh

Troubleshooting

Permission Denied

chmod 600 ~/.ssh/id_rsa

Rsync Connection Failure

Check Pi is reachable:

ping raspberrypi.local
ssh pi@raspberrypi.local

Git Push Rejected

Pull and merge first:

git pull --rebase
git push

Safety

  • Always test with --dry-run first
  • Secrets are excluded by default (see config/sync-exclude.txt)
  • Backups are not automatic - Consider external backup strategy
  • Conflicts require manual resolution - Review carefully before pushing