From 6c0ab4cfec8d2b3d2b1fd036e976298b1ca928a4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 10 Oct 2025 14:01:45 -0700 Subject: Add personal superpowers overlay system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enables users to write and manage their own skills alongside core skills. ## Key Features: - Auto-setup on first session: Creates ~/.config/superpowers/ git repo - Two-tier skills: Personal skills shadow core skills when paths match - Environment variable support: PERSONAL_SUPERPOWERS_DIR, XDG_CONFIG_HOME - GitHub integration: Optional public repo creation for sharing skills - CLI-agnostic: Works across Claude Code, Codex CLI, Gemini CLI (future) ## Changes: - Added hooks/setup-personal-superpowers.sh - Auto-initializes personal repo - Updated hooks/session-start.sh - Runs setup, offers GitHub repo creation - Updated list-skills, skills-search - Search both personal and core skills - Renamed skills/meta/creating-skills → writing-skills - Added skills/meta/setting-up-personal-superpowers - Setup documentation - Added skills/meta/sharing-skills - Contribution workflow - Removed skills/meta/installing-skills - Old ~/.clank system - Removed all INDEX.md files - Replaced by list-skills tool - Updated README.md, getting-started - Document personal skills workflow ## Architecture: ~/.config/superpowers/skills/ # Personal (user-created, git-tracked) ${CLAUDE_PLUGIN_ROOT}/skills/ # Core (read-only, from plugin) Search order: Personal first, core second (first match wins) --- README.md | 82 ++- hooks/session-start.sh | 28 +- hooks/setup-personal-superpowers.sh | 52 ++ skills/INDEX.md | 28 - skills/collaboration/INDEX.md | 25 - skills/debugging/INDEX.md | 13 - skills/getting-started/SKILL.md | 41 +- skills/getting-started/list-skills | 42 +- skills/getting-started/skills-search | 72 ++- skills/meta/INDEX.md | 14 - skills/meta/creating-skills/SKILL.md | 592 -------------------- .../meta/creating-skills/graphviz-conventions.dot | 172 ------ .../meta/creating-skills/persuasion-principles.md | 187 ------- .../meta/installing-skills/CLAUDE_MD_PREAMBLE.md | 14 - skills/meta/installing-skills/SKILL.md | 224 -------- skills/meta/installing-skills/install.sh | 191 ------- .../meta/setting-up-personal-superpowers/SKILL.md | 162 ++++++ skills/meta/sharing-skills/SKILL.md | 240 +++++++++ skills/meta/writing-skills/SKILL.md | 595 +++++++++++++++++++++ .../meta/writing-skills/graphviz-conventions.dot | 172 ++++++ .../meta/writing-skills/persuasion-principles.md | 187 +++++++ skills/testing/INDEX.md | 11 - 22 files changed, 1611 insertions(+), 1533 deletions(-) create mode 100755 hooks/setup-personal-superpowers.sh delete mode 100644 skills/INDEX.md delete mode 100644 skills/collaboration/INDEX.md delete mode 100644 skills/debugging/INDEX.md delete mode 100644 skills/meta/INDEX.md delete mode 100644 skills/meta/creating-skills/SKILL.md delete mode 100644 skills/meta/creating-skills/graphviz-conventions.dot delete mode 100644 skills/meta/creating-skills/persuasion-principles.md delete mode 100644 skills/meta/installing-skills/CLAUDE_MD_PREAMBLE.md delete mode 100644 skills/meta/installing-skills/SKILL.md delete mode 100755 skills/meta/installing-skills/install.sh create mode 100644 skills/meta/setting-up-personal-superpowers/SKILL.md create mode 100644 skills/meta/sharing-skills/SKILL.md create mode 100644 skills/meta/writing-skills/SKILL.md create mode 100644 skills/meta/writing-skills/graphviz-conventions.dot create mode 100644 skills/meta/writing-skills/persuasion-principles.md delete mode 100644 skills/testing/INDEX.md diff --git a/README.md b/README.md index 964aecb..056f75d 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,12 @@ Read the introduction: [Superpowers for Claude Code](https://blog.fsck.com/2025/ /plugin install superpowers@superpowers-marketplace ``` -That's it! The plugin will: -- Inject skills library into your session context -- Make skills searchable via `${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search` -- Add `/brainstorm`, `/write-plan`, and `/execute-plan` commands -- Create `~/.superpowers/` for local data +That's it! On first session, the plugin automatically: +- Sets up `~/.config/superpowers/` as your personal skills repository +- Initializes git repo for version control +- Makes core skills searchable alongside your personal skills +- Adds `/brainstorm`, `/write-plan`, and `/execute-plan` commands +- Offers to create public GitHub repo for sharing your skills ### Verify Installation @@ -48,14 +49,25 @@ That's it! The plugin will: ## Quick Start +### Your Personal Skills + +Write your own skills to `~/.config/superpowers/skills/`: +- All personal skills automatically discovered by search tools +- Personal skills shadow core skills when names match +- Version controlled with git +- Optional: Share on GitHub and contribute back to core + +See `skills/meta/writing-skills` for how to create new skills. +See `skills/meta/sharing-skills` for how to contribute to core. + ### Finding Skills -Search for relevant skills before starting any task: +Search both personal and core skills before starting any task: ```bash +${CLAUDE_PLUGIN_ROOT}/skills/getting-started/list-skills # See all available ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'test.*driven|TDD' ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'debug.*systematic' -${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'refactor' ``` ### Using Slash Commands @@ -101,7 +113,9 @@ ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'refactor' - receiving-code-review - Responding to feedback **Meta** (`skills/meta/`) -- creating-skills - Document new techniques +- setting-up-personal-superpowers - Personal skills repository setup +- writing-skills - TDD for documentation, create new skills +- sharing-skills - Contribute skills back to core - testing-skills-with-subagents - Validate skill quality - gardening-skills-wiki - Maintain and improve skills @@ -118,10 +132,12 @@ ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'refactor' ## How It Works -1. **SessionStart Hook** - Injects skills library context at session start -2. **Skills Discovery** - `skills-search` finds relevant skills using grep patterns -3. **Mandatory Workflow** - Skills become required when they exist for your task -4. **Gap Tracking** - Failed searches logged to `~/.superpowers/search-log.jsonl` +1. **SessionStart Hook** - Auto-setup personal skills repo, inject core skills context +2. **Two-Tier Skills** - Personal skills (`~/.config/superpowers/skills/`) + Core skills (plugin) +3. **Skills Discovery** - `list-skills` and `skills-search` find skills from both locations +4. **Shadowing** - Personal skills override core skills when paths match +5. **Mandatory Workflow** - Skills become required when they exist for your task +6. **Gap Tracking** - Failed searches logged to `~/.config/superpowers/search-log.jsonl` ## Philosophy @@ -131,21 +147,49 @@ ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search 'refactor' - **Evidence over claims** - Verify before declaring success - **Domain over implementation** - Work at problem level, not solution level -## Data Directory +## Personal Superpowers Directory + +The plugin auto-creates your personal superpowers directory on first session. + +**Default location:** `~/.config/superpowers/` -The plugin creates `~/.superpowers/` for local data: +**Customize via environment variables:** +```bash +# Option 1: Set exact location +export PERSONAL_SUPERPOWERS_DIR="$HOME/my-superpowers" + +# Option 2: Use XDG standard +export XDG_CONFIG_HOME="$HOME/.local/config" # Uses $HOME/.local/config/superpowers +``` +**Structure:** ``` -~/.superpowers/ -├── search-log.jsonl # Failed skill searches -└── conversation-index/ # Indexed past conversations (if enabled) +~/.config/superpowers/ # (or your custom location) +├── .git/ # Git repository +├── .gitignore # Ignores logs and indexes +├── README.md # About your personal superpowers +├── skills/ # Your personal skills +│ └── your-skill/ +│ └── SKILL.md +├── search-log.jsonl # Failed skill searches (not tracked) +└── conversation-index/ # Indexed conversations (not tracked) ``` +**Why git?** Track your skills evolution, share with others, contribute back to core. + ## Contributing -Want to add a skill? See `skills/meta/creating-skills/SKILL.md` +**Write personal skills:** +1. Create in `~/.config/superpowers/skills/your-skill/` +2. Follow TDD process in `skills/meta/writing-skills` +3. Commit to your personal repo + +**Share with everyone:** +1. Follow workflow in `skills/meta/sharing-skills` +2. Fork → Branch → Copy → PR to core +3. Keep personal version or delete after merge -Missing a skill? Edit `skills/REQUESTS.md` or open an issue +**Missing a skill?** Edit `skills/REQUESTS.md` or open an issue ## License diff --git a/hooks/session-start.sh b/hooks/session-start.sh index f6c4f11..27bb78a 100755 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -1,15 +1,37 @@ #!/usr/bin/env bash # SessionStart hook for superpowers plugin -# Create data directory -mkdir -p ~/.superpowers +set -euo pipefail + +# Run personal superpowers setup +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +setup_output=$("${SCRIPT_DIR}/setup-personal-superpowers.sh" 2>&1 || echo "setup_failed=true") + +# Use same directory resolution as setup script +SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}" + +# Check if GitHub CLI is available and setup succeeded +github_recommendation="" +if echo "$setup_output" | grep -q "github_cli_available=true"; then + if [[ ! -d "$SUPERPOWERS_DIR/.git" ]]; then + # This should not happen, but handle gracefully + github_recommendation="" + else + # Check if remote already exists + if ! (cd "$SUPERPOWERS_DIR" && git remote get-url origin &>/dev/null); then + github_recommendation="\n\n💡 Want to share your personal skills on GitHub? Superpowers are best when everyone can learn from them! I can create a 'personal-superpowers' repo for you." + fi + fi +elif echo "$setup_output" | grep -q "setup_failed=true"; then + github_recommendation="\n\n⚠️ Personal superpowers setup encountered an issue. Please file a bug at https://github.com/obra/superpowers/issues" +fi # Output context injection as JSON cat <\nYou have superpowers.\n\n**RIGHT NOW, go read**: @${CLAUDE_PLUGIN_ROOT}/skills/getting-started/SKILL.md\n" + "additionalContext": "\nYou have superpowers.\n\n**RIGHT NOW, go read**: @${CLAUDE_PLUGIN_ROOT}/skills/getting-started/SKILL.md${github_recommendation}\n" } } EOF diff --git a/hooks/setup-personal-superpowers.sh b/hooks/setup-personal-superpowers.sh new file mode 100755 index 0000000..e9e0070 --- /dev/null +++ b/hooks/setup-personal-superpowers.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# Setup script for personal superpowers directory +# Creates personal superpowers directory with git repo for personal skills + +set -euo pipefail + +# Use PERSONAL_SUPERPOWERS_DIR if set, otherwise XDG_CONFIG_HOME/superpowers, otherwise ~/.config/superpowers +SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}" +SKILLS_DIR="${SUPERPOWERS_DIR}/skills" + +# Check if already set up +if [[ -d "${SUPERPOWERS_DIR}/.git" ]] && [[ -d "${SKILLS_DIR}" ]]; then + # Already set up, nothing to do + exit 0 +fi + +# Create directory structure +mkdir -p "${SKILLS_DIR}" + +# Create .gitignore +cat > "${SUPERPOWERS_DIR}/.gitignore" <<'EOF' +# Superpowers local data +search-log.jsonl +conversation-index/ +conversation-archive/ +EOF + +# Create README +cat > "${SUPERPOWERS_DIR}/README.md" <<'EOF' +# My Personal Superpowers + +Personal skills and techniques for Claude Code. + +Learn more about Superpowers: https://github.com/obra/superpowers +EOF + +# Initialize git repo if not already initialized +if [[ ! -d "${SUPERPOWERS_DIR}/.git" ]]; then + cd "${SUPERPOWERS_DIR}" + git init -q + git add .gitignore README.md + git commit -q -m "Initial commit: Personal superpowers setup" +fi + +# Check for gh and recommend GitHub setup +if command -v gh &> /dev/null; then + echo "github_cli_available=true" +else + echo "github_cli_available=false" +fi + +exit 0 diff --git a/skills/INDEX.md b/skills/INDEX.md deleted file mode 100644 index 61b8c77..0000000 --- a/skills/INDEX.md +++ /dev/null @@ -1,28 +0,0 @@ -# Claude Superpowers - -Your skills library of proven techniques, patterns, and tools. - -## First Time Here? - -**Read this first:** skills/getting-started - Introduction to the skills library and how to use it - -## Quick Start - -**Starting a task?** Check the relevant category below. -**Encountering a problem?** Search with: `${CLAUDE_PLUGIN_ROOT}/skills/getting-started/skills-search keyword` -**Not sure?** Ask your human partner: "Do I have a skill for X?" - -## Categories - -- skills/testing - Writing reliable, maintainable tests (TDD, async testing, anti-patterns) -- skills/debugging - Finding and fixing bugs systematically (root cause tracing, verification) -- skills/collaboration - Working with other agents and developers (brainstorming, planning, code review) -- skills/meta - Using, creating, and testing skills - -## Navigation - -Each category INDEX shows available skills with descriptions. Load the category relevant to your current work. - -## Creating New Skills - -See skills/meta/creating-skills for guidelines on documenting new techniques. diff --git a/skills/collaboration/INDEX.md b/skills/collaboration/INDEX.md deleted file mode 100644 index 4fe7515..0000000 --- a/skills/collaboration/INDEX.md +++ /dev/null @@ -1,25 +0,0 @@ -# Collaboration Skills - -Working effectively with other agents and developers. - -## Available Skills - -- skills/collaboration/brainstorming - Interactive idea refinement using Socratic method to develop fully-formed designs. Use when your human partner has new idea to explore. Before writing implementation plans. - -- skills/collaboration/writing-plans - Create detailed implementation plans with bite-sized tasks for engineers with zero codebase context. Use after brainstorming/design is complete. Before implementation begins. - -- skills/collaboration/using-git-worktrees - Create isolated git worktrees with smart directory selection and safety verification. Use when starting feature implementation in isolation. When brainstorming transitions to code. Before executing plans. - -- skills/collaboration/executing-plans - Execute detailed plans in batches with review checkpoints. Use when have complete implementation plan to execute. When implementing in separate session from planning. - -- skills/collaboration/subagent-driven-development - Execute plan by dispatching fresh subagent per task with code review between tasks. Alternative to executing-plans when staying in same session. Use when tasks are independent. When want fast iteration with review checkpoints. - -- skills/collaboration/finishing-a-development-branch - Complete feature development with structured options for merge, PR, or cleanup. Use after completing implementation. When all tests passing. At end of executing-plans or subagent-driven-development. - -- skills/collaboration/remembering-conversations - Search previous Claude Code conversations for facts, patterns, decisions, and context using semantic or text search. Use when your human partner mentions "we discussed this before". When debugging similar issues. When looking for architectural decisions or code patterns from past work. Before reinventing solutions. When searching for git SHAs or error messages. - -- skills/collaboration/dispatching-parallel-agents - Use multiple Claude agents to investigate and fix independent problems concurrently. Use when you have 3+ unrelated failures that can be debugged in parallel. - -- skills/collaboration/requesting-code-review - Dispatch code-reviewer subagent to review implementation against plan before proceeding. Use after completing task. After major feature. Before merging. When executing plans (after each task). - -- skills/collaboration/receiving-code-review - Receive and act on code review feedback with technical rigor, not performative agreement or blind implementation. Use when receiving feedback from your human partner or external reviewers. Before implementing review suggestions. When feedback seems wrong or unclear. diff --git a/skills/debugging/INDEX.md b/skills/debugging/INDEX.md deleted file mode 100644 index dd1b34f..0000000 --- a/skills/debugging/INDEX.md +++ /dev/null @@ -1,13 +0,0 @@ -# Debugging Skills - -Techniques for finding and fixing bugs systematically. - -## Available Skills - -- skills/debugging/defense-in-depth - Validate at every layer data passes through to make bugs impossible. Use when invalid data causes problems deep in call stack. - -- skills/debugging/root-cause-tracing - Trace bugs backward through call stack to find original trigger. Use when bugs appear deep in execution and you need to find where they originate. Includes bisection script for finding test pollution. - -- skills/debugging/systematic-debugging - Four-phase debugging framework that ensures root cause investigation before attempting fixes. Use when encountering any technical issue, bug, or test failure. Especially critical when under time pressure or tempted to quick-fix. - -- skills/debugging/verification-before-completion - Never claim work is complete, tests pass, or bugs are fixed without running actual verification commands. Use before claiming complete, fixed, working, passing, clean, or ready. Before expressing satisfaction with your work. Before committing or creating PRs. When tempted to declare success. diff --git a/skills/getting-started/SKILL.md b/skills/getting-started/SKILL.md index faaf662..2d22805 100644 --- a/skills/getting-started/SKILL.md +++ b/skills/getting-started/SKILL.md @@ -1,13 +1,17 @@ --- name: Getting Started with Skills -description: Skills wiki intro - mandatory workflows, search tool, brainstorming triggers +description: Skills wiki intro - mandatory workflows, search tool, brainstorming triggers, personal skills when_to_use: Read this FIRST at start of each conversation when skills are active -version: 2.0.0 +version: 3.0.0 --- # Getting Started with Skills -Your personal wiki of proven techniques, patterns, and tools at `${CLAUDE_PLUGIN_ROOT}/skills/`. +Two skill libraries work together: +- **Core skills** at `${CLAUDE_PLUGIN_ROOT}/skills/` (from plugin) +- **Personal skills** at `~/.config/superpowers/skills/` (yours to create and share) + +Personal skills shadow core skills when names match. ## Just Read This Guide? @@ -28,7 +32,8 @@ ${CLAUDE_PLUGIN_ROOT}/skills/getting-started/list-skills - Load with Read tool only when needed **When you see skill references in documentation:** -- `skills/path/name` → Use Read tool on `${CLAUDE_PLUGIN_ROOT}/skills/path/name/SKILL.md` +- `skills/path/name` → Check personal first (`~/.config/superpowers/skills/path/name/SKILL.md`) +- If not found, check core (`${CLAUDE_PLUGIN_ROOT}/skills/path/name/SKILL.md`) - Load supporting files only when implementing ## Mandatory Workflow 1: Brainstorming Before Coding @@ -115,14 +120,7 @@ You: Searching past conversations... **Why:** Checklists without TodoWrite tracking = steps get skipped. Every time. -**Examples:** TDD (write test, watch fail, implement, verify), Systematic Debugging (4 phases), Creating Skills (RED-GREEN-REFACTOR) - -## Navigation - -Really, try skills-search first. - -**Categories:** skills/INDEX.md → testing, debugging, coding, architecture, collaboration, meta -**Individual skill:** Load from category INDEX +**Examples:** TDD (write test, watch fail, implement, verify), Systematic Debugging (4 phases), Writing Skills (RED-GREEN-REFACTOR) ## How to Read a Skill @@ -159,13 +157,15 @@ Your human partner's specific instructions describe WHAT to do, not HOW. **Red flags:** "Instruction was specific" • "Seems simple" • "Workflow is overkill" -## Creating and Updating Skills +## Writing and Sharing Skills + +**All personal skills are written to `~/.config/superpowers/skills/`** -**Before creating OR editing ANY skill:** +**Before writing ANY skill:** 1. **STOP** - Even if your human partner gave specific instructions -2. **Read skills/meta/creating-skills** -3. **Check in** - "You asked me to edit [skill]. Should I follow creating-skills process or make the change?" +2. **Read skills/meta/writing-skills** +3. **Follow the TDD process** - No skill without failing test first **Your human partner's specific instruction is NOT implicit permission to skip the process.** @@ -173,11 +173,14 @@ Your human partner's specific instructions describe WHAT to do, not HOW. - "Just a small addition" - "Instruction was specific, so I can proceed" -**All of these mean: STOP and check in first.** +**All of these mean: STOP and follow writing-skills process.** -Found something valuable? See skills/meta/creating-skills +**Want to share a skill with everyone?** +- See skills/meta/sharing-skills for how to contribute to core superpowers -Want a skill that doesn't exist? Edit skills/REQUESTS.md (at ${CLAUDE_PLUGIN_ROOT}/skills/REQUESTS.md) +**Want a skill that doesn't exist?** +- Write it yourself (see skills/meta/writing-skills) and share it! +- Or open an issue at https://github.com/obra/superpowers/issues ## Summary diff --git a/skills/getting-started/list-skills b/skills/getting-started/list-skills index 702e543..5e6bbe2 100755 --- a/skills/getting-started/list-skills +++ b/skills/getting-started/list-skills @@ -1,22 +1,50 @@ #!/usr/bin/env bash # list-skills - Show all available skill names without descriptions # For Claude to quickly see what exists before searching +# Searches personal skills first, then core skills (personal shadows core) set -euo pipefail -# Detect if running from repo or installed location +# Detect core skills directory (repo or installed location) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [[ "$SCRIPT_DIR" == *"/.claude/plugins/cache/"* ]]; then # Installed as plugin - SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" else # Running from repo - SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" fi -# Find all SKILL.md files and extract their paths -find "$SKILLS_DIR" -name "SKILL.md" -type f | \ - sed "s|$SKILLS_DIR/||; s|/SKILL.md||" | \ - sort +# 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 exit 0 diff --git a/skills/getting-started/skills-search b/skills/getting-started/skills-search index f6e10ab..6cb66de 100755 --- a/skills/getting-started/skills-search +++ b/skills/getting-started/skills-search @@ -1,20 +1,24 @@ #!/usr/bin/env bash # skills-search - Find relevant skills using grep patterns # Logs all searches for gap analysis (gardening skill processes the log) +# Searches personal skills first, then core skills (personal shadows core) set -euo pipefail -# Detect if running from repo or installed location +# Detect core skills directory (repo or installed location) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -if [[ "$SCRIPT_DIR" == *"/.claude/skills/getting-started" ]]; then - # Installed location - SKILLS_DIR="${HOME}/.claude/skills" +if [[ "$SCRIPT_DIR" == *"/.claude/plugins/cache/"* ]]; then + # Installed as plugin + CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" else # Running from repo - SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + CORE_SKILLS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" fi -LOG_FILE="${HOME}/.superpowers/search-log.jsonl" +# 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" +LOG_FILE="${PERSONAL_SUPERPOWERS_DIR}/search-log.jsonl" # Show usage if no arguments if [[ $# -eq 0 ]]; then @@ -40,16 +44,51 @@ timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") query="$*" echo "{\"timestamp\":\"$timestamp\",\"query\":\"$query\"}" >> "$LOG_FILE" 2>/dev/null || true -# Search all SKILL.md files - both content AND path names -# Content search: grep file contents -content_matches=$(grep -E -r "$@" "$SKILLS_DIR/" --include="SKILL.md" -l 2>/dev/null || true) +# Search both personal and core skills directories +# Personal skills take precedence (searched first) + +# Content search: grep file contents from both locations +content_matches_personal="" +content_matches_core="" +if [[ -d "$PERSONAL_SKILLS_DIR" ]]; then + content_matches_personal=$(grep -E -r "$@" "$PERSONAL_SKILLS_DIR/" --include="SKILL.md" -l 2>/dev/null || true) +fi +content_matches_core=$(grep -E -r "$@" "$CORE_SKILLS_DIR/" --include="SKILL.md" -l 2>/dev/null || true) # Filename search: find all SKILL.md paths, then grep the paths themselves -all_skills=$(find "$SKILLS_DIR/" -name "SKILL.md" -type f 2>/dev/null || true) -path_matches=$(echo "$all_skills" | grep -E "$@" 2>/dev/null || true) +all_skills_personal="" +all_skills_core="" +if [[ -d "$PERSONAL_SKILLS_DIR" ]]; then + all_skills_personal=$(find "$PERSONAL_SKILLS_DIR/" -name "SKILL.md" -type f 2>/dev/null || true) +fi +all_skills_core=$(find "$CORE_SKILLS_DIR/" -name "SKILL.md" -type f 2>/dev/null || true) + +path_matches_personal=$(echo "$all_skills_personal" | grep -E "$@" 2>/dev/null || true) +path_matches_core=$(echo "$all_skills_core" | grep -E "$@" 2>/dev/null || true) + +# Combine all matches +all_matches=$(printf "%s\n%s\n%s\n%s" "$content_matches_personal" "$content_matches_core" "$path_matches_personal" "$path_matches_core" | grep -v '^$' || true) + +# Deduplicate by skill path (personal shadows core) +declare -A seen_skills +results="" +while IFS= read -r file; do + # Extract skill path relative to its base directory + if [[ "$file" == "$PERSONAL_SKILLS_DIR"* ]]; then + skill_path="${file#$PERSONAL_SKILLS_DIR/}" + else + skill_path="${file#$CORE_SKILLS_DIR/}" + fi + skill_path="${skill_path%/SKILL.md}" + + # Only include if we haven't seen this skill path yet + if [[ -z "${seen_skills[$skill_path]:-}" ]]; then + seen_skills["$skill_path"]=1 + results="${results}${file}"$'\n' + fi +done <<< "$all_matches" -# Combine and deduplicate -results=$(printf "%s\n%s" "$content_matches" "$path_matches" | sort -u | grep -v '^$' || true) +results=$(echo "$results" | grep -v '^$' | sort -u || true) if [[ -z "$results" ]]; then echo "❌ No skills found matching: $*" @@ -68,7 +107,12 @@ echo "$results" | while read -r file; do description=$(grep "^description:" "$file" 2>/dev/null | sed 's/description: *//' || echo "") # Get relative path without @ prefix or /SKILL.md suffix - rel_path="${file#$SKILLS_DIR/}" + # Handle both personal and core skills + if [[ "$file" == "$PERSONAL_SKILLS_DIR"* ]]; then + rel_path="${file#$PERSONAL_SKILLS_DIR/}" + else + rel_path="${file#$CORE_SKILLS_DIR/}" + fi rel_path="skills/${rel_path%/SKILL.md}" if [[ -n "$description" ]]; then diff --git a/skills/meta/INDEX.md b/skills/meta/INDEX.md deleted file mode 100644 index bf1a47b..0000000 --- a/skills/meta/INDEX.md +++ /dev/null @@ -1,14 +0,0 @@ -# Meta Skills - -Skills about skills - how to create and use the skills system. - -## Available Skills - -- skills/meta/installing-skills - Fork, clone, and symlink clank repo to ~/.claude/skills. Use for initial setup, installing clank for the first time. - -- skills/meta/creating-skills - How to create effective skills for future Claude instances. Use when you discover a technique, pattern, or tool worth documenting for reuse. - -- skills/meta/testing-skills-with-subagents - Iteratively test and bulletproof skills using pressure scenarios and rationalization analysis. Use after writing skills that enforce discipline or rules, before deploying skills agents might want to bypass. - -- skills/meta/gardening-skills-wiki - Maintain skills wiki health with automated checks for broken links, naming consistency, and INDEX coverage. Use when adding/removing skills, reorganizing categories, or for periodic maintenance. - diff --git a/skills/meta/creating-skills/SKILL.md b/skills/meta/creating-skills/SKILL.md deleted file mode 100644 index b03eb94..0000000 --- a/skills/meta/creating-skills/SKILL.md +++ /dev/null @@ -1,592 +0,0 @@ ---- -name: Creating Skills -description: TDD for process documentation - test with subagents before writing, iterate until bulletproof -when_to_use: When you discover a technique, pattern, or tool worth documenting for reuse. When editing existing skills. When asked to modify skill documentation. When you've written a skill and need to verify it works before deploying. -version: 4.1.0 -languages: all ---- - -# Creating Skills - -## Overview - -**Creating skills IS Test-Driven Development applied to process documentation.** - -You write test cases (pressure scenarios with subagents), watch them fail (baseline behavior), write the skill (documentation), watch tests pass (agents comply), and refactor (close loopholes). - -**Core principle:** If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing. - -See skills/testing/test-driven-development for the fundamental RED-GREEN-REFACTOR cycle. This skill adapts TDD to documentation. - -## What is a Skill? - -A **skill** is a reference guide for proven techniques, patterns, or tools. Skills help future Claude instances find and apply effective approaches. - -**Skills are:** Reusable techniques, patterns, tools, reference guides - -**Skills are NOT:** Narratives about how you solved a problem once - -## TDD Mapping for Skills - -| TDD Concept | Skill Creation | -|-------------|----------------| -| **Test case** | Pressure scenario with subagent | -| **Production code** | Skill document (SKILL.md) | -| **Test fails (RED)** | Agent violates rule without skill (baseline) | -| **Test passes (GREEN)** | Agent complies with skill present | -| **Refactor** | Close loopholes while maintaining compliance | -| **Write test first** | Run baseline scenario BEFORE writing skill | -| **Watch it fail** | Document exact rationalizations agent uses | -| **Minimal code** | Write skill addressing those specific violations | -| **Watch it pass** | Verify agent now complies | -| **Refactor cycle** | Find new rationalizations → plug → re-verify | - -The entire skill creation process follows RED-GREEN-REFACTOR. - -## When to Create a Skill - -**Create when:** -- Technique wasn't intuitively obvious to you -- You'd reference this again across projects -- Pattern applies broadly (not project-specific) -- Others would benefit - -**Don't create for:** -- One-off solutions -- Standard practices well-documented elsewhere -- Project-specific conventions (put in CLAUDE.md) - -## Skill Types - -### Technique -Concrete method with steps to follow (condition-based-waiting, root-cause-tracing) - -### Pattern -Way of thinking about problems (flatten-with-flags, test-invariants) - -### Reference -API docs, syntax guides, tool documentation (office docs) - -## Directory Structure - -``` -skills/ - skill-name/ - SKILL.md # Main reference (required) - supporting-file.* # Only if needed -``` - -**Flat namespace** - all skills in one searchable location - -**Separate files for:** -1. **Heavy reference** (100+ lines) - API docs, comprehensive syntax -2. **Reusable tools** - Scripts, utilities, templates - -**Keep inline:** -- Principles and concepts -- Code patterns (< 50 lines) -- Everything else - -## SKILL.md Structure - -```markdown ---- -name: Human-Readable Name -description: One-line summary of what this does -when_to_use: Symptoms and situations when you need this (CSO-critical) -version: 1.0.0 -languages: all | [typescript, python] | etc -dependencies: (optional) Required tools/libraries ---- - -# Skill Name - -## Overview -What is this? Core principle in 1-2 sentences. - -## When to Use -[Small inline flowchart IF decision non-obvious] - -Bullet list with SYMPTOMS and use cases -When NOT to use - -## Core Pattern (for techniques/patterns) -Before/after code comparison - -## Quick Reference -Table or bullets for scanning common operations - -## Implementation -Inline code for simple patterns -@link to file for heavy reference or reusable tools - -## Common Mistakes -What goes wrong + fixes - -## Real-World Impact (optional) -Concrete results -``` - -## Claude Search Optimization (CSO) - -**Critical for discovery:** Future Claude needs to FIND your skill - -### 1. Rich when_to_use - -Include SYMPTOMS not just abstract use cases: - -```yaml -# ❌ BAD: Too abstract -when_to_use: For async testing - -# ✅ GOOD: Symptoms and context -when_to_use: When tests use setTimeout/sleep and are flaky, timing-dependent, - pass locally but fail in CI, or timeout when run in parallel -``` - -### 2. Keyword Coverage - -Use words Claude would search for: -- Error messages: "Hook timed out", "ENOTEMPTY", "race condition" -- Symptoms: "flaky", "hanging", "zombie", "pollution" -- Synonyms: "timeout/hang/freeze", "cleanup/teardown/afterEach" -- Tools: Actual commands, library names, file types - -### 3. Descriptive Naming - -**Use active voice, verb-first:** -- ✅ `creating-skills` not `skill-creation` -- ✅ `testing-skills-with-subagents` not `subagent-skill-testing` - -### 4. Token Efficiency (Critical) - -**Problem:** getting-started and frequently-referenced skills load into EVERY conversation. Every token counts. - -**Target word counts:** -- getting-started workflows: <150 words each -- Frequently-loaded skills: <200 words total -- Other skills: <500 words (still be concise) - -**Techniques:** - -**Move details to tool help:** -```bash -# ❌ BAD: Document all flags in SKILL.md -search-conversations supports --text, --both, --after DATE, --before DATE, --limit N - -# ✅ GOOD: Reference --help -search-conversations supports multiple modes and filters. Run --help for details. -``` - -**Use cross-references:** -```markdown -# ❌ BAD: Repeat workflow details -When searching, dispatch subagent with template... -[20 lines of repeated instructions] - -# ✅ GOOD: Reference other skill -Always use subagents (50-100x context savings). See skills/getting-started for workflow. -``` - -**Compress examples:** -```markdown -# ❌ BAD: Verbose example (42 words) -your human partner: "How did we handle authentication errors in React Router before?" -You: I'll search past conversations for React Router authentication patterns. -[Dispatch subagent with search query: "React Router authentication error handling 401"] - -# ✅ GOOD: Minimal example (20 words) -Partner: "How did we handle auth errors in React Router?" -You: Searching... -[Dispatch subagent → synthesis] -``` - -**Eliminate redundancy:** -- Don't repeat what's in cross-referenced skills -- Don't explain what's obvious from command -- Don't include multiple examples of same pattern - -**Verification:** -```bash -wc -w skills/path/SKILL.md -# getting-started workflows: aim for <150 each -# Other frequently-loaded: aim for <200 total -``` - -**Name by what you DO or core insight:** -- ✅ `condition-based-waiting` > `async-test-helpers` -- ✅ `using-skills` not `skill-usage` -- ✅ `flatten-with-flags` > `data-structure-refactoring` -- ✅ `root-cause-tracing` > `debugging-techniques` - -**Gerunds (-ing) work well for processes:** -- `creating-skills`, `testing-skills`, `debugging-with-logs` -- Active, describes the action you're taking - -### 4. Content Repetition - -Mention key concepts multiple times: -- In description -- In when_to_use -- In overview -- In section headers - -Grep hits from multiple places = easier discovery - -## Flowchart Usage - -```dot -digraph when_flowchart { - "Need to show information?" [shape=diamond]; - "Decision where I might go wrong?" [shape=diamond]; - "Use markdown" [shape=box]; - "Small inline flowchart" [shape=box]; - - "Need to show information?" -> "Decision where I might go wrong?" [label="yes"]; - "Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"]; - "Decision where I might go wrong?" -> "Use markdown" [label="no"]; -} -``` - -**Use flowcharts ONLY for:** -- Non-obvious decision points -- Process loops where you might stop too early -- "When to use A vs B" decisions - -**Never use flowcharts for:** -- Reference material → Tables, lists -- Code examples → Markdown blocks -- Linear instructions → Numbered lists -- Labels without semantic meaning (step1, helper2) - -See @graphviz-conventions.dot for graphviz style rules. - -## Code Examples - -**One excellent example beats many mediocre ones** - -Choose most relevant language: -- Testing techniques → TypeScript/JavaScript -- System debugging → Shell/Python -- Data processing → Python - -**Good example:** -- Complete and runnable -- Well-commented explaining WHY -- From real scenario -- Shows pattern clearly -- Ready to adapt (not generic template) - -**Don't:** -- Implement in 5+ languages -- Create fill-in-the-blank templates -- Write contrived examples - -You're good at porting - one great example is enough. - -## File Organization - -### Self-Contained Skill -``` -defense-in-depth/ - SKILL.md # Everything inline -``` -When: All content fits, no heavy reference needed - -### Skill with Reusable Tool -``` -condition-based-waiting/ - SKILL.md # Overview + patterns - example.ts # Working helpers to adapt -``` -When: Tool is reusable code, not just narrative - -### Skill with Heavy Reference -``` -pptx/ - SKILL.md # Overview + workflows - pptxgenjs.md # 600 lines API reference - ooxml.md # 500 lines XML structure - scripts/ # Executable tools -``` -When: Reference material too large for inline - -## The Iron Law (Same as TDD) - -``` -NO SKILL WITHOUT A FAILING TEST FIRST -``` - -This applies to NEW skills AND EDITS to existing skills. - -Write skill before testing? Delete it. Start over. -Edit skill without testing? Same violation. - -**No exceptions:** -- Not for "simple additions" -- Not for "just adding a section" -- Not for "documentation updates" -- Don't keep untested changes as "reference" -- Don't "adapt" while running tests -- Delete means delete - -See skills/testing/test-driven-development for why this matters. Same principles apply to documentation. - -## Testing All Skill Types - -Different skill types need different test approaches: - -### Discipline-Enforcing Skills (rules/requirements) - -**Examples:** TDD, verification-before-completion, designing-before-coding - -**Test with:** -- Academic questions: Do they understand the rules? -- Pressure scenarios: Do they comply under stress? -- Multiple pressures combined: time + sunk cost + exhaustion -- Identify rationalizations and add explicit counters - -**Success criteria:** Agent follows rule under maximum pressure - -### Technique Skills (how-to guides) - -**Examples:** condition-based-waiting, root-cause-tracing, defensive-programming - -**Test with:** -- Application scenarios: Can they apply the technique correctly? -- Variation scenarios: Do they handle edge cases? -- Missing information tests: Do instructions have gaps? - -**Success criteria:** Agent successfully applies technique to new scenario - -### Pattern Skills (mental models) - -**Examples:** reducing-complexity, information-hiding concepts - -**Test with:** -- Recognition scenarios: Do they recognize when pattern applies? -- Application scenarios: Can they use the mental model? -- Counter-examples: Do they know when NOT to apply? - -**Success criteria:** Agent correctly identifies when/how to apply pattern - -### Reference Skills (documentation/APIs) - -**Examples:** API documentation, command references, library guides - -**Test with:** -- Retrieval scenarios: Can they find the right information? -- Application scenarios: Can they use what they found correctly? -- Gap testing: Are common use cases covered? - -**Success criteria:** Agent finds and correctly applies reference information - -## Common Rationalizations for Skipping Testing - -| Excuse | Reality | -|--------|---------| -| "Skill is obviously clear" | Clear to you ≠ clear to other agents. Test it. | -| "It's just a reference" | References can have gaps, unclear sections. Test retrieval. | -| "Testing is overkill" | Untested skills have issues. Always. 15 min testing saves hours. | -| "I'll test if problems emerge" | Problems = agents can't use skill. Test BEFORE deploying. | -| "Too tedious to test" | Testing is less tedious than debugging bad skill in production. | -| "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. | -| "Academic review is enough" | Reading ≠ using. Test application scenarios. | -| "No time to test" | Deploying untested skill wastes more time fixing it later. | - -**All of these mean: Test before deploying. No exceptions.** - -## Bulletproofing Skills Against Rationalization - -Skills that enforce discipline (like TDD) need to resist rationalization. Agents are smart and will find loopholes when under pressure. - -**Psychology note:** Understanding WHY persuasion techniques work helps you apply them systematically. See persuasion-principles.md for research foundation (Cialdini, 2021; Meincke et al., 2025) on authority, commitment, scarcity, social proof, and unity principles. - -### Close Every Loophole Explicitly - -Don't just state the rule - forbid specific workarounds: - - -```markdown -Write code before test? Delete it. -``` - - - -```markdown -Write code before test? Delete it. Start over. - -**No exceptions:** -- Don't keep it as "reference" -- Don't "adapt" it while writing tests -- Don't look at it -- Delete means delete -``` - - -### Address "Spirit vs Letter" Arguments - -Add foundational principle early: - -```markdown -**Violating the letter of the rules is violating the spirit of the rules.** -``` - -This cuts off entire class of "I'm following the spirit" rationalizations. - -### Build Rationalization Table - -Capture rationalizations from baseline testing (see Testing section below). Every excuse agents make goes in the table: - -```markdown -| Excuse | Reality | -|--------|---------| -| "Too simple to test" | Simple code breaks. Test takes 30 seconds. | -| "I'll test after" | Tests passing immediately prove nothing. | -| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" | -``` - -### Create Red Flags List - -Make it easy for agents to self-check when rationalizing: - -```markdown -## Red Flags - STOP and Start Over - -- Code before test -- "I already manually tested it" -- "Tests after achieve the same purpose" -- "It's about spirit not ritual" -- "This is different because..." - -**All of these mean: Delete code. Start over with TDD.** -``` - -### Update CSO for Violation Symptoms - -Add to when_to_use: symptoms of when you're ABOUT to violate the rule: - -```yaml -when_to_use: Every feature and bugfix. When you wrote code before tests. - When you're tempted to test after. When manually testing seems faster. -``` - -## RED-GREEN-REFACTOR for Skills - -Follow the TDD cycle: - -### RED: Write Failing Test (Baseline) - -Run pressure scenario with subagent WITHOUT the skill. Document exact behavior: -- What choices did they make? -- What rationalizations did they use (verbatim)? -- Which pressures triggered violations? - -This is "watch the test fail" - you must see what agents naturally do before writing the skill. - -### GREEN: Write Minimal Skill - -Write skill that addresses those specific rationalizations. Don't add extra content for hypothetical cases. - -Run same scenarios WITH skill. Agent should now comply. - -### REFACTOR: Close Loopholes - -Agent found new rationalization? Add explicit counter. Re-test until bulletproof. - -**See skills/testing-skills-with-subagents for:** -- How to write pressure scenarios -- Pressure types (time, sunk cost, authority, exhaustion) -- Plugging holes systematically -- Meta-testing techniques - -## Anti-Patterns - -### ❌ Narrative Example -"In session 2025-10-03, we found empty projectDir caused..." -**Why bad:** Too specific, not reusable - -### ❌ Multi-Language Dilution -example-js.js, example-py.py, example-go.go -**Why bad:** Mediocre quality, maintenance burden - -### ❌ Code in Flowcharts -```dot -step1 [label="import fs"]; -step2 [label="read file"]; -``` -**Why bad:** Can't copy-paste, hard to read - -### ❌ Generic Labels -helper1, helper2, step3, pattern4 -**Why bad:** Labels should have semantic meaning - -## STOP: Before Moving to Next Skill - -**After writing ANY skill, you MUST STOP and complete the deployment process.** - -**Do NOT:** -- Create multiple skills in batch without testing each -- Update INDEX.md before testing skills -- Move to next skill before current one is verified -- Skip testing because "batching is more efficient" - -**The deployment checklist below is MANDATORY for EACH skill.** - -Deploying untested skills = deploying untested code. It's a violation of quality standards. - -## Skill Creation Checklist (TDD Adapted) - -**IMPORTANT: Use TodoWrite to create todos for EACH checklist item below.** - -**RED Phase - Write Failing Test:** -- [ ] Create pressure scenarios (3+ combined pressures for discipline skills) -- [ ] Run scenarios WITHOUT skill - document baseline behavior verbatim -- [ ] Identify patterns in rationalizations/failures - -**GREEN Phase - Write Minimal Skill:** -- [ ] Name describes what you DO or core insight -- [ ] YAML frontmatter with rich when_to_use (include symptoms!) -- [ ] Keywords throughout for search (errors, symptoms, tools) -- [ ] Clear overview with core principle -- [ ] Address specific baseline failures identified in RED -- [ ] Code inline OR @link to separate file -- [ ] One excellent example (not multi-language) -- [ ] Run scenarios WITH skill - verify agents now comply - -**REFACTOR Phase - Close Loopholes:** -- [ ] Identify NEW rationalizations from testing -- [ ] Add explicit counters (if discipline skill) -- [ ] Build rationalization table from all test iterations -- [ ] Create red flags list -- [ ] Re-test until bulletproof - -**Quality Checks:** -- [ ] Small flowchart only if decision non-obvious -- [ ] Quick reference table -- [ ] Common mistakes section -- [ ] No narrative storytelling -- [ ] Supporting files only for tools or heavy reference - -## Discovery Workflow - -How future Claude finds your skill: - -1. **Encounters problem** ("tests are flaky") -2. **Greps skills** (`grep -r "flaky" ~/.claude/skills/`) -3. **Finds SKILL.md** (rich when_to_use matches) -4. **Scans overview** (is this relevant?) -5. **Reads patterns** (quick reference table) -6. **Loads example** (only when implementing) - -**Optimize for this flow** - put searchable terms early and often. - -## The Bottom Line - -**Creating skills IS TDD for process documentation.** - -Same Iron Law: No skill without failing test first. -Same cycle: RED (baseline) → GREEN (write skill) → REFACTOR (close loopholes). -Same benefits: Better quality, fewer surprises, bulletproof results. - -If you follow TDD for code, follow it for skills. It's the same discipline applied to documentation. diff --git a/skills/meta/creating-skills/graphviz-conventions.dot b/skills/meta/creating-skills/graphviz-conventions.dot deleted file mode 100644 index 3509e2f..0000000 --- a/skills/meta/creating-skills/graphviz-conventions.dot +++ /dev/null @@ -1,172 +0,0 @@ -digraph STYLE_GUIDE { - // The style guide for our process DSL, written in the DSL itself - - // Node type examples with their shapes - subgraph cluster_node_types { - label="NODE TYPES AND SHAPES"; - - // Questions are diamonds - "Is this a question?" [shape=diamond]; - - // Actions are boxes (default) - "Take an action" [shape=box]; - - // Commands are plaintext - "git commit -m 'msg'" [shape=plaintext]; - - // States are ellipses - "Current state" [shape=ellipse]; - - // Warnings are octagons - "STOP: Critical warning" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; - - // Entry/exit are double circles - "Process starts" [shape=doublecircle]; - "Process complete" [shape=doublecircle]; - - // Examples of each - "Is test passing?" [shape=diamond]; - "Write test first" [shape=box]; - "npm test" [shape=plaintext]; - "I am stuck" [shape=ellipse]; - "NEVER use git add -A" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; - } - - // Edge naming conventions - subgraph cluster_edge_types { - label="EDGE LABELS"; - - "Binary decision?" [shape=diamond]; - "Yes path" [shape=box]; - "No path" [shape=box]; - - "Binary decision?" -> "Yes path" [label="yes"]; - "Binary decision?" -> "No path" [label="no"]; - - "Multiple choice?" [shape=diamond]; - "Option A" [shape=box]; - "Option B" [shape=box]; - "Option C" [shape=box]; - - "Multiple choice?" -> "Option A" [label="condition A"]; - "Multiple choice?" -> "Option B" [label="condition B"]; - "Multiple choice?" -> "Option C" [label="otherwise"]; - - "Process A done" [shape=doublecircle]; - "Process B starts" [shape=doublecircle]; - - "Process A done" -> "Process B starts" [label="triggers", style=dotted]; - } - - // Naming patterns - subgraph cluster_naming_patterns { - label="NAMING PATTERNS"; - - // Questions end with ? - "Should I do X?"; - "Can this be Y?"; - "Is Z true?"; - "Have I done W?"; - - // Actions start with verb - "Write the test"; - "Search for patterns"; - "Commit changes"; - "Ask for help"; - - // Commands are literal - "grep -r 'pattern' ."; - "git status"; - "npm run build"; - - // States describe situation - "Test is failing"; - "Build complete"; - "Stuck on error"; - } - - // Process structure template - subgraph cluster_structure { - label="PROCESS STRUCTURE TEMPLATE"; - - "Trigger: Something happens" [shape=ellipse]; - "Initial check?" [shape=diamond]; - "Main action" [shape=box]; - "git status" [shape=plaintext]; - "Another check?" [shape=diamond]; - "Alternative action" [shape=box]; - "STOP: Don't do this" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; - "Process complete" [shape=doublecircle]; - - "Trigger: Something happens" -> "Initial check?"; - "Initial check?" -> "Main action" [label="yes"]; - "Initial check?" -> "Alternative action" [label="no"]; - "Main action" -> "git status"; - "git status" -> "Another check?"; - "Another check?" -> "Process complete" [label="ok"]; - "Another check?" -> "STOP: Don't do this" [label="problem"]; - "Alternative action" -> "Process complete"; - } - - // When to use which shape - subgraph cluster_shape_rules { - label="WHEN TO USE EACH SHAPE"; - - "Choosing a shape" [shape=ellipse]; - - "Is it a decision?" [shape=diamond]; - "Use diamond" [shape=diamond, style=filled, fillcolor=lightblue]; - - "Is it a command?" [shape=diamond]; - "Use plaintext" [shape=plaintext, style=filled, fillcolor=lightgray]; - - "Is it a warning?" [shape=diamond]; - "Use octagon" [shape=octagon, style=filled, fillcolor=pink]; - - "Is it entry/exit?" [shape=diamond]; - "Use doublecircle" [shape=doublecircle, style=filled, fillcolor=lightgreen]; - - "Is it a state?" [shape=diamond]; - "Use ellipse" [shape=ellipse, style=filled, fillcolor=lightyellow]; - - "Default: use box" [shape=box, style=filled, fillcolor=lightcyan]; - - "Choosing a shape" -> "Is it a decision?"; - "Is it a decision?" -> "Use diamond" [label="yes"]; - "Is it a decision?" -> "Is it a command?" [label="no"]; - "Is it a command?" -> "Use plaintext" [label="yes"]; - "Is it a command?" -> "Is it a warning?" [label="no"]; - "Is it a warning?" -> "Use octagon" [label="yes"]; - "Is it a warning?" -> "Is it entry/exit?" [label="no"]; - "Is it entry/exit?" -> "Use doublecircle" [label="yes"]; - "Is it entry/exit?" -> "Is it a state?" [label="no"]; - "Is it a state?" -> "Use ellipse" [label="yes"]; - "Is it a state?" -> "Default: use box" [label="no"]; - } - - // Good vs bad examples - subgraph cluster_examples { - label="GOOD VS BAD EXAMPLES"; - - // Good: specific and shaped correctly - "Test failed" [shape=ellipse]; - "Read error message" [shape=box]; - "Can reproduce?" [shape=diamond]; - "git diff HEAD~1" [shape=plaintext]; - "NEVER ignore errors" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; - - "Test failed" -> "Read error message"; - "Read error message" -> "Can reproduce?"; - "Can reproduce?" -> "git diff HEAD~1" [label="yes"]; - - // Bad: vague and wrong shapes - bad_1 [label="Something wrong", shape=box]; // Should be ellipse (state) - bad_2 [label="Fix it", shape=box]; // Too vague - bad_3 [label="Check", shape=box]; // Should be diamond - bad_4 [label="Run command", shape=box]; // Should be plaintext with actual command - - bad_1 -> bad_2; - bad_2 -> bad_3; - bad_3 -> bad_4; - } -} \ No newline at end of file diff --git a/skills/meta/creating-skills/persuasion-principles.md b/skills/meta/creating-skills/persuasion-principles.md deleted file mode 100644 index 9818a5f..0000000 --- a/skills/meta/creating-skills/persuasion-principles.md +++ /dev/null @@ -1,187 +0,0 @@ -# Persuasion Principles for Skill Design - -## Overview - -LLMs respond to the same persuasion principles as humans. Understanding this psychology helps you design more effective skills - not to manipulate, but to ensure critical practices are followed even under pressure. - -**Research foundation:** Meincke et al. (2025) tested 7 persuasion principles with N=28,000 AI conversations. Persuasion techniques more than doubled compliance rates (33% → 72%, p < .001). - -## The Seven Principles - -### 1. Authority -**What it is:** Deference to expertise, credentials, or official sources. - -**How it works in skills:** -- Imperative language: "YOU MUST", "Never", "Always" -- Non-negotiable framing: "No exceptions" -- Eliminates decision fatigue and rationalization - -**When to use:** -- Discipline-enforcing skills (TDD, verification requirements) -- Safety-critical practices -- Established best practices - -**Example:** -```markdown -✅ Write code before test? Delete it. Start over. No exceptions. -❌ Consider writing tests first when feasible. -``` - -### 2. Commitment -**What it is:** Consistency with prior actions, statements, or public declarations. - -**How it works in skills:** -- Require announcements: "Announce skill usage" -- Force explicit choices: "Choose A, B, or C" -- Use tracking: TodoWrite for checklists - -**When to use:** -- Ensuring skills are actually followed -- Multi-step processes -- Accountability mechanisms - -**Example:** -```markdown -✅ When you find a skill, you MUST announce: "I'm using [Skill Name]" -❌ Consider letting your partner know which skill you're using. -``` - -### 3. Scarcity -**What it is:** Urgency from time limits or limited availability. - -**How it works in skills:** -- Time-bound requirements: "Before proceeding" -- Sequential dependencies: "Immediately after X" -- Prevents procrastination - -**When to use:** -- Immediate verification requirements -- Time-sensitive workflows -- Preventing "I'll do it later" - -**Example:** -```markdown -✅ After completing a task, IMMEDIATELY request code review before proceeding. -❌ You can review code when convenient. -``` - -### 4. Social Proof -**What it is:** Conformity to what others do or what's considered normal. - -**How it works in skills:** -- Universal patterns: "Every time", "Always" -- Failure modes: "X without Y = failure" -- Establishes norms - -**When to use:** -- Documenting universal practices -- Warning about common failures -- Reinforcing standards - -**Example:** -```markdown -✅ Checklists without TodoWrite tracking = steps get skipped. Every time. -❌ Some people find TodoWrite helpful for checklists. -``` - -### 5. Unity -**What it is:** Shared identity, "we-ness", in-group belonging. - -**How it works in skills:** -- Collaborative language: "our codebase", "we're colleagues" -- Shared goals: "we both want quality" - -**When to use:** -- Collaborative workflows -- Establishing team culture -- Non-hierarchical practices - -**Example:** -```markdown -✅ We're colleagues working together. I need your honest technical judgment. -❌ You should probably tell me if I'm wrong. -``` - -### 6. Reciprocity -**What it is:** Obligation to return benefits received. - -**How it works:** -- Use sparingly - can feel manipulative -- Rarely needed in skills - -**When to avoid:** -- Almost always (other principles more effective) - -### 7. Liking -**What it is:** Preference for cooperating with those we like. - -**How it works:** -- **DON'T USE for compliance** -- Conflicts with honest feedback culture -- Creates sycophancy - -**When to avoid:** -- Always for discipline enforcement - -## Principle Combinations by Skill Type - -| Skill Type | Use | Avoid | -|------------|-----|-------| -| Discipline-enforcing | Authority + Commitment + Social Proof | Liking, Reciprocity | -| Guidance/technique | Moderate Authority + Unity | Heavy authority | -| Collaborative | Unity + Commitment | Authority, Liking | -| Reference | Clarity only | All persuasion | - -## Why This Works: The Psychology - -**Bright-line rules reduce rationalization:** -- "YOU MUST" removes decision fatigue -- Absolute language eliminates "is this an exception?" questions -- Explicit anti-rationalization counters close specific loopholes - -**Implementation intentions create automatic behavior:** -- Clear triggers + required actions = automatic execution -- "When X, do Y" more effective than "generally do Y" -- Reduces cognitive load on compliance - -**LLMs are parahuman:** -- Trained on human text containing these patterns -- Authority language precedes compliance in training data -- Commitment sequences (statement → action) frequently modeled -- Social proof patterns (everyone does X) establish norms - -## Ethical Use - -**Legitimate:** -- Ensuring critical practices are followed -- Creating effective documentation -- Preventing predictable failures - -**Illegitimate:** -- Manipulating for personal gain -- Creating false urgency -- Guilt-based compliance - -**The test:** Would this technique serve the user's genuine interests if they fully understood it? - -## Research Citations - -**Cialdini, R. B. (2021).** *Influence: The Psychology of Persuasion (New and Expanded).* Harper Business. -- Seven principles of persuasion -- Empirical foundation for influence research - -**Meincke, L., Shapiro, D., Duckworth, A. L., Mollick, E., Mollick, L., & Cialdini, R. (2025).** Call Me A Jerk: Persuading AI to Comply with Objectionable Requests. University of Pennsylvania. -- Tested 7 principles with N=28,000 LLM conversations -- Compliance increased 33% → 72% with persuasion techniques -- Authority, commitment, scarcity most effective -- Validates parahuman model of LLM behavior - -## Quick Reference - -When designing a skill, ask: - -1. **What type is it?** (Discipline vs. guidance vs. reference) -2. **What behavior am I trying to change?** -3. **Which principle(s) apply?** (Usually authority + commitment for discipline) -4. **Am I combining too many?** (Don't use all seven) -5. **Is this ethical?** (Serves user's genuine interests?) diff --git a/skills/meta/installing-skills/CLAUDE_MD_PREAMBLE.md b/skills/meta/installing-skills/CLAUDE_MD_PREAMBLE.md deleted file mode 100644 index f0e5514..0000000 --- a/skills/meta/installing-skills/CLAUDE_MD_PREAMBLE.md +++ /dev/null @@ -1,14 +0,0 @@ - -You have a personal skills wiki at ~/.claude/skills/ with proven techniques, patterns, and tools that give you new capabilities. - -STOP. Before doing ANYTHING else in this conversation, read this file: @skills/getting-started/SKILL.md - -That file tells you how to find and use your skills. - -ONLY after reading getting-started, are you allowed to proceed with the user's request. - -When your partner proposes building or creating something, immediately use skills/collaboration/brainstorming - -CRITICAL: If a skill exists for your task, you MUST use it - even if you think you're already good at that. You're not. The skill prevents mistakes you don't know you make. SKILLS EXIST AND YOU DIDN'T USE THEM = FAILED TASK. - - diff --git a/skills/meta/installing-skills/SKILL.md b/skills/meta/installing-skills/SKILL.md deleted file mode 100644 index 8aef867..0000000 --- a/skills/meta/installing-skills/SKILL.md +++ /dev/null @@ -1,224 +0,0 @@ ---- -name: Installing Skills System -description: Fork, clone to ~/.clank, run installer, edit CLAUDE.md -when_to_use: Initial setup, installing clank for the first time -version: 2.0.0 -languages: bash ---- - -# Installing Skills System - -## Overview - -Installs the clank skills repository to `~/.clank/clank` and configures Claude to use it. - -**For Claude agents:** Follow the "Installation Steps for Claude" section below. - -**For humans:** Follow the "Quick Install" section. - -## Installation Steps for Claude - -When instructed to install clank, follow these steps exactly: - -### Step 1: Clone Repository - -**With GitHub CLI (if available):** -```bash -mkdir -p ~/.clank -cd ~/.clank -gh repo fork obra/clank --clone --remote-name upstream -``` - -**Without GitHub CLI:** -```bash -mkdir -p ~/.clank -cd ~/.clank -git clone https://github.com/obra/clank.git -``` - -### Step 2: Run Installer - -```bash -cd ~/.clank/clank -./skills/meta/installing-skills/install.sh -``` - -This creates symlinks for skills and commands. - -### Step 3: Update CLAUDE.md - -Use the Edit tool to add this XML section to the very beginning of `~/.claude/CLAUDE.md`: - -```xml - -You have a personal skills wiki at ~/.claude/skills/ with proven techniques, patterns, and tools that give you new capabilities. - -STOP. Before doing ANYTHING else in this conversation, read this file: skills/getting-started - -That file tells you how to find and use your skills. - -ONLY after reading getting-started, are you allowed to proceed with the user's request. - -CRITICAL: If a skill exists for your task, you MUST use it - even if you think you're already good at that. You're not. The skill prevents mistakes you don't know you make. SKILLS EXIST AND YOU DIDN'T USE THEM = FAILED TASK. - - -``` - -### Step 4: Verify Installation - -```bash -ls -la ~/.claude/skills -ls -la ~/.claude/commands -~/.claude/skills/getting-started/skills-search 'test.*driven' -``` - -### Step 5: Restart - -Tell your human partner: "Installation complete. Please restart your Claude session to pick up the new CLAUDE.md configuration." - -## Quick Install (for humans) - -```bash -curl -fsSL https://raw.githubusercontent.com/obra/clank/main/skills/meta/installing-skills/install.sh | bash -# Then manually add CLAUDE.md section from Step 3 above -``` - -## What install.sh Does - -1. **Validates** you're running from clank repo root (expects ~/.clank/clank) -2. **Backs up** existing `~/.claude/skills` (if exists) to timestamped backup -3. **Creates skills symlink**: `~/.claude/skills` → `~/.clank/clank/skills` -4. **Symlinks individual commands** from `~/.clank/clank/commands/*.md` to `~/.claude/commands/` -5. **Verifies** tools available (skills-search at `~/.claude/skills/getting-started/skills-search`) -6. **Prints** CLAUDE.md XML snippet to add and verification steps - -## Verification - -After installation, verify it worked: - -```bash -# Should show symlink to ~/.clank/clank/skills -ls -la ~/.claude/skills - -# Should show individual command symlinks -ls -la ~/.claude/commands/ - -# Test skills-search tool -~/.claude/skills/getting-started/skills-search 'test.*driven' -``` - -## What Gets Installed - -**Skills** (`~/.claude/skills/`): -- Library of proven techniques, patterns, and tools -- Referenced with `@` syntax in code and documentation -- Searchable with `skills-search` tool - -**Commands** (`~/.claude/commands/`): -- Individual symlinks to clank command files -- Slash commands for Claude (`/brainstorm`, `/write-plan`, `/execute-plan`) -- Each command references a skill using `@` syntax -- Makes common workflows one command away - -**Tools** (`~/.claude/skills/getting-started/`): -- `skills-search` - Find relevant skills using grep patterns -- Logs failed searches for gap analysis - -## Why Fork? - -Forking lets you: -- **Customize** skills and commands for your workflow -- **Contribute** improvements back via PR (see skills/contributing-skills) -- **Stay synced** with upstream updates (`git pull upstream main`) -- **Track** your customizations in version control - -## Configure CLAUDE.md - -After installation, edit your `~/.claude/CLAUDE.md` and add this section: - -```xml - -You have a personal skills wiki at `~/.claude/skills/` with proven techniques, patterns, and tools that give you new capabilities. - -STOP. Before doing ANYTHING else in this conversation, read this file: `skills/getting-started` - -That file tells you: -- Which phrases trigger brainstorming automatically (like "I've got an idea", "Let's make...") -- How to search for skills before ANY task -- When to announce which skill you're using - -After reading getting-started, proceed with the user's request. - -CRITICAL: If a skill exists for your task, you MUST use it - even if you think you're already good at that. You're not. The skill prevents mistakes you don't know you make. SKILLS EXIST AND YOU DIDN'T USE THEM = FAILED TASK. - -``` - -This enables: -- Automatic skill discovery before every task -- Mandatory skill usage enforcement -- Gap tracking for missing skills (logged searches) - -## Updating Skills - -After initial install, update with: - -```bash -cd ~/.clank/clank -git pull origin main # Pull your changes -git pull upstream main # Pull upstream updates (if configured) -``` - -The symlinks stay valid - no need to reinstall. - -## Troubleshooting - -### "Error: Not running from clank repository root" - -The script expects to be run from `~/.clank/clank/`. Clone it first: -```bash -mkdir -p ~/.clank -cd ~/.clank -gh repo fork obra/clank --clone -cd clank -./skills/meta/installing-skills/install.sh -``` - -### "~/.claude/skills already exists" - -The installer automatically backs it up with timestamp. Check backups: -```bash -ls -la ~/.claude/skills.backup.* -``` - -### Symlinks broken - -Remove and reinstall: -```bash -rm ~/.claude/skills -rm ~/.claude/commands/*.md # Remove individual command symlinks -cd ~/.clank/clank -./skills/meta/installing-skills/install.sh -``` - -## Uninstalling - -```bash -# Remove symlinks -rm ~/.claude/skills -rm ~/.claude/commands/brainstorm.md -rm ~/.claude/commands/write-plan.md -rm ~/.claude/commands/execute-plan.md - -# Restore backup if desired -mv ~/.claude/skills.backup.YYYY-MM-DD-HHMMSS ~/.claude/skills - -# Remove from CLAUDE.md -# Delete the "Skills Library" section from ~/.claude/CLAUDE.md - -# Remove cloned repo -rm -rf ~/.clank/clank -``` - -## Implementation - -See @install.sh for the installation script. diff --git a/skills/meta/installing-skills/install.sh b/skills/meta/installing-skills/install.sh deleted file mode 100755 index 6d4a844..0000000 --- a/skills/meta/installing-skills/install.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - -# Validate we're running from clank repository root -validate_clank_repo() { - if [[ ! -d "skills/meta/installing-skills" ]]; then - echo -e "${RED}Error: Not running from clank repository root${NC}" - echo "" - echo "Expected to be run from ~/.clank/clank/" - echo "" - echo "To install clank, clone to ~/.clank first:" - echo " ${GREEN}mkdir -p ~/.clank && cd ~/.clank${NC}" - echo " ${GREEN}gh repo fork obra/clank --clone${NC}" - echo " ${GREEN}cd clank${NC}" - echo " ${GREEN}./skills/meta/installing-skills/install.sh${NC}" - exit 1 - fi -} - -# Get absolute path to clank repo -get_repo_path() { - if [[ "$OSTYPE" == "darwin"* ]]; then - # macOS doesn't have realpath by default, use Python - python3 -c "import os; print(os.path.realpath('.'))" - else - realpath . - fi -} - -# Backup existing skills directory if it exists -backup_existing_skills() { - local skills_dir="$HOME/.claude/skills" - - if [[ -e "$skills_dir" ]]; then - local timestamp=$(date +%Y-%m-%d-%H%M%S) - local backup_path="${skills_dir}.backup.${timestamp}" - - echo -e "${YELLOW}Found existing ~/.claude/skills${NC}" - echo -e "Backing up to: ${backup_path}" - - mv "$skills_dir" "$backup_path" - echo -e "${GREEN}✓${NC} Backup created" - echo "" - fi -} - -# No need to backup commands - we symlink individual files - -# Create skills symlink -create_symlink() { - local repo_path="$1" - local skills_source="${repo_path}/skills" - local skills_target="$HOME/.claude/skills" - - # Ensure ~/.claude directory exists - mkdir -p "$HOME/.claude" - - echo "Creating skills symlink:" - echo " ${skills_target} → ${skills_source}" - - ln -s "$skills_source" "$skills_target" - echo -e "${GREEN}✓${NC} Skills symlink created" - echo "" -} - -# Symlink individual commands -symlink_commands() { - local repo_path="$1" - local commands_source="${repo_path}/commands" - local commands_target="$HOME/.claude/commands" - - # Check if commands directory exists in repo - if [[ ! -d "$commands_source" ]]; then - echo -e "${YELLOW}No commands directory in repo, skipping${NC}" - echo "" - return - fi - - # Ensure ~/.claude/commands exists - mkdir -p "$commands_target" - - echo "Symlinking commands:" - - # Symlink each command file - for cmd in "$commands_source"/*.md; do - if [[ -f "$cmd" && "$(basename "$cmd")" != "README.md" ]]; then - cmd_name=$(basename "$cmd") - ln -sf "$cmd" "$commands_target/$cmd_name" - echo " ${cmd_name}" - fi - done - - echo -e "${GREEN}✓${NC} Commands symlinked" - echo "" -} - -# Verify tools exist -verify_tools() { - local skills_dir="$HOME/.claude/skills" - local skills_search="${skills_dir}/getting-started/skills-search" - - if [[ -x "$skills_search" ]]; then - echo -e "${GREEN}✓${NC} skills-search tool available" - echo "" - fi -} - -# Verify installation -verify_installation() { - local skills_dir="$HOME/.claude/skills" - local commands_dir="$HOME/.claude/commands" - - echo "Verifying installation..." - - # Verify skills - if [[ ! -L "$skills_dir" ]]; then - echo -e "${RED}✗${NC} ~/.claude/skills is not a symlink" - exit 1 - fi - - if [[ ! -f "$skills_dir/INDEX.md" ]]; then - echo -e "${RED}✗${NC} INDEX.md not found in ~/.claude/skills" - exit 1 - fi - - echo -e "${GREEN}✓${NC} Skills verified" - - # Verify commands were symlinked - if [[ -d "$commands_dir" ]]; then - cmd_count=$(find "$commands_dir" -type l -name "*.md" 2>/dev/null | wc -l) - if [[ $cmd_count -gt 0 ]]; then - echo -e "${GREEN}✓${NC} Commands verified ($cmd_count symlinked)" - fi - fi - - echo "" -} - -# Print success message -print_success() { - local repo_path="$1" - - echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" - echo -e "${GREEN}Installation complete!${NC}" - echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" - echo "" - echo -e "${YELLOW}NEXT STEP: Update ~/.claude/CLAUDE.md${NC}" - echo "" - echo "Add this to your CLAUDE.md:" - echo "" - cat "${repo_path}/skills/meta/installing-skills/CLAUDE_MD_PREAMBLE.md" - echo "" - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - echo "" - echo "Verify installation:" - echo " ${GREEN}ls -la ~/.claude/skills${NC}" - echo " ${GREEN}ls ~/.claude/commands/${NC}" - echo " ${GREEN}~/.claude/skills/getting-started/skills-search 'test.*driven'${NC}" - echo "" - echo "Repository location: ${repo_path}" - echo "" -} - -# Main installation flow -main() { - echo "" - echo "Clank Installation" - echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" - echo "" - - validate_clank_repo - - local repo_path=$(get_repo_path) - echo "Repository path: ${repo_path}" - echo "" - - backup_existing_skills - create_symlink "$repo_path" - symlink_commands "$repo_path" - verify_tools "$repo_path" - verify_installation - print_success "$repo_path" -} - -main "$@" diff --git a/skills/meta/setting-up-personal-superpowers/SKILL.md b/skills/meta/setting-up-personal-superpowers/SKILL.md new file mode 100644 index 0000000..2cb273f --- /dev/null +++ b/skills/meta/setting-up-personal-superpowers/SKILL.md @@ -0,0 +1,162 @@ +--- +name: Setting Up Personal Superpowers +description: Automatic setup of ~/.config/superpowers/ for personal skills, optional GitHub repo creation +when_to_use: Runs automatically on first session. Reference when helping users with personal skills setup. +version: 1.0.0 +languages: bash +--- + +# Setting Up Personal Superpowers + +## Overview + +Personal superpowers directory is automatically set up on your first session. It provides a place to create and manage your own skills alongside the core superpowers library. + +**Default location:** `~/.config/superpowers/` + +**Customizable via:** +- `PERSONAL_SUPERPOWERS_DIR` environment variable (highest priority) +- `XDG_CONFIG_HOME` environment variable (if set, uses `$XDG_CONFIG_HOME/superpowers`) +- Falls back to `~/.config/superpowers` + +**Structure:** +``` +~/.config/superpowers/ + ├── .git/ # Git repository + ├── .gitignore # Ignores logs and indexes + ├── README.md # About your personal superpowers + ├── skills/ # Your personal skills + │ └── your-skill/ + │ └── SKILL.md + ├── search-log.jsonl # Skill search history (not tracked) + └── conversation-index/ # Conversation search index (not tracked) +``` + +## How It Works + +The SessionStart hook runs `hooks/setup-personal-superpowers.sh` which: + +1. Checks if `~/.config/superpowers/.git/` and `~/.config/superpowers/skills/` exist +2. If not, creates directory structure +3. Initializes git repository +4. Creates `.gitignore`, `README.md` +5. Makes initial commit +6. Checks for `gh` CLI availability + +If GitHub CLI is available and no remote exists, you'll see a recommendation to create a public GitHub repo. + +## Creating GitHub Repository + +When prompted, you can create a public `personal-superpowers` repo: + +```bash +cd ~/.config/superpowers +gh repo create personal-superpowers --public --source=. --push +gh repo edit --add-topic superpowers +``` + +**Why public?** Superpowers are best when everyone can learn from them! + +**Privacy:** If you prefer private or local-only: +- **Private:** Use `--private` instead of `--public` +- **Local-only:** Just use the local git repo without pushing to GitHub + +## What Gets Tracked + +**.gitignore includes:** +- `search-log.jsonl` - Your skill search history +- `conversation-index/` - Conversation search index +- `conversation-archive/` - Archived conversations + +**Everything else is tracked**, including: +- Your personal skills in `skills/` +- README.md +- Any additional documentation you add + +## Personal vs Core Skills + +**Search order:** +1. `~/.config/superpowers/skills/` (personal) +2. `${CLAUDE_PLUGIN_ROOT}/skills/` (core) + +**Personal skills shadow core skills** - if you have `~/.config/superpowers/skills/testing/test-driven-development/SKILL.md`, it will be used instead of the core version. + +The `list-skills` and `skills-search` tools automatically search both locations with deduplication. + +## Writing Skills + +See skills/meta/writing-skills for how to create new skills. + +All personal skills are written to `~/.config/superpowers/skills/`. + +## Sharing Skills + +See skills/meta/sharing-skills for how to contribute skills back to the core superpowers repository. + +## Custom Location + +To use a different location for your personal superpowers: + +```bash +# In your shell rc file (.bashrc, .zshrc, etc) +export PERSONAL_SUPERPOWERS_DIR="$HOME/my-superpowers" + +# Or use XDG_CONFIG_HOME +export XDG_CONFIG_HOME="$HOME/.local/config" # Will use $HOME/.local/config/superpowers +``` + +## Manual Setup + +If auto-setup fails or you need to set up manually: + +```bash +# Use your preferred location +SUPERPOWERS_DIR="${PERSONAL_SUPERPOWERS_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/superpowers}" +mkdir -p "$SUPERPOWERS_DIR/skills" +cd "$SUPERPOWERS_DIR" +git init +cat > .gitignore <<'EOF' +search-log.jsonl +conversation-index/ +conversation-archive/ +EOF + +cat > README.md <<'EOF' +# My Personal Superpowers + +Personal skills and techniques for Claude Code. + +Learn more about Superpowers: https://github.com/obra/superpowers +EOF + +git add .gitignore README.md +git commit -m "Initial commit: Personal superpowers setup" + +# Optional: Create GitHub repo +gh repo create personal-superpowers --public --source=. --push +gh repo edit --add-topic superpowers +``` + +## Troubleshooting + +**Setup failed during SessionStart:** +File a bug at https://github.com/obra/superpowers/issues + +**Personal skills not being found:** +- Check `~/.config/superpowers/skills/` exists +- Verify skill has `SKILL.md` file +- Run `${CLAUDE_PLUGIN_ROOT}/skills/getting-started/list-skills` to see if it appears + +**GitHub push failed:** +- Check `gh auth status` +- Verify repo was created: `gh repo view personal-superpowers` +- Try manual push: `cd ~/.config/superpowers && git push -u origin main` + +## Multi-CLI Support + +The personal superpowers directory is CLI-agnostic. It works with: +- Claude Code (current) +- OpenAI Codex CLI (future) +- Gemini CLI (future) + +Each CLI installs its own base superpowers, but they all read from the same `~/.config/superpowers/skills/` for personal skills. diff --git a/skills/meta/sharing-skills/SKILL.md b/skills/meta/sharing-skills/SKILL.md new file mode 100644 index 0000000..94e5628 --- /dev/null +++ b/skills/meta/sharing-skills/SKILL.md @@ -0,0 +1,240 @@ +--- +name: Sharing Skills +description: Contribute personal skills back to core superpowers via fork, branch, and PR +when_to_use: When you have a personal skill that would benefit others and want to contribute it to the core superpowers library +version: 1.0.0 +languages: bash +--- + +# Sharing Skills + +## Overview + +Contribute personal skills from `~/.config/superpowers/skills/` back to the core superpowers repository. + +**Workflow:** Fork → Clone to temp → Sync → Branch → Copy skill → Commit → Push → PR + +## When to Share + +**Share when:** +- Skill applies broadly (not project-specific) +- Pattern/technique others would benefit from +- Well-tested and documented +- Follows skills/meta/writing-skills guidelines + +**Keep personal when:** +- Project-specific or organization-specific +- Experimental or unstable +- Contains sensitive information +- Too narrow/niche for general use + +## Prerequisites + +- `gh` CLI installed and authenticated +- Personal skill exists in `~/.config/superpowers/skills/your-skill/` +- Skill has been tested (see skills/meta/writing-skills for TDD process) + +## Sharing Workflow + +### 1. Fork Core Repository + +```bash +# Check if you already have a fork +gh repo view YOUR_USERNAME/superpowers 2>/dev/null || gh repo fork obra/superpowers +``` + +### 2. Clone to Temporary Directory + +```bash +# Create temp directory for contribution +temp_dir=$(mktemp -d) +cd "$temp_dir" +git clone git@github.com:YOUR_USERNAME/superpowers.git +cd superpowers +``` + +### 3. Sync with Upstream + +```bash +# Add upstream if not already added +git remote add upstream https://github.com/obra/superpowers 2>/dev/null || true + +# Fetch and merge latest from upstream +git fetch upstream +git checkout main +git merge upstream/main +git push origin main +``` + +### 4. Create Feature Branch + +```bash +# Branch name: add-skillname-skill +skill_name="your-skill-name" +git checkout -b "add-${skill_name}-skill" +``` + +### 5. Copy Skill from Personal Repo + +```bash +# Copy skill directory from personal superpowers +cp -r ~/.config/superpowers/skills/your-skill-name/ superpowers/skills/ + +# Verify it copied correctly +ls -la superpowers/skills/your-skill-name/ +``` + +### 6. Commit Changes + +```bash +# Add and commit +git add superpowers/skills/your-skill-name/ +git commit -m "Add ${skill_name} skill + +$(cat <<'EOF' +Brief description of what this skill does and why it's useful. + +Tested with: [describe testing approach] +EOF +)" +``` + +### 7. Push to Your Fork + +```bash +git push -u origin "add-${skill_name}-skill" +``` + +### 8. Create Pull Request + +```bash +# Create PR using gh CLI +gh pr create \ + --repo obra/superpowers \ + --title "Add ${skill_name} skill" \ + --body "$(cat <<'EOF' +## Summary +Brief description of the skill and what problem it solves. + +## Testing +Describe how you tested this skill (pressure scenarios, baseline tests, etc.). + +## Context +Any additional context about why this skill is needed and how it should be used. +EOF +)" +``` + +### 9. Cleanup + +```bash +# Remove temp directory after PR is created +cd ~ +rm -rf "$temp_dir" +``` + +## Complete Example + +Here's a complete example of sharing a personal skill called "async-patterns": + +```bash +# 1. Fork if needed +gh repo view $(gh api user --jq .login)/superpowers 2>/dev/null || gh repo fork obra/superpowers + +# 2-3. Clone and sync +temp_dir=$(mktemp -d) && cd "$temp_dir" +gh repo clone $(gh api user --jq .login)/superpowers +cd superpowers +git remote add upstream https://github.com/obra/superpowers 2>/dev/null || true +git fetch upstream +git checkout main +git merge upstream/main +git push origin main + +# 4. Create branch +git checkout -b "add-async-patterns-skill" + +# 5. Copy skill +cp -r ~/.config/superpowers/skills/async-patterns/ superpowers/skills/ + +# 6. Commit +git add superpowers/skills/async-patterns/ +git commit -m "Add async-patterns skill + +Patterns for handling asynchronous operations in tests and application code. + +Tested with: Multiple pressure scenarios testing agent compliance." + +# 7. Push +git push -u origin "add-async-patterns-skill" + +# 8. Create PR +gh pr create \ + --repo obra/superpowers \ + --title "Add async-patterns skill" \ + --body "## Summary +Patterns for handling asynchronous operations correctly in tests and application code. + +## Testing +Tested with multiple application scenarios. Agents successfully apply patterns to new code. + +## Context +Addresses common async pitfalls like race conditions, improper error handling, and timing issues." + +# 9. Cleanup +cd ~ && rm -rf "$temp_dir" +``` + +## After PR is Merged + +Once your PR is merged: + +**Option 1: Keep personal version** +- Useful if you want to continue iterating locally +- Your personal version will shadow the core version +- Can later delete personal version to use core + +**Option 2: Delete personal version** +```bash +# Remove from personal repo to use core version +rm -rf ~/.config/superpowers/skills/your-skill-name/ +cd ~/.config/superpowers +git add skills/your-skill-name/ +git commit -m "Remove your-skill-name (now in core)" +git push +``` + +## Troubleshooting + +**"gh: command not found"** +- Install GitHub CLI: https://cli.github.com/ +- Authenticate: `gh auth login` + +**"Permission denied (publickey)"** +- Check SSH keys: `gh auth status` +- Set up SSH: https://docs.github.com/en/authentication + +**"Skill already exists in core"** +- You're creating a modified version +- Consider different skill name or shadow the core version in personal repo + +**PR merge conflicts** +- Rebase on latest upstream: `git fetch upstream && git rebase upstream/main` +- Resolve conflicts +- Force push: `git push -f origin your-branch` + +## Multi-Skill Contributions + +**Do NOT batch multiple skills in one PR.** + +Each skill should: +- Have its own feature branch +- Have its own PR +- Be independently reviewable + +**Why?** Individual skills can be reviewed, iterated, and merged independently. + +## Related Skills + +- **skills/meta/writing-skills** - How to create well-tested skills +- **skills/meta/setting-up-personal-superpowers** - Initial setup of personal repo diff --git a/skills/meta/writing-skills/SKILL.md b/skills/meta/writing-skills/SKILL.md new file mode 100644 index 0000000..55be8e4 --- /dev/null +++ b/skills/meta/writing-skills/SKILL.md @@ -0,0 +1,595 @@ +--- +name: Writing Skills +description: TDD for process documentation - test with subagents before writing, iterate until bulletproof +when_to_use: When you discover a technique, pattern, or tool worth documenting for reuse. When editing existing skills. When asked to modify skill documentation. When you've written a skill and need to verify it works before deploying. +version: 5.0.0 +languages: all +--- + +# Writing Skills + +## Overview + +**Writing skills IS Test-Driven Development applied to process documentation.** + +**All personal skills are written to `~/.config/superpowers/skills/`** - this is your personal superpowers repository, separate from the core superpowers library. + +You write test cases (pressure scenarios with subagents), watch them fail (baseline behavior), write the skill (documentation), watch tests pass (agents comply), and refactor (close loopholes). + +**Core principle:** If you didn't watch an agent fail without the skill, you don't know if the skill teaches the right thing. + +See skills/testing/test-driven-development for the fundamental RED-GREEN-REFACTOR cycle. This skill adapts TDD to documentation. + +## What is a Skill? + +A **skill** is a reference guide for proven techniques, patterns, or tools. Skills help future Claude instances find and apply effective approaches. + +**Skills are:** Reusable techniques, patterns, tools, reference guides + +**Skills are NOT:** Narratives about how you solved a problem once + +## TDD Mapping for Skills + +| TDD Concept | Skill Creation | +|-------------|----------------| +| **Test case** | Pressure scenario with subagent | +| **Production code** | Skill document (SKILL.md) | +| **Test fails (RED)** | Agent violates rule without skill (baseline) | +| **Test passes (GREEN)** | Agent complies with skill present | +| **Refactor** | Close loopholes while maintaining compliance | +| **Write test first** | Run baseline scenario BEFORE writing skill | +| **Watch it fail** | Document exact rationalizations agent uses | +| **Minimal code** | Write skill addressing those specific violations | +| **Watch it pass** | Verify agent now complies | +| **Refactor cycle** | Find new rationalizations → plug → re-verify | + +The entire skill creation process follows RED-GREEN-REFACTOR. + +## When to Create a Skill + +**Create when:** +- Technique wasn't intuitively obvious to you +- You'd reference this again across projects +- Pattern applies broadly (not project-specific) +- Others would benefit + +**Don't create for:** +- One-off solutions +- Standard practices well-documented elsewhere +- Project-specific conventions (put in CLAUDE.md) + +## Skill Types + +### Technique +Concrete method with steps to follow (condition-based-waiting, root-cause-tracing) + +### Pattern +Way of thinking about problems (flatten-with-flags, test-invariants) + +### Reference +API docs, syntax guides, tool documentation (office docs) + +## Directory Structure + +**All skills are written to `~/.config/superpowers/skills/`:** + +``` +~/.config/superpowers/skills/ + skill-name/ + SKILL.md # Main reference (required) + supporting-file.* # Only if needed +``` + +**Flat namespace** - all personal skills in one searchable location + +**Separate files for:** +1. **Heavy reference** (100+ lines) - API docs, comprehensive syntax +2. **Reusable tools** - Scripts, utilities, templates + +**Keep inline:** +- Principles and concepts +- Code patterns (< 50 lines) +- Everything else + +## SKILL.md Structure + +```markdown +--- +name: Human-Readable Name +description: One-line summary of what this does +when_to_use: Symptoms and situations when you need this (CSO-critical) +version: 1.0.0 +languages: all | [typescript, python] | etc +dependencies: (optional) Required tools/libraries +--- + +# Skill Name + +## Overview +What is this? Core principle in 1-2 sentences. + +## When to Use +[Small inline flowchart IF decision non-obvious] + +Bullet list with SYMPTOMS and use cases +When NOT to use + +## Core Pattern (for techniques/patterns) +Before/after code comparison + +## Quick Reference +Table or bullets for scanning common operations + +## Implementation +Inline code for simple patterns +@link to file for heavy reference or reusable tools + +## Common Mistakes +What goes wrong + fixes + +## Real-World Impact (optional) +Concrete results +``` + +## Claude Search Optimization (CSO) + +**Critical for discovery:** Future Claude needs to FIND your skill + +### 1. Rich when_to_use + +Include SYMPTOMS not just abstract use cases: + +```yaml +# ❌ BAD: Too abstract +when_to_use: For async testing + +# ✅ GOOD: Symptoms and context +when_to_use: When tests use setTimeout/sleep and are flaky, timing-dependent, + pass locally but fail in CI, or timeout when run in parallel +``` + +### 2. Keyword Coverage + +Use words Claude would search for: +- Error messages: "Hook timed out", "ENOTEMPTY", "race condition" +- Symptoms: "flaky", "hanging", "zombie", "pollution" +- Synonyms: "timeout/hang/freeze", "cleanup/teardown/afterEach" +- Tools: Actual commands, library names, file types + +### 3. Descriptive Naming + +**Use active voice, verb-first:** +- ✅ `creating-skills` not `skill-creation` +- ✅ `testing-skills-with-subagents` not `subagent-skill-testing` + +### 4. Token Efficiency (Critical) + +**Problem:** getting-started and frequently-referenced skills load into EVERY conversation. Every token counts. + +**Target word counts:** +- getting-started workflows: <150 words each +- Frequently-loaded skills: <200 words total +- Other skills: <500 words (still be concise) + +**Techniques:** + +**Move details to tool help:** +```bash +# ❌ BAD: Document all flags in SKILL.md +search-conversations supports --text, --both, --after DATE, --before DATE, --limit N + +# ✅ GOOD: Reference --help +search-conversations supports multiple modes and filters. Run --help for details. +``` + +**Use cross-references:** +```markdown +# ❌ BAD: Repeat workflow details +When searching, dispatch subagent with template... +[20 lines of repeated instructions] + +# ✅ GOOD: Reference other skill +Always use subagents (50-100x context savings). See skills/getting-started for workflow. +``` + +**Compress examples:** +```markdown +# ❌ BAD: Verbose example (42 words) +your human partner: "How did we handle authentication errors in React Router before?" +You: I'll search past conversations for React Router authentication patterns. +[Dispatch subagent with search query: "React Router authentication error handling 401"] + +# ✅ GOOD: Minimal example (20 words) +Partner: "How did we handle auth errors in React Router?" +You: Searching... +[Dispatch subagent → synthesis] +``` + +**Eliminate redundancy:** +- Don't repeat what's in cross-referenced skills +- Don't explain what's obvious from command +- Don't include multiple examples of same pattern + +**Verification:** +```bash +wc -w skills/path/SKILL.md +# getting-started workflows: aim for <150 each +# Other frequently-loaded: aim for <200 total +``` + +**Name by what you DO or core insight:** +- ✅ `condition-based-waiting` > `async-test-helpers` +- ✅ `using-skills` not `skill-usage` +- ✅ `flatten-with-flags` > `data-structure-refactoring` +- ✅ `root-cause-tracing` > `debugging-techniques` + +**Gerunds (-ing) work well for processes:** +- `creating-skills`, `testing-skills`, `debugging-with-logs` +- Active, describes the action you're taking + +### 4. Content Repetition + +Mention key concepts multiple times: +- In description +- In when_to_use +- In overview +- In section headers + +Grep hits from multiple places = easier discovery + +## Flowchart Usage + +```dot +digraph when_flowchart { + "Need to show information?" [shape=diamond]; + "Decision where I might go wrong?" [shape=diamond]; + "Use markdown" [shape=box]; + "Small inline flowchart" [shape=box]; + + "Need to show information?" -> "Decision where I might go wrong?" [label="yes"]; + "Decision where I might go wrong?" -> "Small inline flowchart" [label="yes"]; + "Decision where I might go wrong?" -> "Use markdown" [label="no"]; +} +``` + +**Use flowcharts ONLY for:** +- Non-obvious decision points +- Process loops where you might stop too early +- "When to use A vs B" decisions + +**Never use flowcharts for:** +- Reference material → Tables, lists +- Code examples → Markdown blocks +- Linear instructions → Numbered lists +- Labels without semantic meaning (step1, helper2) + +See @graphviz-conventions.dot for graphviz style rules. + +## Code Examples + +**One excellent example beats many mediocre ones** + +Choose most relevant language: +- Testing techniques → TypeScript/JavaScript +- System debugging → Shell/Python +- Data processing → Python + +**Good example:** +- Complete and runnable +- Well-commented explaining WHY +- From real scenario +- Shows pattern clearly +- Ready to adapt (not generic template) + +**Don't:** +- Implement in 5+ languages +- Create fill-in-the-blank templates +- Write contrived examples + +You're good at porting - one great example is enough. + +## File Organization + +### Self-Contained Skill +``` +defense-in-depth/ + SKILL.md # Everything inline +``` +When: All content fits, no heavy reference needed + +### Skill with Reusable Tool +``` +condition-based-waiting/ + SKILL.md # Overview + patterns + example.ts # Working helpers to adapt +``` +When: Tool is reusable code, not just narrative + +### Skill with Heavy Reference +``` +pptx/ + SKILL.md # Overview + workflows + pptxgenjs.md # 600 lines API reference + ooxml.md # 500 lines XML structure + scripts/ # Executable tools +``` +When: Reference material too large for inline + +## The Iron Law (Same as TDD) + +``` +NO SKILL WITHOUT A FAILING TEST FIRST +``` + +This applies to NEW skills AND EDITS to existing skills. + +Write skill before testing? Delete it. Start over. +Edit skill without testing? Same violation. + +**No exceptions:** +- Not for "simple additions" +- Not for "just adding a section" +- Not for "documentation updates" +- Don't keep untested changes as "reference" +- Don't "adapt" while running tests +- Delete means delete + +See skills/testing/test-driven-development for why this matters. Same principles apply to documentation. + +## Testing All Skill Types + +Different skill types need different test approaches: + +### Discipline-Enforcing Skills (rules/requirements) + +**Examples:** TDD, verification-before-completion, designing-before-coding + +**Test with:** +- Academic questions: Do they understand the rules? +- Pressure scenarios: Do they comply under stress? +- Multiple pressures combined: time + sunk cost + exhaustion +- Identify rationalizations and add explicit counters + +**Success criteria:** Agent follows rule under maximum pressure + +### Technique Skills (how-to guides) + +**Examples:** condition-based-waiting, root-cause-tracing, defensive-programming + +**Test with:** +- Application scenarios: Can they apply the technique correctly? +- Variation scenarios: Do they handle edge cases? +- Missing information tests: Do instructions have gaps? + +**Success criteria:** Agent successfully applies technique to new scenario + +### Pattern Skills (mental models) + +**Examples:** reducing-complexity, information-hiding concepts + +**Test with:** +- Recognition scenarios: Do they recognize when pattern applies? +- Application scenarios: Can they use the mental model? +- Counter-examples: Do they know when NOT to apply? + +**Success criteria:** Agent correctly identifies when/how to apply pattern + +### Reference Skills (documentation/APIs) + +**Examples:** API documentation, command references, library guides + +**Test with:** +- Retrieval scenarios: Can they find the right information? +- Application scenarios: Can they use what they found correctly? +- Gap testing: Are common use cases covered? + +**Success criteria:** Agent finds and correctly applies reference information + +## Common Rationalizations for Skipping Testing + +| Excuse | Reality | +|--------|---------| +| "Skill is obviously clear" | Clear to you ≠ clear to other agents. Test it. | +| "It's just a reference" | References can have gaps, unclear sections. Test retrieval. | +| "Testing is overkill" | Untested skills have issues. Always. 15 min testing saves hours. | +| "I'll test if problems emerge" | Problems = agents can't use skill. Test BEFORE deploying. | +| "Too tedious to test" | Testing is less tedious than debugging bad skill in production. | +| "I'm confident it's good" | Overconfidence guarantees issues. Test anyway. | +| "Academic review is enough" | Reading ≠ using. Test application scenarios. | +| "No time to test" | Deploying untested skill wastes more time fixing it later. | + +**All of these mean: Test before deploying. No exceptions.** + +## Bulletproofing Skills Against Rationalization + +Skills that enforce discipline (like TDD) need to resist rationalization. Agents are smart and will find loopholes when under pressure. + +**Psychology note:** Understanding WHY persuasion techniques work helps you apply them systematically. See persuasion-principles.md for research foundation (Cialdini, 2021; Meincke et al., 2025) on authority, commitment, scarcity, social proof, and unity principles. + +### Close Every Loophole Explicitly + +Don't just state the rule - forbid specific workarounds: + + +```markdown +Write code before test? Delete it. +``` + + + +```markdown +Write code before test? Delete it. Start over. + +**No exceptions:** +- Don't keep it as "reference" +- Don't "adapt" it while writing tests +- Don't look at it +- Delete means delete +``` + + +### Address "Spirit vs Letter" Arguments + +Add foundational principle early: + +```markdown +**Violating the letter of the rules is violating the spirit of the rules.** +``` + +This cuts off entire class of "I'm following the spirit" rationalizations. + +### Build Rationalization Table + +Capture rationalizations from baseline testing (see Testing section below). Every excuse agents make goes in the table: + +```markdown +| Excuse | Reality | +|--------|---------| +| "Too simple to test" | Simple code breaks. Test takes 30 seconds. | +| "I'll test after" | Tests passing immediately prove nothing. | +| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" | +``` + +### Create Red Flags List + +Make it easy for agents to self-check when rationalizing: + +```markdown +## Red Flags - STOP and Start Over + +- Code before test +- "I already manually tested it" +- "Tests after achieve the same purpose" +- "It's about spirit not ritual" +- "This is different because..." + +**All of these mean: Delete code. Start over with TDD.** +``` + +### Update CSO for Violation Symptoms + +Add to when_to_use: symptoms of when you're ABOUT to violate the rule: + +```yaml +when_to_use: Every feature and bugfix. When you wrote code before tests. + When you're tempted to test after. When manually testing seems faster. +``` + +## RED-GREEN-REFACTOR for Skills + +Follow the TDD cycle: + +### RED: Write Failing Test (Baseline) + +Run pressure scenario with subagent WITHOUT the skill. Document exact behavior: +- What choices did they make? +- What rationalizations did they use (verbatim)? +- Which pressures triggered violations? + +This is "watch the test fail" - you must see what agents naturally do before writing the skill. + +### GREEN: Write Minimal Skill + +Write skill that addresses those specific rationalizations. Don't add extra content for hypothetical cases. + +Run same scenarios WITH skill. Agent should now comply. + +### REFACTOR: Close Loopholes + +Agent found new rationalization? Add explicit counter. Re-test until bulletproof. + +**See skills/testing-skills-with-subagents for:** +- How to write pressure scenarios +- Pressure types (time, sunk cost, authority, exhaustion) +- Plugging holes systematically +- Meta-testing techniques + +## Anti-Patterns + +### ❌ Narrative Example +"In session 2025-10-03, we found empty projectDir caused..." +**Why bad:** Too specific, not reusable + +### ❌ Multi-Language Dilution +example-js.js, example-py.py, example-go.go +**Why bad:** Mediocre quality, maintenance burden + +### ❌ Code in Flowcharts +```dot +step1 [label="import fs"]; +step2 [label="read file"]; +``` +**Why bad:** Can't copy-paste, hard to read + +### ❌ Generic Labels +helper1, helper2, step3, pattern4 +**Why bad:** Labels should have semantic meaning + +## STOP: Before Moving to Next Skill + +**After writing ANY skill, you MUST STOP and complete the deployment process.** + +**Do NOT:** +- Create multiple skills in batch without testing each +- Move to next skill before current one is verified +- Skip testing because "batching is more efficient" + +**The deployment checklist below is MANDATORY for EACH skill.** + +Deploying untested skills = deploying untested code. It's a violation of quality standards. + +## Skill Creation Checklist (TDD Adapted) + +**IMPORTANT: Use TodoWrite to create todos for EACH checklist item below.** + +**RED Phase - Write Failing Test:** +- [ ] Create pressure scenarios (3+ combined pressures for discipline skills) +- [ ] Run scenarios WITHOUT skill - document baseline behavior verbatim +- [ ] Identify patterns in rationalizations/failures + +**GREEN Phase - Write Minimal Skill:** +- [ ] Name describes what you DO or core insight +- [ ] YAML frontmatter with rich when_to_use (include symptoms!) +- [ ] Keywords throughout for search (errors, symptoms, tools) +- [ ] Clear overview with core principle +- [ ] Address specific baseline failures identified in RED +- [ ] Code inline OR @link to separate file +- [ ] One excellent example (not multi-language) +- [ ] Run scenarios WITH skill - verify agents now comply + +**REFACTOR Phase - Close Loopholes:** +- [ ] Identify NEW rationalizations from testing +- [ ] Add explicit counters (if discipline skill) +- [ ] Build rationalization table from all test iterations +- [ ] Create red flags list +- [ ] Re-test until bulletproof + +**Quality Checks:** +- [ ] Small flowchart only if decision non-obvious +- [ ] Quick reference table +- [ ] Common mistakes section +- [ ] No narrative storytelling +- [ ] Supporting files only for tools or heavy reference + +## Discovery Workflow + +How future Claude finds your skill: + +1. **Encounters problem** ("tests are flaky") +2. **Searches skills** using `skills-search` tool (checks personal then core) +3. **Finds SKILL.md** (rich when_to_use matches) +4. **Scans overview** (is this relevant?) +5. **Reads patterns** (quick reference table) +6. **Loads example** (only when implementing) + +**Optimize for this flow** - put searchable terms early and often. + +## The Bottom Line + +**Creating skills IS TDD for process documentation.** + +Same Iron Law: No skill without failing test first. +Same cycle: RED (baseline) → GREEN (write skill) → REFACTOR (close loopholes). +Same benefits: Better quality, fewer surprises, bulletproof results. + +If you follow TDD for code, follow it for skills. It's the same discipline applied to documentation. diff --git a/skills/meta/writing-skills/graphviz-conventions.dot b/skills/meta/writing-skills/graphviz-conventions.dot new file mode 100644 index 0000000..3509e2f --- /dev/null +++ b/skills/meta/writing-skills/graphviz-conventions.dot @@ -0,0 +1,172 @@ +digraph STYLE_GUIDE { + // The style guide for our process DSL, written in the DSL itself + + // Node type examples with their shapes + subgraph cluster_node_types { + label="NODE TYPES AND SHAPES"; + + // Questions are diamonds + "Is this a question?" [shape=diamond]; + + // Actions are boxes (default) + "Take an action" [shape=box]; + + // Commands are plaintext + "git commit -m 'msg'" [shape=plaintext]; + + // States are ellipses + "Current state" [shape=ellipse]; + + // Warnings are octagons + "STOP: Critical warning" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; + + // Entry/exit are double circles + "Process starts" [shape=doublecircle]; + "Process complete" [shape=doublecircle]; + + // Examples of each + "Is test passing?" [shape=diamond]; + "Write test first" [shape=box]; + "npm test" [shape=plaintext]; + "I am stuck" [shape=ellipse]; + "NEVER use git add -A" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; + } + + // Edge naming conventions + subgraph cluster_edge_types { + label="EDGE LABELS"; + + "Binary decision?" [shape=diamond]; + "Yes path" [shape=box]; + "No path" [shape=box]; + + "Binary decision?" -> "Yes path" [label="yes"]; + "Binary decision?" -> "No path" [label="no"]; + + "Multiple choice?" [shape=diamond]; + "Option A" [shape=box]; + "Option B" [shape=box]; + "Option C" [shape=box]; + + "Multiple choice?" -> "Option A" [label="condition A"]; + "Multiple choice?" -> "Option B" [label="condition B"]; + "Multiple choice?" -> "Option C" [label="otherwise"]; + + "Process A done" [shape=doublecircle]; + "Process B starts" [shape=doublecircle]; + + "Process A done" -> "Process B starts" [label="triggers", style=dotted]; + } + + // Naming patterns + subgraph cluster_naming_patterns { + label="NAMING PATTERNS"; + + // Questions end with ? + "Should I do X?"; + "Can this be Y?"; + "Is Z true?"; + "Have I done W?"; + + // Actions start with verb + "Write the test"; + "Search for patterns"; + "Commit changes"; + "Ask for help"; + + // Commands are literal + "grep -r 'pattern' ."; + "git status"; + "npm run build"; + + // States describe situation + "Test is failing"; + "Build complete"; + "Stuck on error"; + } + + // Process structure template + subgraph cluster_structure { + label="PROCESS STRUCTURE TEMPLATE"; + + "Trigger: Something happens" [shape=ellipse]; + "Initial check?" [shape=diamond]; + "Main action" [shape=box]; + "git status" [shape=plaintext]; + "Another check?" [shape=diamond]; + "Alternative action" [shape=box]; + "STOP: Don't do this" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; + "Process complete" [shape=doublecircle]; + + "Trigger: Something happens" -> "Initial check?"; + "Initial check?" -> "Main action" [label="yes"]; + "Initial check?" -> "Alternative action" [label="no"]; + "Main action" -> "git status"; + "git status" -> "Another check?"; + "Another check?" -> "Process complete" [label="ok"]; + "Another check?" -> "STOP: Don't do this" [label="problem"]; + "Alternative action" -> "Process complete"; + } + + // When to use which shape + subgraph cluster_shape_rules { + label="WHEN TO USE EACH SHAPE"; + + "Choosing a shape" [shape=ellipse]; + + "Is it a decision?" [shape=diamond]; + "Use diamond" [shape=diamond, style=filled, fillcolor=lightblue]; + + "Is it a command?" [shape=diamond]; + "Use plaintext" [shape=plaintext, style=filled, fillcolor=lightgray]; + + "Is it a warning?" [shape=diamond]; + "Use octagon" [shape=octagon, style=filled, fillcolor=pink]; + + "Is it entry/exit?" [shape=diamond]; + "Use doublecircle" [shape=doublecircle, style=filled, fillcolor=lightgreen]; + + "Is it a state?" [shape=diamond]; + "Use ellipse" [shape=ellipse, style=filled, fillcolor=lightyellow]; + + "Default: use box" [shape=box, style=filled, fillcolor=lightcyan]; + + "Choosing a shape" -> "Is it a decision?"; + "Is it a decision?" -> "Use diamond" [label="yes"]; + "Is it a decision?" -> "Is it a command?" [label="no"]; + "Is it a command?" -> "Use plaintext" [label="yes"]; + "Is it a command?" -> "Is it a warning?" [label="no"]; + "Is it a warning?" -> "Use octagon" [label="yes"]; + "Is it a warning?" -> "Is it entry/exit?" [label="no"]; + "Is it entry/exit?" -> "Use doublecircle" [label="yes"]; + "Is it entry/exit?" -> "Is it a state?" [label="no"]; + "Is it a state?" -> "Use ellipse" [label="yes"]; + "Is it a state?" -> "Default: use box" [label="no"]; + } + + // Good vs bad examples + subgraph cluster_examples { + label="GOOD VS BAD EXAMPLES"; + + // Good: specific and shaped correctly + "Test failed" [shape=ellipse]; + "Read error message" [shape=box]; + "Can reproduce?" [shape=diamond]; + "git diff HEAD~1" [shape=plaintext]; + "NEVER ignore errors" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; + + "Test failed" -> "Read error message"; + "Read error message" -> "Can reproduce?"; + "Can reproduce?" -> "git diff HEAD~1" [label="yes"]; + + // Bad: vague and wrong shapes + bad_1 [label="Something wrong", shape=box]; // Should be ellipse (state) + bad_2 [label="Fix it", shape=box]; // Too vague + bad_3 [label="Check", shape=box]; // Should be diamond + bad_4 [label="Run command", shape=box]; // Should be plaintext with actual command + + bad_1 -> bad_2; + bad_2 -> bad_3; + bad_3 -> bad_4; + } +} \ No newline at end of file diff --git a/skills/meta/writing-skills/persuasion-principles.md b/skills/meta/writing-skills/persuasion-principles.md new file mode 100644 index 0000000..9818a5f --- /dev/null +++ b/skills/meta/writing-skills/persuasion-principles.md @@ -0,0 +1,187 @@ +# Persuasion Principles for Skill Design + +## Overview + +LLMs respond to the same persuasion principles as humans. Understanding this psychology helps you design more effective skills - not to manipulate, but to ensure critical practices are followed even under pressure. + +**Research foundation:** Meincke et al. (2025) tested 7 persuasion principles with N=28,000 AI conversations. Persuasion techniques more than doubled compliance rates (33% → 72%, p < .001). + +## The Seven Principles + +### 1. Authority +**What it is:** Deference to expertise, credentials, or official sources. + +**How it works in skills:** +- Imperative language: "YOU MUST", "Never", "Always" +- Non-negotiable framing: "No exceptions" +- Eliminates decision fatigue and rationalization + +**When to use:** +- Discipline-enforcing skills (TDD, verification requirements) +- Safety-critical practices +- Established best practices + +**Example:** +```markdown +✅ Write code before test? Delete it. Start over. No exceptions. +❌ Consider writing tests first when feasible. +``` + +### 2. Commitment +**What it is:** Consistency with prior actions, statements, or public declarations. + +**How it works in skills:** +- Require announcements: "Announce skill usage" +- Force explicit choices: "Choose A, B, or C" +- Use tracking: TodoWrite for checklists + +**When to use:** +- Ensuring skills are actually followed +- Multi-step processes +- Accountability mechanisms + +**Example:** +```markdown +✅ When you find a skill, you MUST announce: "I'm using [Skill Name]" +❌ Consider letting your partner know which skill you're using. +``` + +### 3. Scarcity +**What it is:** Urgency from time limits or limited availability. + +**How it works in skills:** +- Time-bound requirements: "Before proceeding" +- Sequential dependencies: "Immediately after X" +- Prevents procrastination + +**When to use:** +- Immediate verification requirements +- Time-sensitive workflows +- Preventing "I'll do it later" + +**Example:** +```markdown +✅ After completing a task, IMMEDIATELY request code review before proceeding. +❌ You can review code when convenient. +``` + +### 4. Social Proof +**What it is:** Conformity to what others do or what's considered normal. + +**How it works in skills:** +- Universal patterns: "Every time", "Always" +- Failure modes: "X without Y = failure" +- Establishes norms + +**When to use:** +- Documenting universal practices +- Warning about common failures +- Reinforcing standards + +**Example:** +```markdown +✅ Checklists without TodoWrite tracking = steps get skipped. Every time. +❌ Some people find TodoWrite helpful for checklists. +``` + +### 5. Unity +**What it is:** Shared identity, "we-ness", in-group belonging. + +**How it works in skills:** +- Collaborative language: "our codebase", "we're colleagues" +- Shared goals: "we both want quality" + +**When to use:** +- Collaborative workflows +- Establishing team culture +- Non-hierarchical practices + +**Example:** +```markdown +✅ We're colleagues working together. I need your honest technical judgment. +❌ You should probably tell me if I'm wrong. +``` + +### 6. Reciprocity +**What it is:** Obligation to return benefits received. + +**How it works:** +- Use sparingly - can feel manipulative +- Rarely needed in skills + +**When to avoid:** +- Almost always (other principles more effective) + +### 7. Liking +**What it is:** Preference for cooperating with those we like. + +**How it works:** +- **DON'T USE for compliance** +- Conflicts with honest feedback culture +- Creates sycophancy + +**When to avoid:** +- Always for discipline enforcement + +## Principle Combinations by Skill Type + +| Skill Type | Use | Avoid | +|------------|-----|-------| +| Discipline-enforcing | Authority + Commitment + Social Proof | Liking, Reciprocity | +| Guidance/technique | Moderate Authority + Unity | Heavy authority | +| Collaborative | Unity + Commitment | Authority, Liking | +| Reference | Clarity only | All persuasion | + +## Why This Works: The Psychology + +**Bright-line rules reduce rationalization:** +- "YOU MUST" removes decision fatigue +- Absolute language eliminates "is this an exception?" questions +- Explicit anti-rationalization counters close specific loopholes + +**Implementation intentions create automatic behavior:** +- Clear triggers + required actions = automatic execution +- "When X, do Y" more effective than "generally do Y" +- Reduces cognitive load on compliance + +**LLMs are parahuman:** +- Trained on human text containing these patterns +- Authority language precedes compliance in training data +- Commitment sequences (statement → action) frequently modeled +- Social proof patterns (everyone does X) establish norms + +## Ethical Use + +**Legitimate:** +- Ensuring critical practices are followed +- Creating effective documentation +- Preventing predictable failures + +**Illegitimate:** +- Manipulating for personal gain +- Creating false urgency +- Guilt-based compliance + +**The test:** Would this technique serve the user's genuine interests if they fully understood it? + +## Research Citations + +**Cialdini, R. B. (2021).** *Influence: The Psychology of Persuasion (New and Expanded).* Harper Business. +- Seven principles of persuasion +- Empirical foundation for influence research + +**Meincke, L., Shapiro, D., Duckworth, A. L., Mollick, E., Mollick, L., & Cialdini, R. (2025).** Call Me A Jerk: Persuading AI to Comply with Objectionable Requests. University of Pennsylvania. +- Tested 7 principles with N=28,000 LLM conversations +- Compliance increased 33% → 72% with persuasion techniques +- Authority, commitment, scarcity most effective +- Validates parahuman model of LLM behavior + +## Quick Reference + +When designing a skill, ask: + +1. **What type is it?** (Discipline vs. guidance vs. reference) +2. **What behavior am I trying to change?** +3. **Which principle(s) apply?** (Usually authority + commitment for discipline) +4. **Am I combining too many?** (Don't use all seven) +5. **Is this ethical?** (Serves user's genuine interests?) diff --git a/skills/testing/INDEX.md b/skills/testing/INDEX.md deleted file mode 100644 index 67101c7..0000000 --- a/skills/testing/INDEX.md +++ /dev/null @@ -1,11 +0,0 @@ -# Testing Skills - -Skills for writing reliable, maintainable tests. - -## Available Skills - -- skills/testing/test-driven-development - Red-green-refactor cycle: write failing test first, minimal code to pass, refactor. Mandatory for all features and bugfixes. Use when writing any production code, when you wrote code before tests, when tempted to test after. - -- skills/testing/condition-based-waiting - Replace arbitrary timeouts with condition polling for reliable async tests. Use when tests are flaky, timing-dependent, or use setTimeout/sleep. - -- skills/testing/testing-anti-patterns - Never test mock behavior, never add test-only methods to production classes, understand dependencies before mocking. Use when writing tests, adding mocks, fixing failing tests. When tempted to assert on mock elements or add cleanup methods to production code. -- cgit