[BUG] Write tool permissions not respected when using --settings flag in non-interactive mode

Resolved 💬 3 comments Opened Dec 9, 2025 by stbenjam Closed Dec 9, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When running Claude Code CLI with a settings file that explicitly allows the Write tool via permissions.allow, the Write tool still requests permission and fails in non-interactive mode (--output-format=stream-json).

What Should Happen?

File shout be written to disk

Error Messages/Logs

+ claude --verbose --output-format=stream-json --settings=/var/folders/XX/XXXXXXXXXXXXXXXXXXXXXXXX/T/tmp.XXXXXXXXXX -p 'Please write a simple test file to claude-test-XXXXXXXXXX.html with the content '\''<html><body>Test successful</body></html>'\'' using the Write tool.'
{"type":"system","subtype":"init","cwd":"/Users/user/project","session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","tools":["Task","AgentOutputTool","Bash","Glob","Grep","ExitPlanMode","Read","Edit","Write","NotebookEdit","WebFetch","TodoWrite","WebSearch","BashOutput","KillShell","Skill","SlashCommand","EnterPlanMode"],"mcp_servers":[],"model":"claude-sonnet-4-5-20250929","permissionMode":"default","slash_commands":["<REDACTED>"],"apiKeySource":"none","claude_code_version":"2.0.62","output_style":"default","agents":["general-purpose","statusline-setup","Explore","Plan"],"skills":["<REDACTED>"],"plugins":[{"name":"<REDACTED>","path":"/Users/user/.claude/plugins/cache/<REDACTED>"}],"uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}
{"type":"assistant","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_XXXXXXXXXXXXXXXXXXXXXX","type":"message","role":"assistant","content":[{"type":"text","text":"I'll write the test file for you."}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2,"cache_creation_input_tokens":381,"cache_read_input_tokens":20954,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":381},"output_tokens":4,"service_tier":"standard"},"context_management":null},"parent_tool_use_id":null,"session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}
{"type":"assistant","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_XXXXXXXXXXXXXXXXXXXXXX","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_XXXXXXXXXXXXXXXXXXXXXX","name":"Write","input":{"file_path":"/Users/user/project/claude-test-XXXXXXXXXX.html","content":"<html><body>Test successful</body></html>"}}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2,"cache_creation_input_tokens":381,"cache_read_input_tokens":20954,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":381},"output_tokens":4,"service_tier":"standard"},"context_management":null},"parent_tool_use_id":null,"session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}
{"type":"user","message":{"role":"user","content":[{"type":"tool_result","content":"Claude requested permissions to write to /Users/user/project/claude-test-XXXXXXXXXX.html, but you haven't granted it yet.","is_error":true,"tool_use_id":"toolu_XXXXXXXXXXXXXXXXXXXXXX"}]},"parent_tool_use_id":null,"session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","tool_use_result":"Error: Claude requested permissions to write to /Users/user/project/claude-test-XXXXXXXXXX.html, but you haven't granted it yet."}
{"type":"assistant","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_XXXXXXXXXXXXXXXXXXXXXX","type":"message","role":"assistant","content":[{"type":"text","text":"I've attempted to write the file, but I need your permission first. Please approve the write operation to create the file `claude-test-XXXXXXXXXX.html` with the specified HTML content."}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":6,"cache_creation_input_tokens":166,"cache_read_input_tokens":21335,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":166},"output_tokens":2,"service_tier":"standard"},"context_management":null},"parent_tool_use_id":null,"session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}
{"type":"result","subtype":"success","is_error":false,"duration_ms":6139,"duration_api_ms":12956,"num_turns":2,"result":"I've attempted to write the file, but I need your permission first. Please approve the write operation to create the file `claude-test-XXXXXXXXXX.html` with the specified HTML content.","session_id":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","total_cost_usd":0.02348695,"usage":{"input_tokens":8,"cache_creation_input_tokens":547,"cache_read_input_tokens":42289,"output_tokens":157,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":547,"ephemeral_5m_input_tokens":0}},"modelUsage":{"claude-haiku-4-5-20251001":{"inputTokens":735,"outputTokens":128,"cacheReadInputTokens":0,"cacheCreationInputTokens":0,"webSearchRequests":0,"costUSD":0.001375,"contextWindow":200000},"claude-sonnet-4-5-20250929":{"inputTokens":873,"outputTokens":317,"cacheReadInputTokens":42289,"cacheCreationInputTokens":547,"webSearchRequests":0,"costUSD":0.02211195,"contextWindow":200000}},"permission_denials":[{"tool_name":"Write","tool_use_id":"toolu_XXXXXXXXXXXXXXXXXXXXXX","tool_input":{"file_path":"/Users/user/project/claude-test-XXXXXXXXXX.html","content":"<html><body>Test successful</body></html>"}}],"uuid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"}

Steps to Reproduce

#!/bin/bash
# Minimal reproduction script for Claude Code Write permission bug

set -e
set -x

SETTINGS_FILE=$(mktemp)
trap "rm -f ${SETTINGS_FILE}" EXIT
cat > "${SETTINGS_FILE}" << 'EOF'
{
  "permissions": {
    "allow": [
      "Write(*)",
      "Read(*)"
    ],
    "defaultMode": "acceptEdits"
  }
}
EOF

echo "Settings file created at: ${SETTINGS_FILE}"
echo "Contents:"
cat "${SETTINGS_FILE}"
echo ""

# Test file path
TEST_FILE="claude-test-$(date +%s).html"

echo "Testing Write permission with settings file..."

# Run claude with settings
claude --verbose --output-format=stream-json --settings="${SETTINGS_FILE}" \
  -p "Please write a simple test file to ${TEST_FILE} with the content '<html><body>Test successful</body></html>' using the Write tool."

# Check result
if [[ -f "${TEST_FILE}" ]]; then
    echo ""
    echo "✅ SUCCESS: File was created at ${TEST_FILE}"
    cat "${TEST_FILE}"
    rm -f "${TEST_FILE}"
else
    echo ""
    echo "❌ FAILURE: File was NOT created at ${TEST_FILE}"
    echo "This demonstrates the bug: Write(*) permission in settings.json is not respected."
    exit 1
fi

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.62

Platform

Google Vertex AI

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗