Auto-Sync Claude Memory to Repo¶
This setup ensures your Claude memory (MEMORY.md, gap-analysis.md) is automatically synced to the repo on both Mac and Windows.
Quick Start¶
1. Make script executable¶
2. Test the script manually¶
Should output:
[*] Syncing memory from: /Users/simone/.claude/projects/...
[*] Memory files copied to: ./docs/memory
[✓] Memory sync complete
Automation Setup¶
macOS — LaunchAgent¶
Create ~/Library/LaunchAgents/com.claude.memory-sync.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.claude.memory-sync</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/simone/Desktop/claude_pentesting_skills/.claude/hooks/sync-memory.sh</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
<!-- Runs every 5 minutes (300 seconds) -->
<key>StandardOutPath</key>
<string>/tmp/claude-memory-sync.log</string>
<key>StandardErrorPath</key>
<string>/tmp/claude-memory-sync-error.log</string>
</dict>
</plist>
Install & enable:
# Copy the file
cp ~/Desktop/com.claude.memory-sync.plist ~/Library/LaunchAgents/
# Load it
launchctl load ~/Library/LaunchAgents/com.claude.memory-sync.plist
# Verify it's running
launchctl list | grep claude.memory-sync
# Check logs
tail -f /tmp/claude-memory-sync.log
To disable:
Windows — Task Scheduler¶
Option 1: GUI (easier)
- Open Task Scheduler
- Click Create Task (right sidebar)
- General tab:
- Name:
Claude Memory Sync -
Check: "Run with highest privileges"
-
Triggers tab:
- Click New
- Begin the task:
On a schedule - Repeat task every:
5 minutes -
Click OK
-
Actions tab:
- Click New
- Program/script:
C:\Program Files\Git\bin\bash.exe - Add arguments:
C:\Users\<YourUsername>\Desktop\claude_pentesting_skills\.claude\hooks\sync-memory.sh -
Click OK
-
Settings tab:
- Check: "Run task as soon as possible after a scheduled start is missed"
- Click OK
Option 2: PowerShell script
Create sync-memory.ps1:
# Run the sync script every 5 minutes
while ($true) {
& "C:\Users\<YourUsername>\Desktop\claude_pentesting_skills\.claude\hooks\sync-memory.sh"
Start-Sleep -Seconds 300
}
Run in PowerShell as Admin:
Manual Usage¶
Anytime you want to sync immediately:
How It Works¶
- Reads memory from:
~/.claude/projects/.../memory/ - Copies to repo:
docs/memory/ - Auto-commits if changes detected
- Pushes to remote (if available)
- Logs to
/tmp/claude-memory-sync.log(Mac) or stdout (Windows)
Troubleshooting¶
Script not running on schedule?
- Check logs: tail -f /tmp/claude-memory-sync.log
- Verify repo path is correct in script
- Ensure git has push credentials (SSH key or token)
Permission denied?
Want to change sync interval?
- Mac: Edit the <integer>300</integer> in plist (seconds)
- Windows: Edit the Task Scheduler trigger
What Gets Synced¶
✅ docs/memory/MEMORY.md — Main memory bank
✅ docs/memory/gap-analysis.md — Vulnerability analysis
✅ Any new .md files in Claude memory directory
Verify It's Working¶
Check that memory updates appear in the repo:
Should show recent auto-commits with timestamps.