Codex CLI: Add enforced PowerShell mode (rewrite/lint + exit-code aware execution) to fix Windows reliability
Codex CLI on Windows is still noticeably weak in PowerShell, and this looks fixable with CLI-level product work, not just “train the model more.” Today it routinely outputs Bash/GNU patterns even when the environment is explicitly PowerShell: export, cat/head/
tail, sed/awk, grep, and && chains that are brittle or just wrong (especially in Windows PowerShell 5.1). It also mis-handles quoting and argument passing for native executables (paths with spaces, wildcard expansion, PowerShell re-parsing of args), and it
doesn’t reliably react to failure: a command can error and the next step proceeds as if it succeeded because exit codes aren’t treated as first-class.
Request: introduce a true, enforced “PowerShell mode” in Codex CLI (triggered by shell=powershell and/or Windows auto-detect) with:
- A command linter/rewriter that blocks/rewrites known-bad patterns (&&, export, GNU utilities assumptions) into PowerShell-native equivalents (Get-Content -TotalCount, Select-String, Get-ChildItem, $env:VAR = 'value', etc.).
- A safe native-exec wrapper for tools like git that avoids PowerShell argument parsing pitfalls (use & git ... and --% when needed).
- Exit-code aware execution-loop semantics: always capture and surface exit codes and feed failures into the next model turn; default to recovery behavior on nonzero exit rather than continuing optimistically.
- Session capability detection and caching (PowerShell 5.1 vs 7+, presence of rg, node, npm, git) so the model doesn’t suggest tools that aren’t installed.
Quality bar: add a Windows/PowerShell eval suite that actually executes commands (not just static checks) with regression tasks like:
- show first N lines of a file
- search across repo
- run an npm script and handle failure
- git diff for a path with spaces
- set an env var then run a command
- and more
Without a Windows PowerShell execution harness + enforced rewriting and exit-code handling, Codex CLI will keep regressing on Windows workflows.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗