mirror of
https://github.com/mattpocock/skills.git
synced 2026-04-30 14:03:53 +07:00
39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Links all skills in the repository to ~/.claude/skills, so that
|
|
# they can be used by the local Claude CLI.
|
|
|
|
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 |
|
|
while IFS= read -r -d '' skill_md; do
|
|
src="$(dirname "$skill_md")"
|
|
name="$(basename "$src")"
|
|
target="$DEST/$name"
|
|
|
|
if [ -e "$target" ] && [ ! -L "$target" ]; then
|
|
rm -rf "$target"
|
|
fi
|
|
|
|
ln -sfn "$src" "$target"
|
|
echo "linked $name -> $src"
|
|
done
|