Skip to content

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

chmod +x .claude/hooks/sync-memory.sh

2. Test the script manually

./.claude/hooks/sync-memory.sh

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:

launchctl unload ~/Library/LaunchAgents/com.claude.memory-sync.plist


Windows — Task Scheduler

Option 1: GUI (easier)

  1. Open Task Scheduler
  2. Click Create Task (right sidebar)
  3. General tab:
  4. Name: Claude Memory Sync
  5. Check: "Run with highest privileges"

  6. Triggers tab:

  7. Click New
  8. Begin the task: On a schedule
  9. Repeat task every: 5 minutes
  10. Click OK

  11. Actions tab:

  12. Click New
  13. Program/script: C:\Program Files\Git\bin\bash.exe
  14. Add arguments: C:\Users\<YourUsername>\Desktop\claude_pentesting_skills\.claude\hooks\sync-memory.sh
  15. Click OK

  16. Settings tab:

  17. Check: "Run task as soon as possible after a scheduled start is missed"
  18. 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:

powershell -ExecutionPolicy Bypass -File C:\path\to\sync-memory.ps1


Manual Usage

Anytime you want to sync immediately:

# macOS / Windows (Git Bash)
cd ~/Desktop/claude_pentesting_skills
./.claude/hooks/sync-memory.sh

How It Works

  1. Reads memory from: ~/.claude/projects/.../memory/
  2. Copies to repo: docs/memory/
  3. Auto-commits if changes detected
  4. Pushes to remote (if available)
  5. 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?

chmod +x .claude/hooks/sync-memory.sh

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:

git log --oneline docs/memory/ | head -5

Should show recent auto-commits with timestamps.