From 34e61b2ccb4223aba6872b9f1daf7604dbb6f895 Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Thu, 21 May 2026 10:08:42 -0700 Subject: [PATCH] sync: copy slash commands to ~/.claude/commands on every sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Phase 5b — one-way repo -> global copy of .claude/commands/*.md after the pull, so the CLI always loads the latest skills. Idempotent (only new/changed files) and soft-failing (never aborts a sync). Fixes the drift where the global command set lagged the repo (e.g. /syncro was ~3 weeks stale, and feature-request/forum-post/inject-standards/shape-spec were missing globally) because the automated script skipped the doc's Phase 3. Co-Authored-By: Claude Opus 4.7 (1M context) --- .claude/scripts/sync.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.claude/scripts/sync.sh b/.claude/scripts/sync.sh index 59c2b8b..604dd88 100755 --- a/.claude/scripts/sync.sh +++ b/.claude/scripts/sync.sh @@ -224,6 +224,34 @@ if [ "$INCOMING_COUNT" -gt 0 ] && [ -n "$LOCAL_BEFORE" ]; then fi fi +# Phase 5b: Apply config — sync slash commands to the global Claude dir. +# The repo's .claude/commands/ is canonical; this keeps ~/.claude/commands current +# so the CLI loads the latest skills without a manual copy. One-way (repo -> global), +# idempotent (only copies new/changed files), and soft-fails so it never aborts a sync. +echo "" +echo "=== Phase 5b: Apply config (commands -> global) ===" +GLOBAL_CMD_DIR="$HOME/.claude/commands" +set +e +mkdir -p "$GLOBAL_CMD_DIR" +CMD_UPDATED=0 +CMD_NAMES="" +for src in .claude/commands/*.md; do + [ -f "$src" ] || continue + dst="$GLOBAL_CMD_DIR/$(basename "$src")" + if [ ! -f "$dst" ] || ! cmp -s "$src" "$dst"; then + if cp "$src" "$dst"; then + CMD_UPDATED=$((CMD_UPDATED + 1)) + CMD_NAMES="$CMD_NAMES $(basename "$src")" + fi + fi +done +set -e +if [ "$CMD_UPDATED" -gt 0 ]; then + echo -e "${GREEN}[OK]${NC} Commands synced to global: $CMD_UPDATED updated —$CMD_NAMES" +else + echo -e "${GREEN}[OK]${NC} Global commands already current." +fi + # Phase 6: Vault sync echo "" echo "=== Phase 6: Vault sync ==="