NewsCrawler.org

Counting how often Claude Code's auto mode blocks tool calls

Claude Code の auto mode に止められた操作を、会話ログから数える
Image: zenn.dev

Claude Code's auto mode[1] lets the agent keep working without permission prompts while a separate classifier[2] inspects each operation and stops the ones it judges dangerous, and the interface gives no count of how often this happens. A developer wrote a small script that counts these blocked tool calls[3] from the conversation logs, which are stored as JSONL[4] files under ~/.claude/projects/ with one JSON object per line, plus subagent logs in a subagents/ subfolder. Each denial is recorded as a tool_result entry with is_error: true and a message that names the category in square brackets, and the tool_use_id links it back to the original tool_use — the command or file that was attempted. The script reads only those tool_result blocks instead of searching the full text, because grep commands or the script's own code would otherwise match the same phrase and inflate the count.

On about one month of data (Windows, Claude Code 2.1.296), it counted 19,952 tool calls with 62 denials, about 0.3%; scanning around 300 files totaling several hundred MB took about 10 seconds. By category: Production Deploy 21, denials with no stated reason 9, Irreversible Local Destruction 6, Secret-Store Writes 5, Self-Modification 3, Permission Grant 3, and 15 across 11 other categories. Of the 9 unexplained denials, 6 were script executions related to deployments or permissions and 3 were Write attempts outside the working folder, such as a shell script in a temp folder; edits inside the working directory are approved automatically, while anything outside goes to the classifier.

The Self-Modification cases were edits to .claude/settings.local.json and ~/.claude.json, protected paths that go to the classifier even when permissions.allow contains a matching rule, so asking Claude itself to add an entry to the allow list gets that very edit blocked; the author recommends adding rules manually through /permissions. For recurring denials, the author suggests a narrow allow rule for the specific command, such as Bash(gcloud run deploy *), which removes that command from classifier checks, or a prose description of trusted destinations in autoMode.environment in ~/.claude/settings.json, which cannot be set in the project-side config. Viewing credentials and bulk deletions are correctly blocked and best left as they are, broad rules like Bash(python *) or Bash(*) are disabled in auto mode, and logs are deleted by default after about 30 days, so the countable window is roughly the last month.

Read the original zenn.dev

Sources

  • Zenn JA

    Claude Code の auto mode に止められた操作を、会話ログから数える

    2 likes0 bookmarks0 comments

Published: First seen: Читать по-русски

Open as a page