config-sync

SKILL.md

Config Sync Protocol

Trigger keywords: sync config, sync claude, rsync claude


IMPORTANT: When to Use This Skill vs The Script

For routine syncing, just run the script directly:

~/mcp-recover.sh   # Run on primary - handles everything automatically

The automated script is MORE RELIABLE than asking Claude because:

  • It's deterministic (same behavior every time)
  • No risk of Claude forgetting adaptation rules
  • Already has hostname checks built in
  • Runs daily via cron anyway

Use this skill ONLY for:

  • Complex one-off changes requiring judgment
  • Debugging sync issues
  • Initial setup of new machines

For simple "sync now" requests: Tell the user to run ~/mcp-recover.sh on primary.


CRITICAL: Run from PRIMARY only

This skill MUST only be executed on primary. Never sync config FROM a satellite machine.

Machine Role Action
primary SOURCE/MASTER Pushes config TO satellites
host1 SATELLITE Receives FROM primary only
host2 SATELLITE Receives FROM primary only
hostname SATELLITE Receives FROM primary only

What Gets Synced

Item Treatment
~/.claude/CLAUDE.md Direct copy
~/.claude/skills/ Direct copy (rsync --delete)
~/.claude/agents/ Direct copy (rsync --delete)
~/.claude/commands/ Direct copy (except lm.md - see below)
~/.claude/aw-hook.sh Direct copy
/lm command ADAPTED - path translation for NFS

Excludes: settings*.json, .credentials.json, history.jsonl, projects/, plugins/


Sync Commands

Standard configs (run all in parallel)

# Sync CLAUDE.md, skills, agents, commands (except lm.md), aw-hook.sh
for host in host1 host2 hostname; do
    rsync -av --delete --exclude='lm.md' \
        -e 'sshpass -p khis9 ssh -o StrictHostKeyChecking=no' \
        ~/.claude/CLAUDE.md ~/.claude/skills ~/.claude/agents \
        ~/.claude/commands ~/.claude/aw-hook.sh \
        user@${host}:~/.claude/ &
done
wait

/lm command (path translation for NFS mounts)

# Translates /path/to/source/ → /path/to/source/coding/
for host in host1 host2 hostname; do
    sed 's|/path/to/source/|/path/to/source/coding/|g' ~/.claude/commands/lm.md | \
        sshpass -p 'khis9' ssh -o StrictHostKeyChecking=no user@${host} \
        'cat > ~/.claude/commands/lm.md' &
done
wait

Quick Reference

When user says "sync claude config":

STEP 0 - MANDATORY HOSTNAME CHECK:

# ALWAYS run this first before any sync operations
if [[ "$(hostname)" != "primary" ]]; then
    echo "ERROR: Config sync must run from primary, not $(hostname)"
    echo "This machine is a SATELLITE - it receives config, not pushes it."
    exit 1
fi
echo "✓ Confirmed on primary - proceeding with sync"

Then:

  1. Run standard config sync (CLAUDE.md, skills, agents, commands, aw-hook.sh)
  2. Run /lm path translation
  3. Report success/failure for each machine

If hostname check fails: Stop immediately. Do not attempt to sync from a satellite machine.

Weekly Installs
1
GitHub Stars
28
First Seen
11 days ago
Installed on
amp1
cline1
openclaw1
opencode1
cursor1
kimi-cli1