Files
greyhaven-design-system/skill/install.sh
2026-04-13 15:33:00 -05:00

69 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# install.sh — Symlink the Greyhaven Design System SKILL.md into a consuming project's
# .claude/skills/ directory so that any Claude Code session gets full design system context.
#
# Usage:
# From the greyhaven-design-system repo:
# ./skill/install.sh /path/to/your/project
#
# Or from any directory:
# /path/to/greyhaven-design-system/skill/install.sh /path/to/your/project
set -euo pipefail
# Resolve the absolute path of the SKILL.md file relative to this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_FILE="${SCRIPT_DIR}/SKILL.md"
# Validate SKILL.md exists
if [ ! -f "$SKILL_FILE" ]; then
echo "Error: SKILL.md not found at ${SKILL_FILE}"
exit 1
fi
# Get target project directory from argument or prompt
if [ $# -ge 1 ]; then
TARGET_PROJECT="$1"
else
echo "Usage: $0 <target-project-directory>"
echo ""
echo "Example:"
echo " $0 /path/to/my-app"
echo " $0 ."
exit 1
fi
# Resolve to absolute path
TARGET_PROJECT="$(cd "$TARGET_PROJECT" && pwd)"
# Validate target directory exists
if [ ! -d "$TARGET_PROJECT" ]; then
echo "Error: Directory not found: ${TARGET_PROJECT}"
exit 1
fi
# Create .claude/skills/ directory in target project if it doesn't exist
SKILLS_DIR="${TARGET_PROJECT}/.claude/skills"
mkdir -p "$SKILLS_DIR"
# Create the symlink
LINK_PATH="${SKILLS_DIR}/greyhaven-design-system.md"
if [ -L "$LINK_PATH" ]; then
echo "Updating existing symlink at ${LINK_PATH}"
rm "$LINK_PATH"
elif [ -f "$LINK_PATH" ]; then
echo "Warning: ${LINK_PATH} exists as a regular file. Backing up to ${LINK_PATH}.bak"
mv "$LINK_PATH" "${LINK_PATH}.bak"
fi
ln -s "$SKILL_FILE" "$LINK_PATH"
echo "Done! Greyhaven Design System skill installed."
echo ""
echo " Symlink: ${LINK_PATH}"
echo " Target: ${SKILL_FILE}"
echo ""
echo "Any Claude Code session in ${TARGET_PROJECT} will now have"
echo "full Greyhaven Design System context available."