[BUG] Windows PowerShell tool: permission pre-parse rejects commands over 965 bytes ("Command too long for parsing"), so read-only heredoc scripts can never be auto-approved
Environment
- Claude Code v2.1.214 (native install, Windows Terminal TUI)
- Windows 11 Home 25H2, build 26200.7462, ARM64 (Snapdragon X X1E80100, 64 GB RAM)
- Shell tool: PowerShell (pwsh 7)
- WSL2 installed but not in use — the session runs on native Windows
Behavior
Any PowerShell tool command longer than 965 bytes fails permission pre-parsing with:
Command contains malformed syntax that cannot be parsed: Command too long for parsing (1542 bytes). Maximum supported length is 965 bytes.
Because the command cannot be parsed, it can never be matched against permissions.allow rules or classified as read-only, so it always triggers a permission prompt — in every permission mode, and most painfully in plan mode, where read-only subagents routinely pipe analysis scripts through an interpreter. I hit this repeatedly with read-only SQLite inspection scripts piped to python - (observed sizes: 1542 bytes and 2479 bytes).
Reproduction
- Native Windows session with the PowerShell tool active.
- Ask Claude to run a read-only heredoc-piped script over 965 bytes, e.g. this one (1114 bytes, purely read-only — the prompt appears at the permission stage, so the database does not even need to exist):
$code = @'
import sqlite3, json
conn = sqlite3.connect("file:library.db?mode=ro", uri=True)
conn.row_factory = sqlite3.Row
def trunc(v, n=300):
if isinstance(v, str) and len(v) > n:
return v[:n] + f"...<+{len(v)-n}c>"
return v
def show(rows):
for r in rows:
print(json.dumps({k: trunc(r[k]) for k in r.keys()}, default=str))
cols = conn.execute("PRAGMA table_info(books)").fetchall()
print("ALL COLUMNS (%d):" % len(cols))
for c in cols:
print(" %2d %-26s %-10s dflt=%s" % (c["cid"], c["name"], str(c["type"]), c["dflt_value"]))
print("==== row id=42 ====")
show(conn.execute("SELECT * FROM books WHERE id = 42").fetchall())
for col in ("genre", "language", "format"):
print(f"==== DISTINCT {col} counts ====")
for r in conn.execute(f"SELECT {col}, COUNT(*) n FROM books GROUP BY {col} ORDER BY n DESC"):
print(" ", r[col], r["n"])
print("==== top authors by title count ====")
for r in conn.execute("SELECT author, COUNT(*) n FROM books GROUP BY author ORDER BY n DESC LIMIT 10"):
print(" ", r["author"], r["n"])
conn.close()
print("DONE")
'@
$code | python -
- A permission prompt appears with the parse error above, although the command is read-only and the interpreter invocation could otherwise match an allow rule.
Expected behavior
Parity with the Bash tool. The v2.1.214 changelog entry — "Fixed Bash permission checks misjudging very long commands — commands over 10,000 characters now always prompt" — sets Bash's always-prompt cap at 10,000 characters, while the PowerShell tool's cap is roughly 10× lower at 965 bytes.
On native Windows, heredoc-piping (@'…'@ | python -) is the standard way to run ad-hoc scripts, so a 965-byte cap means routine read-only analysis (especially plan-mode exploration by subagents) drowns in permission prompts. Raising the PowerShell parse cap to match Bash would restore usable auto-approval.
🤖 Generated with Claude Code in the session with id d8e31d61