Environment: context-mode v1.0.162, Claude Code (plugin install), Linux
Description
On Claude Code, the PreToolUse/PostToolUse hooks fire on every Bash invocation and every WebFetch/curl/wget call regardless of expected output size, redirecting the model toward ctx_batch_execute / ctx_execute_file / ctx_fetch_and_index even for outputs of a few hundred bytes to a few KB.
This contrasts with the Gemini CLI integration, whose README explicitly restricts the BeforeTool matcher to "tools that produce large output... avoids unnecessary hook overhead on lightweight tools."
Evidence (3 A/B tests on a ~137K LOC backend repo)
-
git log --stat -30 (~6-7KB raw output) via plain Bash vs ctx_batch_execute (same command + 2 queries): the batch call returned 18.1KB to context — more than the direct command — while padding the "without context-mode" baseline by +36KB (largely duplicated content across the two queries). The reported "51% kept out" ratio is an artifact of that inflated baseline.
-
Direct Read (offset/limit) of a 41-line function (~870B): zero context-mode overhead, zero captures — correct, matches the tool's own "small file → Read directly" guidance.
-
Same 41-line function via ctx_execute_file: added +1KB to context (echoes the executed snippet plus the result), added a "sandbox" capture, and the "kept out" ratio actually dropped 51%→50%.
-
curl/wget to fetch a small README is hard-blocked with no size check, forcing ctx_fetch_and_index even when a direct fetch would return a small, immediately-useful payload.
Suggested fix
Add a size-aware threshold to the Claude Code hook config (e.g., only intercept Bash/WebFetch when expected/observed output exceeds ~X KB), mirroring the Gemini CLI BeforeTool matcher design. This would let small commands and small file reads pass through untouched, reserving the ctx_* sandbox tools for genuinely large outputs where they deliver the documented savings.
🤖 Filed with Claude Code
Environment: context-mode v1.0.162, Claude Code (plugin install), Linux
Description
On Claude Code, the
PreToolUse/PostToolUsehooks fire on everyBashinvocation and everyWebFetch/curl/wgetcall regardless of expected output size, redirecting the model towardctx_batch_execute/ctx_execute_file/ctx_fetch_and_indexeven for outputs of a few hundred bytes to a few KB.This contrasts with the Gemini CLI integration, whose README explicitly restricts the
BeforeToolmatcher to "tools that produce large output... avoids unnecessary hook overhead on lightweight tools."Evidence (3 A/B tests on a ~137K LOC backend repo)
git log --stat -30(~6-7KB raw output) via plain Bash vsctx_batch_execute(same command + 2 queries): the batch call returned 18.1KB to context — more than the direct command — while padding the "without context-mode" baseline by +36KB (largely duplicated content across the two queries). The reported "51% kept out" ratio is an artifact of that inflated baseline.Direct
Read(offset/limit) of a 41-line function (~870B): zero context-mode overhead, zero captures — correct, matches the tool's own "small file → Read directly" guidance.Same 41-line function via
ctx_execute_file: added +1KB to context (echoes the executed snippet plus the result), added a "sandbox" capture, and the "kept out" ratio actually dropped 51%→50%.curl/wgetto fetch a small README is hard-blocked with no size check, forcingctx_fetch_and_indexeven when a direct fetch would return a small, immediately-useful payload.Suggested fix
Add a size-aware threshold to the Claude Code hook config (e.g., only intercept
Bash/WebFetchwhen expected/observed output exceeds ~X KB), mirroring the Gemini CLIBeforeToolmatcher design. This would let small commands and small file reads pass through untouched, reserving thectx_*sandbox tools for genuinely large outputs where they deliver the documented savings.🤖 Filed with Claude Code