Skip to content

BeastMasterGrinder/claude-code-plan-syncer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Claude Plan Sync Service

Automatically bidirectionally syncs plan files between ~/.claude-glm/plans/ and ~/.claude/plans/ using Unison file synchronizer.

Features

  • Bidirectional sync: Changes in either directory are synced to the other
  • No infinite loops: Unison maintains state to track which side originated changes
  • Conflict resolution: Automatically keeps the newer version of files
  • Real-time monitoring: Uses inotifywait to detect changes immediately
  • Runs as a service: Automatically starts on login via systemd

Installation

1. Install Dependencies

sudo apt update
sudo apt install unison inotify-tools

2. Install the Service

The service files are already in place. Just enable and start it:

# Reload systemd to recognize the service
systemctl --user daemon-reload

# Enable auto-start on login
systemctl --user enable claude-plan-sync.service

# Start the service now
systemctl --user start claude-plan-sync.service

Usage

Aliases (add to your ~/.bashrc)

These aliases are already configured - reload your shell with source ~/.bashrc:

# Service control
plan-sync-start       # Start the sync service
plan-sync-stop        # Stop the sync service
plan-sync-restart     # Restart the sync service
plan-sync-status      # View service status
plan-sync-enable      # Enable auto-start on login
plan-sync-disable     # Disable auto-start

# Logs
plan-sync-logs        # Follow the sync activity log
plan-sync-logs-all    # Follow the full service log

Quick Start

# Start the service
plan-sync-start

# Check if it's running
plan-sync-status

# Watch sync activity in real-time
plan-sync-logs

How It Works

  1. Monitoring: The service uses inotifywait to watch both directories for changes (create, modify, move, delete)
  2. Sync Trigger: When a change is detected, Unison runs to sync both directories
  3. State Tracking: Unison stores state in ~/.unison/ to remember:
    • The last sync state of each file
    • Which replica originated each change
    • This prevents infinite sync loops

Directories

  • Source A: ~/.claude-glm/plans/
  • Source B: ~/.claude/plans/

Conflict Resolution

When the same file is modified on both sides between syncs:

  • Unison keeps the newer version (based on modification time)
  • The older version is overwritten
  • No backup copies are kept (configurable)

File Locations

File Location
Sync script ~/.claude-sync-plans/plan-sync.sh
Service file ~/.config/systemd/user/claude-plan-sync.service
Sync log ~/.claude-sync-plans/sync.log
Service log ~/.claude-sync-plans/service.log
Unison state ~/.unison/
Unison profile ~/.unison/plans.prf

Troubleshooting

Service won't start

# Check the service status for errors
plan-sync-status

# View error logs
journalctl --user -u claude-plan-sync.service -n 50

Files not syncing

# Check if inotify-tools is installed
which inotifywait

# If not, install it:
sudo apt install inotify-tools

# Restart the service
plan-sync-restart

Manually trigger a sync

# Run unison directly
unison plans

View detailed sync info

# Run unison with verbose output
unison plans -verbose

Reset Unison state

If sync is behaving strangely, you can reset Unison's state:

# Stop the service first
plan-sync-stop

# Remove Unison state (will rescan all files on next sync)
rm -f ~/.unison/plans*

# Restart service
plan-sync-start

Unison Profile

The service uses a profile at ~/.unison/plans.prf with these settings:

root = ~/.claude-glm/plans
root = ~/.claude/plans
batch = true          # No prompts
auto = true           # Auto-accept non-conflicting changes
prefer = newer        # Keep newer version on conflicts
fastcheck = true      # Quick detection using size/modtime
copyonconflict = false # Don't create conflict copies

To customize, edit ~/.unison/plans.prf and restart the service.

Manual Sync Without Service

If you prefer to sync manually instead of running a service:

# Just run unison with the profile
unison plans

Logs

Sync Activity Log

Shows what files are being synced:

tail -f ~/.claude-sync-plans/sync.log

Service Output/Error Log

Shows service-level messages:

tail -f ~/.claude-sync-plans/service.log

Systemd Journal

Full systemd logs:

journalctl --user -u claude-plan-sync.service -f

About

This repo is for mad lads running multiple LLMs on claude code who want to sync their plans for their vibing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages