Sync global ~/.claude/ config to sandbox (settings, memory, CLAUDE.md)

This commit is contained in:
Harivansh Rathi 2026-03-09 23:26:11 -07:00
parent ec7919c4ba
commit 531d5bfc16
2 changed files with 22 additions and 4 deletions

View file

@ -108,9 +108,9 @@ rsync -avz --progress \
"$(pwd)/" "node@$HANDLE:$REMOTE_WORKSPACE/" "$(pwd)/" "node@$HANDLE:$REMOTE_WORKSPACE/"
``` ```
### Step 8: Sync the Claude session history ### Step 8: Sync the Claude session and config
Transfer the local `.claude/` directory (session history, settings, memory) so the remote Claude session has full context: Transfer the project-level `.claude/` directory (session history, project memory) if it exists:
```bash ```bash
rsync -avz --progress \ rsync -avz --progress \
@ -118,6 +118,16 @@ rsync -avz --progress \
"$(pwd)/.claude/" "node@$HANDLE:$REMOTE_WORKSPACE/.claude/" "$(pwd)/.claude/" "node@$HANDLE:$REMOTE_WORKSPACE/.claude/"
``` ```
Also sync the global `~/.claude/` directory (global settings, global memory, credentials, CLAUDE.md):
```bash
rsync -avz --progress \
-e "ssh $SSH_OPTS" \
"$HOME/.claude/" "node@$HANDLE:/home/node/.claude/"
```
Both are needed: the project-level `.claude/` has session history for `--continue`, and the global `~/.claude/` has settings, global memory, and the user's global CLAUDE.md instructions.
### Step 9: Transfer environment variables ### Step 9: Transfer environment variables
Capture relevant env vars (especially ANTHROPIC_API_KEY) and send them to the sandbox: Capture relevant env vars (especially ANTHROPIC_API_KEY) and send them to the sandbox:

View file

@ -86,14 +86,22 @@ rsync -avz --progress \
-e "$RSYNC_SSH" \ -e "$RSYNC_SSH" \
"$LOCAL_DIR/" "node@$HANDLE:$REMOTE_WORKSPACE/" "$LOCAL_DIR/" "node@$HANDLE:$REMOTE_WORKSPACE/"
# --- Sync Claude session --- # --- Sync project-level Claude session ---
if [ -d "$LOCAL_DIR/.claude" ]; then if [ -d "$LOCAL_DIR/.claude" ]; then
echo "[offload] Syncing Claude session data..." echo "[offload] Syncing project Claude session data..."
rsync -avz --progress \ rsync -avz --progress \
-e "$RSYNC_SSH" \ -e "$RSYNC_SSH" \
"$LOCAL_DIR/.claude/" "node@$HANDLE:$REMOTE_WORKSPACE/.claude/" "$LOCAL_DIR/.claude/" "node@$HANDLE:$REMOTE_WORKSPACE/.claude/"
fi fi
# --- Sync global ~/.claude config (settings, memory, global session history) ---
if [ -d "$HOME/.claude" ]; then
echo "[offload] Syncing global ~/.claude config..."
rsync -avz --progress \
-e "$RSYNC_SSH" \
"$HOME/.claude/" "node@$HANDLE:/home/node/.claude/"
fi
# --- Transfer env vars --- # --- Transfer env vars ---
echo "[offload] Transferring environment variables..." echo "[offload] Transferring environment variables..."
env | grep -v '^_=' | grep -v '^SHELL=' | grep -v '^TERM_' | grep -v '^SSH_' | \ env | grep -v '^_=' | grep -v '^SHELL=' | grep -v '^TERM_' | grep -v '^SSH_' | \