Files
superpowers/skills/getting-started/list-skills
T

51 lines
1.8 KiB
Bash
Raw Normal View History

2025-10-09 13:31:09 -07:00
#!/usr/bin/env bash
# list-skills - Show all available skill names without descriptions
# For Claude to quickly see what exists before searching
2025-10-10 14:01:45 -07:00
# Searches personal skills first, then core skills (personal shadows core)
2025-10-09 13:31:09 -07:00
set -euo pipefail
2025-10-10 14:01:45 -07:00
# Detect core skills directory (repo or installed location)
2025-10-09 13:31:09 -07:00
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ "$SCRIPT_DIR" == *"/.claude/plugins/cache/"* ]]; then
# Installed as plugin
2025-10-10 14:01:45 -07:00
CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
2025-10-09 13:31:09 -07:00
else
# Running from repo
2025-10-10 14:01:45 -07:00
CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
2025-10-09 13:31:09 -07:00
fi
2025-10-10 14:01:45 -07:00
# Use PERSONAL_SUPERPOWERS_DIR if set, otherwise XDG_CONFIG_HOME/superpowers, otherwise ~/.config/superpowers
PERSONAL_SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}"
PERSONAL_SKILLS_DIR="${PERSONAL_SUPERPOWERS_DIR}/skills"
# Collect all skill paths with deduplication
declare -A seen_skills
all_skills=()
# Personal skills first (take precedence)
if [[ -d "$PERSONAL_SKILLS_DIR" ]]; then
while IFS= read -r file; do
skill_path="${file#$PERSONAL_SKILLS_DIR/}"
skill_path="${skill_path%/SKILL.md}"
if [[ -n "$skill_path" ]]; then
seen_skills["$skill_path"]=1
all_skills+=("$skill_path")
fi
done < <(find "$PERSONAL_SKILLS_DIR" -name "SKILL.md" -type f 2>/dev/null || true)
fi
# Core skills (only if not shadowed by personal)
while IFS= read -r file; do
skill_path="${file#$CORE_SKILLS_DIR/}"
skill_path="${skill_path%/SKILL.md}"
if [[ -n "$skill_path" ]] && [[ -z "${seen_skills[$skill_path]:-}" ]]; then
all_skills+=("$skill_path")
fi
done < <(find "$CORE_SKILLS_DIR" -name "SKILL.md" -type f 2>/dev/null || true)
# Sort and output
printf "%s\n" "${all_skills[@]}" | sort
2025-10-09 13:31:09 -07:00
exit 0