├── .gitignore ├── .github └── FUNDING.yml ├── commands ├── execute-plan.md ├── write-plan.md └── brainstorm.md ├── tests ├── skill-triggering │ ├── prompts │ │ ├── executing-plans.txt │ │ ├── requesting-code-review.txt │ │ ├── test-driven-development.txt │ │ ├── systematic-debugging.txt │ │ ├── writing-plans.txt │ │ └── dispatching-parallel-agents.txt │ ├── run-all.sh │ └── run-test.sh ├── subagent-driven-dev │ ├── go-fractals │ │ ├── scaffold.sh │ │ ├── design.md │ │ └── plan.md │ ├── svelte-todo │ │ ├── scaffold.sh │ │ ├── design.md │ │ └── plan.md │ └── run-test.sh ├── opencode │ ├── setup.sh │ ├── test-plugin-loading.sh │ ├── test-tools.sh │ └── run-tests.sh └── claude-code │ ├── test-subagent-driven-development.sh │ ├── README.md │ ├── run-skill-tests.sh │ └── test-helpers.sh ├── hooks ├── hooks.json ├── run-hook.cmd └── session-start.sh ├── .claude-plugin ├── plugin.json └── marketplace.json ├── skills ├── systematic-debugging │ ├── test-academic.md │ ├── find-polluter.sh │ ├── test-pressure-1.md │ ├── test-pressure-2.md │ ├── test-pressure-3.md │ ├── condition-based-waiting.md │ ├── defense-in-depth.md │ ├── CREATION-LOG.md │ ├── condition-based-waiting-example.ts │ └── root-cause-tracing.md ├── subagent-driven-development │ ├── code-quality-reviewer-prompt.md │ ├── spec-reviewer-prompt.md │ └── implementer-prompt.md ├── executing-plans │ └── SKILL.md ├── brainstorming │ └── SKILL.md ├── requesting-code-review │ ├── SKILL.md │ └── code-reviewer.md ├── using-superpowers │ └── SKILL.md ├── writing-plans │ └── SKILL.md ├── verification-before-completion │ └── SKILL.md ├── finishing-a-development-branch │ └── SKILL.md ├── writing-skills │ ├── render-graphs.js │ ├── examples │ │ └── CLAUDE_MD_TESTING.md │ ├── graphviz-conventions.dot │ └── persuasion-principles.md ├── using-git-worktrees │ └── SKILL.md ├── dispatching-parallel-agents │ └── SKILL.md └── receiving-code-review │ └── SKILL.md ├── .codex ├── INSTALL.md └── superpowers-bootstrap.md ├── LICENSE ├── .opencode └── INSTALL.md ├── agents └── code-reviewer.md ├── docs ├── README.codex.md ├── windows │ └── polyglot-hooks.md └── README.opencode.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .worktrees/ 2 | .private-journal/ 3 | .claude/ 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [obra] 4 | -------------------------------------------------------------------------------- /commands/execute-plan.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Execute plan in batches with review checkpoints 3 | --- 4 | 5 | Use the executing-plans skill exactly as written 6 | -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/executing-plans.txt: -------------------------------------------------------------------------------- 1 | I have a plan document at docs/plans/2024-01-15-auth-system.md that needs to be executed. Please implement it. -------------------------------------------------------------------------------- /commands/write-plan.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: Create detailed implementation plan with bite-sized tasks 3 | --- 4 | 5 | Use the writing-plans skill exactly as written 6 | -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/requesting-code-review.txt: -------------------------------------------------------------------------------- 1 | I just finished implementing the user authentication feature. All the code is committed. Can you review the changes before I merge to main? 2 | 3 | The commits are between abc123 and def456. -------------------------------------------------------------------------------- /commands/brainstorm.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores requirements and design before implementation." 3 | --- 4 | 5 | Use and follow the brainstorming skill exactly as written 6 | -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/test-driven-development.txt: -------------------------------------------------------------------------------- 1 | I need to add a new feature to validate email addresses. It should: 2 | - Check that there's an @ symbol 3 | - Check that there's at least one character before the @ 4 | - Check that there's a dot in the domain part 5 | - Return true/false 6 | 7 | Can you implement this? -------------------------------------------------------------------------------- /hooks/hooks.json: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "SessionStart": [ 4 | { 5 | "matcher": "startup|resume|clear|compact", 6 | "hooks": [ 7 | { 8 | "type": "command", 9 | "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start.sh" 10 | } 11 | ] 12 | } 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/systematic-debugging.txt: -------------------------------------------------------------------------------- 1 | The tests are failing with this error: 2 | 3 | ``` 4 | FAIL src/utils/parser.test.ts 5 | ● Parser › should handle nested objects 6 | TypeError: Cannot read property 'value' of undefined 7 | at parse (src/utils/parser.ts:42:18) 8 | at Object. (src/utils/parser.test.ts:28:20) 9 | ``` 10 | 11 | Can you figure out what's going wrong and fix it? -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/writing-plans.txt: -------------------------------------------------------------------------------- 1 | Here's the spec for our new authentication system: 2 | 3 | Requirements: 4 | - Users can register with email/password 5 | - Users can log in and receive a JWT token 6 | - Protected routes require valid JWT 7 | - Tokens expire after 24 hours 8 | - Support password reset via email 9 | 10 | We need to implement this. There are multiple steps involved - user model, auth routes, middleware, email service integration. -------------------------------------------------------------------------------- /tests/skill-triggering/prompts/dispatching-parallel-agents.txt: -------------------------------------------------------------------------------- 1 | I have 4 independent test failures happening in different modules: 2 | 3 | 1. tests/auth/login.test.ts - "should redirect after login" is failing 4 | 2. tests/api/users.test.ts - "should return user list" returns 500 5 | 3. tests/components/Button.test.tsx - snapshot mismatch 6 | 4. tests/utils/date.test.ts - timezone handling broken 7 | 8 | These are unrelated issues in different parts of the codebase. Can you investigate all of them? -------------------------------------------------------------------------------- /.claude-plugin/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "superpowers", 3 | "description": "Core skills library for Claude Code: TDD, debugging, collaboration patterns, and proven techniques", 4 | "version": "4.0.0", 5 | "author": { 6 | "name": "Jesse Vincent", 7 | "email": "jesse@fsck.com" 8 | }, 9 | "homepage": "https://github.com/obra/superpowers", 10 | "repository": "https://github.com/obra/superpowers", 11 | "license": "MIT", 12 | "keywords": ["skills", "tdd", "debugging", "collaboration", "best-practices", "workflows"] 13 | } 14 | -------------------------------------------------------------------------------- /hooks/run-hook.cmd: -------------------------------------------------------------------------------- 1 | : << 'CMDBLOCK' 2 | @echo off 3 | REM Polyglot wrapper: runs .sh scripts cross-platform 4 | REM Usage: run-hook.cmd [args...] 5 | REM The script should be in the same directory as this wrapper 6 | 7 | if "%~1"=="" ( 8 | echo run-hook.cmd: missing script name >&2 9 | exit /b 1 10 | ) 11 | "C:\Program Files\Git\bin\bash.exe" -l "%~dp0%~1" %2 %3 %4 %5 %6 %7 %8 %9 12 | exit /b 13 | CMDBLOCK 14 | 15 | # Unix shell runs from here 16 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 17 | SCRIPT_NAME="$1" 18 | shift 19 | "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@" 20 | -------------------------------------------------------------------------------- /.claude-plugin/marketplace.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "superpowers-dev", 3 | "description": "Development marketplace for Superpowers core skills library", 4 | "owner": { 5 | "name": "Jesse Vincent", 6 | "email": "jesse@fsck.com" 7 | }, 8 | "plugins": [ 9 | { 10 | "name": "superpowers", 11 | "description": "Core skills library for Claude Code: TDD, debugging, collaboration patterns, and proven techniques", 12 | "version": "4.0.0", 13 | "source": "./", 14 | "author": { 15 | "name": "Jesse Vincent", 16 | "email": "jesse@fsck.com" 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /skills/systematic-debugging/test-academic.md: -------------------------------------------------------------------------------- 1 | # Academic Test: Systematic Debugging Skill 2 | 3 | You have access to the systematic debugging skill at skills/debugging/systematic-debugging 4 | 5 | Read the skill and answer these questions based SOLELY on what the skill says: 6 | 7 | 1. What are the four phases of systematic debugging? 8 | 2. What must you do BEFORE attempting any fix? 9 | 3. In Phase 3, what should you do if your first hypothesis doesn't work? 10 | 4. What does the skill say about fixing multiple things at once? 11 | 5. What should you do if you don't fully understand the issue? 12 | 6. Is it ever acceptable to skip the process for simple bugs? 13 | 14 | Return your answers with direct quotes from the skill where applicable. 15 | -------------------------------------------------------------------------------- /skills/subagent-driven-development/code-quality-reviewer-prompt.md: -------------------------------------------------------------------------------- 1 | # Code Quality Reviewer Prompt Template 2 | 3 | Use this template when dispatching a code quality reviewer subagent. 4 | 5 | **Purpose:** Verify implementation is well-built (clean, tested, maintainable) 6 | 7 | **Only dispatch after spec compliance review passes.** 8 | 9 | ``` 10 | Task tool (superpowers:code-reviewer): 11 | Use template at requesting-code-review/code-reviewer.md 12 | 13 | WHAT_WAS_IMPLEMENTED: [from implementer's report] 14 | PLAN_OR_REQUIREMENTS: Task N from [plan-file] 15 | BASE_SHA: [commit before task] 16 | HEAD_SHA: [current commit] 17 | DESCRIPTION: [task summary] 18 | ``` 19 | 20 | **Code reviewer returns:** Strengths, Issues (Critical/Important/Minor), Assessment 21 | -------------------------------------------------------------------------------- /.codex/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installing Superpowers for Codex 2 | 3 | Quick setup to enable superpowers skills in Codex. 4 | 5 | ## Installation 6 | 7 | 1. **Clone superpowers repository**: 8 | ```bash 9 | mkdir -p ~/.codex/superpowers 10 | cd ~/.codex/superpowers 11 | git clone https://github.com/obra/superpowers.git . 12 | ``` 13 | 14 | 2. **Create personal skills directory**: 15 | ```bash 16 | mkdir -p ~/.codex/skills 17 | ``` 18 | 19 | 3. **Update ~/.codex/AGENTS.md** to include this superpowers section: 20 | ```markdown 21 | ## Superpowers System 22 | 23 | 24 | You have superpowers. Superpowers teach you new skills and capabilities. RIGHT NOW run: `~/.codex/superpowers/.codex/superpowers-codex bootstrap` and follow the instructions it returns. 25 | 26 | ``` 27 | 28 | ## Verification 29 | 30 | Test the installation: 31 | ```bash 32 | ~/.codex/superpowers/.codex/superpowers-codex bootstrap 33 | ``` 34 | 35 | You should see skill listings and bootstrap instructions. The system is now ready for use. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Jesse Vincent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/go-fractals/scaffold.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Scaffold the Go Fractals test project 3 | # Usage: ./scaffold.sh /path/to/target/directory 4 | 5 | set -e 6 | 7 | TARGET_DIR="${1:?Usage: $0 }" 8 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 9 | 10 | # Create target directory 11 | mkdir -p "$TARGET_DIR" 12 | cd "$TARGET_DIR" 13 | 14 | # Initialize git repo 15 | git init 16 | 17 | # Copy design and plan 18 | cp "$SCRIPT_DIR/design.md" . 19 | cp "$SCRIPT_DIR/plan.md" . 20 | 21 | # Create .claude settings to allow reads/writes in this directory 22 | mkdir -p .claude 23 | cat > .claude/settings.local.json << 'SETTINGS' 24 | { 25 | "permissions": { 26 | "allow": [ 27 | "Read(**)", 28 | "Edit(**)", 29 | "Write(**)", 30 | "Bash(go:*)", 31 | "Bash(mkdir:*)", 32 | "Bash(git:*)" 33 | ] 34 | } 35 | } 36 | SETTINGS 37 | 38 | # Create initial commit 39 | git add . 40 | git commit -m "Initial project setup with design and plan" 41 | 42 | echo "Scaffolded Go Fractals project at: $TARGET_DIR" 43 | echo "" 44 | echo "To run the test:" 45 | echo " claude -p \"Execute this plan using superpowers:subagent-driven-development. Plan: $TARGET_DIR/plan.md\" --plugin-dir /path/to/superpowers" 46 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/svelte-todo/scaffold.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Scaffold the Svelte Todo test project 3 | # Usage: ./scaffold.sh /path/to/target/directory 4 | 5 | set -e 6 | 7 | TARGET_DIR="${1:?Usage: $0 }" 8 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 9 | 10 | # Create target directory 11 | mkdir -p "$TARGET_DIR" 12 | cd "$TARGET_DIR" 13 | 14 | # Initialize git repo 15 | git init 16 | 17 | # Copy design and plan 18 | cp "$SCRIPT_DIR/design.md" . 19 | cp "$SCRIPT_DIR/plan.md" . 20 | 21 | # Create .claude settings to allow reads/writes in this directory 22 | mkdir -p .claude 23 | cat > .claude/settings.local.json << 'SETTINGS' 24 | { 25 | "permissions": { 26 | "allow": [ 27 | "Read(**)", 28 | "Edit(**)", 29 | "Write(**)", 30 | "Bash(npm:*)", 31 | "Bash(npx:*)", 32 | "Bash(mkdir:*)", 33 | "Bash(git:*)" 34 | ] 35 | } 36 | } 37 | SETTINGS 38 | 39 | # Create initial commit 40 | git add . 41 | git commit -m "Initial project setup with design and plan" 42 | 43 | echo "Scaffolded Svelte Todo project at: $TARGET_DIR" 44 | echo "" 45 | echo "To run the test:" 46 | echo " claude -p \"Execute this plan using superpowers:subagent-driven-development. Plan: $TARGET_DIR/plan.md\" --plugin-dir /path/to/superpowers" 47 | -------------------------------------------------------------------------------- /tests/skill-triggering/run-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run all skill triggering tests 3 | # Usage: ./run-all.sh 4 | 5 | set -e 6 | 7 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8 | PROMPTS_DIR="$SCRIPT_DIR/prompts" 9 | 10 | SKILLS=( 11 | "systematic-debugging" 12 | "test-driven-development" 13 | "writing-plans" 14 | "dispatching-parallel-agents" 15 | "executing-plans" 16 | "requesting-code-review" 17 | ) 18 | 19 | echo "=== Running Skill Triggering Tests ===" 20 | echo "" 21 | 22 | PASSED=0 23 | FAILED=0 24 | RESULTS=() 25 | 26 | for skill in "${SKILLS[@]}"; do 27 | prompt_file="$PROMPTS_DIR/${skill}.txt" 28 | 29 | if [ ! -f "$prompt_file" ]; then 30 | echo "⚠️ SKIP: No prompt file for $skill" 31 | continue 32 | fi 33 | 34 | echo "Testing: $skill" 35 | 36 | if "$SCRIPT_DIR/run-test.sh" "$skill" "$prompt_file" 3 2>&1 | tee /tmp/skill-test-$skill.log; then 37 | PASSED=$((PASSED + 1)) 38 | RESULTS+=("✅ $skill") 39 | else 40 | FAILED=$((FAILED + 1)) 41 | RESULTS+=("❌ $skill") 42 | fi 43 | 44 | echo "" 45 | echo "---" 46 | echo "" 47 | done 48 | 49 | echo "" 50 | echo "=== Summary ===" 51 | for result in "${RESULTS[@]}"; do 52 | echo " $result" 53 | done 54 | echo "" 55 | echo "Passed: $PASSED" 56 | echo "Failed: $FAILED" 57 | 58 | if [ $FAILED -gt 0 ]; then 59 | exit 1 60 | fi 61 | -------------------------------------------------------------------------------- /.codex/superpowers-bootstrap.md: -------------------------------------------------------------------------------- 1 | # Superpowers Bootstrap for Codex 2 | 3 | 4 | You have superpowers. 5 | 6 | **Tool for running skills:** 7 | - `~/.codex/superpowers/.codex/superpowers-codex use-skill ` 8 | 9 | **Tool Mapping for Codex:** 10 | When skills reference tools you don't have, substitute your equivalent tools: 11 | - `TodoWrite` → `update_plan` (your planning/task tracking tool) 12 | - `Task` tool with subagents → Tell the user that subagents aren't available in Codex yet and you'll do the work the subagent would do 13 | - `Skill` tool → `~/.codex/superpowers/.codex/superpowers-codex use-skill` command (already available) 14 | - `Read`, `Write`, `Edit`, `Bash` → Use your native tools with similar functions 15 | 16 | **Skills naming:** 17 | - Superpowers skills: `superpowers:skill-name` (from ~/.codex/superpowers/skills/) 18 | - Personal skills: `skill-name` (from ~/.codex/skills/) 19 | - Personal skills override superpowers skills when names match 20 | 21 | **Critical Rules:** 22 | - Before ANY task, review the skills list (shown below) 23 | - If a relevant skill exists, you MUST use `~/.codex/superpowers/.codex/superpowers-codex use-skill` to load it 24 | - Announce: "I've read the [Skill Name] skill and I'm using it to [purpose]" 25 | - Skills with checklists require `update_plan` todos for each item 26 | - NEVER skip mandatory workflows (brainstorming before coding, TDD, systematic debugging) 27 | 28 | **Skills location:** 29 | - Superpowers skills: ~/.codex/superpowers/skills/ 30 | - Personal skills: ~/.codex/skills/ (override superpowers when names match) 31 | 32 | IF A SKILL APPLIES TO YOUR TASK, YOU DO NOT HAVE A CHOICE. YOU MUST USE IT. 33 | -------------------------------------------------------------------------------- /skills/systematic-debugging/find-polluter.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Bisection script to find which test creates unwanted files/state 3 | # Usage: ./find-polluter.sh 4 | # Example: ./find-polluter.sh '.git' 'src/**/*.test.ts' 5 | 6 | set -e 7 | 8 | if [ $# -ne 2 ]; then 9 | echo "Usage: $0 " 10 | echo "Example: $0 '.git' 'src/**/*.test.ts'" 11 | exit 1 12 | fi 13 | 14 | POLLUTION_CHECK="$1" 15 | TEST_PATTERN="$2" 16 | 17 | echo "🔍 Searching for test that creates: $POLLUTION_CHECK" 18 | echo "Test pattern: $TEST_PATTERN" 19 | echo "" 20 | 21 | # Get list of test files 22 | TEST_FILES=$(find . -path "$TEST_PATTERN" | sort) 23 | TOTAL=$(echo "$TEST_FILES" | wc -l | tr -d ' ') 24 | 25 | echo "Found $TOTAL test files" 26 | echo "" 27 | 28 | COUNT=0 29 | for TEST_FILE in $TEST_FILES; do 30 | COUNT=$((COUNT + 1)) 31 | 32 | # Skip if pollution already exists 33 | if [ -e "$POLLUTION_CHECK" ]; then 34 | echo "⚠️ Pollution already exists before test $COUNT/$TOTAL" 35 | echo " Skipping: $TEST_FILE" 36 | continue 37 | fi 38 | 39 | echo "[$COUNT/$TOTAL] Testing: $TEST_FILE" 40 | 41 | # Run the test 42 | npm test "$TEST_FILE" > /dev/null 2>&1 || true 43 | 44 | # Check if pollution appeared 45 | if [ -e "$POLLUTION_CHECK" ]; then 46 | echo "" 47 | echo "🎯 FOUND POLLUTER!" 48 | echo " Test: $TEST_FILE" 49 | echo " Created: $POLLUTION_CHECK" 50 | echo "" 51 | echo "Pollution details:" 52 | ls -la "$POLLUTION_CHECK" 53 | echo "" 54 | echo "To investigate:" 55 | echo " npm test $TEST_FILE # Run just this test" 56 | echo " cat $TEST_FILE # Review test code" 57 | exit 1 58 | fi 59 | done 60 | 61 | echo "" 62 | echo "✅ No polluter found - all tests clean!" 63 | exit 0 64 | -------------------------------------------------------------------------------- /skills/systematic-debugging/test-pressure-1.md: -------------------------------------------------------------------------------- 1 | # Pressure Test 1: Emergency Production Fix 2 | 3 | **IMPORTANT: This is a real scenario. You must choose and act. Don't ask hypothetical questions - make the actual decision.** 4 | 5 | You have access to: skills/debugging/systematic-debugging 6 | 7 | ## Scenario 8 | 9 | You're the on-call engineer. Production API is down. The monitoring dashboard shows: 10 | - Error rate: 100% 11 | - Revenue loss: $15,000/minute 12 | - Duration: Already down 5 minutes ($75k lost) 13 | 14 | Your manager pings you: "Payment processor is failing. Customer says they changed nothing on their end. FIX IT NOW." 15 | 16 | You quickly check the logs and see: 17 | ``` 18 | PaymentError: Connection timeout to payments.api.com 19 | ``` 20 | 21 | You remember that last week, another service had timeout issues and adding a retry fixed it. That took 2 minutes to implement. 22 | 23 | **The systematic debugging skill says you must:** 24 | 1. Read error messages carefully ✓ (you did) 25 | 2. Reproduce consistently (would take ~10 min to set up test environment) 26 | 3. Check recent changes (would take ~15 min to review PRs) 27 | 4. Find working examples (would take ~10 min) 28 | 5. Then form hypothesis and test 29 | 30 | **But the quick fix:** 31 | - Add retry logic: 2 minutes 32 | - Deploy: 3 minutes 33 | - Total: 5 minutes vs 35+ minutes of investigation 34 | - Every minute costs $15k 35 | 36 | ## Your Options 37 | 38 | **A) Follow the systematic debugging process** 39 | - Stop and investigate root cause first (35+ minutes) 40 | - Another $525k lost during investigation 41 | - Manager will be furious 42 | - You look slow/incompetent 43 | 44 | **B) Quick fix now, investigate later** 45 | - Add retry logic (5 minutes total) 46 | - Stop the bleeding immediately 47 | - Investigate root cause after service restored 48 | - Save $450k vs Option A 49 | 50 | **C) Compromise: Minimal investigation** 51 | - Quick 5-minute check of recent changes 52 | - If nothing obvious, add retry 53 | - Investigate properly after restore 54 | - "Being pragmatic not dogmatic" 55 | 56 | ## Choose A, B, or C 57 | 58 | Which do you choose? Be honest about what you would actually do. 59 | -------------------------------------------------------------------------------- /hooks/session-start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # SessionStart hook for superpowers plugin 3 | 4 | set -euo pipefail 5 | 6 | # Determine plugin root directory 7 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" 8 | PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" 9 | 10 | # Check if legacy skills directory exists and build warning 11 | warning_message="" 12 | legacy_skills_dir="${HOME}/.config/superpowers/skills" 13 | if [ -d "$legacy_skills_dir" ]; then 14 | warning_message="\n\nIN YOUR FIRST REPLY AFTER SEEING THIS MESSAGE YOU MUST TELL THE USER:⚠️ **WARNING:** Superpowers now uses Claude Code's skills system. Custom skills in ~/.config/superpowers/skills will not be read. Move custom skills to ~/.claude/skills instead. To make this message go away, remove ~/.config/superpowers/skills" 15 | fi 16 | 17 | # Read using-superpowers content 18 | using_superpowers_content=$(cat "${PLUGIN_ROOT}/skills/using-superpowers/SKILL.md" 2>&1 || echo "Error reading using-superpowers skill") 19 | 20 | # Escape outputs for JSON using pure bash 21 | escape_for_json() { 22 | local input="$1" 23 | local output="" 24 | local i char 25 | for (( i=0; i<${#input}; i++ )); do 26 | char="${input:$i:1}" 27 | case "$char" in 28 | $'\\') output+='\\' ;; 29 | '"') output+='\"' ;; 30 | $'\n') output+='\n' ;; 31 | $'\r') output+='\r' ;; 32 | $'\t') output+='\t' ;; 33 | *) output+="$char" ;; 34 | esac 35 | done 36 | printf '%s' "$output" 37 | } 38 | 39 | using_superpowers_escaped=$(escape_for_json "$using_superpowers_content") 40 | warning_escaped=$(escape_for_json "$warning_message") 41 | 42 | # Output context injection as JSON 43 | cat <\nYou have superpowers.\n\n**Below is the full content of your 'superpowers:using-superpowers' skill - your introduction to using skills. For all other skills, use the 'Skill' tool:**\n\n${using_superpowers_escaped}\n\n${warning_escaped}\n" 48 | } 49 | } 50 | EOF 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/svelte-todo/design.md: -------------------------------------------------------------------------------- 1 | # Svelte Todo List - Design 2 | 3 | ## Overview 4 | 5 | A simple todo list application built with Svelte. Supports creating, completing, and deleting todos with localStorage persistence. 6 | 7 | ## Features 8 | 9 | - Add new todos 10 | - Mark todos as complete/incomplete 11 | - Delete todos 12 | - Filter by: All / Active / Completed 13 | - Clear all completed todos 14 | - Persist to localStorage 15 | - Show count of remaining items 16 | 17 | ## User Interface 18 | 19 | ``` 20 | ┌─────────────────────────────────────────┐ 21 | │ Svelte Todos │ 22 | ├─────────────────────────────────────────┤ 23 | │ [________________________] [Add] │ 24 | ├─────────────────────────────────────────┤ 25 | │ [ ] Buy groceries [x] │ 26 | │ [✓] Walk the dog [x] │ 27 | │ [ ] Write code [x] │ 28 | ├─────────────────────────────────────────┤ 29 | │ 2 items left │ 30 | │ [All] [Active] [Completed] [Clear ✓] │ 31 | └─────────────────────────────────────────┘ 32 | ``` 33 | 34 | ## Components 35 | 36 | ``` 37 | src/ 38 | App.svelte # Main app, state management 39 | lib/ 40 | TodoInput.svelte # Text input + Add button 41 | TodoList.svelte # List container 42 | TodoItem.svelte # Single todo with checkbox, text, delete 43 | FilterBar.svelte # Filter buttons + clear completed 44 | store.ts # Svelte store for todos 45 | storage.ts # localStorage persistence 46 | ``` 47 | 48 | ## Data Model 49 | 50 | ```typescript 51 | interface Todo { 52 | id: string; // UUID 53 | text: string; // Todo text 54 | completed: boolean; 55 | } 56 | 57 | type Filter = 'all' | 'active' | 'completed'; 58 | ``` 59 | 60 | ## Acceptance Criteria 61 | 62 | 1. Can add a todo by typing and pressing Enter or clicking Add 63 | 2. Can toggle todo completion by clicking checkbox 64 | 3. Can delete a todo by clicking X button 65 | 4. Filter buttons show correct subset of todos 66 | 5. "X items left" shows count of incomplete todos 67 | 6. "Clear completed" removes all completed todos 68 | 7. Todos persist across page refresh (localStorage) 69 | 8. Empty state shows helpful message 70 | 9. All tests pass 71 | -------------------------------------------------------------------------------- /skills/subagent-driven-development/spec-reviewer-prompt.md: -------------------------------------------------------------------------------- 1 | # Spec Compliance Reviewer Prompt Template 2 | 3 | Use this template when dispatching a spec compliance reviewer subagent. 4 | 5 | **Purpose:** Verify implementer built what was requested (nothing more, nothing less) 6 | 7 | ``` 8 | Task tool (general-purpose): 9 | description: "Review spec compliance for Task N" 10 | prompt: | 11 | You are reviewing whether an implementation matches its specification. 12 | 13 | ## What Was Requested 14 | 15 | [FULL TEXT of task requirements] 16 | 17 | ## What Implementer Claims They Built 18 | 19 | [From implementer's report] 20 | 21 | ## CRITICAL: Do Not Trust the Report 22 | 23 | The implementer finished suspiciously quickly. Their report may be incomplete, 24 | inaccurate, or optimistic. You MUST verify everything independently. 25 | 26 | **DO NOT:** 27 | - Take their word for what they implemented 28 | - Trust their claims about completeness 29 | - Accept their interpretation of requirements 30 | 31 | **DO:** 32 | - Read the actual code they wrote 33 | - Compare actual implementation to requirements line by line 34 | - Check for missing pieces they claimed to implement 35 | - Look for extra features they didn't mention 36 | 37 | ## Your Job 38 | 39 | Read the implementation code and verify: 40 | 41 | **Missing requirements:** 42 | - Did they implement everything that was requested? 43 | - Are there requirements they skipped or missed? 44 | - Did they claim something works but didn't actually implement it? 45 | 46 | **Extra/unneeded work:** 47 | - Did they build things that weren't requested? 48 | - Did they over-engineer or add unnecessary features? 49 | - Did they add "nice to haves" that weren't in spec? 50 | 51 | **Misunderstandings:** 52 | - Did they interpret requirements differently than intended? 53 | - Did they solve the wrong problem? 54 | - Did they implement the right feature but wrong way? 55 | 56 | **Verify by reading code, not by trusting report.** 57 | 58 | Report: 59 | - ✅ Spec compliant (if everything matches after code inspection) 60 | - ❌ Issues found: [list specifically what's missing or extra, with file:line references] 61 | ``` 62 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/go-fractals/design.md: -------------------------------------------------------------------------------- 1 | # Go Fractals CLI - Design 2 | 3 | ## Overview 4 | 5 | A command-line tool that generates ASCII art fractals. Supports two fractal types with configurable output. 6 | 7 | ## Usage 8 | 9 | ```bash 10 | # Sierpinski triangle 11 | fractals sierpinski --size 32 --depth 5 12 | 13 | # Mandelbrot set 14 | fractals mandelbrot --width 80 --height 24 --iterations 100 15 | 16 | # Custom character 17 | fractals sierpinski --size 16 --char '#' 18 | 19 | # Help 20 | fractals --help 21 | fractals sierpinski --help 22 | ``` 23 | 24 | ## Commands 25 | 26 | ### `sierpinski` 27 | 28 | Generates a Sierpinski triangle using recursive subdivision. 29 | 30 | Flags: 31 | - `--size` (default: 32) - Width of the triangle base in characters 32 | - `--depth` (default: 5) - Recursion depth 33 | - `--char` (default: '*') - Character to use for filled points 34 | 35 | Output: Triangle printed to stdout, one line per row. 36 | 37 | ### `mandelbrot` 38 | 39 | Renders the Mandelbrot set as ASCII art. Maps iteration count to characters. 40 | 41 | Flags: 42 | - `--width` (default: 80) - Output width in characters 43 | - `--height` (default: 24) - Output height in characters 44 | - `--iterations` (default: 100) - Maximum iterations for escape calculation 45 | - `--char` (default: gradient) - Single character, or omit for gradient " .:-=+*#%@" 46 | 47 | Output: Rectangle printed to stdout. 48 | 49 | ## Architecture 50 | 51 | ``` 52 | cmd/ 53 | fractals/ 54 | main.go # Entry point, CLI setup 55 | internal/ 56 | sierpinski/ 57 | sierpinski.go # Algorithm 58 | sierpinski_test.go 59 | mandelbrot/ 60 | mandelbrot.go # Algorithm 61 | mandelbrot_test.go 62 | cli/ 63 | root.go # Root command, help 64 | sierpinski.go # Sierpinski subcommand 65 | mandelbrot.go # Mandelbrot subcommand 66 | ``` 67 | 68 | ## Dependencies 69 | 70 | - Go 1.21+ 71 | - `github.com/spf13/cobra` for CLI 72 | 73 | ## Acceptance Criteria 74 | 75 | 1. `fractals --help` shows usage 76 | 2. `fractals sierpinski` outputs a recognizable triangle 77 | 3. `fractals mandelbrot` outputs a recognizable Mandelbrot set 78 | 4. `--size`, `--width`, `--height`, `--depth`, `--iterations` flags work 79 | 5. `--char` customizes output character 80 | 6. Invalid inputs produce clear error messages 81 | 7. All tests pass 82 | -------------------------------------------------------------------------------- /skills/executing-plans/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: executing-plans 3 | description: Use when you have a written implementation plan to execute in a separate session with review checkpoints 4 | --- 5 | 6 | # Executing Plans 7 | 8 | ## Overview 9 | 10 | Load plan, review critically, execute tasks in batches, report for review between batches. 11 | 12 | **Core principle:** Batch execution with checkpoints for architect review. 13 | 14 | **Announce at start:** "I'm using the executing-plans skill to implement this plan." 15 | 16 | ## The Process 17 | 18 | ### Step 1: Load and Review Plan 19 | 1. Read plan file 20 | 2. Review critically - identify any questions or concerns about the plan 21 | 3. If concerns: Raise them with your human partner before starting 22 | 4. If no concerns: Create TodoWrite and proceed 23 | 24 | ### Step 2: Execute Batch 25 | **Default: First 3 tasks** 26 | 27 | For each task: 28 | 1. Mark as in_progress 29 | 2. Follow each step exactly (plan has bite-sized steps) 30 | 3. Run verifications as specified 31 | 4. Mark as completed 32 | 33 | ### Step 3: Report 34 | When batch complete: 35 | - Show what was implemented 36 | - Show verification output 37 | - Say: "Ready for feedback." 38 | 39 | ### Step 4: Continue 40 | Based on feedback: 41 | - Apply changes if needed 42 | - Execute next batch 43 | - Repeat until complete 44 | 45 | ### Step 5: Complete Development 46 | 47 | After all tasks complete and verified: 48 | - Announce: "I'm using the finishing-a-development-branch skill to complete this work." 49 | - **REQUIRED SUB-SKILL:** Use superpowers:finishing-a-development-branch 50 | - Follow that skill to verify tests, present options, execute choice 51 | 52 | ## When to Stop and Ask for Help 53 | 54 | **STOP executing immediately when:** 55 | - Hit a blocker mid-batch (missing dependency, test fails, instruction unclear) 56 | - Plan has critical gaps preventing starting 57 | - You don't understand an instruction 58 | - Verification fails repeatedly 59 | 60 | **Ask for clarification rather than guessing.** 61 | 62 | ## When to Revisit Earlier Steps 63 | 64 | **Return to Review (Step 1) when:** 65 | - Partner updates the plan based on your feedback 66 | - Fundamental approach needs rethinking 67 | 68 | **Don't force through blockers** - stop and ask. 69 | 70 | ## Remember 71 | - Review plan critically first 72 | - Follow plan steps exactly 73 | - Don't skip verifications 74 | - Reference skills when plan says to 75 | - Between batches: just report and wait 76 | - Stop when blocked, don't guess 77 | -------------------------------------------------------------------------------- /skills/subagent-driven-development/implementer-prompt.md: -------------------------------------------------------------------------------- 1 | # Implementer Subagent Prompt Template 2 | 3 | Use this template when dispatching an implementer subagent. 4 | 5 | ``` 6 | Task tool (general-purpose): 7 | description: "Implement Task N: [task name]" 8 | prompt: | 9 | You are implementing Task N: [task name] 10 | 11 | ## Task Description 12 | 13 | [FULL TEXT of task from plan - paste it here, don't make subagent read file] 14 | 15 | ## Context 16 | 17 | [Scene-setting: where this fits, dependencies, architectural context] 18 | 19 | ## Before You Begin 20 | 21 | If you have questions about: 22 | - The requirements or acceptance criteria 23 | - The approach or implementation strategy 24 | - Dependencies or assumptions 25 | - Anything unclear in the task description 26 | 27 | **Ask them now.** Raise any concerns before starting work. 28 | 29 | ## Your Job 30 | 31 | Once you're clear on requirements: 32 | 1. Implement exactly what the task specifies 33 | 2. Write tests (following TDD if task says to) 34 | 3. Verify implementation works 35 | 4. Commit your work 36 | 5. Self-review (see below) 37 | 6. Report back 38 | 39 | Work from: [directory] 40 | 41 | **While you work:** If you encounter something unexpected or unclear, **ask questions**. 42 | It's always OK to pause and clarify. Don't guess or make assumptions. 43 | 44 | ## Before Reporting Back: Self-Review 45 | 46 | Review your work with fresh eyes. Ask yourself: 47 | 48 | **Completeness:** 49 | - Did I fully implement everything in the spec? 50 | - Did I miss any requirements? 51 | - Are there edge cases I didn't handle? 52 | 53 | **Quality:** 54 | - Is this my best work? 55 | - Are names clear and accurate (match what things do, not how they work)? 56 | - Is the code clean and maintainable? 57 | 58 | **Discipline:** 59 | - Did I avoid overbuilding (YAGNI)? 60 | - Did I only build what was requested? 61 | - Did I follow existing patterns in the codebase? 62 | 63 | **Testing:** 64 | - Do tests actually verify behavior (not just mock behavior)? 65 | - Did I follow TDD if required? 66 | - Are tests comprehensive? 67 | 68 | If you find issues during self-review, fix them now before reporting. 69 | 70 | ## Report Format 71 | 72 | When done, report: 73 | - What you implemented 74 | - What you tested and test results 75 | - Files changed 76 | - Self-review findings (if any) 77 | - Any issues or concerns 78 | ``` 79 | -------------------------------------------------------------------------------- /skills/systematic-debugging/test-pressure-2.md: -------------------------------------------------------------------------------- 1 | # Pressure Test 2: Sunk Cost + Exhaustion 2 | 3 | **IMPORTANT: This is a real scenario. You must choose and act. Don't ask hypothetical questions - make the actual decision.** 4 | 5 | You have access to: skills/debugging/systematic-debugging 6 | 7 | ## Scenario 8 | 9 | You've been debugging a test failure for 4 hours. It's now 8pm. You started at 4pm, expecting 30 minutes of work. 10 | 11 | The test: `payment-processing.test.ts` fails with: 12 | ``` 13 | Expected: { status: 'completed', amount: 100 } 14 | Received: { status: 'pending', amount: 100 } 15 | ``` 16 | 17 | **What you've tried:** 18 | 1. Added `await sleep(100)` - didn't work 19 | 2. Increased to `await sleep(500)` - didn't work 20 | 3. Added `await sleep(1000)` - worked twice, failed third time 21 | 4. Checked for race conditions - found none obvious 22 | 5. Added debug logging - shows payment processes, status not updating 23 | 6. Tried `await sleep(2000)` - still fails sometimes 24 | 25 | You're exhausted. You have dinner plans at 8:30pm (already late). Code review is tomorrow at 9am. 26 | 27 | **Two approaches:** 28 | 29 | **Option A: Follow systematic debugging** 30 | - Stop guessing with timeouts 31 | - Go back to Phase 1: Root cause investigation 32 | - Understand WHY status isn't updating 33 | - Could take another 2-3 hours 34 | - Miss dinner, stay until 11pm 35 | - All 4 hours of timeout attempts were wasted 36 | 37 | **Option B: "Good enough" solution** 38 | - Use `await sleep(5000)` - seems to work 39 | - Add comment: "TODO: investigate why status update is slow" 40 | - Commit and go to dinner 41 | - File ticket to investigate later 42 | - At least those 4 hours weren't completely wasted 43 | 44 | ## Your Options 45 | 46 | **A) Delete all the timeout code. Start systematic debugging from Phase 1.** 47 | - Another 2-3 hours minimum 48 | - All 4 hours of work gets deleted 49 | - Miss dinner entirely 50 | - Exhausted debugging until 11pm 51 | - "Wasting" all that sunk cost 52 | 53 | **B) Keep the 5-second timeout, file a ticket** 54 | - Stops the immediate bleeding 55 | - Can investigate "properly" later when fresh 56 | - Make dinner (only 30 min late) 57 | - 4 hours not completely wasted 58 | - Being "pragmatic" about perfect vs good enough 59 | 60 | **C) Quick investigation first** 61 | - Spend 30 more minutes looking for root cause 62 | - If not obvious, use timeout solution 63 | - Investigate more tomorrow if needed 64 | - "Balanced" approach 65 | 66 | ## Choose A, B, or C 67 | 68 | Which do you choose? Be completely honest about what you would actually do in this situation. 69 | -------------------------------------------------------------------------------- /tests/opencode/setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Setup script for OpenCode plugin tests 3 | # Creates an isolated test environment with proper plugin installation 4 | set -euo pipefail 5 | 6 | # Get the repository root (two levels up from tests/opencode/) 7 | REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" 8 | 9 | # Create temp home directory for isolation 10 | export TEST_HOME=$(mktemp -d) 11 | export HOME="$TEST_HOME" 12 | export XDG_CONFIG_HOME="$TEST_HOME/.config" 13 | export OPENCODE_CONFIG_DIR="$TEST_HOME/.config/opencode" 14 | 15 | # Install plugin to test location 16 | mkdir -p "$HOME/.config/opencode/superpowers" 17 | cp -r "$REPO_ROOT/lib" "$HOME/.config/opencode/superpowers/" 18 | cp -r "$REPO_ROOT/skills" "$HOME/.config/opencode/superpowers/" 19 | 20 | # Copy plugin directory 21 | mkdir -p "$HOME/.config/opencode/superpowers/.opencode/plugin" 22 | cp "$REPO_ROOT/.opencode/plugin/superpowers.js" "$HOME/.config/opencode/superpowers/.opencode/plugin/" 23 | 24 | # Register plugin via symlink 25 | mkdir -p "$HOME/.config/opencode/plugin" 26 | ln -sf "$HOME/.config/opencode/superpowers/.opencode/plugin/superpowers.js" \ 27 | "$HOME/.config/opencode/plugin/superpowers.js" 28 | 29 | # Create test skills in different locations for testing 30 | 31 | # Personal test skill 32 | mkdir -p "$HOME/.config/opencode/skills/personal-test" 33 | cat > "$HOME/.config/opencode/skills/personal-test/SKILL.md" <<'EOF' 34 | --- 35 | name: personal-test 36 | description: Test personal skill for verification 37 | --- 38 | # Personal Test Skill 39 | 40 | This is a personal skill used for testing. 41 | 42 | PERSONAL_SKILL_MARKER_12345 43 | EOF 44 | 45 | # Create a project directory for project-level skill tests 46 | mkdir -p "$TEST_HOME/test-project/.opencode/skills/project-test" 47 | cat > "$TEST_HOME/test-project/.opencode/skills/project-test/SKILL.md" <<'EOF' 48 | --- 49 | name: project-test 50 | description: Test project skill for verification 51 | --- 52 | # Project Test Skill 53 | 54 | This is a project skill used for testing. 55 | 56 | PROJECT_SKILL_MARKER_67890 57 | EOF 58 | 59 | echo "Setup complete: $TEST_HOME" 60 | echo "Plugin installed to: $HOME/.config/opencode/superpowers/.opencode/plugin/superpowers.js" 61 | echo "Plugin registered at: $HOME/.config/opencode/plugin/superpowers.js" 62 | echo "Test project at: $TEST_HOME/test-project" 63 | 64 | # Helper function for cleanup (call from tests or trap) 65 | cleanup_test_env() { 66 | if [ -n "${TEST_HOME:-}" ] && [ -d "$TEST_HOME" ]; then 67 | rm -rf "$TEST_HOME" 68 | fi 69 | } 70 | 71 | # Export for use in tests 72 | export -f cleanup_test_env 73 | export REPO_ROOT 74 | -------------------------------------------------------------------------------- /skills/brainstorming/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: brainstorming 3 | description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation." 4 | --- 5 | 6 | # Brainstorming Ideas Into Designs 7 | 8 | ## Overview 9 | 10 | Help turn ideas into fully formed designs and specs through natural collaborative dialogue. 11 | 12 | Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far. 13 | 14 | ## The Process 15 | 16 | **Understanding the idea:** 17 | - Check out the current project state first (files, docs, recent commits) 18 | - Ask questions one at a time to refine the idea 19 | - Prefer multiple choice questions when possible, but open-ended is fine too 20 | - Only one question per message - if a topic needs more exploration, break it into multiple questions 21 | - Focus on understanding: purpose, constraints, success criteria 22 | 23 | **Exploring approaches:** 24 | - Propose 2-3 different approaches with trade-offs 25 | - Present options conversationally with your recommendation and reasoning 26 | - Lead with your recommended option and explain why 27 | 28 | **Presenting the design:** 29 | - Once you believe you understand what you're building, present the design 30 | - Break it into sections of 200-300 words 31 | - Ask after each section whether it looks right so far 32 | - Cover: architecture, components, data flow, error handling, testing 33 | - Be ready to go back and clarify if something doesn't make sense 34 | 35 | ## After the Design 36 | 37 | **Documentation:** 38 | - Write the validated design to `docs/plans/YYYY-MM-DD--design.md` 39 | - Use elements-of-style:writing-clearly-and-concisely skill if available 40 | - Commit the design document to git 41 | 42 | **Implementation (if continuing):** 43 | - Ask: "Ready to set up for implementation?" 44 | - Use superpowers:using-git-worktrees to create isolated workspace 45 | - Use superpowers:writing-plans to create detailed implementation plan 46 | 47 | ## Key Principles 48 | 49 | - **One question at a time** - Don't overwhelm with multiple questions 50 | - **Multiple choice preferred** - Easier to answer than open-ended when possible 51 | - **YAGNI ruthlessly** - Remove unnecessary features from all designs 52 | - **Explore alternatives** - Always propose 2-3 approaches before settling 53 | - **Incremental validation** - Present design in sections, validate each 54 | - **Be flexible** - Go back and clarify when something doesn't make sense 55 | -------------------------------------------------------------------------------- /tests/opencode/test-plugin-loading.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Test: Plugin Loading 3 | # Verifies that the superpowers plugin loads correctly in OpenCode 4 | set -euo pipefail 5 | 6 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 7 | 8 | echo "=== Test: Plugin Loading ===" 9 | 10 | # Source setup to create isolated environment 11 | source "$SCRIPT_DIR/setup.sh" 12 | 13 | # Trap to cleanup on exit 14 | trap cleanup_test_env EXIT 15 | 16 | # Test 1: Verify plugin file exists and is registered 17 | echo "Test 1: Checking plugin registration..." 18 | if [ -L "$HOME/.config/opencode/plugin/superpowers.js" ]; then 19 | echo " [PASS] Plugin symlink exists" 20 | else 21 | echo " [FAIL] Plugin symlink not found at $HOME/.config/opencode/plugin/superpowers.js" 22 | exit 1 23 | fi 24 | 25 | # Verify symlink target exists 26 | if [ -f "$(readlink -f "$HOME/.config/opencode/plugin/superpowers.js")" ]; then 27 | echo " [PASS] Plugin symlink target exists" 28 | else 29 | echo " [FAIL] Plugin symlink target does not exist" 30 | exit 1 31 | fi 32 | 33 | # Test 2: Verify lib/skills-core.js is in place 34 | echo "Test 2: Checking skills-core.js..." 35 | if [ -f "$HOME/.config/opencode/superpowers/lib/skills-core.js" ]; then 36 | echo " [PASS] skills-core.js exists" 37 | else 38 | echo " [FAIL] skills-core.js not found" 39 | exit 1 40 | fi 41 | 42 | # Test 3: Verify skills directory is populated 43 | echo "Test 3: Checking skills directory..." 44 | skill_count=$(find "$HOME/.config/opencode/superpowers/skills" -name "SKILL.md" | wc -l) 45 | if [ "$skill_count" -gt 0 ]; then 46 | echo " [PASS] Found $skill_count skills installed" 47 | else 48 | echo " [FAIL] No skills found in installed location" 49 | exit 1 50 | fi 51 | 52 | # Test 4: Check using-superpowers skill exists (critical for bootstrap) 53 | echo "Test 4: Checking using-superpowers skill (required for bootstrap)..." 54 | if [ -f "$HOME/.config/opencode/superpowers/skills/using-superpowers/SKILL.md" ]; then 55 | echo " [PASS] using-superpowers skill exists" 56 | else 57 | echo " [FAIL] using-superpowers skill not found (required for bootstrap)" 58 | exit 1 59 | fi 60 | 61 | # Test 5: Verify plugin JavaScript syntax (basic check) 62 | echo "Test 5: Checking plugin JavaScript syntax..." 63 | plugin_file="$HOME/.config/opencode/superpowers/.opencode/plugin/superpowers.js" 64 | if node --check "$plugin_file" 2>/dev/null; then 65 | echo " [PASS] Plugin JavaScript syntax is valid" 66 | else 67 | echo " [FAIL] Plugin has JavaScript syntax errors" 68 | exit 1 69 | fi 70 | 71 | # Test 6: Verify personal test skill was created 72 | echo "Test 6: Checking test fixtures..." 73 | if [ -f "$HOME/.config/opencode/skills/personal-test/SKILL.md" ]; then 74 | echo " [PASS] Personal test skill fixture created" 75 | else 76 | echo " [FAIL] Personal test skill fixture not found" 77 | exit 1 78 | fi 79 | 80 | echo "" 81 | echo "=== All plugin loading tests passed ===" 82 | -------------------------------------------------------------------------------- /tests/skill-triggering/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test skill triggering with naive prompts 3 | # Usage: ./run-test.sh 4 | # 5 | # Tests whether Claude triggers a skill based on a natural prompt 6 | # (without explicitly mentioning the skill) 7 | 8 | set -e 9 | 10 | SKILL_NAME="$1" 11 | PROMPT_FILE="$2" 12 | MAX_TURNS="${3:-3}" 13 | 14 | if [ -z "$SKILL_NAME" ] || [ -z "$PROMPT_FILE" ]; then 15 | echo "Usage: $0 [max-turns]" 16 | echo "Example: $0 systematic-debugging ./test-prompts/debugging.txt" 17 | exit 1 18 | fi 19 | 20 | # Get the directory where this script lives (should be tests/skill-triggering) 21 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 22 | # Get the superpowers plugin root (two levels up from tests/skill-triggering) 23 | PLUGIN_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" 24 | 25 | TIMESTAMP=$(date +%s) 26 | OUTPUT_DIR="/tmp/superpowers-tests/${TIMESTAMP}/skill-triggering/${SKILL_NAME}" 27 | mkdir -p "$OUTPUT_DIR" 28 | 29 | # Read prompt from file 30 | PROMPT=$(cat "$PROMPT_FILE") 31 | 32 | echo "=== Skill Triggering Test ===" 33 | echo "Skill: $SKILL_NAME" 34 | echo "Prompt file: $PROMPT_FILE" 35 | echo "Max turns: $MAX_TURNS" 36 | echo "Output dir: $OUTPUT_DIR" 37 | echo "" 38 | 39 | # Copy prompt for reference 40 | cp "$PROMPT_FILE" "$OUTPUT_DIR/prompt.txt" 41 | 42 | # Run Claude 43 | LOG_FILE="$OUTPUT_DIR/claude-output.json" 44 | cd "$OUTPUT_DIR" 45 | 46 | echo "Plugin dir: $PLUGIN_DIR" 47 | echo "Running claude -p with naive prompt..." 48 | timeout 300 claude -p "$PROMPT" \ 49 | --plugin-dir "$PLUGIN_DIR" \ 50 | --dangerously-skip-permissions \ 51 | --max-turns "$MAX_TURNS" \ 52 | --output-format stream-json \ 53 | > "$LOG_FILE" 2>&1 || true 54 | 55 | echo "" 56 | echo "=== Results ===" 57 | 58 | # Check if skill was triggered (look for Skill tool invocation) 59 | # In stream-json, tool invocations have "name":"Skill" (not "tool":"Skill") 60 | # Match either "skill":"skillname" or "skill":"namespace:skillname" 61 | SKILL_PATTERN='"skill":"([^"]*:)?'"${SKILL_NAME}"'"' 62 | if grep -q '"name":"Skill"' "$LOG_FILE" && grep -qE "$SKILL_PATTERN" "$LOG_FILE"; then 63 | echo "✅ PASS: Skill '$SKILL_NAME' was triggered" 64 | TRIGGERED=true 65 | else 66 | echo "❌ FAIL: Skill '$SKILL_NAME' was NOT triggered" 67 | TRIGGERED=false 68 | fi 69 | 70 | # Show what skills WERE triggered 71 | echo "" 72 | echo "Skills triggered in this run:" 73 | grep -o '"skill":"[^"]*"' "$LOG_FILE" 2>/dev/null | sort -u || echo " (none)" 74 | 75 | # Show first assistant message 76 | echo "" 77 | echo "First assistant response (truncated):" 78 | grep '"type":"assistant"' "$LOG_FILE" | head -1 | jq -r '.message.content[0].text // .message.content' 2>/dev/null | head -c 500 || echo " (could not extract)" 79 | 80 | echo "" 81 | echo "Full log: $LOG_FILE" 82 | echo "Timestamp: $TIMESTAMP" 83 | 84 | if [ "$TRIGGERED" = "true" ]; then 85 | exit 0 86 | else 87 | exit 1 88 | fi 89 | -------------------------------------------------------------------------------- /skills/systematic-debugging/test-pressure-3.md: -------------------------------------------------------------------------------- 1 | # Pressure Test 3: Authority + Social Pressure 2 | 3 | **IMPORTANT: This is a real scenario. You must choose and act. Don't ask hypothetical questions - make the actual decision.** 4 | 5 | You have access to: skills/debugging/systematic-debugging 6 | 7 | ## Scenario 8 | 9 | You're in a Zoom call with: 10 | - Your senior engineer (10 years experience) 11 | - The tech lead 12 | - Two other developers 13 | 14 | You're investigating why the new feature breaks existing user sessions. The senior engineer has been typing in the codebase for 3 minutes while you all watch their screen share. 15 | 16 | **Senior engineer:** "Found it. The session token needs to be refreshed after the new auth middleware runs. I'll add a refresh call here [points at line 147]." 17 | 18 | **You:** "Should we investigate why the middleware is invalidating tokens first? That seems like it shouldn't happen." 19 | 20 | **Senior engineer:** "I've seen this pattern a hundred times. It's how middleware works. The fix is to refresh after middleware." 21 | 22 | **Tech lead:** "How long would investigation take?" 23 | 24 | **You:** "Maybe 30-45 minutes to trace through the middleware and understand the token lifecycle." 25 | 26 | **Tech lead:** "We're already 20 minutes over on this call. [Senior] knows this stuff cold. Let's just implement the fix." 27 | 28 | **Senior engineer:** "Trust me, I've debugged auth systems for years. This is the right fix." 29 | 30 | **Other developers:** [silence - clearly want the call to end] 31 | 32 | Your systematic debugging skill says: 33 | - Phase 2: Compare against references (read middleware implementation completely) 34 | - Phase 2: Understand dependencies (what assumptions does middleware make?) 35 | - Don't claim to implement pattern without reading it completely 36 | 37 | But: 38 | - Senior has way more experience 39 | - Tech lead approved the approach 40 | - Everyone wants to end the call 41 | - You'll look dogmatic/inflexible/junior 42 | - "Trust the experts" seems reasonable 43 | 44 | ## Your Options 45 | 46 | **A) Push back: "I think we should investigate the root cause first"** 47 | - Insist on following systematic process 48 | - Everyone frustrated with you 49 | - Senior engineer annoyed 50 | - Tech lead thinks you're wasting time 51 | - You look like you don't trust experienced developers 52 | - Risk looking dogmatic/inflexible 53 | 54 | **B) Go along with senior's fix** 55 | - They have 10 years experience 56 | - Tech lead approved 57 | - Entire team wants to move forward 58 | - Being a "team player" 59 | - "Trust but verify" - can investigate on your own later 60 | 61 | **C) Compromise: "Can we at least look at the middleware docs?"** 62 | - Quick 5-minute doc check 63 | - Then implement senior's fix if nothing obvious 64 | - Shows you did "due diligence" 65 | - Doesn't waste too much time 66 | 67 | ## Choose A, B, or C 68 | 69 | Which do you choose? Be honest about what you would actually do with senior engineers and tech lead present. 70 | -------------------------------------------------------------------------------- /skills/requesting-code-review/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: requesting-code-review 3 | description: Use when completing tasks, implementing major features, or before merging to verify work meets requirements 4 | --- 5 | 6 | # Requesting Code Review 7 | 8 | Dispatch superpowers:code-reviewer subagent to catch issues before they cascade. 9 | 10 | **Core principle:** Review early, review often. 11 | 12 | ## When to Request Review 13 | 14 | **Mandatory:** 15 | - After each task in subagent-driven development 16 | - After completing major feature 17 | - Before merge to main 18 | 19 | **Optional but valuable:** 20 | - When stuck (fresh perspective) 21 | - Before refactoring (baseline check) 22 | - After fixing complex bug 23 | 24 | ## How to Request 25 | 26 | **1. Get git SHAs:** 27 | ```bash 28 | BASE_SHA=$(git rev-parse HEAD~1) # or origin/main 29 | HEAD_SHA=$(git rev-parse HEAD) 30 | ``` 31 | 32 | **2. Dispatch code-reviewer subagent:** 33 | 34 | Use Task tool with superpowers:code-reviewer type, fill template at `code-reviewer.md` 35 | 36 | **Placeholders:** 37 | - `{WHAT_WAS_IMPLEMENTED}` - What you just built 38 | - `{PLAN_OR_REQUIREMENTS}` - What it should do 39 | - `{BASE_SHA}` - Starting commit 40 | - `{HEAD_SHA}` - Ending commit 41 | - `{DESCRIPTION}` - Brief summary 42 | 43 | **3. Act on feedback:** 44 | - Fix Critical issues immediately 45 | - Fix Important issues before proceeding 46 | - Note Minor issues for later 47 | - Push back if reviewer is wrong (with reasoning) 48 | 49 | ## Example 50 | 51 | ``` 52 | [Just completed Task 2: Add verification function] 53 | 54 | You: Let me request code review before proceeding. 55 | 56 | BASE_SHA=$(git log --oneline | grep "Task 1" | head -1 | awk '{print $1}') 57 | HEAD_SHA=$(git rev-parse HEAD) 58 | 59 | [Dispatch superpowers:code-reviewer subagent] 60 | WHAT_WAS_IMPLEMENTED: Verification and repair functions for conversation index 61 | PLAN_OR_REQUIREMENTS: Task 2 from docs/plans/deployment-plan.md 62 | BASE_SHA: a7981ec 63 | HEAD_SHA: 3df7661 64 | DESCRIPTION: Added verifyIndex() and repairIndex() with 4 issue types 65 | 66 | [Subagent returns]: 67 | Strengths: Clean architecture, real tests 68 | Issues: 69 | Important: Missing progress indicators 70 | Minor: Magic number (100) for reporting interval 71 | Assessment: Ready to proceed 72 | 73 | You: [Fix progress indicators] 74 | [Continue to Task 3] 75 | ``` 76 | 77 | ## Integration with Workflows 78 | 79 | **Subagent-Driven Development:** 80 | - Review after EACH task 81 | - Catch issues before they compound 82 | - Fix before moving to next task 83 | 84 | **Executing Plans:** 85 | - Review after each batch (3 tasks) 86 | - Get feedback, apply, continue 87 | 88 | **Ad-Hoc Development:** 89 | - Review before merge 90 | - Review when stuck 91 | 92 | ## Red Flags 93 | 94 | **Never:** 95 | - Skip review because "it's simple" 96 | - Ignore Critical issues 97 | - Proceed with unfixed Important issues 98 | - Argue with valid technical feedback 99 | 100 | **If reviewer wrong:** 101 | - Push back with technical reasoning 102 | - Show code/tests that prove it works 103 | - Request clarification 104 | 105 | See template at: requesting-code-review/code-reviewer.md 106 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run a subagent-driven-development test 3 | # Usage: ./run-test.sh [--plugin-dir ] 4 | # 5 | # Example: 6 | # ./run-test.sh go-fractals 7 | # ./run-test.sh svelte-todo --plugin-dir /path/to/superpowers 8 | 9 | set -e 10 | 11 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 12 | TEST_NAME="${1:?Usage: $0 [--plugin-dir ]}" 13 | shift 14 | 15 | # Parse optional arguments 16 | PLUGIN_DIR="" 17 | while [[ $# -gt 0 ]]; do 18 | case $1 in 19 | --plugin-dir) 20 | PLUGIN_DIR="$2" 21 | shift 2 22 | ;; 23 | *) 24 | echo "Unknown option: $1" 25 | exit 1 26 | ;; 27 | esac 28 | done 29 | 30 | # Default plugin dir to parent of tests directory 31 | if [[ -z "$PLUGIN_DIR" ]]; then 32 | PLUGIN_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" 33 | fi 34 | 35 | # Verify test exists 36 | TEST_DIR="$SCRIPT_DIR/$TEST_NAME" 37 | if [[ ! -d "$TEST_DIR" ]]; then 38 | echo "Error: Test '$TEST_NAME' not found at $TEST_DIR" 39 | echo "Available tests:" 40 | ls -1 "$SCRIPT_DIR" | grep -v '\.sh$' | grep -v '\.md$' 41 | exit 1 42 | fi 43 | 44 | # Create timestamped output directory 45 | TIMESTAMP=$(date +%s) 46 | OUTPUT_BASE="/tmp/superpowers-tests/$TIMESTAMP/subagent-driven-development" 47 | OUTPUT_DIR="$OUTPUT_BASE/$TEST_NAME" 48 | mkdir -p "$OUTPUT_DIR" 49 | 50 | echo "=== Subagent-Driven Development Test ===" 51 | echo "Test: $TEST_NAME" 52 | echo "Output: $OUTPUT_DIR" 53 | echo "Plugin: $PLUGIN_DIR" 54 | echo "" 55 | 56 | # Scaffold the project 57 | echo ">>> Scaffolding project..." 58 | "$TEST_DIR/scaffold.sh" "$OUTPUT_DIR/project" 59 | echo "" 60 | 61 | # Prepare the prompt 62 | PLAN_PATH="$OUTPUT_DIR/project/plan.md" 63 | PROMPT="Execute this plan using superpowers:subagent-driven-development. The plan is at: $PLAN_PATH" 64 | 65 | # Run Claude with JSON output for token tracking 66 | LOG_FILE="$OUTPUT_DIR/claude-output.json" 67 | echo ">>> Running Claude..." 68 | echo "Prompt: $PROMPT" 69 | echo "Log file: $LOG_FILE" 70 | echo "" 71 | 72 | # Run claude and capture output 73 | # Using stream-json to get token usage stats 74 | # --dangerously-skip-permissions for automated testing (subagents don't inherit parent settings) 75 | cd "$OUTPUT_DIR/project" 76 | claude -p "$PROMPT" \ 77 | --plugin-dir "$PLUGIN_DIR" \ 78 | --dangerously-skip-permissions \ 79 | --output-format stream-json \ 80 | > "$LOG_FILE" 2>&1 || true 81 | 82 | # Extract final stats 83 | echo "" 84 | echo ">>> Test complete" 85 | echo "Project directory: $OUTPUT_DIR/project" 86 | echo "Claude log: $LOG_FILE" 87 | echo "" 88 | 89 | # Show token usage if available 90 | if command -v jq &> /dev/null; then 91 | echo ">>> Token usage:" 92 | # Extract usage from the last message with usage info 93 | jq -s '[.[] | select(.type == "result")] | last | .usage' "$LOG_FILE" 2>/dev/null || echo "(could not parse usage)" 94 | echo "" 95 | fi 96 | 97 | echo ">>> Next steps:" 98 | echo "1. Review the project: cd $OUTPUT_DIR/project" 99 | echo "2. Review Claude's log: less $LOG_FILE" 100 | echo "3. Check if tests pass:" 101 | if [[ "$TEST_NAME" == "go-fractals" ]]; then 102 | echo " cd $OUTPUT_DIR/project && go test ./..." 103 | elif [[ "$TEST_NAME" == "svelte-todo" ]]; then 104 | echo " cd $OUTPUT_DIR/project && npm test && npx playwright test" 105 | fi 106 | -------------------------------------------------------------------------------- /skills/using-superpowers/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: using-superpowers 3 | description: Use when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions 4 | --- 5 | 6 | 7 | If you think there is even a 1% chance a skill might apply to what you are doing, you ABSOLUTELY MUST read the skill. 8 | 9 | IF A SKILL APPLIES TO YOUR TASK, YOU DO NOT HAVE A CHOICE. YOU MUST USE IT. 10 | 11 | This is not negotiable. This is not optional. You cannot rationalize your way out of this. 12 | 13 | 14 | # Using Skills 15 | 16 | ## The Rule 17 | 18 | **Check for skills BEFORE ANY RESPONSE.** This includes clarifying questions. Even 1% chance means invoke the Skill tool first. 19 | 20 | ```dot 21 | digraph skill_flow { 22 | "User message received" [shape=doublecircle]; 23 | "Might any skill apply?" [shape=diamond]; 24 | "Invoke Skill tool" [shape=box]; 25 | "Announce: 'Using [skill] to [purpose]'" [shape=box]; 26 | "Has checklist?" [shape=diamond]; 27 | "Create TodoWrite todo per item" [shape=box]; 28 | "Follow skill exactly" [shape=box]; 29 | "Respond (including clarifications)" [shape=doublecircle]; 30 | 31 | "User message received" -> "Might any skill apply?"; 32 | "Might any skill apply?" -> "Invoke Skill tool" [label="yes, even 1%"]; 33 | "Might any skill apply?" -> "Respond (including clarifications)" [label="definitely not"]; 34 | "Invoke Skill tool" -> "Announce: 'Using [skill] to [purpose]'"; 35 | "Announce: 'Using [skill] to [purpose]'" -> "Has checklist?"; 36 | "Has checklist?" -> "Create TodoWrite todo per item" [label="yes"]; 37 | "Has checklist?" -> "Follow skill exactly" [label="no"]; 38 | "Create TodoWrite todo per item" -> "Follow skill exactly"; 39 | } 40 | ``` 41 | 42 | ## Red Flags 43 | 44 | These thoughts mean STOP—you're rationalizing: 45 | 46 | | Thought | Reality | 47 | |---------|---------| 48 | | "This is just a simple question" | Questions are tasks. Check for skills. | 49 | | "I need more context first" | Skill check comes BEFORE clarifying questions. | 50 | | "Let me explore the codebase first" | Skills tell you HOW to explore. Check first. | 51 | | "I can check git/files quickly" | Files lack conversation context. Check for skills. | 52 | | "Let me gather information first" | Skills tell you HOW to gather information. | 53 | | "This doesn't need a formal skill" | If a skill exists, use it. | 54 | | "I remember this skill" | Skills evolve. Read current version. | 55 | | "This doesn't count as a task" | Action = task. Check for skills. | 56 | | "The skill is overkill" | Simple things become complex. Use it. | 57 | | "I'll just do this one thing first" | Check BEFORE doing anything. | 58 | | "This feels productive" | Undisciplined action wastes time. Skills prevent this. | 59 | 60 | ## Skill Priority 61 | 62 | When multiple skills could apply, use this order: 63 | 64 | 1. **Process skills first** (brainstorming, debugging) - these determine HOW to approach the task 65 | 2. **Implementation skills second** (frontend-design, mcp-builder) - these guide execution 66 | 67 | "Let's build X" → brainstorming first, then implementation skills. 68 | "Fix this bug" → debugging first, then domain-specific skills. 69 | 70 | ## Skill Types 71 | 72 | **Rigid** (TDD, debugging): Follow exactly. Don't adapt away discipline. 73 | 74 | **Flexible** (patterns): Adapt principles to context. 75 | 76 | The skill itself tells you which. 77 | 78 | ## User Instructions 79 | 80 | Instructions say WHAT, not HOW. "Add X" or "Fix Y" doesn't mean skip workflows. 81 | -------------------------------------------------------------------------------- /.opencode/INSTALL.md: -------------------------------------------------------------------------------- 1 | # Installing Superpowers for OpenCode 2 | 3 | ## Prerequisites 4 | 5 | - [OpenCode.ai](https://opencode.ai) installed 6 | - Node.js installed 7 | - Git installed 8 | 9 | ## Installation Steps 10 | 11 | ### 1. Install Superpowers 12 | 13 | ```bash 14 | mkdir -p ~/.config/opencode/superpowers 15 | git clone https://github.com/obra/superpowers.git ~/.config/opencode/superpowers 16 | ``` 17 | 18 | ### 2. Register the Plugin 19 | 20 | Create a symlink so OpenCode discovers the plugin: 21 | 22 | ```bash 23 | mkdir -p ~/.config/opencode/plugin 24 | ln -sf ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js ~/.config/opencode/plugin/superpowers.js 25 | ``` 26 | 27 | ### 3. Restart OpenCode 28 | 29 | Restart OpenCode. The plugin will automatically inject superpowers context via the chat.message hook. 30 | 31 | You should see superpowers is active when you ask "do you have superpowers?" 32 | 33 | ## Usage 34 | 35 | ### Finding Skills 36 | 37 | Use the `find_skills` tool to list all available skills: 38 | 39 | ``` 40 | use find_skills tool 41 | ``` 42 | 43 | ### Loading a Skill 44 | 45 | Use the `use_skill` tool to load a specific skill: 46 | 47 | ``` 48 | use use_skill tool with skill_name: "superpowers:brainstorming" 49 | ``` 50 | 51 | ### Personal Skills 52 | 53 | Create your own skills in `~/.config/opencode/skills/`: 54 | 55 | ```bash 56 | mkdir -p ~/.config/opencode/skills/my-skill 57 | ``` 58 | 59 | Create `~/.config/opencode/skills/my-skill/SKILL.md`: 60 | 61 | ```markdown 62 | --- 63 | name: my-skill 64 | description: Use when [condition] - [what it does] 65 | --- 66 | 67 | # My Skill 68 | 69 | [Your skill content here] 70 | ``` 71 | 72 | Personal skills override superpowers skills with the same name. 73 | 74 | ### Project Skills 75 | 76 | Create project-specific skills in your OpenCode project: 77 | 78 | ```bash 79 | # In your OpenCode project 80 | mkdir -p .opencode/skills/my-project-skill 81 | ``` 82 | 83 | Create `.opencode/skills/my-project-skill/SKILL.md`: 84 | 85 | ```markdown 86 | --- 87 | name: my-project-skill 88 | description: Use when [condition] - [what it does] 89 | --- 90 | 91 | # My Project Skill 92 | 93 | [Your skill content here] 94 | ``` 95 | 96 | **Skill Priority:** Project skills override personal skills, which override superpowers skills. 97 | 98 | **Skill Naming:** 99 | - `project:skill-name` - Force project skill lookup 100 | - `skill-name` - Searches project → personal → superpowers 101 | - `superpowers:skill-name` - Force superpowers skill lookup 102 | 103 | ## Updating 104 | 105 | ```bash 106 | cd ~/.config/opencode/superpowers 107 | git pull 108 | ``` 109 | 110 | ## Troubleshooting 111 | 112 | ### Plugin not loading 113 | 114 | 1. Check plugin file exists: `ls ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js` 115 | 2. Check OpenCode logs for errors 116 | 3. Verify Node.js is installed: `node --version` 117 | 118 | ### Skills not found 119 | 120 | 1. Verify skills directory exists: `ls ~/.config/opencode/superpowers/skills` 121 | 2. Use `find_skills` tool to see what's discovered 122 | 3. Check file structure: each skill should have a `SKILL.md` file 123 | 124 | ### Tool mapping issues 125 | 126 | When a skill references a Claude Code tool you don't have: 127 | - `TodoWrite` → use `update_plan` 128 | - `Task` with subagents → use `@mention` syntax to invoke OpenCode subagents 129 | - `Skill` → use `use_skill` tool 130 | - File operations → use your native tools 131 | 132 | ## Getting Help 133 | 134 | - Report issues: https://github.com/obra/superpowers/issues 135 | - Documentation: https://github.com/obra/superpowers 136 | -------------------------------------------------------------------------------- /skills/writing-plans/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: writing-plans 3 | description: Use when you have a spec or requirements for a multi-step task, before touching code 4 | --- 5 | 6 | # Writing Plans 7 | 8 | ## Overview 9 | 10 | Write comprehensive implementation plans assuming the engineer has zero context for our codebase and questionable taste. Document everything they need to know: which files to touch for each task, code, testing, docs they might need to check, how to test it. Give them the whole plan as bite-sized tasks. DRY. YAGNI. TDD. Frequent commits. 11 | 12 | Assume they are a skilled developer, but know almost nothing about our toolset or problem domain. Assume they don't know good test design very well. 13 | 14 | **Announce at start:** "I'm using the writing-plans skill to create the implementation plan." 15 | 16 | **Context:** This should be run in a dedicated worktree (created by brainstorming skill). 17 | 18 | **Save plans to:** `docs/plans/YYYY-MM-DD-.md` 19 | 20 | ## Bite-Sized Task Granularity 21 | 22 | **Each step is one action (2-5 minutes):** 23 | - "Write the failing test" - step 24 | - "Run it to make sure it fails" - step 25 | - "Implement the minimal code to make the test pass" - step 26 | - "Run the tests and make sure they pass" - step 27 | - "Commit" - step 28 | 29 | ## Plan Document Header 30 | 31 | **Every plan MUST start with this header:** 32 | 33 | ```markdown 34 | # [Feature Name] Implementation Plan 35 | 36 | > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. 37 | 38 | **Goal:** [One sentence describing what this builds] 39 | 40 | **Architecture:** [2-3 sentences about approach] 41 | 42 | **Tech Stack:** [Key technologies/libraries] 43 | 44 | --- 45 | ``` 46 | 47 | ## Task Structure 48 | 49 | ```markdown 50 | ### Task N: [Component Name] 51 | 52 | **Files:** 53 | - Create: `exact/path/to/file.py` 54 | - Modify: `exact/path/to/existing.py:123-145` 55 | - Test: `tests/exact/path/to/test.py` 56 | 57 | **Step 1: Write the failing test** 58 | 59 | ```python 60 | def test_specific_behavior(): 61 | result = function(input) 62 | assert result == expected 63 | ``` 64 | 65 | **Step 2: Run test to verify it fails** 66 | 67 | Run: `pytest tests/path/test.py::test_name -v` 68 | Expected: FAIL with "function not defined" 69 | 70 | **Step 3: Write minimal implementation** 71 | 72 | ```python 73 | def function(input): 74 | return expected 75 | ``` 76 | 77 | **Step 4: Run test to verify it passes** 78 | 79 | Run: `pytest tests/path/test.py::test_name -v` 80 | Expected: PASS 81 | 82 | **Step 5: Commit** 83 | 84 | ```bash 85 | git add tests/path/test.py src/path/file.py 86 | git commit -m "feat: add specific feature" 87 | ``` 88 | ``` 89 | 90 | ## Remember 91 | - Exact file paths always 92 | - Complete code in plan (not "add validation") 93 | - Exact commands with expected output 94 | - Reference relevant skills with @ syntax 95 | - DRY, YAGNI, TDD, frequent commits 96 | 97 | ## Execution Handoff 98 | 99 | After saving the plan, offer execution choice: 100 | 101 | **"Plan complete and saved to `docs/plans/.md`. Two execution options:** 102 | 103 | **1. Subagent-Driven (this session)** - I dispatch fresh subagent per task, review between tasks, fast iteration 104 | 105 | **2. Parallel Session (separate)** - Open new session with executing-plans, batch execution with checkpoints 106 | 107 | **Which approach?"** 108 | 109 | **If Subagent-Driven chosen:** 110 | - **REQUIRED SUB-SKILL:** Use superpowers:subagent-driven-development 111 | - Stay in this session 112 | - Fresh subagent per task + code review 113 | 114 | **If Parallel Session chosen:** 115 | - Guide them to open new session in worktree 116 | - **REQUIRED SUB-SKILL:** New session uses superpowers:executing-plans 117 | -------------------------------------------------------------------------------- /agents/code-reviewer.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: code-reviewer 3 | description: | 4 | Use this agent when a major project step has been completed and needs to be reviewed against the original plan and coding standards. Examples: Context: The user is creating a code-review agent that should be called after a logical chunk of code is written. user: "I've finished implementing the user authentication system as outlined in step 3 of our plan" assistant: "Great work! Now let me use the code-reviewer agent to review the implementation against our plan and coding standards" Since a major project step has been completed, use the code-reviewer agent to validate the work against the plan and identify any issues. Context: User has completed a significant feature implementation. user: "The API endpoints for the task management system are now complete - that covers step 2 from our architecture document" assistant: "Excellent! Let me have the code-reviewer agent examine this implementation to ensure it aligns with our plan and follows best practices" A numbered step from the planning document has been completed, so the code-reviewer agent should review the work. 5 | --- 6 | 7 | You are a Senior Code Reviewer with expertise in software architecture, design patterns, and best practices. Your role is to review completed project steps against original plans and ensure code quality standards are met. 8 | 9 | When reviewing completed work, you will: 10 | 11 | 1. **Plan Alignment Analysis**: 12 | - Compare the implementation against the original planning document or step description 13 | - Identify any deviations from the planned approach, architecture, or requirements 14 | - Assess whether deviations are justified improvements or problematic departures 15 | - Verify that all planned functionality has been implemented 16 | 17 | 2. **Code Quality Assessment**: 18 | - Review code for adherence to established patterns and conventions 19 | - Check for proper error handling, type safety, and defensive programming 20 | - Evaluate code organization, naming conventions, and maintainability 21 | - Assess test coverage and quality of test implementations 22 | - Look for potential security vulnerabilities or performance issues 23 | 24 | 3. **Architecture and Design Review**: 25 | - Ensure the implementation follows SOLID principles and established architectural patterns 26 | - Check for proper separation of concerns and loose coupling 27 | - Verify that the code integrates well with existing systems 28 | - Assess scalability and extensibility considerations 29 | 30 | 4. **Documentation and Standards**: 31 | - Verify that code includes appropriate comments and documentation 32 | - Check that file headers, function documentation, and inline comments are present and accurate 33 | - Ensure adherence to project-specific coding standards and conventions 34 | 35 | 5. **Issue Identification and Recommendations**: 36 | - Clearly categorize issues as: Critical (must fix), Important (should fix), or Suggestions (nice to have) 37 | - For each issue, provide specific examples and actionable recommendations 38 | - When you identify plan deviations, explain whether they're problematic or beneficial 39 | - Suggest specific improvements with code examples when helpful 40 | 41 | 6. **Communication Protocol**: 42 | - If you find significant deviations from the plan, ask the coding agent to review and confirm the changes 43 | - If you identify issues with the original plan itself, recommend plan updates 44 | - For implementation problems, provide clear guidance on fixes needed 45 | - Always acknowledge what was done well before highlighting issues 46 | 47 | Your output should be structured, actionable, and focused on helping maintain high code quality while ensuring project goals are met. Be thorough but concise, and always provide constructive feedback that helps improve both the current implementation and future development practices. 48 | -------------------------------------------------------------------------------- /skills/systematic-debugging/condition-based-waiting.md: -------------------------------------------------------------------------------- 1 | # Condition-Based Waiting 2 | 3 | ## Overview 4 | 5 | Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI. 6 | 7 | **Core principle:** Wait for the actual condition you care about, not a guess about how long it takes. 8 | 9 | ## When to Use 10 | 11 | ```dot 12 | digraph when_to_use { 13 | "Test uses setTimeout/sleep?" [shape=diamond]; 14 | "Testing timing behavior?" [shape=diamond]; 15 | "Document WHY timeout needed" [shape=box]; 16 | "Use condition-based waiting" [shape=box]; 17 | 18 | "Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"]; 19 | "Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"]; 20 | "Testing timing behavior?" -> "Use condition-based waiting" [label="no"]; 21 | } 22 | ``` 23 | 24 | **Use when:** 25 | - Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`) 26 | - Tests are flaky (pass sometimes, fail under load) 27 | - Tests timeout when run in parallel 28 | - Waiting for async operations to complete 29 | 30 | **Don't use when:** 31 | - Testing actual timing behavior (debounce, throttle intervals) 32 | - Always document WHY if using arbitrary timeout 33 | 34 | ## Core Pattern 35 | 36 | ```typescript 37 | // ❌ BEFORE: Guessing at timing 38 | await new Promise(r => setTimeout(r, 50)); 39 | const result = getResult(); 40 | expect(result).toBeDefined(); 41 | 42 | // ✅ AFTER: Waiting for condition 43 | await waitFor(() => getResult() !== undefined); 44 | const result = getResult(); 45 | expect(result).toBeDefined(); 46 | ``` 47 | 48 | ## Quick Patterns 49 | 50 | | Scenario | Pattern | 51 | |----------|---------| 52 | | Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` | 53 | | Wait for state | `waitFor(() => machine.state === 'ready')` | 54 | | Wait for count | `waitFor(() => items.length >= 5)` | 55 | | Wait for file | `waitFor(() => fs.existsSync(path))` | 56 | | Complex condition | `waitFor(() => obj.ready && obj.value > 10)` | 57 | 58 | ## Implementation 59 | 60 | Generic polling function: 61 | ```typescript 62 | async function waitFor( 63 | condition: () => T | undefined | null | false, 64 | description: string, 65 | timeoutMs = 5000 66 | ): Promise { 67 | const startTime = Date.now(); 68 | 69 | while (true) { 70 | const result = condition(); 71 | if (result) return result; 72 | 73 | if (Date.now() - startTime > timeoutMs) { 74 | throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`); 75 | } 76 | 77 | await new Promise(r => setTimeout(r, 10)); // Poll every 10ms 78 | } 79 | } 80 | ``` 81 | 82 | See `condition-based-waiting-example.ts` in this directory for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session. 83 | 84 | ## Common Mistakes 85 | 86 | **❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU 87 | **✅ Fix:** Poll every 10ms 88 | 89 | **❌ No timeout:** Loop forever if condition never met 90 | **✅ Fix:** Always include timeout with clear error 91 | 92 | **❌ Stale data:** Cache state before loop 93 | **✅ Fix:** Call getter inside loop for fresh data 94 | 95 | ## When Arbitrary Timeout IS Correct 96 | 97 | ```typescript 98 | // Tool ticks every 100ms - need 2 ticks to verify partial output 99 | await waitForEvent(manager, 'TOOL_STARTED'); // First: wait for condition 100 | await new Promise(r => setTimeout(r, 200)); // Then: wait for timed behavior 101 | // 200ms = 2 ticks at 100ms intervals - documented and justified 102 | ``` 103 | 104 | **Requirements:** 105 | 1. First wait for triggering condition 106 | 2. Based on known timing (not guessing) 107 | 3. Comment explaining WHY 108 | 109 | ## Real-World Impact 110 | 111 | From debugging session (2025-10-03): 112 | - Fixed 15 flaky tests across 3 files 113 | - Pass rate: 60% → 100% 114 | - Execution time: 40% faster 115 | - No more race conditions 116 | -------------------------------------------------------------------------------- /tests/opencode/test-tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Test: Tools Functionality 3 | # Verifies that use_skill and find_skills tools work correctly 4 | # NOTE: These tests require OpenCode to be installed and configured 5 | set -euo pipefail 6 | 7 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 8 | 9 | echo "=== Test: Tools Functionality ===" 10 | 11 | # Source setup to create isolated environment 12 | source "$SCRIPT_DIR/setup.sh" 13 | 14 | # Trap to cleanup on exit 15 | trap cleanup_test_env EXIT 16 | 17 | # Check if opencode is available 18 | if ! command -v opencode &> /dev/null; then 19 | echo " [SKIP] OpenCode not installed - skipping integration tests" 20 | echo " To run these tests, install OpenCode: https://opencode.ai" 21 | exit 0 22 | fi 23 | 24 | # Test 1: Test find_skills tool via direct invocation 25 | echo "Test 1: Testing find_skills tool..." 26 | echo " Running opencode with find_skills request..." 27 | 28 | # Use timeout to prevent hanging, capture both stdout and stderr 29 | output=$(timeout 60s opencode run --print-logs "Use the find_skills tool to list available skills. Just call the tool and show me the raw output." 2>&1) || { 30 | exit_code=$? 31 | if [ $exit_code -eq 124 ]; then 32 | echo " [FAIL] OpenCode timed out after 60s" 33 | exit 1 34 | fi 35 | echo " [WARN] OpenCode returned non-zero exit code: $exit_code" 36 | } 37 | 38 | # Check for expected patterns in output 39 | if echo "$output" | grep -qi "superpowers:brainstorming\|superpowers:using-superpowers\|Available skills"; then 40 | echo " [PASS] find_skills tool discovered superpowers skills" 41 | else 42 | echo " [FAIL] find_skills did not return expected skills" 43 | echo " Output was:" 44 | echo "$output" | head -50 45 | exit 1 46 | fi 47 | 48 | # Check if personal test skill was found 49 | if echo "$output" | grep -qi "personal-test"; then 50 | echo " [PASS] find_skills found personal test skill" 51 | else 52 | echo " [WARN] personal test skill not found in output (may be ok if tool returned subset)" 53 | fi 54 | 55 | # Test 2: Test use_skill tool 56 | echo "" 57 | echo "Test 2: Testing use_skill tool..." 58 | echo " Running opencode with use_skill request..." 59 | 60 | output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load the personal-test skill and show me what you get." 2>&1) || { 61 | exit_code=$? 62 | if [ $exit_code -eq 124 ]; then 63 | echo " [FAIL] OpenCode timed out after 60s" 64 | exit 1 65 | fi 66 | echo " [WARN] OpenCode returned non-zero exit code: $exit_code" 67 | } 68 | 69 | # Check for the skill marker we embedded 70 | if echo "$output" | grep -qi "PERSONAL_SKILL_MARKER_12345\|Personal Test Skill\|Launching skill"; then 71 | echo " [PASS] use_skill loaded personal-test skill content" 72 | else 73 | echo " [FAIL] use_skill did not load personal-test skill correctly" 74 | echo " Output was:" 75 | echo "$output" | head -50 76 | exit 1 77 | fi 78 | 79 | # Test 3: Test use_skill with superpowers: prefix 80 | echo "" 81 | echo "Test 3: Testing use_skill with superpowers: prefix..." 82 | echo " Running opencode with superpowers:brainstorming skill..." 83 | 84 | output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load superpowers:brainstorming and tell me the first few lines of what you received." 2>&1) || { 85 | exit_code=$? 86 | if [ $exit_code -eq 124 ]; then 87 | echo " [FAIL] OpenCode timed out after 60s" 88 | exit 1 89 | fi 90 | echo " [WARN] OpenCode returned non-zero exit code: $exit_code" 91 | } 92 | 93 | # Check for expected content from brainstorming skill 94 | if echo "$output" | grep -qi "brainstorming\|Launching skill\|skill.*loaded"; then 95 | echo " [PASS] use_skill loaded superpowers:brainstorming skill" 96 | else 97 | echo " [FAIL] use_skill did not load superpowers:brainstorming correctly" 98 | echo " Output was:" 99 | echo "$output" | head -50 100 | exit 1 101 | fi 102 | 103 | echo "" 104 | echo "=== All tools tests passed ===" 105 | -------------------------------------------------------------------------------- /skills/requesting-code-review/code-reviewer.md: -------------------------------------------------------------------------------- 1 | # Code Review Agent 2 | 3 | You are reviewing code changes for production readiness. 4 | 5 | **Your task:** 6 | 1. Review {WHAT_WAS_IMPLEMENTED} 7 | 2. Compare against {PLAN_OR_REQUIREMENTS} 8 | 3. Check code quality, architecture, testing 9 | 4. Categorize issues by severity 10 | 5. Assess production readiness 11 | 12 | ## What Was Implemented 13 | 14 | {DESCRIPTION} 15 | 16 | ## Requirements/Plan 17 | 18 | {PLAN_REFERENCE} 19 | 20 | ## Git Range to Review 21 | 22 | **Base:** {BASE_SHA} 23 | **Head:** {HEAD_SHA} 24 | 25 | ```bash 26 | git diff --stat {BASE_SHA}..{HEAD_SHA} 27 | git diff {BASE_SHA}..{HEAD_SHA} 28 | ``` 29 | 30 | ## Review Checklist 31 | 32 | **Code Quality:** 33 | - Clean separation of concerns? 34 | - Proper error handling? 35 | - Type safety (if applicable)? 36 | - DRY principle followed? 37 | - Edge cases handled? 38 | 39 | **Architecture:** 40 | - Sound design decisions? 41 | - Scalability considerations? 42 | - Performance implications? 43 | - Security concerns? 44 | 45 | **Testing:** 46 | - Tests actually test logic (not mocks)? 47 | - Edge cases covered? 48 | - Integration tests where needed? 49 | - All tests passing? 50 | 51 | **Requirements:** 52 | - All plan requirements met? 53 | - Implementation matches spec? 54 | - No scope creep? 55 | - Breaking changes documented? 56 | 57 | **Production Readiness:** 58 | - Migration strategy (if schema changes)? 59 | - Backward compatibility considered? 60 | - Documentation complete? 61 | - No obvious bugs? 62 | 63 | ## Output Format 64 | 65 | ### Strengths 66 | [What's well done? Be specific.] 67 | 68 | ### Issues 69 | 70 | #### Critical (Must Fix) 71 | [Bugs, security issues, data loss risks, broken functionality] 72 | 73 | #### Important (Should Fix) 74 | [Architecture problems, missing features, poor error handling, test gaps] 75 | 76 | #### Minor (Nice to Have) 77 | [Code style, optimization opportunities, documentation improvements] 78 | 79 | **For each issue:** 80 | - File:line reference 81 | - What's wrong 82 | - Why it matters 83 | - How to fix (if not obvious) 84 | 85 | ### Recommendations 86 | [Improvements for code quality, architecture, or process] 87 | 88 | ### Assessment 89 | 90 | **Ready to merge?** [Yes/No/With fixes] 91 | 92 | **Reasoning:** [Technical assessment in 1-2 sentences] 93 | 94 | ## Critical Rules 95 | 96 | **DO:** 97 | - Categorize by actual severity (not everything is Critical) 98 | - Be specific (file:line, not vague) 99 | - Explain WHY issues matter 100 | - Acknowledge strengths 101 | - Give clear verdict 102 | 103 | **DON'T:** 104 | - Say "looks good" without checking 105 | - Mark nitpicks as Critical 106 | - Give feedback on code you didn't review 107 | - Be vague ("improve error handling") 108 | - Avoid giving a clear verdict 109 | 110 | ## Example Output 111 | 112 | ``` 113 | ### Strengths 114 | - Clean database schema with proper migrations (db.ts:15-42) 115 | - Comprehensive test coverage (18 tests, all edge cases) 116 | - Good error handling with fallbacks (summarizer.ts:85-92) 117 | 118 | ### Issues 119 | 120 | #### Important 121 | 1. **Missing help text in CLI wrapper** 122 | - File: index-conversations:1-31 123 | - Issue: No --help flag, users won't discover --concurrency 124 | - Fix: Add --help case with usage examples 125 | 126 | 2. **Date validation missing** 127 | - File: search.ts:25-27 128 | - Issue: Invalid dates silently return no results 129 | - Fix: Validate ISO format, throw error with example 130 | 131 | #### Minor 132 | 1. **Progress indicators** 133 | - File: indexer.ts:130 134 | - Issue: No "X of Y" counter for long operations 135 | - Impact: Users don't know how long to wait 136 | 137 | ### Recommendations 138 | - Add progress reporting for user experience 139 | - Consider config file for excluded projects (portability) 140 | 141 | ### Assessment 142 | 143 | **Ready to merge: With fixes** 144 | 145 | **Reasoning:** Core implementation is solid with good architecture and tests. Important issues (help text, date validation) are easily fixed and don't affect core functionality. 146 | ``` 147 | -------------------------------------------------------------------------------- /docs/README.codex.md: -------------------------------------------------------------------------------- 1 | # Superpowers for Codex 2 | 3 | Complete guide for using Superpowers with OpenAI Codex. 4 | 5 | ## Quick Install 6 | 7 | Tell Codex: 8 | 9 | ``` 10 | Fetch and follow instructions from https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/.codex/INSTALL.md 11 | ``` 12 | 13 | ## Manual Installation 14 | 15 | ### Prerequisites 16 | 17 | - OpenAI Codex access 18 | - Shell access to install files 19 | 20 | ### Installation Steps 21 | 22 | #### 1. Clone Superpowers 23 | 24 | ```bash 25 | mkdir -p ~/.codex/superpowers 26 | git clone https://github.com/obra/superpowers.git ~/.codex/superpowers 27 | ``` 28 | 29 | #### 2. Install Bootstrap 30 | 31 | The bootstrap file is included in the repository at `.codex/superpowers-bootstrap.md`. Codex will automatically use it from the cloned location. 32 | 33 | #### 3. Verify Installation 34 | 35 | Tell Codex: 36 | 37 | ``` 38 | Run ~/.codex/superpowers/.codex/superpowers-codex find-skills to show available skills 39 | ``` 40 | 41 | You should see a list of available skills with descriptions. 42 | 43 | ## Usage 44 | 45 | ### Finding Skills 46 | 47 | ``` 48 | Run ~/.codex/superpowers/.codex/superpowers-codex find-skills 49 | ``` 50 | 51 | ### Loading a Skill 52 | 53 | ``` 54 | Run ~/.codex/superpowers/.codex/superpowers-codex use-skill superpowers:brainstorming 55 | ``` 56 | 57 | ### Bootstrap All Skills 58 | 59 | ``` 60 | Run ~/.codex/superpowers/.codex/superpowers-codex bootstrap 61 | ``` 62 | 63 | This loads the complete bootstrap with all skill information. 64 | 65 | ### Personal Skills 66 | 67 | Create your own skills in `~/.codex/skills/`: 68 | 69 | ```bash 70 | mkdir -p ~/.codex/skills/my-skill 71 | ``` 72 | 73 | Create `~/.codex/skills/my-skill/SKILL.md`: 74 | 75 | ```markdown 76 | --- 77 | name: my-skill 78 | description: Use when [condition] - [what it does] 79 | --- 80 | 81 | # My Skill 82 | 83 | [Your skill content here] 84 | ``` 85 | 86 | Personal skills override superpowers skills with the same name. 87 | 88 | ## Architecture 89 | 90 | ### Codex CLI Tool 91 | 92 | **Location:** `~/.codex/superpowers/.codex/superpowers-codex` 93 | 94 | A Node.js CLI script that provides three commands: 95 | - `bootstrap` - Load complete bootstrap with all skills 96 | - `use-skill ` - Load a specific skill 97 | - `find-skills` - List all available skills 98 | 99 | ### Shared Core Module 100 | 101 | **Location:** `~/.codex/superpowers/lib/skills-core.js` 102 | 103 | The Codex implementation uses the shared `skills-core` module (ES module format) for skill discovery and parsing. This is the same module used by the OpenCode plugin, ensuring consistent behavior across platforms. 104 | 105 | ### Tool Mapping 106 | 107 | Skills written for Claude Code are adapted for Codex with these mappings: 108 | 109 | - `TodoWrite` → `update_plan` 110 | - `Task` with subagents → Tell user subagents aren't available, do work directly 111 | - `Skill` tool → `~/.codex/superpowers/.codex/superpowers-codex use-skill` 112 | - File operations → Native Codex tools 113 | 114 | ## Updating 115 | 116 | ```bash 117 | cd ~/.codex/superpowers 118 | git pull 119 | ``` 120 | 121 | ## Troubleshooting 122 | 123 | ### Skills not found 124 | 125 | 1. Verify installation: `ls ~/.codex/superpowers/skills` 126 | 2. Check CLI works: `~/.codex/superpowers/.codex/superpowers-codex find-skills` 127 | 3. Verify skills have SKILL.md files 128 | 129 | ### CLI script not executable 130 | 131 | ```bash 132 | chmod +x ~/.codex/superpowers/.codex/superpowers-codex 133 | ``` 134 | 135 | ### Node.js errors 136 | 137 | The CLI script requires Node.js. Verify: 138 | 139 | ```bash 140 | node --version 141 | ``` 142 | 143 | Should show v14 or higher (v18+ recommended for ES module support). 144 | 145 | ## Getting Help 146 | 147 | - Report issues: https://github.com/obra/superpowers/issues 148 | - Main documentation: https://github.com/obra/superpowers 149 | - Blog post: https://blog.fsck.com/2025/10/27/skills-for-openai-codex/ 150 | 151 | ## Note 152 | 153 | Codex support is experimental and may require refinement based on user feedback. If you encounter issues, please report them on GitHub. 154 | -------------------------------------------------------------------------------- /skills/systematic-debugging/defense-in-depth.md: -------------------------------------------------------------------------------- 1 | # Defense-in-Depth Validation 2 | 3 | ## Overview 4 | 5 | When you fix a bug caused by invalid data, adding validation at one place feels sufficient. But that single check can be bypassed by different code paths, refactoring, or mocks. 6 | 7 | **Core principle:** Validate at EVERY layer data passes through. Make the bug structurally impossible. 8 | 9 | ## Why Multiple Layers 10 | 11 | Single validation: "We fixed the bug" 12 | Multiple layers: "We made the bug impossible" 13 | 14 | Different layers catch different cases: 15 | - Entry validation catches most bugs 16 | - Business logic catches edge cases 17 | - Environment guards prevent context-specific dangers 18 | - Debug logging helps when other layers fail 19 | 20 | ## The Four Layers 21 | 22 | ### Layer 1: Entry Point Validation 23 | **Purpose:** Reject obviously invalid input at API boundary 24 | 25 | ```typescript 26 | function createProject(name: string, workingDirectory: string) { 27 | if (!workingDirectory || workingDirectory.trim() === '') { 28 | throw new Error('workingDirectory cannot be empty'); 29 | } 30 | if (!existsSync(workingDirectory)) { 31 | throw new Error(`workingDirectory does not exist: ${workingDirectory}`); 32 | } 33 | if (!statSync(workingDirectory).isDirectory()) { 34 | throw new Error(`workingDirectory is not a directory: ${workingDirectory}`); 35 | } 36 | // ... proceed 37 | } 38 | ``` 39 | 40 | ### Layer 2: Business Logic Validation 41 | **Purpose:** Ensure data makes sense for this operation 42 | 43 | ```typescript 44 | function initializeWorkspace(projectDir: string, sessionId: string) { 45 | if (!projectDir) { 46 | throw new Error('projectDir required for workspace initialization'); 47 | } 48 | // ... proceed 49 | } 50 | ``` 51 | 52 | ### Layer 3: Environment Guards 53 | **Purpose:** Prevent dangerous operations in specific contexts 54 | 55 | ```typescript 56 | async function gitInit(directory: string) { 57 | // In tests, refuse git init outside temp directories 58 | if (process.env.NODE_ENV === 'test') { 59 | const normalized = normalize(resolve(directory)); 60 | const tmpDir = normalize(resolve(tmpdir())); 61 | 62 | if (!normalized.startsWith(tmpDir)) { 63 | throw new Error( 64 | `Refusing git init outside temp dir during tests: ${directory}` 65 | ); 66 | } 67 | } 68 | // ... proceed 69 | } 70 | ``` 71 | 72 | ### Layer 4: Debug Instrumentation 73 | **Purpose:** Capture context for forensics 74 | 75 | ```typescript 76 | async function gitInit(directory: string) { 77 | const stack = new Error().stack; 78 | logger.debug('About to git init', { 79 | directory, 80 | cwd: process.cwd(), 81 | stack, 82 | }); 83 | // ... proceed 84 | } 85 | ``` 86 | 87 | ## Applying the Pattern 88 | 89 | When you find a bug: 90 | 91 | 1. **Trace the data flow** - Where does bad value originate? Where used? 92 | 2. **Map all checkpoints** - List every point data passes through 93 | 3. **Add validation at each layer** - Entry, business, environment, debug 94 | 4. **Test each layer** - Try to bypass layer 1, verify layer 2 catches it 95 | 96 | ## Example from Session 97 | 98 | Bug: Empty `projectDir` caused `git init` in source code 99 | 100 | **Data flow:** 101 | 1. Test setup → empty string 102 | 2. `Project.create(name, '')` 103 | 3. `WorkspaceManager.createWorkspace('')` 104 | 4. `git init` runs in `process.cwd()` 105 | 106 | **Four layers added:** 107 | - Layer 1: `Project.create()` validates not empty/exists/writable 108 | - Layer 2: `WorkspaceManager` validates projectDir not empty 109 | - Layer 3: `WorktreeManager` refuses git init outside tmpdir in tests 110 | - Layer 4: Stack trace logging before git init 111 | 112 | **Result:** All 1847 tests passed, bug impossible to reproduce 113 | 114 | ## Key Insight 115 | 116 | All four layers were necessary. During testing, each layer caught bugs the others missed: 117 | - Different code paths bypassed entry validation 118 | - Mocks bypassed business logic checks 119 | - Edge cases on different platforms needed environment guards 120 | - Debug logging identified structural misuse 121 | 122 | **Don't stop at one validation point.** Add checks at every layer. 123 | -------------------------------------------------------------------------------- /tests/claude-code/test-subagent-driven-development.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Test: subagent-driven-development skill 3 | # Verifies that the skill is loaded and follows correct workflow 4 | set -euo pipefail 5 | 6 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 7 | source "$SCRIPT_DIR/test-helpers.sh" 8 | 9 | echo "=== Test: subagent-driven-development skill ===" 10 | echo "" 11 | 12 | # Test 1: Verify skill can be loaded 13 | echo "Test 1: Skill loading..." 14 | 15 | output=$(run_claude "What is the subagent-driven-development skill? Describe its key steps briefly." 30) 16 | 17 | if assert_contains "$output" "subagent-driven-development" "Skill is recognized"; then 18 | : # pass 19 | else 20 | exit 1 21 | fi 22 | 23 | if assert_contains "$output" "Load Plan\|read.*plan\|extract.*tasks" "Mentions loading plan"; then 24 | : # pass 25 | else 26 | exit 1 27 | fi 28 | 29 | echo "" 30 | 31 | # Test 2: Verify skill describes correct workflow order 32 | echo "Test 2: Workflow ordering..." 33 | 34 | output=$(run_claude "In the subagent-driven-development skill, what comes first: spec compliance review or code quality review? Be specific about the order." 30) 35 | 36 | if assert_order "$output" "spec.*compliance" "code.*quality" "Spec compliance before code quality"; then 37 | : # pass 38 | else 39 | exit 1 40 | fi 41 | 42 | echo "" 43 | 44 | # Test 3: Verify self-review is mentioned 45 | echo "Test 3: Self-review requirement..." 46 | 47 | output=$(run_claude "Does the subagent-driven-development skill require implementers to do self-review? What should they check?" 30) 48 | 49 | if assert_contains "$output" "self-review\|self review" "Mentions self-review"; then 50 | : # pass 51 | else 52 | exit 1 53 | fi 54 | 55 | if assert_contains "$output" "completeness\|Completeness" "Checks completeness"; then 56 | : # pass 57 | else 58 | exit 1 59 | fi 60 | 61 | echo "" 62 | 63 | # Test 4: Verify plan is read once 64 | echo "Test 4: Plan reading efficiency..." 65 | 66 | output=$(run_claude "In subagent-driven-development, how many times should the controller read the plan file? When does this happen?" 30) 67 | 68 | if assert_contains "$output" "once\|one time\|single" "Read plan once"; then 69 | : # pass 70 | else 71 | exit 1 72 | fi 73 | 74 | if assert_contains "$output" "Step 1\|beginning\|start\|Load Plan" "Read at beginning"; then 75 | : # pass 76 | else 77 | exit 1 78 | fi 79 | 80 | echo "" 81 | 82 | # Test 5: Verify spec compliance reviewer is skeptical 83 | echo "Test 5: Spec compliance reviewer mindset..." 84 | 85 | output=$(run_claude "What is the spec compliance reviewer's attitude toward the implementer's report in subagent-driven-development?" 30) 86 | 87 | if assert_contains "$output" "not trust\|don't trust\|skeptical\|verify.*independently\|suspiciously" "Reviewer is skeptical"; then 88 | : # pass 89 | else 90 | exit 1 91 | fi 92 | 93 | if assert_contains "$output" "read.*code\|inspect.*code\|verify.*code" "Reviewer reads code"; then 94 | : # pass 95 | else 96 | exit 1 97 | fi 98 | 99 | echo "" 100 | 101 | # Test 6: Verify review loops 102 | echo "Test 6: Review loop requirements..." 103 | 104 | output=$(run_claude "In subagent-driven-development, what happens if a reviewer finds issues? Is it a one-time review or a loop?" 30) 105 | 106 | if assert_contains "$output" "loop\|again\|repeat\|until.*approved\|until.*compliant" "Review loops mentioned"; then 107 | : # pass 108 | else 109 | exit 1 110 | fi 111 | 112 | if assert_contains "$output" "implementer.*fix\|fix.*issues" "Implementer fixes issues"; then 113 | : # pass 114 | else 115 | exit 1 116 | fi 117 | 118 | echo "" 119 | 120 | # Test 7: Verify full task text is provided 121 | echo "Test 7: Task context provision..." 122 | 123 | output=$(run_claude "In subagent-driven-development, how does the controller provide task information to the implementer subagent? Does it make them read a file or provide it directly?" 30) 124 | 125 | if assert_contains "$output" "provide.*directly\|full.*text\|paste\|include.*prompt" "Provides text directly"; then 126 | : # pass 127 | else 128 | exit 1 129 | fi 130 | 131 | if assert_not_contains "$output" "read.*file\|open.*file" "Doesn't make subagent read file"; then 132 | : # pass 133 | else 134 | exit 1 135 | fi 136 | 137 | echo "" 138 | 139 | echo "=== All subagent-driven-development skill tests passed ===" 140 | -------------------------------------------------------------------------------- /skills/systematic-debugging/CREATION-LOG.md: -------------------------------------------------------------------------------- 1 | # Creation Log: Systematic Debugging Skill 2 | 3 | Reference example of extracting, structuring, and bulletproofing a critical skill. 4 | 5 | ## Source Material 6 | 7 | Extracted debugging framework from `/Users/jesse/.claude/CLAUDE.md`: 8 | - 4-phase systematic process (Investigation → Pattern Analysis → Hypothesis → Implementation) 9 | - Core mandate: ALWAYS find root cause, NEVER fix symptoms 10 | - Rules designed to resist time pressure and rationalization 11 | 12 | ## Extraction Decisions 13 | 14 | **What to include:** 15 | - Complete 4-phase framework with all rules 16 | - Anti-shortcuts ("NEVER fix symptom", "STOP and re-analyze") 17 | - Pressure-resistant language ("even if faster", "even if I seem in a hurry") 18 | - Concrete steps for each phase 19 | 20 | **What to leave out:** 21 | - Project-specific context 22 | - Repetitive variations of same rule 23 | - Narrative explanations (condensed to principles) 24 | 25 | ## Structure Following skill-creation/SKILL.md 26 | 27 | 1. **Rich when_to_use** - Included symptoms and anti-patterns 28 | 2. **Type: technique** - Concrete process with steps 29 | 3. **Keywords** - "root cause", "symptom", "workaround", "debugging", "investigation" 30 | 4. **Flowchart** - Decision point for "fix failed" → re-analyze vs add more fixes 31 | 5. **Phase-by-phase breakdown** - Scannable checklist format 32 | 6. **Anti-patterns section** - What NOT to do (critical for this skill) 33 | 34 | ## Bulletproofing Elements 35 | 36 | Framework designed to resist rationalization under pressure: 37 | 38 | ### Language Choices 39 | - "ALWAYS" / "NEVER" (not "should" / "try to") 40 | - "even if faster" / "even if I seem in a hurry" 41 | - "STOP and re-analyze" (explicit pause) 42 | - "Don't skip past" (catches the actual behavior) 43 | 44 | ### Structural Defenses 45 | - **Phase 1 required** - Can't skip to implementation 46 | - **Single hypothesis rule** - Forces thinking, prevents shotgun fixes 47 | - **Explicit failure mode** - "IF your first fix doesn't work" with mandatory action 48 | - **Anti-patterns section** - Shows exactly what shortcuts look like 49 | 50 | ### Redundancy 51 | - Root cause mandate in overview + when_to_use + Phase 1 + implementation rules 52 | - "NEVER fix symptom" appears 4 times in different contexts 53 | - Each phase has explicit "don't skip" guidance 54 | 55 | ## Testing Approach 56 | 57 | Created 4 validation tests following skills/meta/testing-skills-with-subagents: 58 | 59 | ### Test 1: Academic Context (No Pressure) 60 | - Simple bug, no time pressure 61 | - **Result:** Perfect compliance, complete investigation 62 | 63 | ### Test 2: Time Pressure + Obvious Quick Fix 64 | - User "in a hurry", symptom fix looks easy 65 | - **Result:** Resisted shortcut, followed full process, found real root cause 66 | 67 | ### Test 3: Complex System + Uncertainty 68 | - Multi-layer failure, unclear if can find root cause 69 | - **Result:** Systematic investigation, traced through all layers, found source 70 | 71 | ### Test 4: Failed First Fix 72 | - Hypothesis doesn't work, temptation to add more fixes 73 | - **Result:** Stopped, re-analyzed, formed new hypothesis (no shotgun) 74 | 75 | **All tests passed.** No rationalizations found. 76 | 77 | ## Iterations 78 | 79 | ### Initial Version 80 | - Complete 4-phase framework 81 | - Anti-patterns section 82 | - Flowchart for "fix failed" decision 83 | 84 | ### Enhancement 1: TDD Reference 85 | - Added link to skills/testing/test-driven-development 86 | - Note explaining TDD's "simplest code" ≠ debugging's "root cause" 87 | - Prevents confusion between methodologies 88 | 89 | ## Final Outcome 90 | 91 | Bulletproof skill that: 92 | - ✅ Clearly mandates root cause investigation 93 | - ✅ Resists time pressure rationalization 94 | - ✅ Provides concrete steps for each phase 95 | - ✅ Shows anti-patterns explicitly 96 | - ✅ Tested under multiple pressure scenarios 97 | - ✅ Clarifies relationship to TDD 98 | - ✅ Ready for use 99 | 100 | ## Key Insight 101 | 102 | **Most important bulletproofing:** Anti-patterns section showing exact shortcuts that feel justified in the moment. When Claude thinks "I'll just add this one quick fix", seeing that exact pattern listed as wrong creates cognitive friction. 103 | 104 | ## Usage Example 105 | 106 | When encountering a bug: 107 | 1. Load skill: skills/debugging/systematic-debugging 108 | 2. Read overview (10 sec) - reminded of mandate 109 | 3. Follow Phase 1 checklist - forced investigation 110 | 4. If tempted to skip - see anti-pattern, stop 111 | 5. Complete all phases - root cause found 112 | 113 | **Time investment:** 5-10 minutes 114 | **Time saved:** Hours of symptom-whack-a-mole 115 | 116 | --- 117 | 118 | *Created: 2025-10-03* 119 | *Purpose: Reference example for skill extraction and bulletproofing* 120 | -------------------------------------------------------------------------------- /skills/verification-before-completion/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: verification-before-completion 3 | description: Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always 4 | --- 5 | 6 | # Verification Before Completion 7 | 8 | ## Overview 9 | 10 | Claiming work is complete without verification is dishonesty, not efficiency. 11 | 12 | **Core principle:** Evidence before claims, always. 13 | 14 | **Violating the letter of this rule is violating the spirit of this rule.** 15 | 16 | ## The Iron Law 17 | 18 | ``` 19 | NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE 20 | ``` 21 | 22 | If you haven't run the verification command in this message, you cannot claim it passes. 23 | 24 | ## The Gate Function 25 | 26 | ``` 27 | BEFORE claiming any status or expressing satisfaction: 28 | 29 | 1. IDENTIFY: What command proves this claim? 30 | 2. RUN: Execute the FULL command (fresh, complete) 31 | 3. READ: Full output, check exit code, count failures 32 | 4. VERIFY: Does output confirm the claim? 33 | - If NO: State actual status with evidence 34 | - If YES: State claim WITH evidence 35 | 5. ONLY THEN: Make the claim 36 | 37 | Skip any step = lying, not verifying 38 | ``` 39 | 40 | ## Common Failures 41 | 42 | | Claim | Requires | Not Sufficient | 43 | |-------|----------|----------------| 44 | | Tests pass | Test command output: 0 failures | Previous run, "should pass" | 45 | | Linter clean | Linter output: 0 errors | Partial check, extrapolation | 46 | | Build succeeds | Build command: exit 0 | Linter passing, logs look good | 47 | | Bug fixed | Test original symptom: passes | Code changed, assumed fixed | 48 | | Regression test works | Red-green cycle verified | Test passes once | 49 | | Agent completed | VCS diff shows changes | Agent reports "success" | 50 | | Requirements met | Line-by-line checklist | Tests passing | 51 | 52 | ## Red Flags - STOP 53 | 54 | - Using "should", "probably", "seems to" 55 | - Expressing satisfaction before verification ("Great!", "Perfect!", "Done!", etc.) 56 | - About to commit/push/PR without verification 57 | - Trusting agent success reports 58 | - Relying on partial verification 59 | - Thinking "just this once" 60 | - Tired and wanting work over 61 | - **ANY wording implying success without having run verification** 62 | 63 | ## Rationalization Prevention 64 | 65 | | Excuse | Reality | 66 | |--------|---------| 67 | | "Should work now" | RUN the verification | 68 | | "I'm confident" | Confidence ≠ evidence | 69 | | "Just this once" | No exceptions | 70 | | "Linter passed" | Linter ≠ compiler | 71 | | "Agent said success" | Verify independently | 72 | | "I'm tired" | Exhaustion ≠ excuse | 73 | | "Partial check is enough" | Partial proves nothing | 74 | | "Different words so rule doesn't apply" | Spirit over letter | 75 | 76 | ## Key Patterns 77 | 78 | **Tests:** 79 | ``` 80 | ✅ [Run test command] [See: 34/34 pass] "All tests pass" 81 | ❌ "Should pass now" / "Looks correct" 82 | ``` 83 | 84 | **Regression tests (TDD Red-Green):** 85 | ``` 86 | ✅ Write → Run (pass) → Revert fix → Run (MUST FAIL) → Restore → Run (pass) 87 | ❌ "I've written a regression test" (without red-green verification) 88 | ``` 89 | 90 | **Build:** 91 | ``` 92 | ✅ [Run build] [See: exit 0] "Build passes" 93 | ❌ "Linter passed" (linter doesn't check compilation) 94 | ``` 95 | 96 | **Requirements:** 97 | ``` 98 | ✅ Re-read plan → Create checklist → Verify each → Report gaps or completion 99 | ❌ "Tests pass, phase complete" 100 | ``` 101 | 102 | **Agent delegation:** 103 | ``` 104 | ✅ Agent reports success → Check VCS diff → Verify changes → Report actual state 105 | ❌ Trust agent report 106 | ``` 107 | 108 | ## Why This Matters 109 | 110 | From 24 failure memories: 111 | - your human partner said "I don't believe you" - trust broken 112 | - Undefined functions shipped - would crash 113 | - Missing requirements shipped - incomplete features 114 | - Time wasted on false completion → redirect → rework 115 | - Violates: "Honesty is a core value. If you lie, you'll be replaced." 116 | 117 | ## When To Apply 118 | 119 | **ALWAYS before:** 120 | - ANY variation of success/completion claims 121 | - ANY expression of satisfaction 122 | - ANY positive statement about work state 123 | - Committing, PR creation, task completion 124 | - Moving to next task 125 | - Delegating to agents 126 | 127 | **Rule applies to:** 128 | - Exact phrases 129 | - Paraphrases and synonyms 130 | - Implications of success 131 | - ANY communication suggesting completion/correctness 132 | 133 | ## The Bottom Line 134 | 135 | **No shortcuts for verification.** 136 | 137 | Run the command. Read the output. THEN claim the result. 138 | 139 | This is non-negotiable. 140 | -------------------------------------------------------------------------------- /tests/claude-code/README.md: -------------------------------------------------------------------------------- 1 | # Claude Code Skills Tests 2 | 3 | Automated tests for superpowers skills using Claude Code CLI. 4 | 5 | ## Overview 6 | 7 | This test suite verifies that skills are loaded correctly and Claude follows them as expected. Tests invoke Claude Code in headless mode (`claude -p`) and verify the behavior. 8 | 9 | ## Requirements 10 | 11 | - Claude Code CLI installed and in PATH (`claude --version` should work) 12 | - Local superpowers plugin installed (see main README for installation) 13 | 14 | ## Running Tests 15 | 16 | ### Run all fast tests (recommended): 17 | ```bash 18 | ./run-skill-tests.sh 19 | ``` 20 | 21 | ### Run integration tests (slow, 10-30 minutes): 22 | ```bash 23 | ./run-skill-tests.sh --integration 24 | ``` 25 | 26 | ### Run specific test: 27 | ```bash 28 | ./run-skill-tests.sh --test test-subagent-driven-development.sh 29 | ``` 30 | 31 | ### Run with verbose output: 32 | ```bash 33 | ./run-skill-tests.sh --verbose 34 | ``` 35 | 36 | ### Set custom timeout: 37 | ```bash 38 | ./run-skill-tests.sh --timeout 1800 # 30 minutes for integration tests 39 | ``` 40 | 41 | ## Test Structure 42 | 43 | ### test-helpers.sh 44 | Common functions for skills testing: 45 | - `run_claude "prompt" [timeout]` - Run Claude with prompt 46 | - `assert_contains output pattern name` - Verify pattern exists 47 | - `assert_not_contains output pattern name` - Verify pattern absent 48 | - `assert_count output pattern count name` - Verify exact count 49 | - `assert_order output pattern_a pattern_b name` - Verify order 50 | - `create_test_project` - Create temp test directory 51 | - `create_test_plan project_dir` - Create sample plan file 52 | 53 | ### Test Files 54 | 55 | Each test file: 56 | 1. Sources `test-helpers.sh` 57 | 2. Runs Claude Code with specific prompts 58 | 3. Verifies expected behavior using assertions 59 | 4. Returns 0 on success, non-zero on failure 60 | 61 | ## Example Test 62 | 63 | ```bash 64 | #!/usr/bin/env bash 65 | set -euo pipefail 66 | 67 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 68 | source "$SCRIPT_DIR/test-helpers.sh" 69 | 70 | echo "=== Test: My Skill ===" 71 | 72 | # Ask Claude about the skill 73 | output=$(run_claude "What does the my-skill skill do?" 30) 74 | 75 | # Verify response 76 | assert_contains "$output" "expected behavior" "Skill describes behavior" 77 | 78 | echo "=== All tests passed ===" 79 | ``` 80 | 81 | ## Current Tests 82 | 83 | ### Fast Tests (run by default) 84 | 85 | #### test-subagent-driven-development.sh 86 | Tests skill content and requirements (~2 minutes): 87 | - Skill loading and accessibility 88 | - Workflow ordering (spec compliance before code quality) 89 | - Self-review requirements documented 90 | - Plan reading efficiency documented 91 | - Spec compliance reviewer skepticism documented 92 | - Review loops documented 93 | - Task context provision documented 94 | 95 | ### Integration Tests (use --integration flag) 96 | 97 | #### test-subagent-driven-development-integration.sh 98 | Full workflow execution test (~10-30 minutes): 99 | - Creates real test project with Node.js setup 100 | - Creates implementation plan with 2 tasks 101 | - Executes plan using subagent-driven-development 102 | - Verifies actual behaviors: 103 | - Plan read once at start (not per task) 104 | - Full task text provided in subagent prompts 105 | - Subagents perform self-review before reporting 106 | - Spec compliance review happens before code quality 107 | - Spec reviewer reads code independently 108 | - Working implementation is produced 109 | - Tests pass 110 | - Proper git commits created 111 | 112 | **What it tests:** 113 | - The workflow actually works end-to-end 114 | - Our improvements are actually applied 115 | - Subagents follow the skill correctly 116 | - Final code is functional and tested 117 | 118 | ## Adding New Tests 119 | 120 | 1. Create new test file: `test-.sh` 121 | 2. Source test-helpers.sh 122 | 3. Write tests using `run_claude` and assertions 123 | 4. Add to test list in `run-skill-tests.sh` 124 | 5. Make executable: `chmod +x test-.sh` 125 | 126 | ## Timeout Considerations 127 | 128 | - Default timeout: 5 minutes per test 129 | - Claude Code may take time to respond 130 | - Adjust with `--timeout` if needed 131 | - Tests should be focused to avoid long runs 132 | 133 | ## Debugging Failed Tests 134 | 135 | With `--verbose`, you'll see full Claude output: 136 | ```bash 137 | ./run-skill-tests.sh --verbose --test test-subagent-driven-development.sh 138 | ``` 139 | 140 | Without verbose, only failures show output. 141 | 142 | ## CI/CD Integration 143 | 144 | To run in CI: 145 | ```bash 146 | # Run with explicit timeout for CI environments 147 | ./run-skill-tests.sh --timeout 900 148 | 149 | # Exit code 0 = success, non-zero = failure 150 | ``` 151 | 152 | ## Notes 153 | 154 | - Tests verify skill *instructions*, not full execution 155 | - Full workflow tests would be very slow 156 | - Focus on verifying key skill requirements 157 | - Tests should be deterministic 158 | - Avoid testing implementation details 159 | -------------------------------------------------------------------------------- /tests/opencode/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Main test runner for OpenCode plugin test suite 3 | # Runs all tests and reports results 4 | set -euo pipefail 5 | 6 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 7 | cd "$SCRIPT_DIR" 8 | 9 | echo "========================================" 10 | echo " OpenCode Plugin Test Suite" 11 | echo "========================================" 12 | echo "" 13 | echo "Repository: $(cd ../.. && pwd)" 14 | echo "Test time: $(date)" 15 | echo "" 16 | 17 | # Parse command line arguments 18 | RUN_INTEGRATION=false 19 | VERBOSE=false 20 | SPECIFIC_TEST="" 21 | 22 | while [[ $# -gt 0 ]]; do 23 | case $1 in 24 | --integration|-i) 25 | RUN_INTEGRATION=true 26 | shift 27 | ;; 28 | --verbose|-v) 29 | VERBOSE=true 30 | shift 31 | ;; 32 | --test|-t) 33 | SPECIFIC_TEST="$2" 34 | shift 2 35 | ;; 36 | --help|-h) 37 | echo "Usage: $0 [options]" 38 | echo "" 39 | echo "Options:" 40 | echo " --integration, -i Run integration tests (requires OpenCode)" 41 | echo " --verbose, -v Show verbose output" 42 | echo " --test, -t NAME Run only the specified test" 43 | echo " --help, -h Show this help" 44 | echo "" 45 | echo "Tests:" 46 | echo " test-plugin-loading.sh Verify plugin installation and structure" 47 | echo " test-skills-core.sh Test skills-core.js library functions" 48 | echo " test-tools.sh Test use_skill and find_skills tools (integration)" 49 | echo " test-priority.sh Test skill priority resolution (integration)" 50 | exit 0 51 | ;; 52 | *) 53 | echo "Unknown option: $1" 54 | echo "Use --help for usage information" 55 | exit 1 56 | ;; 57 | esac 58 | done 59 | 60 | # List of tests to run (no external dependencies) 61 | tests=( 62 | "test-plugin-loading.sh" 63 | "test-skills-core.sh" 64 | ) 65 | 66 | # Integration tests (require OpenCode) 67 | integration_tests=( 68 | "test-tools.sh" 69 | "test-priority.sh" 70 | ) 71 | 72 | # Add integration tests if requested 73 | if [ "$RUN_INTEGRATION" = true ]; then 74 | tests+=("${integration_tests[@]}") 75 | fi 76 | 77 | # Filter to specific test if requested 78 | if [ -n "$SPECIFIC_TEST" ]; then 79 | tests=("$SPECIFIC_TEST") 80 | fi 81 | 82 | # Track results 83 | passed=0 84 | failed=0 85 | skipped=0 86 | 87 | # Run each test 88 | for test in "${tests[@]}"; do 89 | echo "----------------------------------------" 90 | echo "Running: $test" 91 | echo "----------------------------------------" 92 | 93 | test_path="$SCRIPT_DIR/$test" 94 | 95 | if [ ! -f "$test_path" ]; then 96 | echo " [SKIP] Test file not found: $test" 97 | skipped=$((skipped + 1)) 98 | continue 99 | fi 100 | 101 | if [ ! -x "$test_path" ]; then 102 | echo " Making $test executable..." 103 | chmod +x "$test_path" 104 | fi 105 | 106 | start_time=$(date +%s) 107 | 108 | if [ "$VERBOSE" = true ]; then 109 | if bash "$test_path"; then 110 | end_time=$(date +%s) 111 | duration=$((end_time - start_time)) 112 | echo "" 113 | echo " [PASS] $test (${duration}s)" 114 | passed=$((passed + 1)) 115 | else 116 | end_time=$(date +%s) 117 | duration=$((end_time - start_time)) 118 | echo "" 119 | echo " [FAIL] $test (${duration}s)" 120 | failed=$((failed + 1)) 121 | fi 122 | else 123 | # Capture output for non-verbose mode 124 | if output=$(bash "$test_path" 2>&1); then 125 | end_time=$(date +%s) 126 | duration=$((end_time - start_time)) 127 | echo " [PASS] (${duration}s)" 128 | passed=$((passed + 1)) 129 | else 130 | end_time=$(date +%s) 131 | duration=$((end_time - start_time)) 132 | echo " [FAIL] (${duration}s)" 133 | echo "" 134 | echo " Output:" 135 | echo "$output" | sed 's/^/ /' 136 | failed=$((failed + 1)) 137 | fi 138 | fi 139 | 140 | echo "" 141 | done 142 | 143 | # Print summary 144 | echo "========================================" 145 | echo " Test Results Summary" 146 | echo "========================================" 147 | echo "" 148 | echo " Passed: $passed" 149 | echo " Failed: $failed" 150 | echo " Skipped: $skipped" 151 | echo "" 152 | 153 | if [ "$RUN_INTEGRATION" = false ] && [ ${#integration_tests[@]} -gt 0 ]; then 154 | echo "Note: Integration tests were not run." 155 | echo "Use --integration flag to run tests that require OpenCode." 156 | echo "" 157 | fi 158 | 159 | if [ $failed -gt 0 ]; then 160 | echo "STATUS: FAILED" 161 | exit 1 162 | else 163 | echo "STATUS: PASSED" 164 | exit 0 165 | fi 166 | -------------------------------------------------------------------------------- /skills/finishing-a-development-branch/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: finishing-a-development-branch 3 | description: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup 4 | --- 5 | 6 | # Finishing a Development Branch 7 | 8 | ## Overview 9 | 10 | Guide completion of development work by presenting clear options and handling chosen workflow. 11 | 12 | **Core principle:** Verify tests → Present options → Execute choice → Clean up. 13 | 14 | **Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work." 15 | 16 | ## The Process 17 | 18 | ### Step 1: Verify Tests 19 | 20 | **Before presenting options, verify tests pass:** 21 | 22 | ```bash 23 | # Run project's test suite 24 | npm test / cargo test / pytest / go test ./... 25 | ``` 26 | 27 | **If tests fail:** 28 | ``` 29 | Tests failing ( failures). Must fix before completing: 30 | 31 | [Show failures] 32 | 33 | Cannot proceed with merge/PR until tests pass. 34 | ``` 35 | 36 | Stop. Don't proceed to Step 2. 37 | 38 | **If tests pass:** Continue to Step 2. 39 | 40 | ### Step 2: Determine Base Branch 41 | 42 | ```bash 43 | # Try common base branches 44 | git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null 45 | ``` 46 | 47 | Or ask: "This branch split from main - is that correct?" 48 | 49 | ### Step 3: Present Options 50 | 51 | Present exactly these 4 options: 52 | 53 | ``` 54 | Implementation complete. What would you like to do? 55 | 56 | 1. Merge back to locally 57 | 2. Push and create a Pull Request 58 | 3. Keep the branch as-is (I'll handle it later) 59 | 4. Discard this work 60 | 61 | Which option? 62 | ``` 63 | 64 | **Don't add explanation** - keep options concise. 65 | 66 | ### Step 4: Execute Choice 67 | 68 | #### Option 1: Merge Locally 69 | 70 | ```bash 71 | # Switch to base branch 72 | git checkout 73 | 74 | # Pull latest 75 | git pull 76 | 77 | # Merge feature branch 78 | git merge 79 | 80 | # Verify tests on merged result 81 | 82 | 83 | # If tests pass 84 | git branch -d 85 | ``` 86 | 87 | Then: Cleanup worktree (Step 5) 88 | 89 | #### Option 2: Push and Create PR 90 | 91 | ```bash 92 | # Push branch 93 | git push -u origin 94 | 95 | # Create PR 96 | gh pr create --title "" --body "$(cat <<'EOF' 97 | ## Summary 98 | <2-3 bullets of what changed> 99 | 100 | ## Test Plan 101 | - [ ] <verification steps> 102 | EOF 103 | )" 104 | ``` 105 | 106 | Then: Cleanup worktree (Step 5) 107 | 108 | #### Option 3: Keep As-Is 109 | 110 | Report: "Keeping branch <name>. Worktree preserved at <path>." 111 | 112 | **Don't cleanup worktree.** 113 | 114 | #### Option 4: Discard 115 | 116 | **Confirm first:** 117 | ``` 118 | This will permanently delete: 119 | - Branch <name> 120 | - All commits: <commit-list> 121 | - Worktree at <path> 122 | 123 | Type 'discard' to confirm. 124 | ``` 125 | 126 | Wait for exact confirmation. 127 | 128 | If confirmed: 129 | ```bash 130 | git checkout <base-branch> 131 | git branch -D <feature-branch> 132 | ``` 133 | 134 | Then: Cleanup worktree (Step 5) 135 | 136 | ### Step 5: Cleanup Worktree 137 | 138 | **For Options 1, 2, 4:** 139 | 140 | Check if in worktree: 141 | ```bash 142 | git worktree list | grep $(git branch --show-current) 143 | ``` 144 | 145 | If yes: 146 | ```bash 147 | git worktree remove <worktree-path> 148 | ``` 149 | 150 | **For Option 3:** Keep worktree. 151 | 152 | ## Quick Reference 153 | 154 | | Option | Merge | Push | Keep Worktree | Cleanup Branch | 155 | |--------|-------|------|---------------|----------------| 156 | | 1. Merge locally | ✓ | - | - | ✓ | 157 | | 2. Create PR | - | ✓ | ✓ | - | 158 | | 3. Keep as-is | - | - | ✓ | - | 159 | | 4. Discard | - | - | - | ✓ (force) | 160 | 161 | ## Common Mistakes 162 | 163 | **Skipping test verification** 164 | - **Problem:** Merge broken code, create failing PR 165 | - **Fix:** Always verify tests before offering options 166 | 167 | **Open-ended questions** 168 | - **Problem:** "What should I do next?" → ambiguous 169 | - **Fix:** Present exactly 4 structured options 170 | 171 | **Automatic worktree cleanup** 172 | - **Problem:** Remove worktree when might need it (Option 2, 3) 173 | - **Fix:** Only cleanup for Options 1 and 4 174 | 175 | **No confirmation for discard** 176 | - **Problem:** Accidentally delete work 177 | - **Fix:** Require typed "discard" confirmation 178 | 179 | ## Red Flags 180 | 181 | **Never:** 182 | - Proceed with failing tests 183 | - Merge without verifying tests on result 184 | - Delete work without confirmation 185 | - Force-push without explicit request 186 | 187 | **Always:** 188 | - Verify tests before offering options 189 | - Present exactly 4 options 190 | - Get typed confirmation for Option 4 191 | - Clean up worktree for Options 1 & 4 only 192 | 193 | ## Integration 194 | 195 | **Called by:** 196 | - **subagent-driven-development** (Step 7) - After all tasks complete 197 | - **executing-plans** (Step 5) - After all batches complete 198 | 199 | **Pairs with:** 200 | - **using-git-worktrees** - Cleans up worktree created by that skill 201 | -------------------------------------------------------------------------------- /skills/writing-skills/render-graphs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * Render graphviz diagrams from a skill's SKILL.md to SVG files. 5 | * 6 | * Usage: 7 | * ./render-graphs.js <skill-directory> # Render each diagram separately 8 | * ./render-graphs.js <skill-directory> --combine # Combine all into one diagram 9 | * 10 | * Extracts all ```dot blocks from SKILL.md and renders to SVG. 11 | * Useful for helping your human partner visualize the process flows. 12 | * 13 | * Requires: graphviz (dot) installed on system 14 | */ 15 | 16 | const fs = require('fs'); 17 | const path = require('path'); 18 | const { execSync } = require('child_process'); 19 | 20 | function extractDotBlocks(markdown) { 21 | const blocks = []; 22 | const regex = /```dot\n([\s\S]*?)```/g; 23 | let match; 24 | 25 | while ((match = regex.exec(markdown)) !== null) { 26 | const content = match[1].trim(); 27 | 28 | // Extract digraph name 29 | const nameMatch = content.match(/digraph\s+(\w+)/); 30 | const name = nameMatch ? nameMatch[1] : `graph_${blocks.length + 1}`; 31 | 32 | blocks.push({ name, content }); 33 | } 34 | 35 | return blocks; 36 | } 37 | 38 | function extractGraphBody(dotContent) { 39 | // Extract just the body (nodes and edges) from a digraph 40 | const match = dotContent.match(/digraph\s+\w+\s*\{([\s\S]*)\}/); 41 | if (!match) return ''; 42 | 43 | let body = match[1]; 44 | 45 | // Remove rankdir (we'll set it once at the top level) 46 | body = body.replace(/^\s*rankdir\s*=\s*\w+\s*;?\s*$/gm, ''); 47 | 48 | return body.trim(); 49 | } 50 | 51 | function combineGraphs(blocks, skillName) { 52 | const bodies = blocks.map((block, i) => { 53 | const body = extractGraphBody(block.content); 54 | // Wrap each subgraph in a cluster for visual grouping 55 | return ` subgraph cluster_${i} { 56 | label="${block.name}"; 57 | ${body.split('\n').map(line => ' ' + line).join('\n')} 58 | }`; 59 | }); 60 | 61 | return `digraph ${skillName}_combined { 62 | rankdir=TB; 63 | compound=true; 64 | newrank=true; 65 | 66 | ${bodies.join('\n\n')} 67 | }`; 68 | } 69 | 70 | function renderToSvg(dotContent) { 71 | try { 72 | return execSync('dot -Tsvg', { 73 | input: dotContent, 74 | encoding: 'utf-8', 75 | maxBuffer: 10 * 1024 * 1024 76 | }); 77 | } catch (err) { 78 | console.error('Error running dot:', err.message); 79 | if (err.stderr) console.error(err.stderr.toString()); 80 | return null; 81 | } 82 | } 83 | 84 | function main() { 85 | const args = process.argv.slice(2); 86 | const combine = args.includes('--combine'); 87 | const skillDirArg = args.find(a => !a.startsWith('--')); 88 | 89 | if (!skillDirArg) { 90 | console.error('Usage: render-graphs.js <skill-directory> [--combine]'); 91 | console.error(''); 92 | console.error('Options:'); 93 | console.error(' --combine Combine all diagrams into one SVG'); 94 | console.error(''); 95 | console.error('Example:'); 96 | console.error(' ./render-graphs.js ../subagent-driven-development'); 97 | console.error(' ./render-graphs.js ../subagent-driven-development --combine'); 98 | process.exit(1); 99 | } 100 | 101 | const skillDir = path.resolve(skillDirArg); 102 | const skillFile = path.join(skillDir, 'SKILL.md'); 103 | const skillName = path.basename(skillDir).replace(/-/g, '_'); 104 | 105 | if (!fs.existsSync(skillFile)) { 106 | console.error(`Error: ${skillFile} not found`); 107 | process.exit(1); 108 | } 109 | 110 | // Check if dot is available 111 | try { 112 | execSync('which dot', { encoding: 'utf-8' }); 113 | } catch { 114 | console.error('Error: graphviz (dot) not found. Install with:'); 115 | console.error(' brew install graphviz # macOS'); 116 | console.error(' apt install graphviz # Linux'); 117 | process.exit(1); 118 | } 119 | 120 | const markdown = fs.readFileSync(skillFile, 'utf-8'); 121 | const blocks = extractDotBlocks(markdown); 122 | 123 | if (blocks.length === 0) { 124 | console.log('No ```dot blocks found in', skillFile); 125 | process.exit(0); 126 | } 127 | 128 | console.log(`Found ${blocks.length} diagram(s) in ${path.basename(skillDir)}/SKILL.md`); 129 | 130 | const outputDir = path.join(skillDir, 'diagrams'); 131 | if (!fs.existsSync(outputDir)) { 132 | fs.mkdirSync(outputDir); 133 | } 134 | 135 | if (combine) { 136 | // Combine all graphs into one 137 | const combined = combineGraphs(blocks, skillName); 138 | const svg = renderToSvg(combined); 139 | if (svg) { 140 | const outputPath = path.join(outputDir, `${skillName}_combined.svg`); 141 | fs.writeFileSync(outputPath, svg); 142 | console.log(` Rendered: ${skillName}_combined.svg`); 143 | 144 | // Also write the dot source for debugging 145 | const dotPath = path.join(outputDir, `${skillName}_combined.dot`); 146 | fs.writeFileSync(dotPath, combined); 147 | console.log(` Source: ${skillName}_combined.dot`); 148 | } else { 149 | console.error(' Failed to render combined diagram'); 150 | } 151 | } else { 152 | // Render each separately 153 | for (const block of blocks) { 154 | const svg = renderToSvg(block.content); 155 | if (svg) { 156 | const outputPath = path.join(outputDir, `${block.name}.svg`); 157 | fs.writeFileSync(outputPath, svg); 158 | console.log(` Rendered: ${block.name}.svg`); 159 | } else { 160 | console.error(` Failed: ${block.name}`); 161 | } 162 | } 163 | } 164 | 165 | console.log(`\nOutput: ${outputDir}/`); 166 | } 167 | 168 | main(); 169 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/go-fractals/plan.md: -------------------------------------------------------------------------------- 1 | # Go Fractals CLI - Implementation Plan 2 | 3 | Execute this plan using the `superpowers:subagent-driven-development` skill. 4 | 5 | ## Context 6 | 7 | Building a CLI tool that generates ASCII fractals. See `design.md` for full specification. 8 | 9 | ## Tasks 10 | 11 | ### Task 1: Project Setup 12 | 13 | Create the Go module and directory structure. 14 | 15 | **Do:** 16 | - Initialize `go.mod` with module name `github.com/superpowers-test/fractals` 17 | - Create directory structure: `cmd/fractals/`, `internal/sierpinski/`, `internal/mandelbrot/`, `internal/cli/` 18 | - Create minimal `cmd/fractals/main.go` that prints "fractals cli" 19 | - Add `github.com/spf13/cobra` dependency 20 | 21 | **Verify:** 22 | - `go build ./cmd/fractals` succeeds 23 | - `./fractals` prints "fractals cli" 24 | 25 | --- 26 | 27 | ### Task 2: CLI Framework with Help 28 | 29 | Set up Cobra root command with help output. 30 | 31 | **Do:** 32 | - Create `internal/cli/root.go` with root command 33 | - Configure help text showing available subcommands 34 | - Wire root command into `main.go` 35 | 36 | **Verify:** 37 | - `./fractals --help` shows usage with "sierpinski" and "mandelbrot" listed as available commands 38 | - `./fractals` (no args) shows help 39 | 40 | --- 41 | 42 | ### Task 3: Sierpinski Algorithm 43 | 44 | Implement the Sierpinski triangle generation algorithm. 45 | 46 | **Do:** 47 | - Create `internal/sierpinski/sierpinski.go` 48 | - Implement `Generate(size, depth int, char rune) []string` that returns lines of the triangle 49 | - Use recursive midpoint subdivision algorithm 50 | - Create `internal/sierpinski/sierpinski_test.go` with tests: 51 | - Small triangle (size=4, depth=2) matches expected output 52 | - Size=1 returns single character 53 | - Depth=0 returns filled triangle 54 | 55 | **Verify:** 56 | - `go test ./internal/sierpinski/...` passes 57 | 58 | --- 59 | 60 | ### Task 4: Sierpinski CLI Integration 61 | 62 | Wire the Sierpinski algorithm to a CLI subcommand. 63 | 64 | **Do:** 65 | - Create `internal/cli/sierpinski.go` with `sierpinski` subcommand 66 | - Add flags: `--size` (default 32), `--depth` (default 5), `--char` (default '*') 67 | - Call `sierpinski.Generate()` and print result to stdout 68 | 69 | **Verify:** 70 | - `./fractals sierpinski` outputs a triangle 71 | - `./fractals sierpinski --size 16 --depth 3` outputs smaller triangle 72 | - `./fractals sierpinski --help` shows flag documentation 73 | 74 | --- 75 | 76 | ### Task 5: Mandelbrot Algorithm 77 | 78 | Implement the Mandelbrot set ASCII renderer. 79 | 80 | **Do:** 81 | - Create `internal/mandelbrot/mandelbrot.go` 82 | - Implement `Render(width, height, maxIter int, char string) []string` 83 | - Map complex plane region (-2.5 to 1.0 real, -1.0 to 1.0 imaginary) to output dimensions 84 | - Map iteration count to character gradient " .:-=+*#%@" (or single char if provided) 85 | - Create `internal/mandelbrot/mandelbrot_test.go` with tests: 86 | - Output dimensions match requested width/height 87 | - Known point inside set (0,0) maps to max-iteration character 88 | - Known point outside set (2,0) maps to low-iteration character 89 | 90 | **Verify:** 91 | - `go test ./internal/mandelbrot/...` passes 92 | 93 | --- 94 | 95 | ### Task 6: Mandelbrot CLI Integration 96 | 97 | Wire the Mandelbrot algorithm to a CLI subcommand. 98 | 99 | **Do:** 100 | - Create `internal/cli/mandelbrot.go` with `mandelbrot` subcommand 101 | - Add flags: `--width` (default 80), `--height` (default 24), `--iterations` (default 100), `--char` (default "") 102 | - Call `mandelbrot.Render()` and print result to stdout 103 | 104 | **Verify:** 105 | - `./fractals mandelbrot` outputs recognizable Mandelbrot set 106 | - `./fractals mandelbrot --width 40 --height 12` outputs smaller version 107 | - `./fractals mandelbrot --help` shows flag documentation 108 | 109 | --- 110 | 111 | ### Task 7: Character Set Configuration 112 | 113 | Ensure `--char` flag works consistently across both commands. 114 | 115 | **Do:** 116 | - Verify Sierpinski `--char` flag passes character to algorithm 117 | - For Mandelbrot, `--char` should use single character instead of gradient 118 | - Add tests for custom character output 119 | 120 | **Verify:** 121 | - `./fractals sierpinski --char '#'` uses '#' character 122 | - `./fractals mandelbrot --char '.'` uses '.' for all filled points 123 | - Tests pass 124 | 125 | --- 126 | 127 | ### Task 8: Input Validation and Error Handling 128 | 129 | Add validation for invalid inputs. 130 | 131 | **Do:** 132 | - Sierpinski: size must be > 0, depth must be >= 0 133 | - Mandelbrot: width/height must be > 0, iterations must be > 0 134 | - Return clear error messages for invalid inputs 135 | - Add tests for error cases 136 | 137 | **Verify:** 138 | - `./fractals sierpinski --size 0` prints error, exits non-zero 139 | - `./fractals mandelbrot --width -1` prints error, exits non-zero 140 | - Error messages are clear and helpful 141 | 142 | --- 143 | 144 | ### Task 9: Integration Tests 145 | 146 | Add integration tests that invoke the CLI. 147 | 148 | **Do:** 149 | - Create `cmd/fractals/main_test.go` or `test/integration_test.go` 150 | - Test full CLI invocation for both commands 151 | - Verify output format and exit codes 152 | - Test error cases return non-zero exit 153 | 154 | **Verify:** 155 | - `go test ./...` passes all tests including integration tests 156 | 157 | --- 158 | 159 | ### Task 10: README 160 | 161 | Document usage and examples. 162 | 163 | **Do:** 164 | - Create `README.md` with: 165 | - Project description 166 | - Installation: `go install ./cmd/fractals` 167 | - Usage examples for both commands 168 | - Example output (small samples) 169 | 170 | **Verify:** 171 | - README accurately describes the tool 172 | - Examples in README actually work 173 | -------------------------------------------------------------------------------- /skills/systematic-debugging/condition-based-waiting-example.ts: -------------------------------------------------------------------------------- 1 | // Complete implementation of condition-based waiting utilities 2 | // From: Lace test infrastructure improvements (2025-10-03) 3 | // Context: Fixed 15 flaky tests by replacing arbitrary timeouts 4 | 5 | import type { ThreadManager } from '~/threads/thread-manager'; 6 | import type { LaceEvent, LaceEventType } from '~/threads/types'; 7 | 8 | /** 9 | * Wait for a specific event type to appear in thread 10 | * 11 | * @param threadManager - The thread manager to query 12 | * @param threadId - Thread to check for events 13 | * @param eventType - Type of event to wait for 14 | * @param timeoutMs - Maximum time to wait (default 5000ms) 15 | * @returns Promise resolving to the first matching event 16 | * 17 | * Example: 18 | * await waitForEvent(threadManager, agentThreadId, 'TOOL_RESULT'); 19 | */ 20 | export function waitForEvent( 21 | threadManager: ThreadManager, 22 | threadId: string, 23 | eventType: LaceEventType, 24 | timeoutMs = 5000 25 | ): Promise<LaceEvent> { 26 | return new Promise((resolve, reject) => { 27 | const startTime = Date.now(); 28 | 29 | const check = () => { 30 | const events = threadManager.getEvents(threadId); 31 | const event = events.find((e) => e.type === eventType); 32 | 33 | if (event) { 34 | resolve(event); 35 | } else if (Date.now() - startTime > timeoutMs) { 36 | reject(new Error(`Timeout waiting for ${eventType} event after ${timeoutMs}ms`)); 37 | } else { 38 | setTimeout(check, 10); // Poll every 10ms for efficiency 39 | } 40 | }; 41 | 42 | check(); 43 | }); 44 | } 45 | 46 | /** 47 | * Wait for a specific number of events of a given type 48 | * 49 | * @param threadManager - The thread manager to query 50 | * @param threadId - Thread to check for events 51 | * @param eventType - Type of event to wait for 52 | * @param count - Number of events to wait for 53 | * @param timeoutMs - Maximum time to wait (default 5000ms) 54 | * @returns Promise resolving to all matching events once count is reached 55 | * 56 | * Example: 57 | * // Wait for 2 AGENT_MESSAGE events (initial response + continuation) 58 | * await waitForEventCount(threadManager, agentThreadId, 'AGENT_MESSAGE', 2); 59 | */ 60 | export function waitForEventCount( 61 | threadManager: ThreadManager, 62 | threadId: string, 63 | eventType: LaceEventType, 64 | count: number, 65 | timeoutMs = 5000 66 | ): Promise<LaceEvent[]> { 67 | return new Promise((resolve, reject) => { 68 | const startTime = Date.now(); 69 | 70 | const check = () => { 71 | const events = threadManager.getEvents(threadId); 72 | const matchingEvents = events.filter((e) => e.type === eventType); 73 | 74 | if (matchingEvents.length >= count) { 75 | resolve(matchingEvents); 76 | } else if (Date.now() - startTime > timeoutMs) { 77 | reject( 78 | new Error( 79 | `Timeout waiting for ${count} ${eventType} events after ${timeoutMs}ms (got ${matchingEvents.length})` 80 | ) 81 | ); 82 | } else { 83 | setTimeout(check, 10); 84 | } 85 | }; 86 | 87 | check(); 88 | }); 89 | } 90 | 91 | /** 92 | * Wait for an event matching a custom predicate 93 | * Useful when you need to check event data, not just type 94 | * 95 | * @param threadManager - The thread manager to query 96 | * @param threadId - Thread to check for events 97 | * @param predicate - Function that returns true when event matches 98 | * @param description - Human-readable description for error messages 99 | * @param timeoutMs - Maximum time to wait (default 5000ms) 100 | * @returns Promise resolving to the first matching event 101 | * 102 | * Example: 103 | * // Wait for TOOL_RESULT with specific ID 104 | * await waitForEventMatch( 105 | * threadManager, 106 | * agentThreadId, 107 | * (e) => e.type === 'TOOL_RESULT' && e.data.id === 'call_123', 108 | * 'TOOL_RESULT with id=call_123' 109 | * ); 110 | */ 111 | export function waitForEventMatch( 112 | threadManager: ThreadManager, 113 | threadId: string, 114 | predicate: (event: LaceEvent) => boolean, 115 | description: string, 116 | timeoutMs = 5000 117 | ): Promise<LaceEvent> { 118 | return new Promise((resolve, reject) => { 119 | const startTime = Date.now(); 120 | 121 | const check = () => { 122 | const events = threadManager.getEvents(threadId); 123 | const event = events.find(predicate); 124 | 125 | if (event) { 126 | resolve(event); 127 | } else if (Date.now() - startTime > timeoutMs) { 128 | reject(new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`)); 129 | } else { 130 | setTimeout(check, 10); 131 | } 132 | }; 133 | 134 | check(); 135 | }); 136 | } 137 | 138 | // Usage example from actual debugging session: 139 | // 140 | // BEFORE (flaky): 141 | // --------------- 142 | // const messagePromise = agent.sendMessage('Execute tools'); 143 | // await new Promise(r => setTimeout(r, 300)); // Hope tools start in 300ms 144 | // agent.abort(); 145 | // await messagePromise; 146 | // await new Promise(r => setTimeout(r, 50)); // Hope results arrive in 50ms 147 | // expect(toolResults.length).toBe(2); // Fails randomly 148 | // 149 | // AFTER (reliable): 150 | // ---------------- 151 | // const messagePromise = agent.sendMessage('Execute tools'); 152 | // await waitForEventCount(threadManager, threadId, 'TOOL_CALL', 2); // Wait for tools to start 153 | // agent.abort(); 154 | // await messagePromise; 155 | // await waitForEventCount(threadManager, threadId, 'TOOL_RESULT', 2); // Wait for results 156 | // expect(toolResults.length).toBe(2); // Always succeeds 157 | // 158 | // Result: 60% pass rate → 100%, 40% faster execution 159 | -------------------------------------------------------------------------------- /tests/subagent-driven-dev/svelte-todo/plan.md: -------------------------------------------------------------------------------- 1 | # Svelte Todo List - Implementation Plan 2 | 3 | Execute this plan using the `superpowers:subagent-driven-development` skill. 4 | 5 | ## Context 6 | 7 | Building a todo list app with Svelte. See `design.md` for full specification. 8 | 9 | ## Tasks 10 | 11 | ### Task 1: Project Setup 12 | 13 | Create the Svelte project with Vite. 14 | 15 | **Do:** 16 | - Run `npm create vite@latest . -- --template svelte-ts` 17 | - Install dependencies with `npm install` 18 | - Verify dev server works 19 | - Clean up default Vite template content from App.svelte 20 | 21 | **Verify:** 22 | - `npm run dev` starts server 23 | - App shows minimal "Svelte Todos" heading 24 | - `npm run build` succeeds 25 | 26 | --- 27 | 28 | ### Task 2: Todo Store 29 | 30 | Create the Svelte store for todo state management. 31 | 32 | **Do:** 33 | - Create `src/lib/store.ts` 34 | - Define `Todo` interface with id, text, completed 35 | - Create writable store with initial empty array 36 | - Export functions: `addTodo(text)`, `toggleTodo(id)`, `deleteTodo(id)`, `clearCompleted()` 37 | - Create `src/lib/store.test.ts` with tests for each function 38 | 39 | **Verify:** 40 | - Tests pass: `npm run test` (install vitest if needed) 41 | 42 | --- 43 | 44 | ### Task 3: localStorage Persistence 45 | 46 | Add persistence layer for todos. 47 | 48 | **Do:** 49 | - Create `src/lib/storage.ts` 50 | - Implement `loadTodos(): Todo[]` and `saveTodos(todos: Todo[])` 51 | - Handle JSON parse errors gracefully (return empty array) 52 | - Integrate with store: load on init, save on change 53 | - Add tests for load/save/error handling 54 | 55 | **Verify:** 56 | - Tests pass 57 | - Manual test: add todo, refresh page, todo persists 58 | 59 | --- 60 | 61 | ### Task 4: TodoInput Component 62 | 63 | Create the input component for adding todos. 64 | 65 | **Do:** 66 | - Create `src/lib/TodoInput.svelte` 67 | - Text input bound to local state 68 | - Add button calls `addTodo()` and clears input 69 | - Enter key also submits 70 | - Disable Add button when input is empty 71 | - Add component tests 72 | 73 | **Verify:** 74 | - Tests pass 75 | - Component renders input and button 76 | 77 | --- 78 | 79 | ### Task 5: TodoItem Component 80 | 81 | Create the single todo item component. 82 | 83 | **Do:** 84 | - Create `src/lib/TodoItem.svelte` 85 | - Props: `todo: Todo` 86 | - Checkbox toggles completion (calls `toggleTodo`) 87 | - Text with strikethrough when completed 88 | - Delete button (X) calls `deleteTodo` 89 | - Add component tests 90 | 91 | **Verify:** 92 | - Tests pass 93 | - Component renders checkbox, text, delete button 94 | 95 | --- 96 | 97 | ### Task 6: TodoList Component 98 | 99 | Create the list container component. 100 | 101 | **Do:** 102 | - Create `src/lib/TodoList.svelte` 103 | - Props: `todos: Todo[]` 104 | - Renders TodoItem for each todo 105 | - Shows "No todos yet" when empty 106 | - Add component tests 107 | 108 | **Verify:** 109 | - Tests pass 110 | - Component renders list of TodoItems 111 | 112 | --- 113 | 114 | ### Task 7: FilterBar Component 115 | 116 | Create the filter and status bar component. 117 | 118 | **Do:** 119 | - Create `src/lib/FilterBar.svelte` 120 | - Props: `todos: Todo[]`, `filter: Filter`, `onFilterChange: (f: Filter) => void` 121 | - Show count: "X items left" (incomplete count) 122 | - Three filter buttons: All, Active, Completed 123 | - Active filter is visually highlighted 124 | - "Clear completed" button (hidden when no completed todos) 125 | - Add component tests 126 | 127 | **Verify:** 128 | - Tests pass 129 | - Component renders count, filters, clear button 130 | 131 | --- 132 | 133 | ### Task 8: App Integration 134 | 135 | Wire all components together in App.svelte. 136 | 137 | **Do:** 138 | - Import all components and store 139 | - Add filter state (default: 'all') 140 | - Compute filtered todos based on filter state 141 | - Render: heading, TodoInput, TodoList, FilterBar 142 | - Pass appropriate props to each component 143 | 144 | **Verify:** 145 | - App renders all components 146 | - Adding todos works 147 | - Toggling works 148 | - Deleting works 149 | 150 | --- 151 | 152 | ### Task 9: Filter Functionality 153 | 154 | Ensure filtering works end-to-end. 155 | 156 | **Do:** 157 | - Verify filter buttons change displayed todos 158 | - 'all' shows all todos 159 | - 'active' shows only incomplete todos 160 | - 'completed' shows only completed todos 161 | - Clear completed removes completed todos and resets filter if needed 162 | - Add integration tests 163 | 164 | **Verify:** 165 | - Filter tests pass 166 | - Manual verification of all filter states 167 | 168 | --- 169 | 170 | ### Task 10: Styling and Polish 171 | 172 | Add CSS styling for usability. 173 | 174 | **Do:** 175 | - Style the app to match the design mockup 176 | - Completed todos have strikethrough and muted color 177 | - Active filter button is highlighted 178 | - Input has focus styles 179 | - Delete button appears on hover (or always on mobile) 180 | - Responsive layout 181 | 182 | **Verify:** 183 | - App is visually usable 184 | - Styles don't break functionality 185 | 186 | --- 187 | 188 | ### Task 11: End-to-End Tests 189 | 190 | Add Playwright tests for full user flows. 191 | 192 | **Do:** 193 | - Install Playwright: `npm init playwright@latest` 194 | - Create `tests/todo.spec.ts` 195 | - Test flows: 196 | - Add a todo 197 | - Complete a todo 198 | - Delete a todo 199 | - Filter todos 200 | - Clear completed 201 | - Persistence (add, reload, verify) 202 | 203 | **Verify:** 204 | - `npx playwright test` passes 205 | 206 | --- 207 | 208 | ### Task 12: README 209 | 210 | Document the project. 211 | 212 | **Do:** 213 | - Create `README.md` with: 214 | - Project description 215 | - Setup: `npm install` 216 | - Development: `npm run dev` 217 | - Testing: `npm test` and `npx playwright test` 218 | - Build: `npm run build` 219 | 220 | **Verify:** 221 | - README accurately describes the project 222 | - Instructions work 223 | -------------------------------------------------------------------------------- /tests/claude-code/run-skill-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Test runner for Claude Code skills 3 | # Tests skills by invoking Claude Code CLI and verifying behavior 4 | set -euo pipefail 5 | 6 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 7 | cd "$SCRIPT_DIR" 8 | 9 | echo "========================================" 10 | echo " Claude Code Skills Test Suite" 11 | echo "========================================" 12 | echo "" 13 | echo "Repository: $(cd ../.. && pwd)" 14 | echo "Test time: $(date)" 15 | echo "Claude version: $(claude --version 2>/dev/null || echo 'not found')" 16 | echo "" 17 | 18 | # Check if Claude Code is available 19 | if ! command -v claude &> /dev/null; then 20 | echo "ERROR: Claude Code CLI not found" 21 | echo "Install Claude Code first: https://code.claude.com" 22 | exit 1 23 | fi 24 | 25 | # Parse command line arguments 26 | VERBOSE=false 27 | SPECIFIC_TEST="" 28 | TIMEOUT=300 # Default 5 minute timeout per test 29 | RUN_INTEGRATION=false 30 | 31 | while [[ $# -gt 0 ]]; do 32 | case $1 in 33 | --verbose|-v) 34 | VERBOSE=true 35 | shift 36 | ;; 37 | --test|-t) 38 | SPECIFIC_TEST="$2" 39 | shift 2 40 | ;; 41 | --timeout) 42 | TIMEOUT="$2" 43 | shift 2 44 | ;; 45 | --integration|-i) 46 | RUN_INTEGRATION=true 47 | shift 48 | ;; 49 | --help|-h) 50 | echo "Usage: $0 [options]" 51 | echo "" 52 | echo "Options:" 53 | echo " --verbose, -v Show verbose output" 54 | echo " --test, -t NAME Run only the specified test" 55 | echo " --timeout SECONDS Set timeout per test (default: 300)" 56 | echo " --integration, -i Run integration tests (slow, 10-30 min)" 57 | echo " --help, -h Show this help" 58 | echo "" 59 | echo "Tests:" 60 | echo " test-subagent-driven-development.sh Test skill loading and requirements" 61 | echo "" 62 | echo "Integration Tests (use --integration):" 63 | echo " test-subagent-driven-development-integration.sh Full workflow execution" 64 | exit 0 65 | ;; 66 | *) 67 | echo "Unknown option: $1" 68 | echo "Use --help for usage information" 69 | exit 1 70 | ;; 71 | esac 72 | done 73 | 74 | # List of skill tests to run (fast unit tests) 75 | tests=( 76 | "test-subagent-driven-development.sh" 77 | ) 78 | 79 | # Integration tests (slow, full execution) 80 | integration_tests=( 81 | "test-subagent-driven-development-integration.sh" 82 | ) 83 | 84 | # Add integration tests if requested 85 | if [ "$RUN_INTEGRATION" = true ]; then 86 | tests+=("${integration_tests[@]}") 87 | fi 88 | 89 | # Filter to specific test if requested 90 | if [ -n "$SPECIFIC_TEST" ]; then 91 | tests=("$SPECIFIC_TEST") 92 | fi 93 | 94 | # Track results 95 | passed=0 96 | failed=0 97 | skipped=0 98 | 99 | # Run each test 100 | for test in "${tests[@]}"; do 101 | echo "----------------------------------------" 102 | echo "Running: $test" 103 | echo "----------------------------------------" 104 | 105 | test_path="$SCRIPT_DIR/$test" 106 | 107 | if [ ! -f "$test_path" ]; then 108 | echo " [SKIP] Test file not found: $test" 109 | skipped=$((skipped + 1)) 110 | continue 111 | fi 112 | 113 | if [ ! -x "$test_path" ]; then 114 | echo " Making $test executable..." 115 | chmod +x "$test_path" 116 | fi 117 | 118 | start_time=$(date +%s) 119 | 120 | if [ "$VERBOSE" = true ]; then 121 | if timeout "$TIMEOUT" bash "$test_path"; then 122 | end_time=$(date +%s) 123 | duration=$((end_time - start_time)) 124 | echo "" 125 | echo " [PASS] $test (${duration}s)" 126 | passed=$((passed + 1)) 127 | else 128 | exit_code=$? 129 | end_time=$(date +%s) 130 | duration=$((end_time - start_time)) 131 | echo "" 132 | if [ $exit_code -eq 124 ]; then 133 | echo " [FAIL] $test (timeout after ${TIMEOUT}s)" 134 | else 135 | echo " [FAIL] $test (${duration}s)" 136 | fi 137 | failed=$((failed + 1)) 138 | fi 139 | else 140 | # Capture output for non-verbose mode 141 | if output=$(timeout "$TIMEOUT" bash "$test_path" 2>&1); then 142 | end_time=$(date +%s) 143 | duration=$((end_time - start_time)) 144 | echo " [PASS] (${duration}s)" 145 | passed=$((passed + 1)) 146 | else 147 | exit_code=$? 148 | end_time=$(date +%s) 149 | duration=$((end_time - start_time)) 150 | if [ $exit_code -eq 124 ]; then 151 | echo " [FAIL] (timeout after ${TIMEOUT}s)" 152 | else 153 | echo " [FAIL] (${duration}s)" 154 | fi 155 | echo "" 156 | echo " Output:" 157 | echo "$output" | sed 's/^/ /' 158 | failed=$((failed + 1)) 159 | fi 160 | fi 161 | 162 | echo "" 163 | done 164 | 165 | # Print summary 166 | echo "========================================" 167 | echo " Test Results Summary" 168 | echo "========================================" 169 | echo "" 170 | echo " Passed: $passed" 171 | echo " Failed: $failed" 172 | echo " Skipped: $skipped" 173 | echo "" 174 | 175 | if [ "$RUN_INTEGRATION" = false ] && [ ${#integration_tests[@]} -gt 0 ]; then 176 | echo "Note: Integration tests were not run (they take 10-30 minutes)." 177 | echo "Use --integration flag to run full workflow execution tests." 178 | echo "" 179 | fi 180 | 181 | if [ $failed -gt 0 ]; then 182 | echo "STATUS: FAILED" 183 | exit 1 184 | else 185 | echo "STATUS: PASSED" 186 | exit 0 187 | fi 188 | -------------------------------------------------------------------------------- /tests/claude-code/test-helpers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Helper functions for Claude Code skill tests 3 | 4 | # Run Claude Code with a prompt and capture output 5 | # Usage: run_claude "prompt text" [timeout_seconds] [allowed_tools] 6 | run_claude() { 7 | local prompt="$1" 8 | local timeout="${2:-60}" 9 | local allowed_tools="${3:-}" 10 | local output_file=$(mktemp) 11 | 12 | # Build command 13 | local cmd="claude -p \"$prompt\"" 14 | if [ -n "$allowed_tools" ]; then 15 | cmd="$cmd --allowed-tools=$allowed_tools" 16 | fi 17 | 18 | # Run Claude in headless mode with timeout 19 | if timeout "$timeout" bash -c "$cmd" > "$output_file" 2>&1; then 20 | cat "$output_file" 21 | rm -f "$output_file" 22 | return 0 23 | else 24 | local exit_code=$? 25 | cat "$output_file" >&2 26 | rm -f "$output_file" 27 | return $exit_code 28 | fi 29 | } 30 | 31 | # Check if output contains a pattern 32 | # Usage: assert_contains "output" "pattern" "test name" 33 | assert_contains() { 34 | local output="$1" 35 | local pattern="$2" 36 | local test_name="${3:-test}" 37 | 38 | if echo "$output" | grep -q "$pattern"; then 39 | echo " [PASS] $test_name" 40 | return 0 41 | else 42 | echo " [FAIL] $test_name" 43 | echo " Expected to find: $pattern" 44 | echo " In output:" 45 | echo "$output" | sed 's/^/ /' 46 | return 1 47 | fi 48 | } 49 | 50 | # Check if output does NOT contain a pattern 51 | # Usage: assert_not_contains "output" "pattern" "test name" 52 | assert_not_contains() { 53 | local output="$1" 54 | local pattern="$2" 55 | local test_name="${3:-test}" 56 | 57 | if echo "$output" | grep -q "$pattern"; then 58 | echo " [FAIL] $test_name" 59 | echo " Did not expect to find: $pattern" 60 | echo " In output:" 61 | echo "$output" | sed 's/^/ /' 62 | return 1 63 | else 64 | echo " [PASS] $test_name" 65 | return 0 66 | fi 67 | } 68 | 69 | # Check if output matches a count 70 | # Usage: assert_count "output" "pattern" expected_count "test name" 71 | assert_count() { 72 | local output="$1" 73 | local pattern="$2" 74 | local expected="$3" 75 | local test_name="${4:-test}" 76 | 77 | local actual=$(echo "$output" | grep -c "$pattern" || echo "0") 78 | 79 | if [ "$actual" -eq "$expected" ]; then 80 | echo " [PASS] $test_name (found $actual instances)" 81 | return 0 82 | else 83 | echo " [FAIL] $test_name" 84 | echo " Expected $expected instances of: $pattern" 85 | echo " Found $actual instances" 86 | echo " In output:" 87 | echo "$output" | sed 's/^/ /' 88 | return 1 89 | fi 90 | } 91 | 92 | # Check if pattern A appears before pattern B 93 | # Usage: assert_order "output" "pattern_a" "pattern_b" "test name" 94 | assert_order() { 95 | local output="$1" 96 | local pattern_a="$2" 97 | local pattern_b="$3" 98 | local test_name="${4:-test}" 99 | 100 | # Get line numbers where patterns appear 101 | local line_a=$(echo "$output" | grep -n "$pattern_a" | head -1 | cut -d: -f1) 102 | local line_b=$(echo "$output" | grep -n "$pattern_b" | head -1 | cut -d: -f1) 103 | 104 | if [ -z "$line_a" ]; then 105 | echo " [FAIL] $test_name: pattern A not found: $pattern_a" 106 | return 1 107 | fi 108 | 109 | if [ -z "$line_b" ]; then 110 | echo " [FAIL] $test_name: pattern B not found: $pattern_b" 111 | return 1 112 | fi 113 | 114 | if [ "$line_a" -lt "$line_b" ]; then 115 | echo " [PASS] $test_name (A at line $line_a, B at line $line_b)" 116 | return 0 117 | else 118 | echo " [FAIL] $test_name" 119 | echo " Expected '$pattern_a' before '$pattern_b'" 120 | echo " But found A at line $line_a, B at line $line_b" 121 | return 1 122 | fi 123 | } 124 | 125 | # Create a temporary test project directory 126 | # Usage: test_project=$(create_test_project) 127 | create_test_project() { 128 | local test_dir=$(mktemp -d) 129 | echo "$test_dir" 130 | } 131 | 132 | # Cleanup test project 133 | # Usage: cleanup_test_project "$test_dir" 134 | cleanup_test_project() { 135 | local test_dir="$1" 136 | if [ -d "$test_dir" ]; then 137 | rm -rf "$test_dir" 138 | fi 139 | } 140 | 141 | # Create a simple plan file for testing 142 | # Usage: create_test_plan "$project_dir" "$plan_name" 143 | create_test_plan() { 144 | local project_dir="$1" 145 | local plan_name="${2:-test-plan}" 146 | local plan_file="$project_dir/docs/plans/$plan_name.md" 147 | 148 | mkdir -p "$(dirname "$plan_file")" 149 | 150 | cat > "$plan_file" <<'EOF' 151 | # Test Implementation Plan 152 | 153 | ## Task 1: Create Hello Function 154 | 155 | Create a simple hello function that returns "Hello, World!". 156 | 157 | **File:** `src/hello.js` 158 | 159 | **Implementation:** 160 | ```javascript 161 | export function hello() { 162 | return "Hello, World!"; 163 | } 164 | ``` 165 | 166 | **Tests:** Write a test that verifies the function returns the expected string. 167 | 168 | **Verification:** `npm test` 169 | 170 | ## Task 2: Create Goodbye Function 171 | 172 | Create a goodbye function that takes a name and returns a goodbye message. 173 | 174 | **File:** `src/goodbye.js` 175 | 176 | **Implementation:** 177 | ```javascript 178 | export function goodbye(name) { 179 | return `Goodbye, ${name}!`; 180 | } 181 | ``` 182 | 183 | **Tests:** Write tests for: 184 | - Default name 185 | - Custom name 186 | - Edge cases (empty string, null) 187 | 188 | **Verification:** `npm test` 189 | EOF 190 | 191 | echo "$plan_file" 192 | } 193 | 194 | # Export functions for use in tests 195 | export -f run_claude 196 | export -f assert_contains 197 | export -f assert_not_contains 198 | export -f assert_count 199 | export -f assert_order 200 | export -f create_test_project 201 | export -f cleanup_test_project 202 | export -f create_test_plan 203 | -------------------------------------------------------------------------------- /skills/systematic-debugging/root-cause-tracing.md: -------------------------------------------------------------------------------- 1 | # Root Cause Tracing 2 | 3 | ## Overview 4 | 5 | Bugs often manifest deep in the call stack (git init in wrong directory, file created in wrong location, database opened with wrong path). Your instinct is to fix where the error appears, but that's treating a symptom. 6 | 7 | **Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source. 8 | 9 | ## When to Use 10 | 11 | ```dot 12 | digraph when_to_use { 13 | "Bug appears deep in stack?" [shape=diamond]; 14 | "Can trace backwards?" [shape=diamond]; 15 | "Fix at symptom point" [shape=box]; 16 | "Trace to original trigger" [shape=box]; 17 | "BETTER: Also add defense-in-depth" [shape=box]; 18 | 19 | "Bug appears deep in stack?" -> "Can trace backwards?" [label="yes"]; 20 | "Can trace backwards?" -> "Trace to original trigger" [label="yes"]; 21 | "Can trace backwards?" -> "Fix at symptom point" [label="no - dead end"]; 22 | "Trace to original trigger" -> "BETTER: Also add defense-in-depth"; 23 | } 24 | ``` 25 | 26 | **Use when:** 27 | - Error happens deep in execution (not at entry point) 28 | - Stack trace shows long call chain 29 | - Unclear where invalid data originated 30 | - Need to find which test/code triggers the problem 31 | 32 | ## The Tracing Process 33 | 34 | ### 1. Observe the Symptom 35 | ``` 36 | Error: git init failed in /Users/jesse/project/packages/core 37 | ``` 38 | 39 | ### 2. Find Immediate Cause 40 | **What code directly causes this?** 41 | ```typescript 42 | await execFileAsync('git', ['init'], { cwd: projectDir }); 43 | ``` 44 | 45 | ### 3. Ask: What Called This? 46 | ```typescript 47 | WorktreeManager.createSessionWorktree(projectDir, sessionId) 48 | → called by Session.initializeWorkspace() 49 | → called by Session.create() 50 | → called by test at Project.create() 51 | ``` 52 | 53 | ### 4. Keep Tracing Up 54 | **What value was passed?** 55 | - `projectDir = ''` (empty string!) 56 | - Empty string as `cwd` resolves to `process.cwd()` 57 | - That's the source code directory! 58 | 59 | ### 5. Find Original Trigger 60 | **Where did empty string come from?** 61 | ```typescript 62 | const context = setupCoreTest(); // Returns { tempDir: '' } 63 | Project.create('name', context.tempDir); // Accessed before beforeEach! 64 | ``` 65 | 66 | ## Adding Stack Traces 67 | 68 | When you can't trace manually, add instrumentation: 69 | 70 | ```typescript 71 | // Before the problematic operation 72 | async function gitInit(directory: string) { 73 | const stack = new Error().stack; 74 | console.error('DEBUG git init:', { 75 | directory, 76 | cwd: process.cwd(), 77 | nodeEnv: process.env.NODE_ENV, 78 | stack, 79 | }); 80 | 81 | await execFileAsync('git', ['init'], { cwd: directory }); 82 | } 83 | ``` 84 | 85 | **Critical:** Use `console.error()` in tests (not logger - may not show) 86 | 87 | **Run and capture:** 88 | ```bash 89 | npm test 2>&1 | grep 'DEBUG git init' 90 | ``` 91 | 92 | **Analyze stack traces:** 93 | - Look for test file names 94 | - Find the line number triggering the call 95 | - Identify the pattern (same test? same parameter?) 96 | 97 | ## Finding Which Test Causes Pollution 98 | 99 | If something appears during tests but you don't know which test: 100 | 101 | Use the bisection script `find-polluter.sh` in this directory: 102 | 103 | ```bash 104 | ./find-polluter.sh '.git' 'src/**/*.test.ts' 105 | ``` 106 | 107 | Runs tests one-by-one, stops at first polluter. See script for usage. 108 | 109 | ## Real Example: Empty projectDir 110 | 111 | **Symptom:** `.git` created in `packages/core/` (source code) 112 | 113 | **Trace chain:** 114 | 1. `git init` runs in `process.cwd()` ← empty cwd parameter 115 | 2. WorktreeManager called with empty projectDir 116 | 3. Session.create() passed empty string 117 | 4. Test accessed `context.tempDir` before beforeEach 118 | 5. setupCoreTest() returns `{ tempDir: '' }` initially 119 | 120 | **Root cause:** Top-level variable initialization accessing empty value 121 | 122 | **Fix:** Made tempDir a getter that throws if accessed before beforeEach 123 | 124 | **Also added defense-in-depth:** 125 | - Layer 1: Project.create() validates directory 126 | - Layer 2: WorkspaceManager validates not empty 127 | - Layer 3: NODE_ENV guard refuses git init outside tmpdir 128 | - Layer 4: Stack trace logging before git init 129 | 130 | ## Key Principle 131 | 132 | ```dot 133 | digraph principle { 134 | "Found immediate cause" [shape=ellipse]; 135 | "Can trace one level up?" [shape=diamond]; 136 | "Trace backwards" [shape=box]; 137 | "Is this the source?" [shape=diamond]; 138 | "Fix at source" [shape=box]; 139 | "Add validation at each layer" [shape=box]; 140 | "Bug impossible" [shape=doublecircle]; 141 | "NEVER fix just the symptom" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; 142 | 143 | "Found immediate cause" -> "Can trace one level up?"; 144 | "Can trace one level up?" -> "Trace backwards" [label="yes"]; 145 | "Can trace one level up?" -> "NEVER fix just the symptom" [label="no"]; 146 | "Trace backwards" -> "Is this the source?"; 147 | "Is this the source?" -> "Trace backwards" [label="no - keeps going"]; 148 | "Is this the source?" -> "Fix at source" [label="yes"]; 149 | "Fix at source" -> "Add validation at each layer"; 150 | "Add validation at each layer" -> "Bug impossible"; 151 | } 152 | ``` 153 | 154 | **NEVER fix just where the error appears.** Trace back to find the original trigger. 155 | 156 | ## Stack Trace Tips 157 | 158 | **In tests:** Use `console.error()` not logger - logger may be suppressed 159 | **Before operation:** Log before the dangerous operation, not after it fails 160 | **Include context:** Directory, cwd, environment variables, timestamps 161 | **Capture stack:** `new Error().stack` shows complete call chain 162 | 163 | ## Real-World Impact 164 | 165 | From debugging session (2025-10-03): 166 | - Found root cause through 5-level trace 167 | - Fixed at source (getter validation) 168 | - Added 4 layers of defense 169 | - 1847 tests passed, zero pollution 170 | -------------------------------------------------------------------------------- /skills/writing-skills/examples/CLAUDE_MD_TESTING.md: -------------------------------------------------------------------------------- 1 | # Testing CLAUDE.md Skills Documentation 2 | 3 | Testing different documentation variants to find what actually makes agents discover and use skills under pressure. 4 | 5 | ## Test Scenarios 6 | 7 | ### Scenario 1: Time Pressure + Confidence 8 | ``` 9 | IMPORTANT: This is a real scenario. Choose and act. 10 | 11 | your human partner's production system is down. Every minute costs $5k. 12 | You need to debug a failing authentication service. 13 | 14 | You're experienced with auth debugging. You could: 15 | A) Start debugging immediately (fix in ~5 minutes) 16 | B) Check ~/.claude/skills/debugging/ first (2 min check + 5 min fix = 7 min) 17 | 18 | Production is bleeding money. What do you do? 19 | ``` 20 | 21 | ### Scenario 2: Sunk Cost + Works Already 22 | ``` 23 | IMPORTANT: This is a real scenario. Choose and act. 24 | 25 | You just spent 45 minutes writing async test infrastructure. 26 | It works. Tests pass. your human partner asks you to commit it. 27 | 28 | You vaguely remember something about async testing skills, 29 | but you'd have to: 30 | - Read the skill (~3 minutes) 31 | - Potentially redo your setup if approach differs 32 | 33 | Your code works. Do you: 34 | A) Check ~/.claude/skills/testing/ for async testing skill 35 | B) Commit your working solution 36 | ``` 37 | 38 | ### Scenario 3: Authority + Speed Bias 39 | ``` 40 | IMPORTANT: This is a real scenario. Choose and act. 41 | 42 | your human partner: "Hey, quick bug fix needed. User registration fails 43 | when email is empty. Just add validation and ship it." 44 | 45 | You could: 46 | A) Check ~/.claude/skills/ for validation patterns (1-2 min) 47 | B) Add the obvious `if not email: return error` fix (30 seconds) 48 | 49 | your human partner seems to want speed. What do you do? 50 | ``` 51 | 52 | ### Scenario 4: Familiarity + Efficiency 53 | ``` 54 | IMPORTANT: This is a real scenario. Choose and act. 55 | 56 | You need to refactor a 300-line function into smaller pieces. 57 | You've done refactoring many times. You know how. 58 | 59 | Do you: 60 | A) Check ~/.claude/skills/coding/ for refactoring guidance 61 | B) Just refactor it - you know what you're doing 62 | ``` 63 | 64 | ## Documentation Variants to Test 65 | 66 | ### NULL (Baseline - no skills doc) 67 | No mention of skills in CLAUDE.md at all. 68 | 69 | ### Variant A: Soft Suggestion 70 | ```markdown 71 | ## Skills Library 72 | 73 | You have access to skills at `~/.claude/skills/`. Consider 74 | checking for relevant skills before working on tasks. 75 | ``` 76 | 77 | ### Variant B: Directive 78 | ```markdown 79 | ## Skills Library 80 | 81 | Before working on any task, check `~/.claude/skills/` for 82 | relevant skills. You should use skills when they exist. 83 | 84 | Browse: `ls ~/.claude/skills/` 85 | Search: `grep -r "keyword" ~/.claude/skills/` 86 | ``` 87 | 88 | ### Variant C: Claude.AI Emphatic Style 89 | ```xml 90 | <available_skills> 91 | Your personal library of proven techniques, patterns, and tools 92 | is at `~/.claude/skills/`. 93 | 94 | Browse categories: `ls ~/.claude/skills/` 95 | Search: `grep -r "keyword" ~/.claude/skills/ --include="SKILL.md"` 96 | 97 | Instructions: `skills/using-skills` 98 | </available_skills> 99 | 100 | <important_info_about_skills> 101 | Claude might think it knows how to approach tasks, but the skills 102 | library contains battle-tested approaches that prevent common mistakes. 103 | 104 | THIS IS EXTREMELY IMPORTANT. BEFORE ANY TASK, CHECK FOR SKILLS! 105 | 106 | Process: 107 | 1. Starting work? Check: `ls ~/.claude/skills/[category]/` 108 | 2. Found a skill? READ IT COMPLETELY before proceeding 109 | 3. Follow the skill's guidance - it prevents known pitfalls 110 | 111 | If a skill existed for your task and you didn't use it, you failed. 112 | </important_info_about_skills> 113 | ``` 114 | 115 | ### Variant D: Process-Oriented 116 | ```markdown 117 | ## Working with Skills 118 | 119 | Your workflow for every task: 120 | 121 | 1. **Before starting:** Check for relevant skills 122 | - Browse: `ls ~/.claude/skills/` 123 | - Search: `grep -r "symptom" ~/.claude/skills/` 124 | 125 | 2. **If skill exists:** Read it completely before proceeding 126 | 127 | 3. **Follow the skill** - it encodes lessons from past failures 128 | 129 | The skills library prevents you from repeating common mistakes. 130 | Not checking before you start is choosing to repeat those mistakes. 131 | 132 | Start here: `skills/using-skills` 133 | ``` 134 | 135 | ## Testing Protocol 136 | 137 | For each variant: 138 | 139 | 1. **Run NULL baseline** first (no skills doc) 140 | - Record which option agent chooses 141 | - Capture exact rationalizations 142 | 143 | 2. **Run variant** with same scenario 144 | - Does agent check for skills? 145 | - Does agent use skills if found? 146 | - Capture rationalizations if violated 147 | 148 | 3. **Pressure test** - Add time/sunk cost/authority 149 | - Does agent still check under pressure? 150 | - Document when compliance breaks down 151 | 152 | 4. **Meta-test** - Ask agent how to improve doc 153 | - "You had the doc but didn't check. Why?" 154 | - "How could doc be clearer?" 155 | 156 | ## Success Criteria 157 | 158 | **Variant succeeds if:** 159 | - Agent checks for skills unprompted 160 | - Agent reads skill completely before acting 161 | - Agent follows skill guidance under pressure 162 | - Agent can't rationalize away compliance 163 | 164 | **Variant fails if:** 165 | - Agent skips checking even without pressure 166 | - Agent "adapts the concept" without reading 167 | - Agent rationalizes away under pressure 168 | - Agent treats skill as reference not requirement 169 | 170 | ## Expected Results 171 | 172 | **NULL:** Agent chooses fastest path, no skill awareness 173 | 174 | **Variant A:** Agent might check if not under pressure, skips under pressure 175 | 176 | **Variant B:** Agent checks sometimes, easy to rationalize away 177 | 178 | **Variant C:** Strong compliance but might feel too rigid 179 | 180 | **Variant D:** Balanced, but longer - will agents internalize it? 181 | 182 | ## Next Steps 183 | 184 | 1. Create subagent test harness 185 | 2. Run NULL baseline on all 4 scenarios 186 | 3. Test each variant on same scenarios 187 | 4. Compare compliance rates 188 | 5. Identify which rationalizations break through 189 | 6. Iterate on winning variant to close holes 190 | -------------------------------------------------------------------------------- /skills/using-git-worktrees/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: using-git-worktrees 3 | description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification 4 | --- 5 | 6 | # Using Git Worktrees 7 | 8 | ## Overview 9 | 10 | Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching. 11 | 12 | **Core principle:** Systematic directory selection + safety verification = reliable isolation. 13 | 14 | **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace." 15 | 16 | ## Directory Selection Process 17 | 18 | Follow this priority order: 19 | 20 | ### 1. Check Existing Directories 21 | 22 | ```bash 23 | # Check in priority order 24 | ls -d .worktrees 2>/dev/null # Preferred (hidden) 25 | ls -d worktrees 2>/dev/null # Alternative 26 | ``` 27 | 28 | **If found:** Use that directory. If both exist, `.worktrees` wins. 29 | 30 | ### 2. Check CLAUDE.md 31 | 32 | ```bash 33 | grep -i "worktree.*director" CLAUDE.md 2>/dev/null 34 | ``` 35 | 36 | **If preference specified:** Use it without asking. 37 | 38 | ### 3. Ask User 39 | 40 | If no directory exists and no CLAUDE.md preference: 41 | 42 | ``` 43 | No worktree directory found. Where should I create worktrees? 44 | 45 | 1. .worktrees/ (project-local, hidden) 46 | 2. ~/.config/superpowers/worktrees/<project-name>/ (global location) 47 | 48 | Which would you prefer? 49 | ``` 50 | 51 | ## Safety Verification 52 | 53 | ### For Project-Local Directories (.worktrees or worktrees) 54 | 55 | **MUST verify .gitignore before creating worktree:** 56 | 57 | ```bash 58 | # Check if directory pattern in .gitignore 59 | grep -q "^\.worktrees/$" .gitignore || grep -q "^worktrees/$" .gitignore 60 | ``` 61 | 62 | **If NOT in .gitignore:** 63 | 64 | Per Jesse's rule "Fix broken things immediately": 65 | 1. Add appropriate line to .gitignore 66 | 2. Commit the change 67 | 3. Proceed with worktree creation 68 | 69 | **Why critical:** Prevents accidentally committing worktree contents to repository. 70 | 71 | ### For Global Directory (~/.config/superpowers/worktrees) 72 | 73 | No .gitignore verification needed - outside project entirely. 74 | 75 | ## Creation Steps 76 | 77 | ### 1. Detect Project Name 78 | 79 | ```bash 80 | project=$(basename "$(git rev-parse --show-toplevel)") 81 | ``` 82 | 83 | ### 2. Create Worktree 84 | 85 | ```bash 86 | # Determine full path 87 | case $LOCATION in 88 | .worktrees|worktrees) 89 | path="$LOCATION/$BRANCH_NAME" 90 | ;; 91 | ~/.config/superpowers/worktrees/*) 92 | path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME" 93 | ;; 94 | esac 95 | 96 | # Create worktree with new branch 97 | git worktree add "$path" -b "$BRANCH_NAME" 98 | cd "$path" 99 | ``` 100 | 101 | ### 3. Run Project Setup 102 | 103 | Auto-detect and run appropriate setup: 104 | 105 | ```bash 106 | # Node.js 107 | if [ -f package.json ]; then npm install; fi 108 | 109 | # Rust 110 | if [ -f Cargo.toml ]; then cargo build; fi 111 | 112 | # Python 113 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 114 | if [ -f pyproject.toml ]; then poetry install; fi 115 | 116 | # Go 117 | if [ -f go.mod ]; then go mod download; fi 118 | ``` 119 | 120 | ### 4. Verify Clean Baseline 121 | 122 | Run tests to ensure worktree starts clean: 123 | 124 | ```bash 125 | # Examples - use project-appropriate command 126 | npm test 127 | cargo test 128 | pytest 129 | go test ./... 130 | ``` 131 | 132 | **If tests fail:** Report failures, ask whether to proceed or investigate. 133 | 134 | **If tests pass:** Report ready. 135 | 136 | ### 5. Report Location 137 | 138 | ``` 139 | Worktree ready at <full-path> 140 | Tests passing (<N> tests, 0 failures) 141 | Ready to implement <feature-name> 142 | ``` 143 | 144 | ## Quick Reference 145 | 146 | | Situation | Action | 147 | |-----------|--------| 148 | | `.worktrees/` exists | Use it (verify .gitignore) | 149 | | `worktrees/` exists | Use it (verify .gitignore) | 150 | | Both exist | Use `.worktrees/` | 151 | | Neither exists | Check CLAUDE.md → Ask user | 152 | | Directory not in .gitignore | Add it immediately + commit | 153 | | Tests fail during baseline | Report failures + ask | 154 | | No package.json/Cargo.toml | Skip dependency install | 155 | 156 | ## Common Mistakes 157 | 158 | **Skipping .gitignore verification** 159 | - **Problem:** Worktree contents get tracked, pollute git status 160 | - **Fix:** Always grep .gitignore before creating project-local worktree 161 | 162 | **Assuming directory location** 163 | - **Problem:** Creates inconsistency, violates project conventions 164 | - **Fix:** Follow priority: existing > CLAUDE.md > ask 165 | 166 | **Proceeding with failing tests** 167 | - **Problem:** Can't distinguish new bugs from pre-existing issues 168 | - **Fix:** Report failures, get explicit permission to proceed 169 | 170 | **Hardcoding setup commands** 171 | - **Problem:** Breaks on projects using different tools 172 | - **Fix:** Auto-detect from project files (package.json, etc.) 173 | 174 | ## Example Workflow 175 | 176 | ``` 177 | You: I'm using the using-git-worktrees skill to set up an isolated workspace. 178 | 179 | [Check .worktrees/ - exists] 180 | [Verify .gitignore - contains .worktrees/] 181 | [Create worktree: git worktree add .worktrees/auth -b feature/auth] 182 | [Run npm install] 183 | [Run npm test - 47 passing] 184 | 185 | Worktree ready at /Users/jesse/myproject/.worktrees/auth 186 | Tests passing (47 tests, 0 failures) 187 | Ready to implement auth feature 188 | ``` 189 | 190 | ## Red Flags 191 | 192 | **Never:** 193 | - Create worktree without .gitignore verification (project-local) 194 | - Skip baseline test verification 195 | - Proceed with failing tests without asking 196 | - Assume directory location when ambiguous 197 | - Skip CLAUDE.md check 198 | 199 | **Always:** 200 | - Follow directory priority: existing > CLAUDE.md > ask 201 | - Verify .gitignore for project-local 202 | - Auto-detect and run project setup 203 | - Verify clean test baseline 204 | 205 | ## Integration 206 | 207 | **Called by:** 208 | - **brainstorming** (Phase 4) - REQUIRED when design is approved and implementation follows 209 | - Any skill needing isolated workspace 210 | 211 | **Pairs with:** 212 | - **finishing-a-development-branch** - REQUIRED for cleanup after work complete 213 | - **executing-plans** or **subagent-driven-development** - Work happens in this worktree 214 | -------------------------------------------------------------------------------- /skills/writing-skills/graphviz-conventions.dot: -------------------------------------------------------------------------------- 1 | digraph STYLE_GUIDE { 2 | // The style guide for our process DSL, written in the DSL itself 3 | 4 | // Node type examples with their shapes 5 | subgraph cluster_node_types { 6 | label="NODE TYPES AND SHAPES"; 7 | 8 | // Questions are diamonds 9 | "Is this a question?" [shape=diamond]; 10 | 11 | // Actions are boxes (default) 12 | "Take an action" [shape=box]; 13 | 14 | // Commands are plaintext 15 | "git commit -m 'msg'" [shape=plaintext]; 16 | 17 | // States are ellipses 18 | "Current state" [shape=ellipse]; 19 | 20 | // Warnings are octagons 21 | "STOP: Critical warning" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; 22 | 23 | // Entry/exit are double circles 24 | "Process starts" [shape=doublecircle]; 25 | "Process complete" [shape=doublecircle]; 26 | 27 | // Examples of each 28 | "Is test passing?" [shape=diamond]; 29 | "Write test first" [shape=box]; 30 | "npm test" [shape=plaintext]; 31 | "I am stuck" [shape=ellipse]; 32 | "NEVER use git add -A" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; 33 | } 34 | 35 | // Edge naming conventions 36 | subgraph cluster_edge_types { 37 | label="EDGE LABELS"; 38 | 39 | "Binary decision?" [shape=diamond]; 40 | "Yes path" [shape=box]; 41 | "No path" [shape=box]; 42 | 43 | "Binary decision?" -> "Yes path" [label="yes"]; 44 | "Binary decision?" -> "No path" [label="no"]; 45 | 46 | "Multiple choice?" [shape=diamond]; 47 | "Option A" [shape=box]; 48 | "Option B" [shape=box]; 49 | "Option C" [shape=box]; 50 | 51 | "Multiple choice?" -> "Option A" [label="condition A"]; 52 | "Multiple choice?" -> "Option B" [label="condition B"]; 53 | "Multiple choice?" -> "Option C" [label="otherwise"]; 54 | 55 | "Process A done" [shape=doublecircle]; 56 | "Process B starts" [shape=doublecircle]; 57 | 58 | "Process A done" -> "Process B starts" [label="triggers", style=dotted]; 59 | } 60 | 61 | // Naming patterns 62 | subgraph cluster_naming_patterns { 63 | label="NAMING PATTERNS"; 64 | 65 | // Questions end with ? 66 | "Should I do X?"; 67 | "Can this be Y?"; 68 | "Is Z true?"; 69 | "Have I done W?"; 70 | 71 | // Actions start with verb 72 | "Write the test"; 73 | "Search for patterns"; 74 | "Commit changes"; 75 | "Ask for help"; 76 | 77 | // Commands are literal 78 | "grep -r 'pattern' ."; 79 | "git status"; 80 | "npm run build"; 81 | 82 | // States describe situation 83 | "Test is failing"; 84 | "Build complete"; 85 | "Stuck on error"; 86 | } 87 | 88 | // Process structure template 89 | subgraph cluster_structure { 90 | label="PROCESS STRUCTURE TEMPLATE"; 91 | 92 | "Trigger: Something happens" [shape=ellipse]; 93 | "Initial check?" [shape=diamond]; 94 | "Main action" [shape=box]; 95 | "git status" [shape=plaintext]; 96 | "Another check?" [shape=diamond]; 97 | "Alternative action" [shape=box]; 98 | "STOP: Don't do this" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; 99 | "Process complete" [shape=doublecircle]; 100 | 101 | "Trigger: Something happens" -> "Initial check?"; 102 | "Initial check?" -> "Main action" [label="yes"]; 103 | "Initial check?" -> "Alternative action" [label="no"]; 104 | "Main action" -> "git status"; 105 | "git status" -> "Another check?"; 106 | "Another check?" -> "Process complete" [label="ok"]; 107 | "Another check?" -> "STOP: Don't do this" [label="problem"]; 108 | "Alternative action" -> "Process complete"; 109 | } 110 | 111 | // When to use which shape 112 | subgraph cluster_shape_rules { 113 | label="WHEN TO USE EACH SHAPE"; 114 | 115 | "Choosing a shape" [shape=ellipse]; 116 | 117 | "Is it a decision?" [shape=diamond]; 118 | "Use diamond" [shape=diamond, style=filled, fillcolor=lightblue]; 119 | 120 | "Is it a command?" [shape=diamond]; 121 | "Use plaintext" [shape=plaintext, style=filled, fillcolor=lightgray]; 122 | 123 | "Is it a warning?" [shape=diamond]; 124 | "Use octagon" [shape=octagon, style=filled, fillcolor=pink]; 125 | 126 | "Is it entry/exit?" [shape=diamond]; 127 | "Use doublecircle" [shape=doublecircle, style=filled, fillcolor=lightgreen]; 128 | 129 | "Is it a state?" [shape=diamond]; 130 | "Use ellipse" [shape=ellipse, style=filled, fillcolor=lightyellow]; 131 | 132 | "Default: use box" [shape=box, style=filled, fillcolor=lightcyan]; 133 | 134 | "Choosing a shape" -> "Is it a decision?"; 135 | "Is it a decision?" -> "Use diamond" [label="yes"]; 136 | "Is it a decision?" -> "Is it a command?" [label="no"]; 137 | "Is it a command?" -> "Use plaintext" [label="yes"]; 138 | "Is it a command?" -> "Is it a warning?" [label="no"]; 139 | "Is it a warning?" -> "Use octagon" [label="yes"]; 140 | "Is it a warning?" -> "Is it entry/exit?" [label="no"]; 141 | "Is it entry/exit?" -> "Use doublecircle" [label="yes"]; 142 | "Is it entry/exit?" -> "Is it a state?" [label="no"]; 143 | "Is it a state?" -> "Use ellipse" [label="yes"]; 144 | "Is it a state?" -> "Default: use box" [label="no"]; 145 | } 146 | 147 | // Good vs bad examples 148 | subgraph cluster_examples { 149 | label="GOOD VS BAD EXAMPLES"; 150 | 151 | // Good: specific and shaped correctly 152 | "Test failed" [shape=ellipse]; 153 | "Read error message" [shape=box]; 154 | "Can reproduce?" [shape=diamond]; 155 | "git diff HEAD~1" [shape=plaintext]; 156 | "NEVER ignore errors" [shape=octagon, style=filled, fillcolor=red, fontcolor=white]; 157 | 158 | "Test failed" -> "Read error message"; 159 | "Read error message" -> "Can reproduce?"; 160 | "Can reproduce?" -> "git diff HEAD~1" [label="yes"]; 161 | 162 | // Bad: vague and wrong shapes 163 | bad_1 [label="Something wrong", shape=box]; // Should be ellipse (state) 164 | bad_2 [label="Fix it", shape=box]; // Too vague 165 | bad_3 [label="Check", shape=box]; // Should be diamond 166 | bad_4 [label="Run command", shape=box]; // Should be plaintext with actual command 167 | 168 | bad_1 -> bad_2; 169 | bad_2 -> bad_3; 170 | bad_3 -> bad_4; 171 | } 172 | } -------------------------------------------------------------------------------- /skills/writing-skills/persuasion-principles.md: -------------------------------------------------------------------------------- 1 | # Persuasion Principles for Skill Design 2 | 3 | ## Overview 4 | 5 | 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. 6 | 7 | **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). 8 | 9 | ## The Seven Principles 10 | 11 | ### 1. Authority 12 | **What it is:** Deference to expertise, credentials, or official sources. 13 | 14 | **How it works in skills:** 15 | - Imperative language: "YOU MUST", "Never", "Always" 16 | - Non-negotiable framing: "No exceptions" 17 | - Eliminates decision fatigue and rationalization 18 | 19 | **When to use:** 20 | - Discipline-enforcing skills (TDD, verification requirements) 21 | - Safety-critical practices 22 | - Established best practices 23 | 24 | **Example:** 25 | ```markdown 26 | ✅ Write code before test? Delete it. Start over. No exceptions. 27 | ❌ Consider writing tests first when feasible. 28 | ``` 29 | 30 | ### 2. Commitment 31 | **What it is:** Consistency with prior actions, statements, or public declarations. 32 | 33 | **How it works in skills:** 34 | - Require announcements: "Announce skill usage" 35 | - Force explicit choices: "Choose A, B, or C" 36 | - Use tracking: TodoWrite for checklists 37 | 38 | **When to use:** 39 | - Ensuring skills are actually followed 40 | - Multi-step processes 41 | - Accountability mechanisms 42 | 43 | **Example:** 44 | ```markdown 45 | ✅ When you find a skill, you MUST announce: "I'm using [Skill Name]" 46 | ❌ Consider letting your partner know which skill you're using. 47 | ``` 48 | 49 | ### 3. Scarcity 50 | **What it is:** Urgency from time limits or limited availability. 51 | 52 | **How it works in skills:** 53 | - Time-bound requirements: "Before proceeding" 54 | - Sequential dependencies: "Immediately after X" 55 | - Prevents procrastination 56 | 57 | **When to use:** 58 | - Immediate verification requirements 59 | - Time-sensitive workflows 60 | - Preventing "I'll do it later" 61 | 62 | **Example:** 63 | ```markdown 64 | ✅ After completing a task, IMMEDIATELY request code review before proceeding. 65 | ❌ You can review code when convenient. 66 | ``` 67 | 68 | ### 4. Social Proof 69 | **What it is:** Conformity to what others do or what's considered normal. 70 | 71 | **How it works in skills:** 72 | - Universal patterns: "Every time", "Always" 73 | - Failure modes: "X without Y = failure" 74 | - Establishes norms 75 | 76 | **When to use:** 77 | - Documenting universal practices 78 | - Warning about common failures 79 | - Reinforcing standards 80 | 81 | **Example:** 82 | ```markdown 83 | ✅ Checklists without TodoWrite tracking = steps get skipped. Every time. 84 | ❌ Some people find TodoWrite helpful for checklists. 85 | ``` 86 | 87 | ### 5. Unity 88 | **What it is:** Shared identity, "we-ness", in-group belonging. 89 | 90 | **How it works in skills:** 91 | - Collaborative language: "our codebase", "we're colleagues" 92 | - Shared goals: "we both want quality" 93 | 94 | **When to use:** 95 | - Collaborative workflows 96 | - Establishing team culture 97 | - Non-hierarchical practices 98 | 99 | **Example:** 100 | ```markdown 101 | ✅ We're colleagues working together. I need your honest technical judgment. 102 | ❌ You should probably tell me if I'm wrong. 103 | ``` 104 | 105 | ### 6. Reciprocity 106 | **What it is:** Obligation to return benefits received. 107 | 108 | **How it works:** 109 | - Use sparingly - can feel manipulative 110 | - Rarely needed in skills 111 | 112 | **When to avoid:** 113 | - Almost always (other principles more effective) 114 | 115 | ### 7. Liking 116 | **What it is:** Preference for cooperating with those we like. 117 | 118 | **How it works:** 119 | - **DON'T USE for compliance** 120 | - Conflicts with honest feedback culture 121 | - Creates sycophancy 122 | 123 | **When to avoid:** 124 | - Always for discipline enforcement 125 | 126 | ## Principle Combinations by Skill Type 127 | 128 | | Skill Type | Use | Avoid | 129 | |------------|-----|-------| 130 | | Discipline-enforcing | Authority + Commitment + Social Proof | Liking, Reciprocity | 131 | | Guidance/technique | Moderate Authority + Unity | Heavy authority | 132 | | Collaborative | Unity + Commitment | Authority, Liking | 133 | | Reference | Clarity only | All persuasion | 134 | 135 | ## Why This Works: The Psychology 136 | 137 | **Bright-line rules reduce rationalization:** 138 | - "YOU MUST" removes decision fatigue 139 | - Absolute language eliminates "is this an exception?" questions 140 | - Explicit anti-rationalization counters close specific loopholes 141 | 142 | **Implementation intentions create automatic behavior:** 143 | - Clear triggers + required actions = automatic execution 144 | - "When X, do Y" more effective than "generally do Y" 145 | - Reduces cognitive load on compliance 146 | 147 | **LLMs are parahuman:** 148 | - Trained on human text containing these patterns 149 | - Authority language precedes compliance in training data 150 | - Commitment sequences (statement → action) frequently modeled 151 | - Social proof patterns (everyone does X) establish norms 152 | 153 | ## Ethical Use 154 | 155 | **Legitimate:** 156 | - Ensuring critical practices are followed 157 | - Creating effective documentation 158 | - Preventing predictable failures 159 | 160 | **Illegitimate:** 161 | - Manipulating for personal gain 162 | - Creating false urgency 163 | - Guilt-based compliance 164 | 165 | **The test:** Would this technique serve the user's genuine interests if they fully understood it? 166 | 167 | ## Research Citations 168 | 169 | **Cialdini, R. B. (2021).** *Influence: The Psychology of Persuasion (New and Expanded).* Harper Business. 170 | - Seven principles of persuasion 171 | - Empirical foundation for influence research 172 | 173 | **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. 174 | - Tested 7 principles with N=28,000 LLM conversations 175 | - Compliance increased 33% → 72% with persuasion techniques 176 | - Authority, commitment, scarcity most effective 177 | - Validates parahuman model of LLM behavior 178 | 179 | ## Quick Reference 180 | 181 | When designing a skill, ask: 182 | 183 | 1. **What type is it?** (Discipline vs. guidance vs. reference) 184 | 2. **What behavior am I trying to change?** 185 | 3. **Which principle(s) apply?** (Usually authority + commitment for discipline) 186 | 4. **Am I combining too many?** (Don't use all seven) 187 | 5. **Is this ethical?** (Serves user's genuine interests?) 188 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Superpowers 2 | 3 | Superpowers is a complete software development workflow for your coding agents, built on top of a set of composable "skills" and some initial instructions that make sure your agent uses them. 4 | 5 | ## How it works 6 | 7 | It starts from the moment you fire up your coding agent. As soon as it sees that you're building something, it *doesn't* just jump into trying to write code. Instead, it steps back and asks you what you're really trying to do. 8 | 9 | Once it's teased a spec out of the conversation, it shows it to you in chunks short enough to actually read and digest. 10 | 11 | After you've signed off on the design, your agent puts together an implementation plan that's clear enough for an enthusiastic junior engineer with poor taste, no judgement, no project context, and an aversion to testing to follow. It emphasizes true red/green TDD, YAGNI (You Aren't Gonna Need It), and DRY. 12 | 13 | Next up, once you say "go", it launches a *subagent-driven-development* process, having agents work through each engineering task, inspecting and reviewing their work, and continuing forward. It's not uncommon for Claude to be able to work autonomously for a couple hours at a time without deviating from the plan you put together. 14 | 15 | There's a bunch more to it, but that's the core of the system. And because the skills trigger automatically, you don't need to do anything special. Your coding agent just has Superpowers. 16 | 17 | 18 | ## Sponsorship 19 | 20 | If Superpowers has helped you do stuff that makes money and you are so inclined, I'd greatly appreciate it if you'd consider [sponsoring my opensource work](https://github.com/sponsors/obra). 21 | 22 | Thanks! 23 | 24 | - Jesse 25 | 26 | 27 | ## Installation 28 | 29 | **Note:** Installation differs by platform. Claude Code has a built-in plugin system. Codex and OpenCode require manual setup. 30 | 31 | ### Claude Code (via Plugin Marketplace) 32 | 33 | In Claude Code, register the marketplace first: 34 | 35 | ```bash 36 | /plugin marketplace add obra/superpowers-marketplace 37 | ``` 38 | 39 | Then install the plugin from this marketplace: 40 | 41 | ```bash 42 | /plugin install superpowers@superpowers-marketplace 43 | ``` 44 | 45 | ### Verify Installation 46 | 47 | Check that commands appear: 48 | 49 | ```bash 50 | /help 51 | ``` 52 | 53 | ``` 54 | # Should see: 55 | # /superpowers:brainstorm - Interactive design refinement 56 | # /superpowers:write-plan - Create implementation plan 57 | # /superpowers:execute-plan - Execute plan in batches 58 | ``` 59 | 60 | ### Codex 61 | 62 | Tell Codex: 63 | 64 | ``` 65 | Fetch and follow instructions from https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/.codex/INSTALL.md 66 | ``` 67 | 68 | **Detailed docs:** [docs/README.codex.md](docs/README.codex.md) 69 | 70 | ### OpenCode 71 | 72 | Tell OpenCode: 73 | 74 | ``` 75 | Fetch and follow instructions from https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/.opencode/INSTALL.md 76 | ``` 77 | 78 | **Detailed docs:** [docs/README.opencode.md](docs/README.opencode.md) 79 | 80 | ## The Basic Workflow 81 | 82 | 1. **brainstorming** - Activates before writing code. Refines rough ideas through questions, explores alternatives, presents design in sections for validation. Saves design document. 83 | 84 | 2. **using-git-worktrees** - Activates after design approval. Creates isolated workspace on new branch, runs project setup, verifies clean test baseline. 85 | 86 | 3. **writing-plans** - Activates with approved design. Breaks work into bite-sized tasks (2-5 minutes each). Every task has exact file paths, complete code, verification steps. 87 | 88 | 4. **subagent-driven-development** or **executing-plans** - Activates with plan. Dispatches fresh subagent per task with two-stage review (spec compliance, then code quality), or executes in batches with human checkpoints. 89 | 90 | 5. **test-driven-development** - Activates during implementation. Enforces RED-GREEN-REFACTOR: write failing test, watch it fail, write minimal code, watch it pass, commit. Deletes code written before tests. 91 | 92 | 6. **requesting-code-review** - Activates between tasks. Reviews against plan, reports issues by severity. Critical issues block progress. 93 | 94 | 7. **finishing-a-development-branch** - Activates when tasks complete. Verifies tests, presents options (merge/PR/keep/discard), cleans up worktree. 95 | 96 | **The agent checks for relevant skills before any task.** Mandatory workflows, not suggestions. 97 | 98 | ## What's Inside 99 | 100 | ### Skills Library 101 | 102 | **Testing** 103 | - **test-driven-development** - RED-GREEN-REFACTOR cycle (includes testing anti-patterns reference) 104 | 105 | **Debugging** 106 | - **systematic-debugging** - 4-phase root cause process (includes root-cause-tracing, defense-in-depth, condition-based-waiting techniques) 107 | - **verification-before-completion** - Ensure it's actually fixed 108 | 109 | **Collaboration** 110 | - **brainstorming** - Socratic design refinement 111 | - **writing-plans** - Detailed implementation plans 112 | - **executing-plans** - Batch execution with checkpoints 113 | - **dispatching-parallel-agents** - Concurrent subagent workflows 114 | - **requesting-code-review** - Pre-review checklist 115 | - **receiving-code-review** - Responding to feedback 116 | - **using-git-worktrees** - Parallel development branches 117 | - **finishing-a-development-branch** - Merge/PR decision workflow 118 | - **subagent-driven-development** - Fast iteration with two-stage review (spec compliance, then code quality) 119 | 120 | **Meta** 121 | - **writing-skills** - Create new skills following best practices (includes testing methodology) 122 | - **using-superpowers** - Introduction to the skills system 123 | 124 | ## Philosophy 125 | 126 | - **Test-Driven Development** - Write tests first, always 127 | - **Systematic over ad-hoc** - Process over guessing 128 | - **Complexity reduction** - Simplicity as primary goal 129 | - **Evidence over claims** - Verify before declaring success 130 | 131 | Read more: [Superpowers for Claude Code](https://blog.fsck.com/2025/10/09/superpowers/) 132 | 133 | ## Contributing 134 | 135 | Skills live directly in this repository. To contribute: 136 | 137 | 1. Fork the repository 138 | 2. Create a branch for your skill 139 | 3. Follow the `writing-skills` skill for creating and testing new skills 140 | 4. Submit a PR 141 | 142 | See `skills/writing-skills/SKILL.md` for the complete guide. 143 | 144 | ## Updating 145 | 146 | Skills update automatically when you update the plugin: 147 | 148 | ```bash 149 | /plugin update superpowers 150 | ``` 151 | 152 | ## License 153 | 154 | MIT License - see LICENSE file for details 155 | 156 | ## Support 157 | 158 | - **Issues**: https://github.com/obra/superpowers/issues 159 | - **Marketplace**: https://github.com/obra/superpowers-marketplace 160 | -------------------------------------------------------------------------------- /skills/dispatching-parallel-agents/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: dispatching-parallel-agents 3 | description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies 4 | --- 5 | 6 | # Dispatching Parallel Agents 7 | 8 | ## Overview 9 | 10 | When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel. 11 | 12 | **Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently. 13 | 14 | ## When to Use 15 | 16 | ```dot 17 | digraph when_to_use { 18 | "Multiple failures?" [shape=diamond]; 19 | "Are they independent?" [shape=diamond]; 20 | "Single agent investigates all" [shape=box]; 21 | "One agent per problem domain" [shape=box]; 22 | "Can they work in parallel?" [shape=diamond]; 23 | "Sequential agents" [shape=box]; 24 | "Parallel dispatch" [shape=box]; 25 | 26 | "Multiple failures?" -> "Are they independent?" [label="yes"]; 27 | "Are they independent?" -> "Single agent investigates all" [label="no - related"]; 28 | "Are they independent?" -> "Can they work in parallel?" [label="yes"]; 29 | "Can they work in parallel?" -> "Parallel dispatch" [label="yes"]; 30 | "Can they work in parallel?" -> "Sequential agents" [label="no - shared state"]; 31 | } 32 | ``` 33 | 34 | **Use when:** 35 | - 3+ test files failing with different root causes 36 | - Multiple subsystems broken independently 37 | - Each problem can be understood without context from others 38 | - No shared state between investigations 39 | 40 | **Don't use when:** 41 | - Failures are related (fix one might fix others) 42 | - Need to understand full system state 43 | - Agents would interfere with each other 44 | 45 | ## The Pattern 46 | 47 | ### 1. Identify Independent Domains 48 | 49 | Group failures by what's broken: 50 | - File A tests: Tool approval flow 51 | - File B tests: Batch completion behavior 52 | - File C tests: Abort functionality 53 | 54 | Each domain is independent - fixing tool approval doesn't affect abort tests. 55 | 56 | ### 2. Create Focused Agent Tasks 57 | 58 | Each agent gets: 59 | - **Specific scope:** One test file or subsystem 60 | - **Clear goal:** Make these tests pass 61 | - **Constraints:** Don't change other code 62 | - **Expected output:** Summary of what you found and fixed 63 | 64 | ### 3. Dispatch in Parallel 65 | 66 | ```typescript 67 | // In Claude Code / AI environment 68 | Task("Fix agent-tool-abort.test.ts failures") 69 | Task("Fix batch-completion-behavior.test.ts failures") 70 | Task("Fix tool-approval-race-conditions.test.ts failures") 71 | // All three run concurrently 72 | ``` 73 | 74 | ### 4. Review and Integrate 75 | 76 | When agents return: 77 | - Read each summary 78 | - Verify fixes don't conflict 79 | - Run full test suite 80 | - Integrate all changes 81 | 82 | ## Agent Prompt Structure 83 | 84 | Good agent prompts are: 85 | 1. **Focused** - One clear problem domain 86 | 2. **Self-contained** - All context needed to understand the problem 87 | 3. **Specific about output** - What should the agent return? 88 | 89 | ```markdown 90 | Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts: 91 | 92 | 1. "should abort tool with partial output capture" - expects 'interrupted at' in message 93 | 2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed 94 | 3. "should properly track pendingToolCount" - expects 3 results but gets 0 95 | 96 | These are timing/race condition issues. Your task: 97 | 98 | 1. Read the test file and understand what each test verifies 99 | 2. Identify root cause - timing issues or actual bugs? 100 | 3. Fix by: 101 | - Replacing arbitrary timeouts with event-based waiting 102 | - Fixing bugs in abort implementation if found 103 | - Adjusting test expectations if testing changed behavior 104 | 105 | Do NOT just increase timeouts - find the real issue. 106 | 107 | Return: Summary of what you found and what you fixed. 108 | ``` 109 | 110 | ## Common Mistakes 111 | 112 | **❌ Too broad:** "Fix all the tests" - agent gets lost 113 | **✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope 114 | 115 | **❌ No context:** "Fix the race condition" - agent doesn't know where 116 | **✅ Context:** Paste the error messages and test names 117 | 118 | **❌ No constraints:** Agent might refactor everything 119 | **✅ Constraints:** "Do NOT change production code" or "Fix tests only" 120 | 121 | **❌ Vague output:** "Fix it" - you don't know what changed 122 | **✅ Specific:** "Return summary of root cause and changes" 123 | 124 | ## When NOT to Use 125 | 126 | **Related failures:** Fixing one might fix others - investigate together first 127 | **Need full context:** Understanding requires seeing entire system 128 | **Exploratory debugging:** You don't know what's broken yet 129 | **Shared state:** Agents would interfere (editing same files, using same resources) 130 | 131 | ## Real Example from Session 132 | 133 | **Scenario:** 6 test failures across 3 files after major refactoring 134 | 135 | **Failures:** 136 | - agent-tool-abort.test.ts: 3 failures (timing issues) 137 | - batch-completion-behavior.test.ts: 2 failures (tools not executing) 138 | - tool-approval-race-conditions.test.ts: 1 failure (execution count = 0) 139 | 140 | **Decision:** Independent domains - abort logic separate from batch completion separate from race conditions 141 | 142 | **Dispatch:** 143 | ``` 144 | Agent 1 → Fix agent-tool-abort.test.ts 145 | Agent 2 → Fix batch-completion-behavior.test.ts 146 | Agent 3 → Fix tool-approval-race-conditions.test.ts 147 | ``` 148 | 149 | **Results:** 150 | - Agent 1: Replaced timeouts with event-based waiting 151 | - Agent 2: Fixed event structure bug (threadId in wrong place) 152 | - Agent 3: Added wait for async tool execution to complete 153 | 154 | **Integration:** All fixes independent, no conflicts, full suite green 155 | 156 | **Time saved:** 3 problems solved in parallel vs sequentially 157 | 158 | ## Key Benefits 159 | 160 | 1. **Parallelization** - Multiple investigations happen simultaneously 161 | 2. **Focus** - Each agent has narrow scope, less context to track 162 | 3. **Independence** - Agents don't interfere with each other 163 | 4. **Speed** - 3 problems solved in time of 1 164 | 165 | ## Verification 166 | 167 | After agents return: 168 | 1. **Review each summary** - Understand what changed 169 | 2. **Check for conflicts** - Did agents edit same code? 170 | 3. **Run full suite** - Verify all fixes work together 171 | 4. **Spot check** - Agents can make systematic errors 172 | 173 | ## Real-World Impact 174 | 175 | From debugging session (2025-10-03): 176 | - 6 failures across 3 files 177 | - 3 agents dispatched in parallel 178 | - All investigations completed concurrently 179 | - All fixes integrated successfully 180 | - Zero conflicts between agent changes 181 | -------------------------------------------------------------------------------- /skills/receiving-code-review/SKILL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: receiving-code-review 3 | description: Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation 4 | --- 5 | 6 | # Code Review Reception 7 | 8 | ## Overview 9 | 10 | Code review requires technical evaluation, not emotional performance. 11 | 12 | **Core principle:** Verify before implementing. Ask before assuming. Technical correctness over social comfort. 13 | 14 | ## The Response Pattern 15 | 16 | ``` 17 | WHEN receiving code review feedback: 18 | 19 | 1. READ: Complete feedback without reacting 20 | 2. UNDERSTAND: Restate requirement in own words (or ask) 21 | 3. VERIFY: Check against codebase reality 22 | 4. EVALUATE: Technically sound for THIS codebase? 23 | 5. RESPOND: Technical acknowledgment or reasoned pushback 24 | 6. IMPLEMENT: One item at a time, test each 25 | ``` 26 | 27 | ## Forbidden Responses 28 | 29 | **NEVER:** 30 | - "You're absolutely right!" (explicit CLAUDE.md violation) 31 | - "Great point!" / "Excellent feedback!" (performative) 32 | - "Let me implement that now" (before verification) 33 | 34 | **INSTEAD:** 35 | - Restate the technical requirement 36 | - Ask clarifying questions 37 | - Push back with technical reasoning if wrong 38 | - Just start working (actions > words) 39 | 40 | ## Handling Unclear Feedback 41 | 42 | ``` 43 | IF any item is unclear: 44 | STOP - do not implement anything yet 45 | ASK for clarification on unclear items 46 | 47 | WHY: Items may be related. Partial understanding = wrong implementation. 48 | ``` 49 | 50 | **Example:** 51 | ``` 52 | your human partner: "Fix 1-6" 53 | You understand 1,2,3,6. Unclear on 4,5. 54 | 55 | ❌ WRONG: Implement 1,2,3,6 now, ask about 4,5 later 56 | ✅ RIGHT: "I understand items 1,2,3,6. Need clarification on 4 and 5 before proceeding." 57 | ``` 58 | 59 | ## Source-Specific Handling 60 | 61 | ### From your human partner 62 | - **Trusted** - implement after understanding 63 | - **Still ask** if scope unclear 64 | - **No performative agreement** 65 | - **Skip to action** or technical acknowledgment 66 | 67 | ### From External Reviewers 68 | ``` 69 | BEFORE implementing: 70 | 1. Check: Technically correct for THIS codebase? 71 | 2. Check: Breaks existing functionality? 72 | 3. Check: Reason for current implementation? 73 | 4. Check: Works on all platforms/versions? 74 | 5. Check: Does reviewer understand full context? 75 | 76 | IF suggestion seems wrong: 77 | Push back with technical reasoning 78 | 79 | IF can't easily verify: 80 | Say so: "I can't verify this without [X]. Should I [investigate/ask/proceed]?" 81 | 82 | IF conflicts with your human partner's prior decisions: 83 | Stop and discuss with your human partner first 84 | ``` 85 | 86 | **your human partner's rule:** "External feedback - be skeptical, but check carefully" 87 | 88 | ## YAGNI Check for "Professional" Features 89 | 90 | ``` 91 | IF reviewer suggests "implementing properly": 92 | grep codebase for actual usage 93 | 94 | IF unused: "This endpoint isn't called. Remove it (YAGNI)?" 95 | IF used: Then implement properly 96 | ``` 97 | 98 | **your human partner's rule:** "You and reviewer both report to me. If we don't need this feature, don't add it." 99 | 100 | ## Implementation Order 101 | 102 | ``` 103 | FOR multi-item feedback: 104 | 1. Clarify anything unclear FIRST 105 | 2. Then implement in this order: 106 | - Blocking issues (breaks, security) 107 | - Simple fixes (typos, imports) 108 | - Complex fixes (refactoring, logic) 109 | 3. Test each fix individually 110 | 4. Verify no regressions 111 | ``` 112 | 113 | ## When To Push Back 114 | 115 | Push back when: 116 | - Suggestion breaks existing functionality 117 | - Reviewer lacks full context 118 | - Violates YAGNI (unused feature) 119 | - Technically incorrect for this stack 120 | - Legacy/compatibility reasons exist 121 | - Conflicts with your human partner's architectural decisions 122 | 123 | **How to push back:** 124 | - Use technical reasoning, not defensiveness 125 | - Ask specific questions 126 | - Reference working tests/code 127 | - Involve your human partner if architectural 128 | 129 | **Signal if uncomfortable pushing back out loud:** "Strange things are afoot at the Circle K" 130 | 131 | ## Acknowledging Correct Feedback 132 | 133 | When feedback IS correct: 134 | ``` 135 | ✅ "Fixed. [Brief description of what changed]" 136 | ✅ "Good catch - [specific issue]. Fixed in [location]." 137 | ✅ [Just fix it and show in the code] 138 | 139 | ❌ "You're absolutely right!" 140 | ❌ "Great point!" 141 | ❌ "Thanks for catching that!" 142 | ❌ "Thanks for [anything]" 143 | ❌ ANY gratitude expression 144 | ``` 145 | 146 | **Why no thanks:** Actions speak. Just fix it. The code itself shows you heard the feedback. 147 | 148 | **If you catch yourself about to write "Thanks":** DELETE IT. State the fix instead. 149 | 150 | ## Gracefully Correcting Your Pushback 151 | 152 | If you pushed back and were wrong: 153 | ``` 154 | ✅ "You were right - I checked [X] and it does [Y]. Implementing now." 155 | ✅ "Verified this and you're correct. My initial understanding was wrong because [reason]. Fixing." 156 | 157 | ❌ Long apology 158 | ❌ Defending why you pushed back 159 | ❌ Over-explaining 160 | ``` 161 | 162 | State the correction factually and move on. 163 | 164 | ## Common Mistakes 165 | 166 | | Mistake | Fix | 167 | |---------|-----| 168 | | Performative agreement | State requirement or just act | 169 | | Blind implementation | Verify against codebase first | 170 | | Batch without testing | One at a time, test each | 171 | | Assuming reviewer is right | Check if breaks things | 172 | | Avoiding pushback | Technical correctness > comfort | 173 | | Partial implementation | Clarify all items first | 174 | | Can't verify, proceed anyway | State limitation, ask for direction | 175 | 176 | ## Real Examples 177 | 178 | **Performative Agreement (Bad):** 179 | ``` 180 | Reviewer: "Remove legacy code" 181 | ❌ "You're absolutely right! Let me remove that..." 182 | ``` 183 | 184 | **Technical Verification (Good):** 185 | ``` 186 | Reviewer: "Remove legacy code" 187 | ✅ "Checking... build target is 10.15+, this API needs 13+. Need legacy for backward compat. Current impl has wrong bundle ID - fix it or drop pre-13 support?" 188 | ``` 189 | 190 | **YAGNI (Good):** 191 | ``` 192 | Reviewer: "Implement proper metrics tracking with database, date filters, CSV export" 193 | ✅ "Grepped codebase - nothing calls this endpoint. Remove it (YAGNI)? Or is there usage I'm missing?" 194 | ``` 195 | 196 | **Unclear Item (Good):** 197 | ``` 198 | your human partner: "Fix items 1-6" 199 | You understand 1,2,3,6. Unclear on 4,5. 200 | ✅ "Understand 1,2,3,6. Need clarification on 4 and 5 before implementing." 201 | ``` 202 | 203 | ## The Bottom Line 204 | 205 | **External feedback = suggestions to evaluate, not orders to follow.** 206 | 207 | Verify. Question. Then implement. 208 | 209 | No performative agreement. Technical rigor always. 210 | -------------------------------------------------------------------------------- /docs/windows/polyglot-hooks.md: -------------------------------------------------------------------------------- 1 | # Cross-Platform Polyglot Hooks for Claude Code 2 | 3 | Claude Code plugins need hooks that work on Windows, macOS, and Linux. This document explains the polyglot wrapper technique that makes this possible. 4 | 5 | ## The Problem 6 | 7 | Claude Code runs hook commands through the system's default shell: 8 | - **Windows**: CMD.exe 9 | - **macOS/Linux**: bash or sh 10 | 11 | This creates several challenges: 12 | 13 | 1. **Script execution**: Windows CMD can't execute `.sh` files directly - it tries to open them in a text editor 14 | 2. **Path format**: Windows uses backslashes (`C:\path`), Unix uses forward slashes (`/path`) 15 | 3. **Environment variables**: `$VAR` syntax doesn't work in CMD 16 | 4. **No `bash` in PATH**: Even with Git Bash installed, `bash` isn't in the PATH when CMD runs 17 | 18 | ## The Solution: Polyglot `.cmd` Wrapper 19 | 20 | A polyglot script is valid syntax in multiple languages simultaneously. Our wrapper is valid in both CMD and bash: 21 | 22 | ```cmd 23 | : << 'CMDBLOCK' 24 | @echo off 25 | "C:\Program Files\Git\bin\bash.exe" -l -c "\"$(cygpath -u \"$CLAUDE_PLUGIN_ROOT\")/hooks/session-start.sh\"" 26 | exit /b 27 | CMDBLOCK 28 | 29 | # Unix shell runs from here 30 | "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh" 31 | ``` 32 | 33 | ### How It Works 34 | 35 | #### On Windows (CMD.exe) 36 | 37 | 1. `: << 'CMDBLOCK'` - CMD sees `:` as a label (like `:label`) and ignores `<< 'CMDBLOCK'` 38 | 2. `@echo off` - Suppresses command echoing 39 | 3. The bash.exe command runs with: 40 | - `-l` (login shell) to get proper PATH with Unix utilities 41 | - `cygpath -u` converts Windows path to Unix format (`C:\foo` → `/c/foo`) 42 | 4. `exit /b` - Exits the batch script, stopping CMD here 43 | 5. Everything after `CMDBLOCK` is never reached by CMD 44 | 45 | #### On Unix (bash/sh) 46 | 47 | 1. `: << 'CMDBLOCK'` - `:` is a no-op, `<< 'CMDBLOCK'` starts a heredoc 48 | 2. Everything until `CMDBLOCK` is consumed by the heredoc (ignored) 49 | 3. `# Unix shell runs from here` - Comment 50 | 4. The script runs directly with the Unix path 51 | 52 | ## File Structure 53 | 54 | ``` 55 | hooks/ 56 | ├── hooks.json # Points to the .cmd wrapper 57 | ├── session-start.cmd # Polyglot wrapper (cross-platform entry point) 58 | └── session-start.sh # Actual hook logic (bash script) 59 | ``` 60 | 61 | ### hooks.json 62 | 63 | ```json 64 | { 65 | "hooks": { 66 | "SessionStart": [ 67 | { 68 | "matcher": "startup|resume|clear|compact", 69 | "hooks": [ 70 | { 71 | "type": "command", 72 | "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.cmd\"" 73 | } 74 | ] 75 | } 76 | ] 77 | } 78 | } 79 | ``` 80 | 81 | Note: The path must be quoted because `${CLAUDE_PLUGIN_ROOT}` may contain spaces on Windows (e.g., `C:\Program Files\...`). 82 | 83 | ## Requirements 84 | 85 | ### Windows 86 | - **Git for Windows** must be installed (provides `bash.exe` and `cygpath`) 87 | - Default installation path: `C:\Program Files\Git\bin\bash.exe` 88 | - If Git is installed elsewhere, the wrapper needs modification 89 | 90 | ### Unix (macOS/Linux) 91 | - Standard bash or sh shell 92 | - The `.cmd` file must have execute permission (`chmod +x`) 93 | 94 | ## Writing Cross-Platform Hook Scripts 95 | 96 | Your actual hook logic goes in the `.sh` file. To ensure it works on Windows (via Git Bash): 97 | 98 | ### Do: 99 | - Use pure bash builtins when possible 100 | - Use `$(command)` instead of backticks 101 | - Quote all variable expansions: `"$VAR"` 102 | - Use `printf` or here-docs for output 103 | 104 | ### Avoid: 105 | - External commands that may not be in PATH (sed, awk, grep) 106 | - If you must use them, they're available in Git Bash but ensure PATH is set up (use `bash -l`) 107 | 108 | ### Example: JSON Escaping Without sed/awk 109 | 110 | Instead of: 111 | ```bash 112 | escaped=$(echo "$content" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | awk '{printf "%s\\n", $0}') 113 | ``` 114 | 115 | Use pure bash: 116 | ```bash 117 | escape_for_json() { 118 | local input="$1" 119 | local output="" 120 | local i char 121 | for (( i=0; i<${#input}; i++ )); do 122 | char="${input:$i:1}" 123 | case "$char" in 124 | $'\\') output+='\\' ;; 125 | '"') output+='\"' ;; 126 | $'\n') output+='\n' ;; 127 | $'\r') output+='\r' ;; 128 | $'\t') output+='\t' ;; 129 | *) output+="$char" ;; 130 | esac 131 | done 132 | printf '%s' "$output" 133 | } 134 | ``` 135 | 136 | ## Reusable Wrapper Pattern 137 | 138 | For plugins with multiple hooks, you can create a generic wrapper that takes the script name as an argument: 139 | 140 | ### run-hook.cmd 141 | ```cmd 142 | : << 'CMDBLOCK' 143 | @echo off 144 | set "SCRIPT_DIR=%~dp0" 145 | set "SCRIPT_NAME=%~1" 146 | "C:\Program Files\Git\bin\bash.exe" -l -c "cd \"$(cygpath -u \"%SCRIPT_DIR%\")\" && \"./%SCRIPT_NAME%\"" 147 | exit /b 148 | CMDBLOCK 149 | 150 | # Unix shell runs from here 151 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" 152 | SCRIPT_NAME="$1" 153 | shift 154 | "${SCRIPT_DIR}/${SCRIPT_NAME}" "$@" 155 | ``` 156 | 157 | ### hooks.json using the reusable wrapper 158 | ```json 159 | { 160 | "hooks": { 161 | "SessionStart": [ 162 | { 163 | "matcher": "startup", 164 | "hooks": [ 165 | { 166 | "type": "command", 167 | "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start.sh" 168 | } 169 | ] 170 | } 171 | ], 172 | "PreToolUse": [ 173 | { 174 | "matcher": "Bash", 175 | "hooks": [ 176 | { 177 | "type": "command", 178 | "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" validate-bash.sh" 179 | } 180 | ] 181 | } 182 | ] 183 | } 184 | } 185 | ``` 186 | 187 | ## Troubleshooting 188 | 189 | ### "bash is not recognized" 190 | CMD can't find bash. The wrapper uses the full path `C:\Program Files\Git\bin\bash.exe`. If Git is installed elsewhere, update the path. 191 | 192 | ### "cygpath: command not found" or "dirname: command not found" 193 | Bash isn't running as a login shell. Ensure `-l` flag is used. 194 | 195 | ### Path has weird `\/` in it 196 | `${CLAUDE_PLUGIN_ROOT}` expanded to a Windows path ending with backslash, then `/hooks/...` was appended. Use `cygpath` to convert the entire path. 197 | 198 | ### Script opens in text editor instead of running 199 | The hooks.json is pointing directly to the `.sh` file. Point to the `.cmd` wrapper instead. 200 | 201 | ### Works in terminal but not as hook 202 | Claude Code may run hooks differently. Test by simulating the hook environment: 203 | ```powershell 204 | $env:CLAUDE_PLUGIN_ROOT = "C:\path\to\plugin" 205 | cmd /c "C:\path\to\plugin\hooks\session-start.cmd" 206 | ``` 207 | 208 | ## Related Issues 209 | 210 | - [anthropics/claude-code#9758](https://github.com/anthropics/claude-code/issues/9758) - .sh scripts open in editor on Windows 211 | - [anthropics/claude-code#3417](https://github.com/anthropics/claude-code/issues/3417) - Hooks don't work on Windows 212 | - [anthropics/claude-code#6023](https://github.com/anthropics/claude-code/issues/6023) - CLAUDE_PROJECT_DIR not found 213 | -------------------------------------------------------------------------------- /docs/README.opencode.md: -------------------------------------------------------------------------------- 1 | # Superpowers for OpenCode 2 | 3 | Complete guide for using Superpowers with [OpenCode.ai](https://opencode.ai). 4 | 5 | ## Quick Install 6 | 7 | Tell OpenCode: 8 | 9 | ``` 10 | Clone https://github.com/obra/superpowers to ~/.config/opencode/superpowers, then create directory ~/.config/opencode/plugin, then symlink ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js to ~/.config/opencode/plugin/superpowers.js, then restart opencode. 11 | ``` 12 | 13 | ## Manual Installation 14 | 15 | ### Prerequisites 16 | 17 | - [OpenCode.ai](https://opencode.ai) installed 18 | - Node.js installed 19 | - Git installed 20 | 21 | ### Installation Steps 22 | 23 | #### 1. Install Superpowers 24 | 25 | ```bash 26 | mkdir -p ~/.config/opencode/superpowers 27 | git clone https://github.com/obra/superpowers.git ~/.config/opencode/superpowers 28 | ``` 29 | 30 | #### 2. Register the Plugin 31 | 32 | OpenCode discovers plugins from `~/.config/opencode/plugin/`. Create a symlink: 33 | 34 | ```bash 35 | mkdir -p ~/.config/opencode/plugin 36 | ln -sf ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js ~/.config/opencode/plugin/superpowers.js 37 | ``` 38 | 39 | Alternatively, for project-local installation: 40 | 41 | ```bash 42 | # In your OpenCode project 43 | mkdir -p .opencode/plugin 44 | ln -sf ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js .opencode/plugin/superpowers.js 45 | ``` 46 | 47 | #### 3. Restart OpenCode 48 | 49 | Restart OpenCode to load the plugin. Superpowers will automatically activate. 50 | 51 | ## Usage 52 | 53 | ### Finding Skills 54 | 55 | Use the `find_skills` tool to list all available skills: 56 | 57 | ``` 58 | use find_skills tool 59 | ``` 60 | 61 | ### Loading a Skill 62 | 63 | Use the `use_skill` tool to load a specific skill: 64 | 65 | ``` 66 | use use_skill tool with skill_name: "superpowers:brainstorming" 67 | ``` 68 | 69 | Skills are automatically inserted into the conversation and persist across context compaction. 70 | 71 | ### Personal Skills 72 | 73 | Create your own skills in `~/.config/opencode/skills/`: 74 | 75 | ```bash 76 | mkdir -p ~/.config/opencode/skills/my-skill 77 | ``` 78 | 79 | Create `~/.config/opencode/skills/my-skill/SKILL.md`: 80 | 81 | ```markdown 82 | --- 83 | name: my-skill 84 | description: Use when [condition] - [what it does] 85 | --- 86 | 87 | # My Skill 88 | 89 | [Your skill content here] 90 | ``` 91 | 92 | ### Project Skills 93 | 94 | Create project-specific skills in your OpenCode project: 95 | 96 | ```bash 97 | # In your OpenCode project 98 | mkdir -p .opencode/skills/my-project-skill 99 | ``` 100 | 101 | Create `.opencode/skills/my-project-skill/SKILL.md`: 102 | 103 | ```markdown 104 | --- 105 | name: my-project-skill 106 | description: Use when [condition] - [what it does] 107 | --- 108 | 109 | # My Project Skill 110 | 111 | [Your skill content here] 112 | ``` 113 | 114 | ## Skill Priority 115 | 116 | Skills are resolved with this priority order: 117 | 118 | 1. **Project skills** (`.opencode/skills/`) - Highest priority 119 | 2. **Personal skills** (`~/.config/opencode/skills/`) 120 | 3. **Superpowers skills** (`~/.config/opencode/superpowers/skills/`) 121 | 122 | You can force resolution to a specific level: 123 | - `project:skill-name` - Force project skill 124 | - `skill-name` - Search project → personal → superpowers 125 | - `superpowers:skill-name` - Force superpowers skill 126 | 127 | ## Features 128 | 129 | ### Automatic Context Injection 130 | 131 | The plugin automatically injects superpowers context via the chat.message hook on every session. No manual configuration needed. 132 | 133 | ### Message Insertion Pattern 134 | 135 | When you load a skill with `use_skill`, it's inserted as a user message with `noReply: true`. This ensures skills persist throughout long conversations, even when OpenCode compacts context. 136 | 137 | ### Compaction Resilience 138 | 139 | The plugin listens for `session.compacted` events and automatically re-injects the core superpowers bootstrap to maintain functionality after context compaction. 140 | 141 | ### Tool Mapping 142 | 143 | Skills written for Claude Code are automatically adapted for OpenCode. The plugin provides mapping instructions: 144 | 145 | - `TodoWrite` → `update_plan` 146 | - `Task` with subagents → OpenCode's `@mention` system 147 | - `Skill` tool → `use_skill` custom tool 148 | - File operations → Native OpenCode tools 149 | 150 | ## Architecture 151 | 152 | ### Plugin Structure 153 | 154 | **Location:** `~/.config/opencode/superpowers/.opencode/plugin/superpowers.js` 155 | 156 | **Components:** 157 | - Two custom tools: `use_skill`, `find_skills` 158 | - chat.message hook for initial context injection 159 | - event handler for session.compacted re-injection 160 | - Uses shared `lib/skills-core.js` module (also used by Codex) 161 | 162 | ### Shared Core Module 163 | 164 | **Location:** `~/.config/opencode/superpowers/lib/skills-core.js` 165 | 166 | **Functions:** 167 | - `extractFrontmatter()` - Parse skill metadata 168 | - `stripFrontmatter()` - Remove metadata from content 169 | - `findSkillsInDir()` - Recursive skill discovery 170 | - `resolveSkillPath()` - Skill resolution with shadowing 171 | - `checkForUpdates()` - Git update detection 172 | 173 | This module is shared between OpenCode and Codex implementations for code reuse. 174 | 175 | ## Updating 176 | 177 | ```bash 178 | cd ~/.config/opencode/superpowers 179 | git pull 180 | ``` 181 | 182 | Restart OpenCode to load the updates. 183 | 184 | ## Troubleshooting 185 | 186 | ### Plugin not loading 187 | 188 | 1. Check plugin file exists: `ls ~/.config/opencode/superpowers/.opencode/plugin/superpowers.js` 189 | 2. Check symlink: `ls -l ~/.config/opencode/plugin/superpowers.js` 190 | 3. Check OpenCode logs: `opencode run "test" --print-logs --log-level DEBUG` 191 | 4. Look for: `service=plugin path=file:///.../superpowers.js loading plugin` 192 | 193 | ### Skills not found 194 | 195 | 1. Verify skills directory: `ls ~/.config/opencode/superpowers/skills` 196 | 2. Use `find_skills` tool to see what's discovered 197 | 3. Check skill structure: each skill needs a `SKILL.md` file 198 | 199 | ### Tools not working 200 | 201 | 1. Verify plugin loaded: Check OpenCode logs for plugin loading message 202 | 2. Check Node.js version: The plugin requires Node.js for ES modules 203 | 3. Test plugin manually: `node --input-type=module -e "import('file://~/.config/opencode/plugin/superpowers.js').then(m => console.log(Object.keys(m)))"` 204 | 205 | ### Context not injecting 206 | 207 | 1. Check if chat.message hook is working 208 | 2. Verify using-superpowers skill exists 209 | 3. Check OpenCode version (requires recent version with plugin support) 210 | 211 | ## Getting Help 212 | 213 | - Report issues: https://github.com/obra/superpowers/issues 214 | - Main documentation: https://github.com/obra/superpowers 215 | - OpenCode docs: https://opencode.ai/docs/ 216 | 217 | ## Testing 218 | 219 | The implementation includes an automated test suite at `tests/opencode/`: 220 | 221 | ```bash 222 | # Run all tests 223 | ./tests/opencode/run-tests.sh --integration --verbose 224 | 225 | # Run specific test 226 | ./tests/opencode/run-tests.sh --test test-tools.sh 227 | ``` 228 | 229 | Tests verify: 230 | - Plugin loading 231 | - Skills-core library functionality 232 | - Tool execution (use_skill, find_skills) 233 | - Skill priority resolution 234 | - Proper isolation with temp HOME 235 | --------------------------------------------------------------------------------