[BUG] Claude Code generates 2>/dev/null redirections in Bash commands on Windows

Resolved 💬 3 comments Opened Feb 26, 2026 by JaieParker Closed Feb 26, 2026

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?

Problem: Claude Code's internal tool calls (e.g., cat ... 2>/dev/null) use Unix-style error suppression. On Windows (bash shell), this silently swallows errors that users need to see. The model's CLAUDE.md
instructions say "never redirect stderr/stdout to suppress errors" but the tool calls themselves violate this.

Impact: All Windows users. Error suppression hides real failures. Users who add hooks to block this pattern get hook errors on otherwise normal operations.

Note: I have had to create a hook to defend against this but that means it costs me extra time every time.

One of my errors:
Bash(cd
/c/Users/JaieChamsoft/.claude/extensions/AIDLC-Web && cat ../../aidlc/intents/aidlc-dashboard-ui/units/UNIT-002-core-views/BOLT-CX1-STATE.md 2>/dev/null | he…)
⎿ Error: PreToolUse:Bash hook error: [$USERPROFILE/.claude/hooks/aidlc-host-publish/Aidlc.Host.exe validate]: Redirect to /dev/null blocked - let errors display

What Should Happen?

Expected: Claude Code should not generate 2>/dev/null, 2>nul, or similar redirections in its bash commands, especially on Windows where error visibility is already reduced.

Error Messages/Logs

None as it creates an invalid file that is hard to remove on a windows machine because its just "nul" which is a reserved keyword and gets treated as a drive.

Steps to Reproduce

Steps to Reproduce (for the issue)

  1. Reading files that might not exist

# Claude generates this when checking if a file exists before reading cat some-file.md 2>/dev/null | head -20 This is exactly what triggered your hook — the model tried: cd /c/Users/.../AIDLC-Web && cat ../../aidlc/.../BOLT-CX1-STATE.md 2>/dev/null | he…

  1. Command existence checks

command -v docker >/dev/null 2>&1
which node 2>/dev/null

  1. Git operations with "expected" failures

git merge-base HEAD master 2>nul
git rev-parse --verify some-branch 2>/dev/null
Your own cs-review.md command template has these too — likely model-generated originally.

  1. Conditional file reads

cat .env 2>/dev/null || true
cat package.json 2>/dev/null | jq '.version'

  1. Process/port checks

lsof -i :3000 2>/dev/null
netstat -tlnp 2>/dev/null | grep 8080

The Core Problem

The model does this because it's "being defensive" — treating 2>/dev/null as a polite way to handle missing files/commands. But:

  1. The model has dedicated tools (Read, Glob, Grep) that handle missing files gracefully — there's no need for cat 2>/dev/null
  2. On Windows, suppressing errors hides real issues (wrong paths, permission problems, missing tools)
  3. The system prompt already says to use Read instead of cat — so the model is violating its own instructions twice (using cat AND suppressing errors)
  4. It contradicts user CLAUDE.md rules that explicitly say "never redirect stderr/stdout"

One of my errors:
Bash(cd
/c/Users/JaieChamsoft/.claude/extensions/AIDLC-Web && cat ../../aidlc/intents/aidlc-dashboard-ui/units/UNIT-002-core-views/BOLT-CX1-STATE.md 2>/dev/null | he…)
⎿ Error: PreToolUse:Bash hook error: [$USERPROFILE/.claude/hooks/aidlc-host-publish/Aidlc.Host.exe validate]: Redirect to /dev/null blocked - let errors display

Claude Model

None

Is this a regression?

No its never worked in my time using it. I have lots of other developer friends who have the same issue

Last Working Version

_No response_

Claude Code Version

Claude Code v2.1.59

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗