summaryrefslogtreecommitdiff
path: root/hooks
AgeCommit message (Collapse)Author
2026-03-25fix: add Copilot CLI platform detection for sessionStart context injectionBlaž Čulina
Copilot CLI v1.0.11 reads `additionalContext` from sessionStart hook output, but the session-start script only emits the Claude Code-specific nested format. Add COPILOT_CLI env var detection so Copilot CLI gets the SDK-standard top-level `additionalContext` while Claude Code continues getting `hookSpecificOutput`. Based on PR #910 by @culinablaz.
2026-03-15Update changelog with Cursor hooks support (#709)jesse
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15feat: add Cursor-compatible hooks and fix platform detectionjesse
Add hooks/hooks-cursor.json with Cursor's camelCase format (sessionStart, version: 1) and update .cursor-plugin/plugin.json to reference it. Uses ${CURSOR_PLUGIN_ROOT} and run-hook.cmd for cross-platform support. Fix session-start platform detection: check CURSOR_PLUGIN_ROOT first (Cursor may also set CLAUDE_PLUGIN_ROOT), ensuring correct output format for each platform. Based on PR #709 with fixes for: wrong filename (.sh extension), missing Windows support, fragile relative paths, and incorrect platform detection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15fix(hooks): replace heredoc with printf to fix bash 5.3+ hangjesse
Bash 5.3 has a regression where heredoc variable expansion blocks when content exceeds ~512 bytes. The session_context variable is ~4,500 bytes, causing the SessionStart hook to hang indefinitely on macOS with Homebrew bash 5.3+. Replace cat <<EOF with printf. Tested on Linux (bash 5.2) and Windows (Git Bash 5.2). The hang only affects 5.3+ but printf works correctly on all versions. Based on #572, closes #572. Fixes #571. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15fix(hooks): replace BASH_SOURCE with POSIX-safe $0jesse
Replace ${BASH_SOURCE[0]:-$0} with $0 in hooks/session-start and the polyglot-hooks docs example. BASH_SOURCE uses bash array syntax that causes 'Bad substitution' on systems where /bin/sh is dash (Ubuntu). Since session-start is always executed (never sourced), $0 and BASH_SOURCE give the same result. Tested on Linux (bash + dash) and Windows (Git Bash via CMD and direct). Based on #553, closes #553. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15fix: stop firing SessionStart hook on --resumejesse
Resumed sessions already have injected context in their conversation history. Re-firing the hook was redundant and could cause issues. The hook now fires only on startup, clear, and compact. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10Merge PR #585: fix single quotes in SessionStart hook for Windows/LinuxJesse Vincent
Use escaped double quotes instead of single quotes around ${CLAUDE_PLUGIN_ROOT} path in hooks.json. Single quotes fail on Windows (cmd.exe doesn't recognize them as path delimiters) and on Linux when the shell doesn't expand the variable. Verified the fix works across all combinations: - macOS bash, path without spaces: pass - macOS bash, path with spaces: pass - Windows cmd.exe, path without spaces: FAILED with single quotes, PASS with double quotes - Windows cmd.exe, path with spaces: FAILED with single quotes, PASS with double quotes - Windows Git Bash: pass (both quote styles work here) Testing was done on a Windows 11 (NT 10.0.26200.0) dev box with Claude Code 2.1.72 and Git for Windows. The single-quote bug only manifests when cmd.exe is the executing shell (no Git Bash fallback), which explains why some users hit it and others don't. Closes #577, closes #644.
2026-03-09fix(hooks): emit session-start context only once per platformmvanhorn
Claude Code reads both additional_context and hookSpecificOutput without deduplication, causing double injection. Detect platform via CLAUDE_PLUGIN_ROOT and emit only the appropriate field. Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
2026-03-01fix: use double quotes for CLAUDE_PLUGIN_ROOT in SessionStart hookatian8179
Replace single quotes with escaped double quotes around ${CLAUDE_PLUGIN_ROOT} in hooks.json so the shell variable expands correctly on Linux. Single quotes prevent variable expansion, causing the hook to fail with 'No such file or directory'. Closes #577
2026-02-21fix: quote CLAUDE_PLUGIN_ROOT for spaces, use POSIX-safe path resolutionJesse Vincent
- Quote ${CLAUDE_PLUGIN_ROOT} in hooks.json to handle paths with spaces (e.g. "C:\Users\Robert Zimmermann\...") - Replace bash-only ${BASH_SOURCE[0]:-$0} with POSIX-safe $0 in run-hook.cmd so the Unix path doesn't break on dash (/bin/sh) Addresses: #518 (spaces in path), Ubuntu/Debian compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21fix: restore polyglot wrapper to fix Windows hook window spawningJesse Vincent
Claude Code spawns hook commands with shell:true + windowsHide:true, but on Windows the execution chain cmd.exe -> bash.exe causes Git Bash (MSYS2) to allocate its own console window, bypassing the hide flag. This creates visible terminal windows that steal focus on every SessionStart event (startup, resume, clear, compact). The fix: - Rename session-start.sh to session-start (no extension) so Claude Code's .sh auto-detection regex doesn't fire and prepend "bash" - Restore run-hook.cmd polyglot wrapper to control bash invocation on Windows (tries known Git Bash paths, then PATH, then exits silently if no bash found) - On Unix, the polyglot's shell portion runs the script directly This avoids Claude Code's broken .sh auto-prepend, gives us control over how bash is invoked on Windows, and gracefully handles missing bash instead of erroring. Addresses: #440, #414, #354, #417, #293 Upstream: anthropics/claude-code#14828
2026-02-17Add Cursor plugin manifest and hook response compatibilityericzakariasson
Enable native Cursor plugin discovery with a .cursor-plugin manifest, and make the SessionStart hook emit both Cursor and Claude response shapes so context injection works across both platforms. Document Cursor install usage in the README while keeping Claude-first wording. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12Make SessionStart hook synchronous so using-superpowers loads before first turnJesse Vincent
When async is true, the hook may not complete before the model starts responding, meaning the using-superpowers skill instructions aren't in context for the first message.
2026-02-05fix: replace O(n^2) escape_for_json with parameter substitutionJesse Vincent
The character-by-character loop using ${input:$i:1} was O(n^2) in bash due to substring copy overhead. On Windows Git Bash this took 60+ seconds, freezing terminal input even with async hooks. Replaced with bash parameter substitution (${s//old/new}) which runs each pattern as a single C-level pass. 7x faster on macOS, expected to be dramatically faster on Windows Git Bash where the original caused the worst hangs. Relates to #404, #413
2026-02-05fix: run SessionStart hook async to prevent Windows terminal freezeJesse Vincent
The synchronous SessionStart hook blocked the TUI from entering raw mode on Windows, freezing all keyboard input. The pure-bash escape_for_json function is O(n^2) on Git Bash, taking 60+ seconds. Running the hook async prevents the freeze while still injecting superpowers context. Multiple users confirmed this workaround. Fixes #404, #413, #414, #419
2026-01-23fix: Windows hook execution for Claude Code 2.1.x (#331)Jesse Vincent
* fix: convert shell scripts from CRLF to LF line endings Add .gitattributes to enforce LF line endings for shell scripts, preventing bash errors like "/usr/bin/bash: line 1: : command not found" when scripts are checked out on Windows with CRLF. Fixes #317 (SessionStart hook fails due to CRLF line endings) Files converted: - hooks/session-start.sh - lib/brainstorm-server/start-server.sh - lib/brainstorm-server/stop-server.sh - lib/brainstorm-server/wait-for-feedback.sh - skills/systematic-debugging/find-polluter.sh Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update Windows hook execution for Claude Code 2.1.x Claude Code 2.1.x changed the Windows execution model: it now auto-detects .sh files in hook commands and prepends "bash " automatically. This broke the polyglot wrapper because: Before: "run-hook.cmd" session-start.sh (wrapper executes) After: bash "run-hook.cmd" session-start.sh (bash can't run .cmd) Changes: - hooks.json now calls session-start.sh directly (Claude Code handles bash) - Added deprecation comment to run-hook.cmd explaining the change - Updated RELEASE-NOTES.md Fixes #317, #313, #275, #292 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-03Release v3.6.2: Fix Linux compatibility in polyglot hook wrapperv3.6.2Jesse Vincent
Fixed POSIX compatibility issue in hooks/run-hook.cmd that caused "Bad substitution" errors on Ubuntu/Debian systems where /bin/sh is dash. Changes: - Replaced bash-specific ${BASH_SOURCE[0]:-$0} with POSIX-compliant $0 - Tested with both bash and sh (POSIX mode) on macOS - Updated version to 3.6.2 in all required files Fixes #141
2025-12-01Release v3.6.1: Fix Windows arg forwarding in polyglot wrapperv3.6.1Jesse Vincent
- Add validation for missing script name - Forward up to 8 additional arguments to bash on Windows - Fixes CodeRabbit review feedback from #134
2025-12-01Add Windows support for plugin hooks (#134)Jesse Vincent
* feat: Add Windows support for session-start hook - Create polyglot session-start.cmd that works in both CMD and bash - Update hooks.json to use the .cmd polyglot launcher - Replace sed/awk with pure bash for JSON escaping (Windows compatibility) The polyglot script uses a heredoc trick: - CMD sees the @echo off block and runs bash.exe with cygpath conversion - Bash sees a heredoc and skips to the Unix section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Add execute permission to session-start.cmd for Unix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: Add comprehensive polyglot hooks documentation - Add docs/windows/polyglot-hooks.md explaining the cross-platform technique - Add reusable run-hook.cmd wrapper for parameterized hook execution - Document how the polyglot works in CMD vs bash - Include troubleshooting section and related GitHub issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * test: Add polyglot hook test script for macOS/Linux Run ./test-polyglot.sh from repo root to verify: - Required files exist with execute permissions - Simple wrapper (session-start.cmd) produces valid JSON - Parameterized wrapper (run-hook.cmd) works - Heredoc correctly skips CMD block on Unix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Use direct pipe to jq in test to avoid variable escaping issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: Use single reusable run-hook.cmd for all hooks - Remove session-start.cmd in favor of run-hook.cmd - Update hooks.json to use: run-hook.cmd session-start.sh - Simplify test script to only test run-hook.cmd This makes it easy to add more hooks - just create the .sh file and add a line to hooks.json pointing to run-hook.cmd with the script name. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Simplify run-hook.cmd CMD block Pass path directly to bash instead of using cygpath in a subshell. The complex quoting was causing issues on Windows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: Remove test-polyglot.sh Testing complete - polyglot hooks work on Windows and macOS. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
2025-10-31Optimize superpowers bootstrap to eliminate redundant skill executionJesse Vincent
- Update session-start hook to clarify that using-superpowers content is provided directly - Add explicit guidance to use Skill tool only for other skills - Prevents confusing loop where agents execute using-superpowers manually - Reduces overhead and improves user experience Fixes redundant skill execution in bootstrap workflow.
2025-10-16Strengthen the migration messageJesse Vincent
2025-10-16Update our bootstrap for first-party claude skillsJesse Vincent
2025-10-15Revert "Reapply "Move superpowers plugin into plugins/superpowers-bootstrap ↵Jesse Vincent
subdirectory"" This reverts commit 0fdea80a7d6b2e5d6b2d3e59ff2ca378ecd56cc0.
2025-10-15Reapply "Move superpowers plugin into plugins/superpowers-bootstrap ↵Jesse Vincent
subdirectory" This reverts commit d6ac9a8b5d5884413b194330653b6aa336d3c87a. turns out this worked. it's just that anthropic changed claude's startup hook output
2025-10-15Revert "Move superpowers plugin into plugins/superpowers-bootstrap subdirectory"Jesse Vincent
This reverts commit 809956f3bff3a9eb9891f08ce8dd41504e4a5af1.
2025-10-15Move superpowers plugin into plugins/superpowers-bootstrap subdirectoryJesse Vincent
This restructures the repo to support multiple plugins by moving the current plugin into a subdirectory. The plugin continues to be published as "superpowers" in the marketplace.
2025-10-12Fix session-start hook execution in plugin contextRyan Nelson
Fixes #8 - Use /bin/zsh fallback when BASH_SOURCE is unbound - Add || true to handle empty grep results gracefully Co-authored-by: ryancnelson <ryancnelson@users.noreply.github.com>
2025-10-11Move 'skills behind' warning to end of session start outputJesse Vincent
2025-10-11Add skills location info to session-start outputJesse Vincent
2025-10-11Remove obsolete setup-personal-superpowers call and github recommendation logicJesse Vincent
2025-10-11Remove obsolete setup-personal-superpowers hook (replaced by ↵Jesse Vincent
initialize-skills.sh)
2025-10-11Update hooks to use skills repository from ~/.config/superpowers/skillsJesse Vincent
Changes: - Set SUPERPOWERS_SKILLS_ROOT environment variable - Call lib/initialize-skills.sh to handle clone/fetch/notification - Update find-skills path to ${SUPERPOWERS_SKILLS_ROOT}/skills/using-skills/find-skills - Update using-skills path (renamed from getting-started) - Include initialization output in session start message - Update slash command paths to use SUPERPOWERS_SKILLS_ROOT Implements Task 7 from skills-repo-separation plan.
2025-10-10Show skills list and getting-started at session startJesse Vincent
Session start hook now: - Inlines full getting-started/SKILL.md content (no @ links in hooks) - Runs find-skills and shows complete skills list - Shows tool paths after the guide Getting-started improvements: - Removed "Just Read This Guide?" section (redundant with hook) - Removed "Last thing" announcement requirement - Tightened intro from ~80 to ~35 words - Simplified "How to Load Skills" section - Updated Workflow 2 to reference skills list shown at session start - Removed redundant find-skills path examples This eliminates friction - agents see all available skills immediately without needing to search first. No excuse for "I didn't want to spend time searching."
2025-10-10Inject skill tool paths via SessionStart hookJesse Vincent
The SessionStart hook now tells Claude the exact paths to find-skills and skill-run tools. Since hooks have CLAUDE_PLUGIN_ROOT expanded, the actual paths are injected into Claude's context. This solves the problem of CLAUDE_PLUGIN_ROOT not being available as a bash environment variable.
2025-10-10Add personal superpowers overlay systemJesse Vincent
Enables users to write and manage their own skills alongside core skills. ## Key Features: - Auto-setup on first session: Creates ~/.config/superpowers/ git repo - Two-tier skills: Personal skills shadow core skills when paths match - Environment variable support: PERSONAL_SUPERPOWERS_DIR, XDG_CONFIG_HOME - GitHub integration: Optional public repo creation for sharing skills - CLI-agnostic: Works across Claude Code, Codex CLI, Gemini CLI (future) ## Changes: - Added hooks/setup-personal-superpowers.sh - Auto-initializes personal repo - Updated hooks/session-start.sh - Runs setup, offers GitHub repo creation - Updated list-skills, skills-search - Search both personal and core skills - Renamed skills/meta/creating-skills → writing-skills - Added skills/meta/setting-up-personal-superpowers - Setup documentation - Added skills/meta/sharing-skills - Contribution workflow - Removed skills/meta/installing-skills - Old ~/.clank system - Removed all INDEX.md files - Replaced by list-skills tool - Updated README.md, getting-started - Document personal skills workflow ## Architecture: ~/.config/superpowers/skills/ # Personal (user-created, git-tracked) ${CLAUDE_PLUGIN_ROOT}/skills/ # Core (read-only, from plugin) Search order: Personal first, core second (first match wins)
2025-10-09Minimal bootstrap: just point to getting-started guideJesse Vincent
Everything is in the SKILL.md.
2025-10-09Simplify SessionStart hook to minimal bootstrapJesse Vincent
Just point to skills-search and getting-started guide. All details are in the SKILL.md itself.
2025-10-09Fix variable expansion and use @ referenceJesse Vincent
- Changed heredoc from single to double quotes for variable expansion - Added @ prefix to SKILL.md reference so Claude loads the file
2025-10-09Add clear and compact to SessionStart matcherJesse Vincent
2025-10-09Fix hooks.json structure: wrap in top-level 'hooks' keyJesse Vincent
2025-10-09Fix SessionStart hook: use command type with scriptJesse Vincent
- Changed from invalid 'type: json' to 'type: command' - Created session-start.sh script that outputs JSON - Script creates ~/.superpowers/ and injects context
2025-10-09Fix SessionStart hook: add hookEventName fieldJesse Vincent
The hookSpecificOutput requires hookEventName to be set.
2025-10-09Initial commit: Superpowers plugin v1.0.0Jesse Vincent
Core skills library as Claude Code plugin: - Testing skills: TDD, async testing, anti-patterns - Debugging skills: Systematic debugging, root cause tracing - Collaboration skills: Brainstorming, planning, code review - Meta skills: Creating and testing skills Features: - SessionStart hook for context injection - Skills-search tool for discovery - Commands: /brainstorm, /write-plan, /execute-plan - Data directory at ~/.superpowers/