#!/usr/bin/env bash
# The Claude Web Design Killer Setup: installs the 3 design skills and the 2 build-and-test tools
# into the current project folder. Run it from your website project's root:  bash install.sh
# Needs Node 22+ (node -v). Claude Code for step 3 (https://claude.com/claude-code).
set -euo pipefail

major=$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)
if [ "$major" -lt 22 ]; then
  echo "Node 22 or newer is needed (you have $(node -v 2>/dev/null || echo none)). Install it from nodejs.org, then rerun."; exit 1
fi
mkdir -p .claude/skills

echo "1/5  Emil Kowalski design skill (emil-design-eng)"
npx -y skills@latest add emilkowalski/skills --skill emil-design-eng -a claude-code -y

echo "2/5  Impeccable"
npx -y impeccable install --providers=claude --scope=project

echo "3/5  Taste skill (design-taste-frontend)"
if ! npx -y skills@latest add https://github.com/Leonxlnx/taste-skill --skill design-taste-frontend -a claude-code -y 2>&1 | tee /tmp/taste-install.log | grep -q "Done"; then
  echo "     skills CLI could not load it, copying it straight from GitHub instead"
  tmp=$(mktemp -d)
  git clone -q --depth 1 https://github.com/Leonxlnx/taste-skill "$tmp/taste-skill"
  rm -rf .claude/skills/design-taste-frontend
  cp -R "$tmp/taste-skill/skills/taste-skill" .claude/skills/design-taste-frontend
  rm -rf "$tmp"
fi

if command -v claude >/dev/null 2>&1; then
  echo "4/5  Playwright MCP (Claude opens, screenshots and checks the site)"
  claude mcp add --scope project playwright npx @playwright/mcp@latest || echo "     (already added)"
  echo "5/5  Figma MCP (design side; you log in to Figma the first time Claude uses it)"
  claude mcp add --scope project --transport http figma https://mcp.figma.com/mcp || echo "     (already added)"
else
  echo "4-5/5  Claude Code not found. Install it, then run:"
  echo "       claude mcp add --scope project playwright npx @playwright/mcp@latest"
  echo "       claude mcp add --scope project --transport http figma https://mcp.figma.com/mcp"
fi

echo
echo "Installed skills:"; ls .claude/skills
echo "Done. Open Claude Code here (claude), type /mcp to log in to Figma, then paste the brief prompt."
