#!/bin/bash set -e # ============================================================================ # PRD Skill Installer # # Usage: # From a clone: ./install.sh # From GitHub: curl -fsSL https://raw.githubusercontent.com/codesoda/make-prd/main/install.sh | bash # ============================================================================ # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' CYAN='\033[0;36m' NC='\033[0m' # No Color SKILL_NAME="prd" REPO_URL="https://github.com/codesoda/make-prd.git" CLONE_DIR="$HOME/.local/share/make-prd" # ============================================================================ # Functions # ============================================================================ print_header() { echo -e "${CYAN}" echo " ____ ____ ____ ____ _ _ _ _ " echo " | _ \\| _ \\| _ \\ / ___|| | _(_) | |" echo " | |_) | |_) | | | | \\___ \\| |/ / | | |" echo " | __/| _ <| |_| | ___) | <| | | |" echo " |_| |_| \\_\\____/ |____/|_|\\_\\_|_|_|" echo -e "${NC}" echo "PRD Generator Skill for Claude Code & Codex" echo "============================================" echo "" } print_section() { local title="$1" echo "" echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${YELLOW}${title}${NC}" echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo "" } resolve_source_dir() { # If running from a clone (BASH_SOURCE is set and points to a real file), # use that directory. Otherwise, clone from GitHub. if [ -n "${BASH_SOURCE[0]:-}" ] && [ -f "${BASH_SOURCE[0]}" ]; then SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo -e "Installing from local clone: ${CYAN}$SOURCE_DIR${NC}" else print_section "Downloading from GitHub" if [ -d "$CLONE_DIR/.git" ]; then echo "Updating existing clone..." git -C "$CLONE_DIR" pull --ff-only else echo "Cloning repository..." git clone "$REPO_URL" "$CLONE_DIR" fi SOURCE_DIR="$CLONE_DIR" echo -e "${GREEN}Downloaded to $SOURCE_DIR${NC}" fi } detect_install_location() { print_section "Detecting Installation Location" local HAS_CLAUDE=false local HAS_CODEX=false if command -v claude &> /dev/null; then HAS_CLAUDE=true fi if command -v codex &> /dev/null; then HAS_CODEX=true fi if ! $HAS_CLAUDE && ! $HAS_CODEX; then echo -e "${RED}Error: Neither Claude Code nor Codex CLI found.${NC}" echo -e "${RED}Install at least one before running this installer.${NC}" exit 1 fi INSTALL_DIR="" if $HAS_CLAUDE; then INSTALL_DIR="$HOME/.claude/skills" mkdir -p "$INSTALL_DIR" echo -e "${GREEN}Claude Code detected${NC} — installing to $INSTALL_DIR" fi CODEX_INSTALL_DIR="" if $HAS_CODEX; then CODEX_INSTALL_DIR="$HOME/.codex/skills" mkdir -p "$CODEX_INSTALL_DIR" echo -e "${GREEN}Codex detected${NC} — installing to $CODEX_INSTALL_DIR" fi echo "" } install_skill_to_dir() { local dir="$1" local label="$2" echo -e "${YELLOW}${label}:${NC}" echo "" local TARGET="$dir/$SKILL_NAME" if [ -e "$TARGET" ] || [ -L "$TARGET" ]; then rm -rf "$TARGET" echo -e " Replacing existing $SKILL_NAME skill..." fi ln -s "$SOURCE_DIR" "$TARGET" echo -e "${GREEN} + $SKILL_NAME${NC}" echo "" } install_skill() { print_section "Installing PRD Skill" echo "Creating skill symlink..." echo "" if [ -n "$INSTALL_DIR" ]; then install_skill_to_dir "$INSTALL_DIR" "Claude Code ($INSTALL_DIR)" fi if [ -n "$CODEX_INSTALL_DIR" ]; then install_skill_to_dir "$CODEX_INSTALL_DIR" "Codex ($CODEX_INSTALL_DIR)" fi } show_usage() { print_section "Getting Started" echo "The PRD skill is now installed! Use it like this:" echo "" echo -e "${CYAN}Create a PRD:${NC}" echo " /prd build a task priority system" echo "" echo -e "${CYAN}Or describe what you want:${NC}" echo " /prd add user authentication with OAuth" echo "" echo -e "${CYAN}To update later:${NC}" echo " Re-run this installer to pull the latest version." echo "" } # ============================================================================ # Main Installation Flow # ============================================================================ main() { print_header resolve_source_dir detect_install_location install_skill show_usage print_section "Installation Complete" echo -e "${GREEN}PRD skill is ready to use!${NC}" echo "" } main