From b7bf8cc3c165a0c3de8343485d39fb9803ab0cb0 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Tue, 28 Apr 2026 12:37:23 +0100 Subject: [PATCH] Enhance link-skills.sh to check for symlink conflicts and provide user guidance --- scripts/link-skills.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/link-skills.sh b/scripts/link-skills.sh index ffdca36..a988256 100755 --- a/scripts/link-skills.sh +++ b/scripts/link-skills.sh @@ -6,6 +6,21 @@ set -euo pipefail REPO="$(cd "$(dirname "$0")/.." && pwd)" DEST="$HOME/.claude/skills" + +# If ~/.claude/skills is a symlink that resolves into this repo, we'd end up +# writing the per-skill symlinks back into the repo's own skills/ tree. Detect +# and bail out instead of polluting the working copy. +if [ -L "$DEST" ]; then + resolved="$(readlink -f "$DEST")" + case "$resolved" in + "$REPO"|"$REPO"/*) + echo "error: $DEST is a symlink into this repo ($resolved)." >&2 + echo "Remove it (rm \"$DEST\") and re-run; the script will recreate it as a real dir." >&2 + exit 1 + ;; + esac +fi + mkdir -p "$DEST" find "$REPO/skills" -name SKILL.md -not -path '*/node_modules/*' -print0 |