#!/usr/bin/env bash # Deploy a skill from this repo to dotfiles for system-wide availability set -euo pipefail SKILLS_REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DOTFILES_REPO="$HOME/proj/dotfiles" SKILL_NAME="${1:-}" usage() { cat < Deploy a skill from ~/proj/skills to ~/proj/dotfiles for system-wide deployment. Arguments: skill-name Name of skill directory in skills/ Examples: $0 screenshot-latest $0 niri-window-capture This script: 1. Copies skill to dotfiles/claude/skills/ 2. Shows you the Nix config to add 3. Reminds you to rebuild You must manually: - Edit home/claude.nix - Edit home/opencode.nix - Run: sudo nixos-rebuild switch --flake .#delpad - Restart AI agents Available skills: EOF ls -1 "$SKILLS_REPO/skills" | grep -v template | sed 's/^/ /' exit 1 } if [[ -z "$SKILL_NAME" ]]; then usage fi SKILL_SOURCE="$SKILLS_REPO/skills/$SKILL_NAME" SKILL_DEST="$DOTFILES_REPO/claude/skills/$SKILL_NAME" # Validate skill exists if [[ ! -d "$SKILL_SOURCE" ]]; then echo "Error: Skill not found: $SKILL_SOURCE" >&2 echo "" >&2 usage fi # Validate dotfiles repo exists if [[ ! -d "$DOTFILES_REPO" ]]; then echo "Error: Dotfiles repo not found: $DOTFILES_REPO" >&2 exit 1 fi # Check if skill has SKILL.md if [[ ! -f "$SKILL_SOURCE/SKILL.md" ]]; then echo "Error: $SKILL_NAME missing SKILL.md" >&2 exit 1 fi # Check if already deployed if [[ -d "$SKILL_DEST" ]]; then echo "⚠️ Skill already deployed: $SKILL_DEST" read -p "Overwrite? [y/N] " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Cancelled" exit 1 fi rm -rf "$SKILL_DEST" fi # Check for security docs SECURITY_WARNING="" if [[ -f "$SKILL_SOURCE/SECURITY.md" ]]; then SECURITY_WARNING=" ⚠️ ⚠️ ⚠️ SECURITY WARNING ⚠️ ⚠️ ⚠️ This skill has security documentation. READ BEFORE DEPLOYING: $SKILL_DEST/SECURITY.md Security-sensitive skills should only be deployed after: 1. Reviewing security documentation 2. Understanding risks and mitigations 3. Configuring protection mechanisms " fi echo "Deploying skill: $SKILL_NAME" echo "" echo "Source: $SKILL_SOURCE" echo "Dest: $SKILL_DEST" echo "" # Copy skill mkdir -p "$(dirname "$SKILL_DEST")" cp -r "$SKILL_SOURCE" "$SKILL_DEST" echo "✓ Skill copied to dotfiles" echo "" if [[ -n "$SECURITY_WARNING" ]]; then echo "$SECURITY_WARNING" fi echo "Next steps:" echo "" echo "1. Add to Claude Code (edit $DOTFILES_REPO/home/claude.nix):" echo "" echo " home.file.\".claude/skills/$SKILL_NAME\" = {" echo " source = ../claude/skills/$SKILL_NAME;" echo " recursive = true;" echo " };" echo "" echo "2. Add to OpenCode (edit $DOTFILES_REPO/home/opencode.nix):" echo "" echo " home.file.\".config/opencode/skills/$SKILL_NAME\" = {" echo " source = ../claude/skills/$SKILL_NAME;" echo " recursive = true;" echo " };" echo "" echo "3. Rebuild system:" echo "" echo " cd $DOTFILES_REPO" echo " sudo nixos-rebuild switch --flake .#delpad" echo "" echo "4. Restart AI agents (OpenCode and Claude Code)" echo "" if [[ -n "$SECURITY_WARNING" ]]; then echo "⚠️ REMEMBER: Review SECURITY.md before rebuilding!" echo "" fi echo "Skill deployment prepared. Complete steps 1-4 to activate."