windows-adapter
Coding agents on Windows write PowerShell into Git Bash, bash into PowerShell, PowerShell 7 flags into 5.1, and print → through a cp1252 console. This adapter catches those mistakes before the command runs. It works with pi, Claude Code and Codex.
Results
The benchmark has 120 shell tasks, run 2× each with and without the adapter, on the same day. Each cell shows the pass rate and the number of Windows-caused failed calls.
| Agent | Shell | Without | With adapter |
|---|
| Claude Code + Haiku | Git Bash | 80.0% · 19 | 80.0% · 0 |
| Claude Code + Haiku | PowerShell | 74.6% · 5 | 76.3% · 0 |
| Codex + Luna | PowerShell 5.1 | 75.4% · 34 | 75.4% · 1 |
| pi + Luna | Git Bash | 80.4% · 28 | 80.8% · 0 |
| pi + Luna | PowerShell 5.1 | 73.8% · 24 | 75.0% · 1 |
| Total | | 110 | 2 |
Windows failures fell 55× and no cell lost pass rate (pooled +0.7pp, 95% CI −1.2 to +2.5). Counting every classified call, failures fell 11×, from 136 to 12. Method and confidence intervals: bench/history/v10.md. The adapter was then rerun on a model it was never tuned on, gpt-6-luna (pi and Codex). Windows failures fell from 96 to 8, pass rate rose 3.9pp, and the gate passed (v11). Comparison with other tools: docs/alternatives.md.
Install
You need Windows, Git for Windows, and Node.js 22.18 or newer on PATH.
pi
pi install git:github.com/aritejhg/pi-windows-adapter
Claude Code
claude plugin marketplace add aritejhg/pi-windows-adapter
claude plugin install windows-adapter@windows-adapter
Codex
codex plugin marketplace add aritejhg/pi-windows-adapter
codex plugin add windows-adapter@windows-adapter
Then run /hooks in Codex to trust the hooks. A Codex plugin can't set environment variables. For Python UTF-8, add this to ~/.codex/config.toml:
[shell_environment_policy.set]
PYTHONUTF8 = "1"
PYTHONIOENCODING = "utf-8"
How it works
flowchart LR
C[command] --> D{dialect matches<br>the tool's shell?}
D -->|no, and the real parsers agree| R[run it unchanged<br>in the other shell]
D -->|yes| F[apply safe fixes<br>for known Windows traps]
R --> O[output + adapter note]
F --> O
O -->|known failure| H[add a one-line hint]
- Route. A scorer reads the dialect from syntax that is valid in only one shell. If the command is in the wrong dialect, and
bash -n and the PowerShell parser agree, the command runs unchanged in its own shell from a temp script. Nothing is translated.
- Fix. Small rewrites for constructs that always fail on Windows, such as
> nul, && on 5.1, -AsUTC and ls -la in PowerShell. Each one has a fires / must-not-fire test. If a fix would break a command that parses, all fixes are dropped.
- Encode. Python gets
PYTHONUTF8=1 and PYTHONIOENCODING=utf-8. Windows PowerShell 5.1 gets a UTF-8 prelude when a command reads text.
- Hint. After a known Windows failure, one line tells the model what went wrong.
The model is told whenever its command changed:
[windows-adapter] This is PowerShell syntax (...) but the bash tool runs Git Bash, so it was run with Windows PowerShell 5.1 instead.
src/core/ engine: dialect scoring, real-parser checks, fixes, PowerShell 5.1 repairs, hints
src/hooks/ shell hook shared by Claude Code and Codex
src/pi/ pi extension
src/claude/ Claude Code hook (plugin: .claude-plugin/)
src/codex/ Codex hook (plugin: .codex-plugin/)
bench/ live benchmark, Harbor tasks, scorer, results history
test/ unit tests and e2e tests on real Git Bash and PowerShell 5.1
To integrate another agent, map its pre- and post-shell hooks to handleShellHook in src/hooks/shell-hook.ts. src/claude/hook.ts is a complete example in about 60 lines.
Configuration
| Environment variable | Effect |
|---|
PI_WINDOWS_ADAPTER=off | disable |
PI_WINDOWS_ADAPTER=prompt-only | shell guidance only, no rewrites |
PI_WINDOWS_ADAPTER_ROUTE=off | fixes and hints, no rerouting |
PI_WINDOWS_ADAPTER_PRELUDE=off | no UTF-8 prelude on PowerShell 5.1 |
PI_WINDOWS_ADAPTER_POWERSHELL=5.1|7 | which PowerShell the agent runs (default: pwsh if installed) |
PI_WINDOWS_ADAPTER_CODEX_SHELL=bash | your Codex runs Git Bash, not PowerShell |
PI_WINDOWS_ADAPTER_CODEX_REWRITE=allow|deny | rewrite in place, or deny and return the fix (default: allow only when approvals are bypassed) |
Development