Files
dotfiles/claude/install.sh
T
David F GliddenandClaude Opus 4.7 119285cf43 claude: back up custom skills, memory, and settings with symlink pattern
The ~/.claude/ directory was previously local-only — a machine wipe
would have lost the accumulated memory, custom skills, and settings.
This commit moves the durable parts into dotfiles with the same
symlink-to-home pattern used for CLAUDE.md, PENDING.md, REVIEWED.md,
and L2-BOOTSTRAP.md.

Preserved (symlinked from ~/.claude/* into here):
  skills/audit/              — thinking-folder drift scanner
  skills/symmetria/          — practice-of-return discipline
  skills/vault-update-people/ — Obsidian People-file maintainer
  skills/wake-up/            — session restoration
  skills/wrap-up/            — session state capture
  memory/                    — 55+ memory files (MEMORY.md, sessions,
                               ledgers, project state, feedback, etc.)
  settings/settings.json     — user preferences (hooks, flags, no secrets)

Deliberately NOT backed up:
  settings.local.json   — contains operational secrets (HF_TOKEN,
                           SSH password in expect scripts); by naming
                           convention, *.local.* is not synced.
                           Needs separate review and probable rotation.
  sessions/, history.jsonl, caches, telemetry — ephemeral
  plugins/, marketplace skills and agents — reinstallable

The working copies at ~/.claude/skills/* and
~/.claude/projects/-Users-davidglidden/memory are symlinks into this
directory, so every write flows here automatically. install.sh
recreates the symlinks on a fresh machine.

FOLLOW-ON (flagged, not in this commit):
  settings.local.json contains a HuggingFace token and an SSH password
  as plaintext strings inside allowed Bash command patterns. These
  should be rotated and moved to secure storage (keychain / pass /
  env file outside the settings file).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 13:51:04 +02:00

81 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Restore Claude Code's custom skills, memory, and settings from dotfiles.
# Run once on a fresh machine after cloning dotfiles.
#
# Idempotent: skips anything already in place. Safe to re-run.
set -euo pipefail
DOTFILES_CLAUDE="${HOME}/dotfiles/claude"
CLAUDE_HOME="${HOME}/.claude"
echo "Restoring Claude Code configuration from ${DOTFILES_CLAUDE}..."
echo ""
# Sanity check
if [ ! -d "${DOTFILES_CLAUDE}" ]; then
echo "Error: ${DOTFILES_CLAUDE} not found. Clone dotfiles first."
exit 1
fi
# 1. Ensure .claude structure exists
mkdir -p "${CLAUDE_HOME}/skills"
mkdir -p "${CLAUDE_HOME}/projects/-Users-davidglidden"
# 2. Symlink custom skills
echo "Linking custom skills..."
for skill in audit symmetria vault-update-people wake-up wrap-up; do
src="${DOTFILES_CLAUDE}/skills/${skill}"
dst="${CLAUDE_HOME}/skills/${skill}"
if [ ! -d "$src" ]; then
echo " skip: ${skill} (not in dotfiles)"
continue
fi
if [ -L "$dst" ]; then
echo " skip: ${skill} (already a symlink)"
continue
fi
if [ -e "$dst" ]; then
echo " WARN: ${skill} exists at ${dst} and is not a symlink; leaving untouched"
continue
fi
ln -s "$src" "$dst"
echo " linked: ${dst} -> ${src}"
done
# 3. Symlink memory tree
echo ""
echo "Linking memory tree..."
memory_src="${DOTFILES_CLAUDE}/memory"
memory_dst="${CLAUDE_HOME}/projects/-Users-davidglidden/memory"
if [ -L "$memory_dst" ]; then
echo " skip: memory (already a symlink)"
elif [ -e "$memory_dst" ]; then
echo " WARN: ${memory_dst} exists and is not a symlink; leaving untouched"
echo " If you want to merge: back up ${memory_dst}, remove it, then re-run."
else
ln -s "$memory_src" "$memory_dst"
echo " linked: ${memory_dst} -> ${memory_src}"
fi
# 4. Copy settings.json (does not overwrite existing)
echo ""
echo "Restoring settings.json..."
settings_src="${DOTFILES_CLAUDE}/settings/settings.json"
settings_dst="${CLAUDE_HOME}/settings.json"
if [ -e "$settings_dst" ]; then
echo " skip: settings.json (already at ${settings_dst}; diff manually if you want to merge)"
else
cp "$settings_src" "$settings_dst"
echo " copied: ${settings_dst}"
fi
echo ""
echo "Done."
echo ""
echo "NOT restored by design:"
echo " - settings.local.json (may contain secrets; restore manually from secure backup)"
echo " - session transcripts (ephemeral)"
echo " - marketplace-installed skills and agents (reinstall via plugin system)"
echo " - caches, telemetry, runtime state (regenerate)"