Skip to content
BENIBIX Learn

CLAUDE_CODE_SHELL_PREFIX

AI⌨️ Claude CodeConfiguration

Also known as CLAUDE_CODE_SHELL_PREFIX=/path/to/logger.sh

It wraps each shell command in a tool of yours, often a log.

Think of it like

It is like a guard at the door. The guard writes down each one who walks in.

Example

Lucy's team must keep a record of each command an AI runs. She points this at a small logger script.

Why it matters

It gives one place to see, log or block each command. The commands stay the same.

Definition

CLAUDE_CODE_SHELL_PREFIX names a program that wraps each shell command Claude Code starts. That covers Bash tool calls, hooks, the status line and the start of local MCP servers. The program gets the whole command as one value in $1. It must run it again, for example with exec bash -c "$1". It is mostly used to log or check commands.

Example code

bash
#!/bin/bash
# logger.sh
echo "$(date) $1" >> ~/claude-commands.log
exec bash -c "$1"
A wrapper that logs, then runs the command.
The prefix is the outer box.

Common mistake

Running $1 as if it were a program name. MCP servers that pass extra words then break.

Key takeaways

  1. 1
    Wraps each command. Bash, hooks, MCP.
  2. 2
    Command in $1. As one value.
  3. 3
    Run it again. bash -c "$1".

Compare