this repo has no description
1#!/usr/bin/env bash
2# Symlinks skills, commands, scripts, and plugins from this monorepo to ~/.claude/
3# Also installs Codex user-level skills, scripts, and prompts in ~/.codex/
4
5set -euo pipefail
6
7MONOREPO="$(cd "$(dirname "$0")" && pwd)"
8CLAUDE_DIR="$HOME/.claude"
9CODEX_DIR="$HOME/.codex"
10
11mkdir -p "$CLAUDE_DIR/skills" "$CLAUDE_DIR/commands" "$CLAUDE_DIR/scripts" "$CLAUDE_DIR/plugins"
12mkdir -p "$CODEX_DIR/skills" "$CODEX_DIR/scripts" "$CODEX_DIR/prompts"
13
14# Link skills (each skill is a directory)
15for skill in "$MONOREPO/skills"/*/; do
16 name=$(basename "$skill")
17 target="$CLAUDE_DIR/skills/$name"
18 if [ -L "$target" ]; then
19 echo "Updating: $name"
20 rm "$target"
21 elif [ -e "$target" ]; then
22 echo "Skipping $name (exists and is not a symlink)"
23 continue
24 fi
25 ln -s "$skill" "$target"
26 echo "Linked: skills/$name"
27
28 # Codex user-level skills
29 codex_target="$CODEX_DIR/skills/$name"
30 if [ -L "$codex_target" ]; then
31 echo "Updating (codex): $name"
32 rm "$codex_target"
33 elif [ -e "$codex_target" ]; then
34 echo "Skipping $name for codex (exists and is not a symlink)"
35 else
36 ln -s "$skill" "$codex_target"
37 echo "Linked (codex): skills/$name"
38 fi
39done
40
41# Link commands (each command is a .md file)
42for cmd in "$MONOREPO/commands"/*.md; do
43 [ -e "$cmd" ] || continue
44 name=$(basename "$cmd")
45 target="$CLAUDE_DIR/commands/$name"
46 if [ -L "$target" ]; then
47 echo "Updating: $name"
48 rm "$target"
49 elif [ -e "$target" ]; then
50 echo "Skipping $name (exists and is not a symlink)"
51 continue
52 fi
53 ln -s "$cmd" "$target"
54 echo "Linked: commands/$name"
55
56 # Codex compatibility layer: generate prompt files from Claude commands
57 codex_prompt="$CODEX_DIR/prompts/$name"
58 {
59 cat <<'EOF'
60---
61description: "Generated from claude-code-skills-monorepo commands for Codex."
62---
63
64EOF
65 # Rewrite Claude paths for Codex
66 sed -e 's#~/.claude#~/.codex#g' -e 's#\.claude#\.codex#g' "$cmd"
67 } > "$codex_prompt"
68 echo "Generated (codex prompt): prompts/$name"
69done
70
71# Link scripts (.sh and .py files)
72for script in "$MONOREPO/scripts"/*.sh "$MONOREPO/scripts"/*.py; do
73 [ -e "$script" ] || continue
74 name=$(basename "$script")
75 target="$CLAUDE_DIR/scripts/$name"
76 if [ -L "$target" ]; then
77 echo "Updating: $name"
78 rm "$target"
79 elif [ -e "$target" ]; then
80 echo "Skipping $name (exists and is not a symlink)"
81 continue
82 fi
83 ln -s "$script" "$target"
84 echo "Linked: scripts/$name"
85
86 # Codex user-level scripts
87 codex_target="$CODEX_DIR/scripts/$name"
88 if [ -L "$codex_target" ]; then
89 echo "Updating (codex): $name"
90 rm "$codex_target"
91 elif [ -e "$codex_target" ]; then
92 echo "Skipping $name for codex (exists and is not a symlink)"
93 else
94 ln -s "$script" "$codex_target"
95 echo "Linked (codex): scripts/$name"
96 fi
97done
98
99# Link plugins (each plugin is a directory)
100for plugin in "$MONOREPO/plugins"/*/; do
101 [ -d "$plugin" ] || continue
102 name=$(basename "$plugin")
103 target="$CLAUDE_DIR/plugins/$name"
104 if [[ -L "$target" ]]; then
105 echo "Updating: $name"
106 rm "$target"
107 elif [[ -e "$target" ]]; then
108 echo "Skipping $name (exists and is not a symlink)"
109 continue
110 fi
111 ln -s "$plugin" "$target"
112 echo "Linked: plugins/$name"
113
114 # Run plugin's install.sh if it exists (for extra setup like daemons)
115 if [[ -x "$plugin/install.sh" ]]; then
116 echo "Running $name installer..."
117 "$plugin/install.sh"
118 fi
119done
120
121echo "Done."