#!/bin/sh
# KuanAI free agent skills installer - https://kuan-ai.com/skills
set -e
ALL="code-review commit-message pr-description write-tests debug-detective refactor-safely readme-writer sql-helper api-docs dockerize changelog security-check meeting-notes email-replier seo-article research-brief competitor-analysis data-analyst product-spec support-reply migration-safety ci-failure-fix dependency-upgrade incident-postmortem eval-prompt"
DIR="${CLAUDE_SKILLS_DIR:-$HOME/.claude/skills}"
if [ "$1" = "--project" ]; then DIR=".claude/skills"; shift; fi
if [ "$1" = "--list" ]; then for s in $ALL; do echo "$s"; done; exit 0; fi
[ $# -eq 0 ] && set -- $ALL
for s in "$@"; do
  case " $ALL " in
    *" $s "*) ;;
    *) echo "Unknown skill: $s (see: curl -fsSL https://kuan-ai.com/skills/install | sh -s -- --list)" >&2; exit 1 ;;
  esac
done
n=0
for s in "$@"; do
  mkdir -p "$DIR/$s"
  curl -fsSL "https://kuan-ai.com/skills/$s/raw" -o "$DIR/$s/SKILL.md"
  echo "  + $s -> $DIR/$s/SKILL.md"
  n=$((n + 1))
done
echo "Installed $n skill(s). Restart Claude Code and ask for the task normally."
