STACKS
As of +30 days +90 days +1 yearToday
python3-in-claude-code
0 within valid-until
13 past it, not rechecked

Whether to replace the python3 that Claude Code uses in Bash (jq, uv, bun, Edit)

How often and for what Claude Code reaches for python3 in Bash calls, what the alternatives are and whether a switch pays off; with a measurement on the author's transcripts from November 2026.

It is not worth changing the interpreter. Python is the model's default choice, not a result of configuration: with no language named the agent writes Python c4, and the surplus code comes from the agent's habits, not from the language c5. Anthropic itself treats code written by the agent as a way to a leaner context c11.

A local measurement of 19 November 2026 (14 days of the author's transcripts […]): python is in 23.2% of Bash calls, its errors are as frequent as in the rest of Bash (2.6%), and process start takes 21 ms against 5 ms for jq. Switching to jq, bun, uv or Ruby therefore gives milliseconds and a fraction of a percent of tokens. In other people's data there is less python but it takes more time c6; in the author's case it is the other way round, because these are short edits.

The only switch that changes anything is Edit instead of a script for replacements in existing files: in the measurement about 46% of inline code is such edits, and about 72% of all replacements go through them. A script bypasses diff review c3, the deny rules for Read and Edit do not cover it c2, and rewind will not restore a file changed only through Bash c13. 40% of the scripts have no assertion on the number of matches, so a replacement that misses ends silently. The recommendation of 19 November 2026: leave it; if the author wants diffs and rewind, one line in CLAUDE.md (Edit for existing files, a script only for a mechanical change across many files and always with an assertion).

How to enforce it, should that be needed: an instruction in CLAUDE.md alone works unreliably, a PreToolUse hook is more dependable c8, but an account on HN says subagents reached for python anyway c12. In the author's sessions subagents make 65% of the calls with python.

uv: it manages environments for scripts by itself c9, which would solve the dependence on conda base (python3 is miniforge with 443 packages), but a missing module occurred 16 times in 14,565 calls. It does not change permissions, because a broad rule on uv run covers any Python code c10, and python is not among the listed read-only commands c1.

For one's own CLIs, a command that returns the finished answer matters more than the scripting language: after such a redesign the model stopped assembling pipelines of jq and python c7.

Claims

In our words

In the source's words

c1checked on 19 Nov 2026not rechecked since 19 Dec 2026

Claude Code has a built-in, non-configurable set of read-only commands; the documentation lists among them ls, cat, grep, find and the read-only forms of git.

The set includes `ls`, `cat`, `echo`, `pwd`, `head`, `tail`, `grep`, `find`, `wc`, `which`, `diff`, `stat`, `du`, `cd`, and read-only forms of `git`. The set is not configurable

code.claude.com · T1

c2checked on 19 Nov 2026not rechecked since 19 Dec 2026

The deny rules for Read and Edit do not cover a Python or Node script that opens files itself.

They also don’t apply to arbitrary subprocesses that read or write files indirectly, like a Python or Node script that opens files itself.

code.claude.com · T1

c3checked on 19 Nov 2026not rechecked since 19 Dec 2026

Editing files through a python3 heredoc or sed -i in Bash bypasses the diff review that the Edit and Write tools give.

In manual permission mode, file modifications made through the **Bash tool** (e.g. a `python3` heredoc or `sed -i` performing string replacements) bypass the per-edit diff review that the Edit/Write tools provide.

github.com · T4

c4checked on 19 Nov 2026not rechecked since 19 Dec 2026

With no instruction about the language the agent chooses Python: 10 of 10 runs in a practitioner's measurement.

All ten wrote Python.

dev.to · T2

c5checked on 19 Nov 2026not rechecked since 19 Dec 2026

Most of the surplus code in Python is the agent's habits (docstring, main, guard), not the language itself.

Most of that 120% is not the language, it is what the agent wraps around it: the docstring, the `main()`, the `if __name__` guard, the line-ending bookkeeping.

dev.to · T2

c6checked on 19 Nov 2026not rechecked since 19 Dec 2026

In the TraceLab traces python is 3.7% of the programs Claude runs, but more than half of the total execution time.

For Claude, `python` accounts for only 3.7% of executable invocations but more than half of the total observed execution time.

syfi.cs.washington.edu · T2

c7checked on 19 Nov 2026not rechecked since 19 Dec 2026

After flags that return the finished answer were added to the Infracost CLI, the model stopped assembling pipelines of jq, python, sort and wc and called one command.

the model stopped writing pipelines. Where it had been chaining `jq`, `python`, `sort`, and `wc`, it produced a single `infracost inspect` invocation that returned the answer directly.

infracost.io · T2

c8checked on 19 Nov 2026not rechecked since 19 Dec 2026

An instruction in CLAUDE.md alone is not enough to stop Claude reaching for bare python; a PreToolUse hook is effective.

This is more reliable than CLAUDE.md instructions because it’s enforcement, not suggestion.

mcginniscommawill.com · T4

c9checked on 19 Nov 2026not rechecked since 19 Dec 2026

uv manages virtual environments for the scripts it runs by itself.

uv automatically manages virtual environments for you

docs.astral.sh · T1

c10checked on 19 Nov 2026not rechecked since 19 Dec 2026

A broad permission rule Bash(uv run *) covers the execution of any Python code.

A broad `Bash(uv run *)` rule includes arbitrary Python execution

pydevtools.com · T3

c11checked on 19 Nov 2026not rechecked since 19 Dec 2026

Anthropic describes code execution by the agent as a way to a leaner context, among other things by filtering data before it reaches the model.

Code execution with MCP enables agents to use context more efficiently by loading tools on demand, filtering data before it reaches the model, and executing complex logic in a single step.

anthropic.com · T2

c12checked on 19 Nov 2026not rechecked since 19 Dec 2026

A hook that blocks python -c in the main session does not stop subagents (a user's account on HN).

It can still invoke them in subagents and does this.

news.ycombinator.com · T4

c13checked on 19 Nov 2026not rechecked since 19 Dec 2026

Rewind does not restore a file that only Bash commands changed; that takes Git.

A file that only Bash commands changed isn’t tracked and stays as it is. To revert it, use version control, such as Git.

code.claude.com · T1

This card

Last checked on 19 Nov 2026. As data: JSON, Markdown. A claim's permanent address is its number: stacks.jakubdudek.com/python3-in-claude-code/c1.