Skip to main content

build_claude_command

Function build_claude_command 

Source
pub fn build_claude_command(
    binary: &Path,
    prompt: &str,
    json_schema: &str,
    model: Option<&str>,
    max_turns: u32,
) -> Command
Expand description

Builds a Command for claude -p with least-privilege environment.

G28-A (v1.0.68): respects SQLITE_GRAPHRAG_CLAUDE_EMPTY_CONFIG_DIR as a directory that exists but is empty; when set, we export it as CLAUDE_CONFIG_DIR so Claude Code loads no user-scoped MCP servers (and no settings.json hooks). This cuts the typical 8-10 MCP process tree to zero. When the env var is unset, behaviour is unchanged.

We deliberately do NOT pass --strict-mcp-config or --mcp-config '{}' because GitHub issue anthropics/claude-code#10787 documents that Claude Code CLI ignores both flags and always falls back to ~/.mcp.json regardless. The CLAUDE_CONFIG_DIR env var is the only mechanism upstream actually honours.