sync: copy slash commands to ~/.claude/commands on every sync
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 ==="
|
||||
|
||||
Reference in New Issue
Block a user