From 9a681f87427c5af32a4d555066da7a5505db6c47 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 27 Feb 2026 21:01:57 +0100 Subject: [PATCH] refactor(hooks): move blast radius guidance from PreToolUse to session start Move the Edit blast radius check from a per-call PreToolUse prompt hook to the session start context. This is more efficient (injected once vs on every Edit call) and the guidance is static behavioral instruction that doesn't need runtime parameter inspection. - Remove PreToolUse Edit matcher and prompt hook - Delete hooks/pre-tool-use-edit-blast-radius/ - Add blast radius guidance to session start base_context Co-Authored-By: Claude Opus 4.6 --- .claude-plugin/plugin.json | 9 --------- hooks/pre-tool-use-edit-blast-radius/prompt.txt | 5 ----- hooks/session-start/script.sh | 2 ++ 3 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 hooks/pre-tool-use-edit-blast-radius/prompt.txt diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index c42ac26..6b978c6 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -37,15 +37,6 @@ "command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-tool-use-traversal/script.sh" } ] - }, - { - "matcher": "Edit", - "hooks": [ - { - "type": "prompt", - "prompt": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-tool-use-edit-blast-radius/prompt.txt" - } - ] } ] } diff --git a/hooks/pre-tool-use-edit-blast-radius/prompt.txt b/hooks/pre-tool-use-edit-blast-radius/prompt.txt deleted file mode 100644 index b1461ab..0000000 --- a/hooks/pre-tool-use-edit-blast-radius/prompt.txt +++ /dev/null @@ -1,5 +0,0 @@ -Check the file_path in this Edit tool call. If the file appears to be in a critical integration, infrastructure, or shared middleware path based on its location (e.g. directories named integrations, middleware, connectors, adapters, clients, providers, gateway, or similar), AND is NOT a test file or mock, then respond with: - -"This file appears to be in a shared integration or infrastructure path. Consider querying OpenTrace (search_nodes, get_neighbors, traverse_dependencies) to understand the blast radius — which services depend on this component and what downstream effects this change may have." - -Otherwise, respond with an empty string. \ No newline at end of file diff --git a/hooks/session-start/script.sh b/hooks/session-start/script.sh index 8c56793..8b9f62c 100755 --- a/hooks/session-start/script.sh +++ b/hooks/session-start/script.sh @@ -99,6 +99,8 @@ Proactively query OpenTrace (search_nodes, get_neighbors, traverse_dependencies) - Asks about dependencies, impact, blast radius, or upstream/downstream effects - Involves editing code that integrates with external services or shared middleware +When about to edit files in shared integration or infrastructure paths (e.g. directories named integrations, middleware, connectors, adapters, clients, providers, gateway, or similar) that are NOT test files or mocks, consider querying OpenTrace (search_nodes, get_neighbors, traverse_dependencies) first to understand the blast radius — which services depend on this component and what downstream effects the change may have. + After receiving OpenTrace tool results, automatically call the most useful follow-up tool to deepen the exploration rather than stopping to ask the user what to do next. Choose the follow-up based on which tool just ran: - search_nodes or query_nodes → call get_neighbors on the most relevant node - get_node → call get_neighbors or traverse_incoming/traverse_outgoing to understand the node's role