claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Code Mode reads files with one Read call each instead of scanning them inside the script (about 2.4x slower in a test)

Open Helban opened this issue 2 weeks ago • 0 comments

Claude Code 2.1.327, Opus 5.5, auto mode, WSL2. I ran the same prompt twice, each time in a fresh session: once as usual and once with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. Both tasks were read-only scans over a few hundred small Markdown files. Times below are the turn times shown in the terminal, costs come from /cost.

Task 1 was finding dead [[wiki]] links in 432 files. Without Code Mode, Claude did the scan in one python3 -c (3 Bash calls in total) and finished in 40 s for $0.58. With Code Mode, it made 742 Read calls and took 1 min 36 s for $0.62. Both runs found the same 18 dead links.

Task 2 was filtering the headers of 579 files. Without Code Mode it took 3 Bash calls and one Read, 40 s. With Code Mode it took 583 Read calls, 1 min 41 s and $0.83 (I didn't capture /cost for the plain run). Both runs returned the same 26 entries.

That's one run per variant, so the timings are rough, but the gap is large. My guess is that the time goes into the per-call permission checks and PreToolUse hooks, since every Read passes through them. I haven't measured that part. The model seems to use Code Mode to issue many tool calls from one script, when the faster move here is to do the whole scan inside the script. On a setup with hooks, that makes Code Mode slower than the plain mode for this kind of task.

Helban avatar Nov 18 '26 20:11 Helban