Skip to content

Commit 9d449ca

Browse files
committed
Add helper script for linking slime Codex skills
1 parent 97ae715 commit 9d449ca

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ pre-commit run --all-files --show-diff-on-failure --color=always
9999

100100
- For debugging tips, please refer to the [Debugging Guide](docs/en/developer_guide/debug.md)
101101

102+
- To link repository skills into your local Codex skill directory, run `scripts/link_codex_skills.sh`
103+
102104
## FAQ & Acknowledgements
103105

104106
- For frequently asked questions, please see the [Q\&A](docs/en/get_started/qa.md)

scripts/link_codex_skills.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
cat <<'USAGE'
6+
Usage: scripts/link_codex_skills.sh [--remove]
7+
8+
Link slime repository skills from .claude/skills into the local Codex skills directory.
9+
10+
Options:
11+
--remove Remove previously created slime-* symlinks instead of creating them.
12+
-h, --help Show this help message.
13+
USAGE
14+
}
15+
16+
remove_mode=0
17+
case "${1-}" in
18+
"") ;;
19+
--remove) remove_mode=1 ;;
20+
-h|--help) usage; exit 0 ;;
21+
*)
22+
usage >&2
23+
exit 1
24+
;;
25+
esac
26+
27+
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
28+
repo_root="$(cd -- "$script_dir/.." && pwd)"
29+
source_dir="$repo_root/.claude/skills"
30+
codex_home="${CODEX_HOME:-$HOME/.codex}"
31+
target_dir="$codex_home/skills"
32+
prefix="slime-"
33+
34+
if [[ ! -d "$source_dir" ]]; then
35+
echo "Missing source skills directory: $source_dir" >&2
36+
exit 1
37+
fi
38+
39+
mkdir -p "$target_dir"
40+
41+
linked=0
42+
removed=0
43+
44+
while IFS= read -r -d '' skill_dir; do
45+
skill_name="$(basename "$skill_dir")"
46+
link_path="$target_dir/${prefix}${skill_name}"
47+
48+
if (( remove_mode )); then
49+
if [[ -L "$link_path" ]]; then
50+
rm -f "$link_path"
51+
printf 'removed %s\n' "$link_path"
52+
removed=$((removed + 1))
53+
fi
54+
continue
55+
fi
56+
57+
ln -sfn "$skill_dir" "$link_path"
58+
printf 'linked %s -> %s\n' "$link_path" "$skill_dir"
59+
linked=$((linked + 1))
60+
done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
61+
62+
if (( remove_mode )); then
63+
printf 'removed %d slime Codex skill link(s) from %s\n' "$removed" "$target_dir"
64+
else
65+
printf 'linked %d slime Codex skill(s) into %s\n' "$linked" "$target_dir"
66+
fi

0 commit comments

Comments
 (0)