No documentation exists for CLAUDE_CODE_SHELL_PREFIX

Status Fixed / completed
Maintainer reply ✓ Yes — catherinewu
Activity 3 comments · opened Jul 25, 2025 · closed Dec 2, 2025
💡 Likely answer: A maintainer (catherinewu, contributor) responded on this thread — see the highlighted reply below.

I see it mentioned in the release notes, but CLAUDE_CODE_SHELL_PREFIX is not in the documentation anywhere. I think this should be documented.

View original on GitHub ↗

3 Comments

ooo27 · 1 year ago

Allows you to wrap invoked bash commands in a script. For example, you want to log every command Claude invokes:

Consider this log_and_run.sh script:

```#!/bin/bash
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> log.txt
eval "$*"


Then in your shell 
`export CLAUDE_CODE_SHELL_PREFIX=./log_and_run.sh`

Launch Claude.
"Run an arbitrary non-destructive bash command"

> ● I'll run a non-destructive command to check the system date and time.
> 
> ● Bash(date)
>   ⎿  Tue Aug 12 16:48:08 PDT 2025
> 
> ● The current date and time is Tuesday, August 12, 2025, 4:48 PM PDT.

Produces `log.txt` with

`[2025-08-12 16:48:08] source /home/<redacted>/.claude/shell-snapshots/snapshot-bash-1755042239230-87cw6n.sh && eval date \< /dev/null && pwd -P >| /tmp/claude-13a4-cwd`

Also works with -p. 

`claude -p "Run an quick idempotent bash command."`

Adds a line to log.txt:

`[2025-08-12 16:53:55] source /home/<redacted>/.claude/shell-snapshots/snapshot-bash-1755042830662-kkud8z.sh && eval pwd \< /dev/null && pwd -P >| /tmp/claude-f1d0-cwd`
catherinewu contributor · 10 months ago

thanks for reporting! i just added CLAUDE_CODE_SHELL_PREFIX to the docs. should be live in the next few days!

github-actions[bot] · 10 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.