-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·61 lines (55 loc) · 1.86 KB
/
install
File metadata and controls
executable file
·61 lines (55 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# Symlink every skill in skills/* AND every sub-skill in <bundle>/skills/*
# into ~/.claude/skills/ so Claude Code discovers them.
# A "bundle" is any top-level directory (other than skills/) that has its own
# skills/<sub-skill>/ tree plus helper files (e.g. shared/*.md) at the bundle
# root, which sub-skills load via relative paths resolved through the symlink.
# Idempotent: re-run after pulling updates.
set -euo pipefail
REPO="$(cd "$(dirname "$0")" && pwd)"
TARGET="$HOME/.claude/skills"
mkdir -p "$TARGET"
link_skill() {
local skill="$1"
local name; name="$(basename "$skill")"
local link="$TARGET/$name"
if [[ -e "$link" && ! -L "$link" ]]; then
echo "skip: $link exists and is not a symlink (manual cleanup required)"
return
fi
ln -sfn "$skill" "$link"
echo "linked: /$name -> $skill"
}
# Forward-link standalone skills
if compgen -G "$REPO/skills/*/" >/dev/null; then
for skill in "$REPO"/skills/*/; do
link_skill "$skill"
done
fi
# Forward-link bundle sub-skills (<bundle>/skills/<sub-skill>/).
# Bundles keep their own shared/ files; sub-skills reference them as
# "shared/core.md from the bundle root", which resolves through the symlink.
for bundle in "$REPO"/*/; do
name="$(basename "$bundle")"
[[ "$name" == "skills" ]] && continue
compgen -G "${bundle}skills/*/" >/dev/null || continue
for skill in "${bundle}skills"/*/; do
link_skill "$skill"
done
done
# Clean stale symlinks pointing into this repo whose targets no longer exist
# (e.g. after renaming or deleting a skill directory).
for link in "$TARGET"/*; do
[[ -L "$link" ]] || continue
target="$(readlink "$link")"
case "$target" in
"$REPO"/*)
if [[ ! -e "$target" ]]; then
rm "$link"
echo "removed stale: $link -> $target"
fi
;;
esac
done
echo
echo "Done. Restart your Claude Code session to pick up new skills."