From 1031f8591362b10d9f933121987aa719704e6e8f Mon Sep 17 00:00:00 2001 From: cmj Date: Tue, 6 Oct 2026 10:49:20 +0800 Subject: [PATCH] fix(shortcut): dispatch magic words only from the user's own prompt A subagent's report, a background-task event and a message from another session all reach UserPromptSubmit as a prompt. A magic word in one was written by a model, yet the hook told the session to run its skill: `afk mode` fired twice from reports about the afk skill. Skip a prompt that opens with one of the frames Claude Code puts on such text. Matching is on the opening only, so a user who mentions a frame mid-sentence still gets their word dispatched. Bump the plugin and the marketplace to 3.2.1. Closes #47 Co-Authored-By: Claude Opus 5.5 --- .claude-plugin/marketplace.json | 4 ++-- plugins/wisdom/.claude-plugin/plugin.json | 2 +- plugins/wisdom/hooks/shortcut-prompt.py | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 6a96390..0319aab 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -1,6 +1,6 @@ { "name": "wisdom", - "version": "3.2.0", + "version": "3.2.1", "owner": { "name": "cmj", "url": "https://github.com/cmj0121" @@ -9,7 +9,7 @@ { "name": "wisdom", "description": "Single-purpose skills to plan, build, review and ship software, led by smith.", - "version": "3.2.0", + "version": "3.2.1", "source": "./plugins/wisdom" } ] diff --git a/plugins/wisdom/.claude-plugin/plugin.json b/plugins/wisdom/.claude-plugin/plugin.json index 536396b..b2b3860 100644 --- a/plugins/wisdom/.claude-plugin/plugin.json +++ b/plugins/wisdom/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "wisdom", "description": "Single-purpose skills to plan, build, review and ship software, led by smith.", - "version": "3.2.0", + "version": "3.2.1", "license": "MIT", "author": { "name": "cmj", diff --git a/plugins/wisdom/hooks/shortcut-prompt.py b/plugins/wisdom/hooks/shortcut-prompt.py index ed54159..10d1a8d 100644 --- a/plugins/wisdom/hooks/shortcut-prompt.py +++ b/plugins/wisdom/hooks/shortcut-prompt.py @@ -5,7 +5,7 @@ (`metadata.shortcut` in their frontmatter) and, on a hit, tells the model which skill to run. Dispatch therefore no longer depends on the model choosing to run the `shortcut` skill, and no skill file is read at the model's expense. -Silent no-op when no word matches. +Silent no-op when no word matches, or when the prompt is not the user's own text. """ import glob import json @@ -13,6 +13,18 @@ import re import sys +# How Claude Code opens a prompt the user did not type: a subagent's report, a +# background-task event, a message from another session. A magic word in one +# is something a model wrote, so it must not dispatch a skill. +NOT_USER = ( + "Another Claude session sent a message:", + "`; user and project ones bare. def sources(cwd, plugin_root): @@ -56,6 +68,8 @@ def main() -> int: # tell the model to run what it is running. if not prompt.strip() or prompt.lstrip().startswith("/"): return 0 + if prompt.lstrip().startswith(NOT_USER): + return 0 cwd = data.get("cwd") or os.environ.get("CLAUDE_PROJECT_DIR") or os.getcwd() plugin_root = os.environ.get("CLAUDE_PLUGIN_ROOT") or os.path.dirname(os.path.dirname(__file__))