f83a247de3
- skills/ shared by both tools (open Agent Skills standard) - portable cross-skill refs (root-relative, no ~/.claude hardcode) - bin/link.sh bootstrap for non-Nix machines - nix/home.nix + flake.nix for home-manager Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014SK5Lo7LQfwLRVdCv1A8uF
44 lines
1.3 KiB
Bash
Executable File
44 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Symlink centralized skills/commands into each agent's config dir.
|
|
# For non-Nix machines (NixOS boxes use nix/home.nix instead).
|
|
# Idempotent. Backs up any pre-existing real dir once to <name>.bak.
|
|
set -euo pipefail
|
|
|
|
REPO="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
# targets: agent config skill roots. Claude Code reads ~/.claude/skills,
|
|
# Codex reads ~/.agents/skills. Both consume the same SKILL.md dirs.
|
|
CLAUDE_SKILLS="$HOME/.claude/skills"
|
|
CODEX_SKILLS="$HOME/.agents/skills"
|
|
CLAUDE_CMDS="$HOME/.claude/commands" # commands are Claude-only; Codex ignores
|
|
|
|
# backups go OUTSIDE the skill dirs — a *.bak left inside gets discovered as a
|
|
# duplicate skill by both Claude Code and Codex.
|
|
BACKUP="$HOME/.agent-skills-backup"
|
|
|
|
link() { # link <src> <dst>
|
|
local src="$1" dst="$2"
|
|
if [ -e "$dst" ] && [ ! -L "$dst" ]; then
|
|
mkdir -p "$BACKUP"
|
|
mv "$dst" "$BACKUP/$(basename "$(dirname "$dst")")-$(basename "$dst").bak"
|
|
echo "backed up existing $dst -> $BACKUP/"
|
|
fi
|
|
ln -sfn "$src" "$dst"
|
|
echo "linked $dst -> $src"
|
|
}
|
|
|
|
mkdir -p "$CLAUDE_SKILLS" "$CODEX_SKILLS" "$CLAUDE_CMDS"
|
|
|
|
for d in "$REPO"/skills/*/; do
|
|
name="$(basename "$d")"
|
|
link "$d" "$CLAUDE_SKILLS/$name"
|
|
link "$d" "$CODEX_SKILLS/$name"
|
|
done
|
|
|
|
for f in "$REPO"/commands/*.md; do
|
|
[ -e "$f" ] || continue
|
|
link "$f" "$CLAUDE_CMDS/$(basename "$f")"
|
|
done
|
|
|
|
echo "done."
|