Windows PowerShell sessions are being steered by Unix/bash startup instructions
What version of Codex CLI is running?
codex-cli 0.112.0-alpha.4
What subscription do you have?
Plus
Which model were you using?
gpt-5.4
What platform is your computer?
Microsoft Windows NT 10.0.26300.0 x64
What terminal emulator and version are you using (if applicable)?
PowerShell
What issue are you seeing?
In Windows 11 PowerShell sessions, Codex CLI appears to be primed by Unix/bash-oriented startup instructions and examples. Over longer context windows, this keeps pulling the model back toward Unix command habits even when the shell is clearly PowerShell.
This causes Codex to repeatedly prefer or suggest commands/shapes such as:
catlssednlwc- other bash/Unix-style examples and wording
The core problem is not rg. I am fine assuming rg is available on Windows, and I would actually prefer to keep using it because it is fast. The problem is that the surrounding startup guidance and examples are still mostly Unix-flavored, so the agent keeps drifting back into the wrong shell mental model.
In practice this creates:
- wasted turns correcting shell assumptions
- commands that are awkward or incorrect for PowerShell
- repeated regressions in long sessions, where Codex briefly adapts and then falls back to Unix-style behavior again
This feels like an environment-specific prompting issue in the CLI experience. Once the shell is known to be PowerShell, the instructions/examples should stay PowerShell-native for the rest of the session.
What steps can reproduce the bug?
- Start a Codex CLI session on Windows 11 in PowerShell.
- Work in a normal coding session long enough to build a larger context window.
- Ask Codex to inspect files, search text, view slices of files, or do basic shell-based repo exploration.
- Observe that it repeatedly falls back to Unix/bash-oriented command habits and examples, even though the shell is PowerShell.
Typical examples of the drift:
- preferring
cat/ls/sed/nl/wcstyle examples instead of PowerShell-native examples - using bash-shaped command assumptions in explanations and suggestions
- reintroducing Unix-centric examples after earlier corrections in the same session
This is especially noticeable in longer sessions, where the initial Unix-biased prior seems to keep resurfacing.
What is the expected behavior?
If Codex CLI is running in Windows PowerShell, it should switch to PowerShell-native startup instructions, examples, and command preferences.
I would expect PowerShell sessions to prefer examples like:
Get-ContentGet-Content -RawGet-ChildItemSelect-StringMeasure-ObjectGet-CommandGet-Content -HeadGet-Content -TailSelect-Object -Skip/-First-replace-LiteralPath
I would also expect the agent to stop using bash-specific wording/examples once the shell is identified as PowerShell.
Additional information
A shell-specific prompt bundle would likely fix most of this:
- bash/zsh/Linux/macOS startup examples for Unix-like shells
- PowerShell-native startup examples for Windows PowerShell / pwsh sessions
Suggested PowerShell equivalents for common examples that currently tend to be expressed in Unix terms:
cat file.txt->Get-Content file.txtcat file.txtas one string ->Get-Content -Raw file.txtls->Get-ChildItemrg foo .->rg foo .head -n 40 file.txt->Get-Content file.txt -Head 40tail -n 40 file.txt->Get-Content file.txt -Tail 40sed -n '1,120p' file.txt->Get-Content file.txt | Select-Object -First 120sed -n '121,240p' file.txt->Get-Content file.txt | Select-Object -Skip 120 -First 120grep foo file.txt->Select-String -Path file.txt -Pattern 'foo'nl -ba file.txt->$i=1; Get-Content file.txt | ForEach-Object { '{0,6} {1}' -f $i++, $_ }wc -l file.txt->(Get-Content file.txt | Measure-Object -Line).Lineswhich git->(Get-Command git).Path
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗