Files
custom-claude-skills/scripts/install.sh
Paul O'Reilly 93a47bc0a5 feat: add --all-profiles flag to install.sh
Loops over ~/.claude and all ~/.claude-* directories, installing
skills into each. Default (no flag) retains the existing behaviour
of installing only into the active profile.
2026-10-12 16:11:18 +13:00

84 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Symlink all skills from this repo into Claude profile skill directories.
#
# Default: installs into the active profile (CLAUDE_CONFIG_DIR or ~/.claude).
# --all-profiles: installs into every ~/.claude and ~/.claude-* profile found.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
SKILLS_SRC="$REPO_DIR/skills"
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
ALL_PROFILES=0
for arg in "$@"; do
[[ "$arg" == "--all-profiles" ]] && ALL_PROFILES=1
done
# Build target list
declare -a TARGET_DIRS=()
if (( ALL_PROFILES )); then
# Active profile first, then all others
[[ -d "$HOME/.claude" ]] && TARGET_DIRS+=("$HOME/.claude")
for d in "$HOME"/.claude-*/; do
[[ -d "$d" ]] || continue
# Skip backup/json files that match the glob
[[ "$d" == *.json/ || "$d" == *.backup/ ]] && continue
TARGET_DIRS+=("${d%/}")
done
else
TARGET_DIRS=("${CLAUDE_CONFIG_DIR:-$HOME/.claude}")
fi
total_installed=0
total_skipped=0
install_to() {
local skills_dst="$1/skills"
mkdir -p "$skills_dst"
local installed=0 skipped=0
for skill_dir in "$SKILLS_SRC"/*/; do
[ -d "$skill_dir" ] || continue
skill_name="$(basename "$skill_dir")"
target="$skills_dst/$skill_name"
if [ -L "$target" ]; then
existing="$(readlink -f "$target")"
expected="$(readlink -f "$skill_dir")"
if [ "$existing" = "$expected" ]; then
skipped=$((skipped + 1))
continue
else
echo -e " ${YELLOW}UPDATE${NC} $skill_name"
rm "$target"
fi
elif [ -e "$target" ]; then
echo -e " ${YELLOW}SKIP${NC} $skill_name (non-symlink — remove manually to update)"
skipped=$((skipped + 1))
continue
fi
ln -s "$skill_dir" "$target"
echo -e " ${GREEN}INSTALLED${NC} $skill_name"
installed=$((installed + 1))
done
total_installed=$((total_installed + installed))
total_skipped=$((total_skipped + skipped))
echo " → $installed installed, $skipped already up to date"
}
for profile_dir in "${TARGET_DIRS[@]}"; do
echo "Profile: $profile_dir"
install_to "$profile_dir"
echo ""
done
echo "Done. Total installed: $total_installed, skipped: $total_skipped"
echo "Skills are available as slash commands in Claude Code (e.g. /reflect M8)"