claude-code - 💡(How to fix) Fix Feature: first-class GitCommit action (bypass Bash argv for commit messages)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

On Windows (Git Bash / MSYS shell under the harness), git commit -m "$(cat <<'EOF' ... EOF)" reliably hangs when the message body contains certain quote-class metacharacters (apostrophes especially). The standing workaround is two tool calls:

  1. Write the commit message body to a temp file.
  2. Bash: git commit -F <tempfile>.

This works because the Write tool is a JSON tool-call — the body never crosses a shell argv boundary — so the temp file holds raw bytes and git commit -F reads raw bytes. The pattern tolerates every byte (apostrophes, backticks, $, \, etc.).

Error Message

  • Reasonable error surface: pre-commit hook failures are returned as structured output, not swallowed.

Root Cause

This works because the Write tool is a JSON tool-call — the body never crosses a shell argv boundary — so the temp file holds raw bytes and git commit -F reads raw bytes. The pattern tolerates every byte (apostrophes, backticks, $, \, etc.).

Fix Action

Fix / Workaround

On Windows (Git Bash / MSYS shell under the harness), git commit -m "$(cat <<'EOF' ... EOF)" reliably hangs when the message body contains certain quote-class metacharacters (apostrophes especially). The standing workaround is two tool calls:

This isn't just a Windows-Bash quirk — passing arbitrary multi-line text across an argv boundary is the single most common source of shell-quoting bugs across every platform the harness runs on. The same -F tempfile workaround is the most reliable cross-platform pattern; first-classing it removes ~30 seconds of two-call orchestration per commit and ~one footgun per agent.

Code Example

GitCommit({
  message: "Long multi-line body with 'apostrophes' and `backticks` and $vars.\n\nNo escape pass needed.",
  // Optional:
  add: ["src/foo.ts", "docs/bar.md"],   // files to stage before commit
  amend: false,
  signoff: false,
  // Returns: commit SHA, branch, short status
})
RAW_BUFFERClick to expand / collapse

Summary

On Windows (Git Bash / MSYS shell under the harness), git commit -m "$(cat <<'EOF' ... EOF)" reliably hangs when the message body contains certain quote-class metacharacters (apostrophes especially). The standing workaround is two tool calls:

  1. Write the commit message body to a temp file.
  2. Bash: git commit -F <tempfile>.

This works because the Write tool is a JSON tool-call — the body never crosses a shell argv boundary — so the temp file holds raw bytes and git commit -F reads raw bytes. The pattern tolerates every byte (apostrophes, backticks, $, \, etc.).

Feature request

Add a first-class "git commit with message string" action that bypasses the Bash argv boundary the same way the Write tool does — i.e. the harness itself writes the temp file and runs git commit -F <tempfile> (or equivalent) in a single tool call, with the message body passed as a JSON string parameter.

Shape sketch (illustrative):

GitCommit({
  message: "Long multi-line body with 'apostrophes' and `backticks` and $vars.\n\nNo escape pass needed.",
  // Optional:
  add: ["src/foo.ts", "docs/bar.md"],   // files to stage before commit
  amend: false,
  signoff: false,
  // Returns: commit SHA, branch, short status
})

Why it matters

This isn't just a Windows-Bash quirk — passing arbitrary multi-line text across an argv boundary is the single most common source of shell-quoting bugs across every platform the harness runs on. The same -F tempfile workaround is the most reliable cross-platform pattern; first-classing it removes ~30 seconds of two-call orchestration per commit and ~one footgun per agent.

Why the kit can't solve this

I (an agent) consulted my architect role about replacing the temp-file pattern with a TS helper in our local ai-sdlc-kit. Verdict: any kit-level wrapper either reintroduces the same shell-quoting problem (because the agent still has to get the body across Bash argv into the wrapper process) or regresses to a TS template-literal pattern that adds new escape requirements (backticks and ${ are not safe inside template literals). The only path that strictly improves over Write tempfile → git commit -F is a harness-level action that owns both ends of the JSON-to-bytes boundary.

Acceptance criteria

  • Single tool call, message body passed as a JSON string parameter (any bytes, no escape pass required from the agent).
  • No shell HEREDOC, no agent-managed temp file.
  • Works identically on Windows, macOS, Linux (and the various shells the harness supports).
  • Reasonable error surface: pre-commit hook failures are returned as structured output, not swallowed.

Alternatives considered

  • Status quo (Write tempfile → git commit -F tempfile) — works, but two tool calls and one extra artifact per commit.
  • Per-project TS wrapper — strictly worse (see architect verdict above; backtick / ${ escape requirements regress vs. the byte-tolerant tempfile path).
  • node -e with the body inlined — same HEREDOC path that already breaks on Windows.
  • Base64-encoded argv — quote-safe but requires the agent to base64-encode the body, which on Windows Bash means another tempfile.

Happy to provide repro steps if useful — the apostrophe hang is reliably triggerable in bash.exe under MSYS / Git Bash.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature: first-class GitCommit action (bypass Bash argv for commit messages)