summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvanhorn <mvanhorn@users.noreply.github.com>2026-03-09 17:20:31 -0700
committerJesse Vincent <jesse@fsck.com>2026-03-09 17:20:31 -0700
commit74f2b1c96e4eeef4169ad80c91de9d05f6d2a95a (patch)
tree206571c22a340654a49ea633a881f00e86dbeae4
parent991e9d4de93b17ee08646a8115e3f9f88dad2208 (diff)
fix(hooks): emit session-start context only once per platform
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>
-rwxr-xr-xhooks/session-start20
1 files changed, 15 insertions, 5 deletions
diff --git a/hooks/session-start b/hooks/session-start
index 0eba96b..f9e94dd 100755
--- a/hooks/session-start
+++ b/hooks/session-start
@@ -35,17 +35,27 @@ warning_escaped=$(escape_for_json "$warning_message")
session_context="<EXTREMELY_IMPORTANT>\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</EXTREMELY_IMPORTANT>"
# Output context injection as JSON.
-# Keep both shapes for compatibility:
-# - Cursor hooks expect additional_context.
-# - Claude hooks expect hookSpecificOutput.additionalContext.
-cat <<EOF
+# Cursor hooks expect additional_context.
+# Claude Code hooks expect hookSpecificOutput.additionalContext.
+# Claude Code reads BOTH fields without deduplication, so we must only
+# emit the field consumed by the current platform to avoid double injection.
+if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
+ # Claude Code sets CLAUDE_PLUGIN_ROOT — emit only hookSpecificOutput
+ cat <<EOF
{
- "additional_context": "${session_context}",
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": "${session_context}"
}
}
EOF
+else
+ # Other platforms (Cursor, etc.) — emit only additional_context
+ cat <<EOF
+{
+ "additional_context": "${session_context}"
+}
+EOF
+fi
exit 0