Description
Auto-approve patterns in settings.json and agent auto_approve_patterns frontmatter fail to match multiline commands containing heredocs or newlines.
Reproduction
- Add pattern to settings.json:
"permissions": {
"allow": [
"Bash(echo '"
]
}
- 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
- Expected: Command auto-approves (prefix matches)
- 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:
- Match patterns against first line only (before first newline)
- Document that multiline commands cannot be auto-approved
- Add a flag for multiline pattern matching
Description
Auto-approve patterns in
settings.jsonand agentauto_approve_patternsfrontmatter fail to match multiline commands containing heredocs or newlines.Reproduction
Patterns Tested (all failed)
Bash(echo '- pure prefixBash(echo:*)- colon wildcardBash(echo *)- space wildcardBash(cat > /tmp/*)- with redirectauto_approve_patternsImpact
Environment
~/.claude/settings.jsonand agent frontmatterSuggested Fix
Either: