Approving heredoc/complex bash commands creates invalid permission entries that break settings file

Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Feb 2, 2026 · closed Feb 5, 2026

Summary

When approving bash commands containing heredocs or special characters, Claude Code adds the literal full command to settings.local.json instead of a valid pattern. These malformed entries fail validation on next session load, causing the entire settings file to be skipped.

Environment

  • Claude Code version: latest
  • macOS: Darwin 25.3.0

Reproduction

  1. Run a command like:

```bash
git commit -m "$(cat <<'EOF'
Some commit message

Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
```

  1. Approve when prompted
  2. Check .claude/settings.local.json - the literal command is added to permissions.allow
  3. Next session shows settings error and skips the file

Actual Behavior

The full literal command gets added:

"Bash(git commit -m \"$\\(cat <<''EOF''\nSome commit message\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")"

This fails validation with:

The : pattern must be at the end. Move : to the end for prefix matching, or use * for wildcard matching.

The error occurs because colons (:) appear in the command body, not as the :* suffix pattern.

Expected Behavior

Either:

  1. Normalize complex commands to a valid prefix pattern (e.g., Bash(git commit:*))
  2. Or don't add commands that can't be represented as valid patterns
  3. Or support a different escaping/quoting mechanism for literal commands

Impact

  • Users silently lose all project settings (the error is shown but easy to miss)
  • Accumulated permissions from previous sessions are lost
  • Users must manually edit the JSON to fix it

---
🤖 Generated with Claude Code

View original on GitHub ↗

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