[BUG] Bash tool's heredoc commit format triggers approval prompt on every commit regardless of auto-accept settings
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?
The Bash tool's system prompt instructs Claude to format all commit messages using a $() heredoc pattern:
git commit -m "$(cat <<'EOF'
Commit message here.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
EOF
)"
Problem: This $() command substitution causes every git commit to require manual user approval, even when the user has auto-accept enabled. The shell substitution is presumably flagged as
potentially dangerous, bypassing the auto-accept setting.
Note: Trying to work around this with instructions in claude.md doesn't help
What Should Happen?
Expected behavior: Commits should respect auto-accept settings. The built-in example should use a format that doesn't trigger approval prompts, such as multiple -m flags or git commit -F
<file>.
Error Messages/Logs
Steps to Reproduce
- Make a code change
- Ask Claude to commit
- Claude generates a commit using the built-in heredoc pattern: git commit -m "$(cat <<'EOF' ... EOF)"
- User is prompted for approval even with "Accept edits" enabled
- This happens on every commit with no way to avoid it, since the Bash tool's system prompt hardcodes this format
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.69
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
6 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
This is the same root cause as #31117 — the Bash tool's
descriptionfield contains hardcoded heredoc templates for bothgit commitandgh pr createthat use$(cat <<'EOF' ... EOF), which triggers the command substitution approval prompt regardless of auto-accept settings.See my detailed comment on #31117 for the specific system prompt text, why CLAUDE.md overrides don't reliably work, workarounds, and a suggested fix.
tl;dr: The Bash tool description says
ALWAYS pass the commit message via a HEREDOC. This fights project-level instructions and triggers approval prompts on every commit and PR creation. Fix: replace the heredoc examples withgit commit -F <file>andgh pr create --body-file <file>.My workarounds appear to be successful, both in tandem:
Git Commit went through without prompt with a deny-retry cycle
We have a pre tool use hook that denies the permission-prompting syntax with a message that remind claude to do it the "better" way, using a temp file
This was achieved with a PreToolUse hook
the script specifically targets these two forms to avoid over-firing
Pull Request went through without prompt
We updated our pull request skill:
and this was respected
The
$()heredoc pattern triggers a safety heuristic that can't be suppressed via settings. A PreToolUse hook can auto-approve git commits specifically:The hook matches on
git commitas the first line, so both the heredoc format and simple-m "message"format are auto-approved. The$()substitution is irrelevant to the hook — it only looks at the command name, not the shell syntax.This was fixed in v2.1.71 — Fixed false-positive permission prompts for compound bash commands containing heredoc commit messages (e.g. git commit -m "$(cat <<'EOF'...)"). If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.