[Bug] Claude Code passes invalid `--no-stat` flag to `git show` command

Status Open
Maintainer reply None cached
Activity 15 comments · opened Dec 4, 2025

Bug Description

In Claude Code 2.0.58, please know that Claude often tries git show with --no-stat, but there's no such option:

● Bash(git show HEAD --no-stat)
⎿  Error: Exit code 128
fatal: unrecognized argument: --no-stat

This can waste precious context.

Maybe this could be part of the system prompt or some tool config?

Just a suggestion.

Environment Info

  • Platform: linux
  • Terminal: kitty
  • Version: 2.0.58
  • Feedback ID: 83675796-99ee-4502-aeeb-cd20505f0696

Errors

[]

View original on GitHub ↗

15 Comments

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

Ashesh3 · 7 months ago

Still happening.

wahuneke · 7 months ago

This is still happening today, in 2.1.15

dstaple · 7 months ago

Still active as of 2.1.19

TrustySteed · 7 months ago

Just happened to me today...

Version: 2.1.22
Model: opus (claude-opus-4-5-20251101)

<img width="375" height="297" alt="Image" src="https://github.com/user-attachments/assets/31450bfa-98be-4654-b3c7-8bf6875f378c" />

jstasiak · 6 months ago

Happening on 2.1.25 as well (not sure about newer versions, I downgraded because of all the performance issues in 2.1.29).

FWIW including instructions in CLAUDE.md doesn't seem to help:

> cat ~/.claude/CLAUDE.md | rg no-stat
* Git commands don't support the `--no-stat` flag, never use it.
lpgauth · 6 months ago

Very annoying, should be a simple fix.

⏺ Bash(git show e5f9ca9 --no-stat)
  ⎿  Error: Exit code 128
     fatal: unrecognized argument: --no-stat
amgcc · 6 months ago

This continues to be an annoyance and waste of time. If this is a difficult fix, then explain why or just take care of it already.

drmercer-lucid · 6 months ago

As a workaround, you can use a PreToolUse hook to strip that flag from the command. Something like this:

#!/usr/bin/env bash
#
# Claude hook: remove --no-stat from 'git show' calls.
#
# PreToolUse hook that intercepts Bash tool calls and strips --no-stat
# from git show commands, so the diff stat is always shown.
#
# Install like this:
# {
#   "hooks": {
#     "PreToolUse": [
#       {
#         "matcher": "Bash",
#         "hooks": [
#           {
#             "type": "command",
#             "command": "bash /path/to/this/file.sh"
#           }
#         ]
#       }
#     ]
#   }
# }


set -euo pipefail

input=$(cat)

tool_name=$(jq -r '.tool_name // ""' <<< "$input")

# Only handle Bash tool calls
if [[ "$tool_name" != "Bash" ]]; then
  echo '{}'
  exit 0
fi

command=$(jq -r '.tool_input.command // ""' <<< "$input")

# Only handle commands that contain 'git show'
trimmed="${command#"${command%%[![:space:]]*}"}"
if [[ "$trimmed" != git[[:space:]]*show* ]] && [[ "$trimmed" != "git show"* ]]; then
  echo '{}'
  exit 0
fi

# Only act if --no-stat is present
if [[ "$command" != *"--no-stat"* ]]; then
  echo '{}'
  exit 0
fi

# Remove --no-stat (with surrounding whitespace collapsed)
new_command=$(sed -E 's/ --no-stat//' <<< "$command")

jq -n --arg cmd "$new_command" '{
  hookSpecificOutput: {
    hookEventName: "PreToolUse",
    updatedInput: {
      command: $cmd
    }
  }
}'
eepp · 6 months ago

@drmercer-lucid Did you vibe-code this? 😉

drmercer-lucid · 6 months ago

Absolutely 😄 I just wish Claude made it a little easier to vibe code hooks (it's surprisingly tedious to install and test them)

yurukusa · 5 months ago

Hook workaround: strip --no-stat automatically
Until this is fixed upstream, you can use a PreToolUse hook to silently rewrite git show ... --no-stat into a valid command.
git-show-flag-sanitizer.sh:

INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
[ -z "$COMMAND" ] && exit 0
case "$COMMAND" in
  *git\ show*--no-stat*) ;;
  *) exit 0 ;;
esac
NEW_COMMAND=$(echo "$COMMAND" | sed 's/ --no-stat//' | sed 's/  */ /g')
jq -n --arg cmd "$NEW_COMMAND" '{
  hookSpecificOutput: {
    hookEventName: "PreToolUse",
    permissionDecision: "allow",
    updatedInput: { command: $cmd }
  }
}'

Install in .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "bash /path/to/git-show-flag-sanitizer.sh"
          }
        ]
      }
    ]
  }
}

This intercepts every Bash tool call, checks if it's a git show with --no-stat, strips the invalid flag, and returns the corrected command via updatedInput. Other commands pass through untouched.
The hook is also available as part of cc-safe-setup (tested with 10 test cases).

empresarrollo · 4 months ago

This still is happening now with 2,1,92 macos

myarcana · 3 months ago

Claude Code does this all the time, it exclusively does this. I've never seen it run a git show without trying git show --no-stat first and watching it fail.

mtbc · 2 months ago

I still see this with v2.1.170.