Skip to content

[Bug] Auto-approve patterns don't match multiline commands (heredocs) #11932

@michaelgrafwebdev

Description

@michaelgrafwebdev

Description

Auto-approve patterns in settings.json and agent auto_approve_patterns frontmatter fail to match multiline commands containing heredocs or newlines.

Reproduction

  1. Add pattern to settings.json:
"permissions": {
  "allow": [
    "Bash(echo '"
  ]
}
  1. Run a command that starts with that prefix but contains newlines:
echo 'chore: Update files

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>' > /tmp/file.txt
  1. Expected: Command auto-approves (prefix matches)
  2. Actual: Prompts for approval

Patterns Tested (all failed)

  • Bash(echo ' - pure prefix
  • Bash(echo:*) - colon wildcard
  • Bash(echo *) - space wildcard
  • Bash(cat > /tmp/*) - with redirect
  • Agent frontmatter auto_approve_patterns

Impact

  • Cannot auto-approve git commit workflows that use multiline messages
  • Subagents always prompt for heredoc commands
  • Breaks autonomous agent workflows

Environment

  • Claude Code v2.0.30
  • macOS
  • Pattern location: ~/.claude/settings.json and agent frontmatter

Suggested Fix

Either:

  1. Match patterns against first line only (before first newline)
  2. Document that multiline commands cannot be auto-approved
  3. Add a flag for multiline pattern matching

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions