Repository navigation
Send the SessionStart context from a command hook (0.6.1) - #12
Merged
Merged
Conversation
The model never got the code-mode line at session start. Claude Code's built-in security module skips a hooks module's classic.SessionStart; the debug log says "retroagent+code-mode: classic.SessionStart bypassed by cc-plugin-sec-default (tier user); beneath runs". Command hooks in hooks.json still run. - hooks/session-start.sh prints the line as hookSpecificOutput.additionalContext. It reads blockDirectMcp from CLAUDE_PLUGIN_OPTION_BLOCKDIRECTMCP. - The module handler and sessionContext are removed, so the model cannot get the line twice if a later Claude Code runs module handlers again. - The sandbox test runs the real script in both option states. The fake host has no security module, so its SessionStart tests passed and could not find this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The model never gets the code-mode instruction at session start ("use run_code for MCP tool calls…"). This is true in normal sessions and in headless runs.
Claude Code 2.1.296 has a built-in security module,
cc-plugin-sec-default. It handlesclassic.*events before the plugin modules. For SessionStart, it skips the user-tier modules. The debug log of every run says:code-mode added its line in a module handler (
on('classic.SessionStart', …)), so the line was lost. Command hooks inhooks.jsonstill run: retroagent'skbline comes from one and reaches the model.What this PR does
hooks/session-start.sh: a command hook inhooks/hooks.json. It prints the line ashookSpecificOutput.additionalContext. It readsblockDirectMcpfromCLAUDE_PLUGIN_OPTION_BLOCKDIRECTMCP, which Claude Code sets for an option that is set.sessionContextare removed. If a later Claude Code version runs module handlers again, the model does not get the line twice.tests/runner.integration.mjsruns the real script in both option states.CODING_STANDARDS.mdhas the rule, anddocs/development.mdxhas the new file.Evidence
Before (0.6.0):
--restrictedwith--plugin-dir;--plugin-diralone;Probe: a temporary command hook printed a test line. The line reached the transcript, and the hook's environment had
CLAUDE_PLUGIN_OPTION_BLOCKDIRECTMCP=true,CLAUDE_PLUGIN_ROOTandCLAUDE_PLUGIN_DATA.After (this branch), 2 headless Haiku runs:
code-mode: use run_code for MCP tool calls, …in the SessionStart context (hook_additional_context).blockDirectMcp: truehascode-mode: call MCP tools only from run_code, … Direct MCP tool calls are denied.Hook SessionStart (sh "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh") provided additionalContext.retroagent.Checks:
claude plugin test .(114 pass, 0 fail),node tests/runner.integration.mjs,node tests/docs.check.mjs,tests/version.check.mjs(0.6.0 → 0.6.1),tscandclaude plugin validate .all pass.Open point
The projection bench blocked direct calls, so its numbers do not depend on this fix. How often the model calls MCP tools directly when it has the instruction is not measured yet.
🤖 Generated with Claude Code