Why AI coding feels smoother on a Mac — and the first fix every Windows user needs
AI-written commands keep failing on Windows? Install PowerShell 7, make your agent use pwsh, and add agent-skills and coreutils. About 15 minutes.
Sound familiar?
A friend on a Mac opens Cursor or Claude Code, types “write me a script that batch-renames these files,” and the AI writes it, runs it, done. You try the exact same prompt on Windows. The AI hesitates, then hands you a script. You run it: error. It patches it: another error. A few rounds later you’ve burned through a pile of tokens and the script still doesn’t work.
Frustrating? Very.
But here’s the thing: it isn’t your fault, and it isn’t really Windows’ fault either. The problem is what the AI was trained on.
In AI’s world, the command line means Linux and macOS
Every major model — Claude, GPT, Gemini — learned the command line almost entirely from Linux and macOS examples. ls, not dir. grep, not Select-String. chmod, not icacls.
Worse, the AI assumes you’re in a shell like Bash or Zsh. Drop it into the Windows PowerShell 5.1 that ships with Windows and it’s like asking someone who only speaks English to read a French menu: a few lucky guesses, mostly bluffing.
So what exactly is wrong with PowerShell 5.1? Three things:
- Encoding — where garbled text comes from. PowerShell 5.1 defaults to UTF-8 with a BOM, or even Windows-1252. AI-generated content is usually BOM-less UTF-8, so anything non-ASCII turns into mojibake. Try asking the AI to handle a file name with non-English characters and watch the errors pile up.
- Commands that behave differently. In PowerShell 5.1,
curlis just an alias forInvoke-WebRequest, with a completely different set of parameters. Paste the AI’s one-linecurlcommand and it won’t do what you expect. - Friction with modern toolchains. Node.js, Python and Git all speak UTF-8 and follow Linux conventions. PowerShell 5.1 shipped in 2016 on the old .NET Framework, and it simply doesn’t get along with them.
The result: every conversation with your AI wastes a chunk of tokens on fixing compatibility errors. The AI isn’t dumb — it’s just talking to a shell from an older generation.
So what do you do?
First, untangle three names
Before we start, let’s untangle three names that confuse a lot of Windows users: “PowerShell,” “Windows PowerShell” and “Windows Terminal.”
| Name | What it is | Command | How to use it |
|---|---|---|---|
| Windows PowerShell 5.1 | The legacy shell built into Windows (2016, .NET Framework) | powershell or powershell.exe |
Keep it for old modules and system compatibility; keep it out of your daily work |
| PowerShell 7 | The modern rewrite on current .NET — cross-platform, open source, UTF-8 by default | pwsh or pwsh.exe |
Your default for AI, development and automation |
| Windows Terminal | A good-looking terminal window that can host several shells | wt |
Set PowerShell 7 as the default profile and make it your main interface |
Think of it this way: Windows Terminal is your garage, PowerShell 5.1 is a 2016 clunker, and PowerShell 7 is a 2024 model. When you walk into the garage, you should end up in the new car, not the clunker.
Let’s go pick it up.
Step 1: check which car you’re driving
Press Win + R, type powershell and hit Enter. In the blue window, run:
$PSVersionTable.PSVersion
If the major version is 5, congratulations — this article is for you. If it’s already 7, you’re in the minority; forward this to a friend who’s still suffering 😉
Step 2: install PowerShell 7
There are three ways to do it. Option A is fast and clean, and it’s the one I recommend.
🥇 Option A: install with WinGet (recommended)
Meet WinGet — the command-line version of an app store
If you’ve used apt/yum on Linux or Homebrew on macOS, you already get it: WinGet is Microsoft’s official package manager for Windows.
What it’s good for:
- Install software with one command — no hunting for download links
- Upgrade everything with one command — no clicking through updaters one by one
- Uninstall cleanly, with no leftovers
WinGet ships with Windows 11 and Windows Server 2025. On Windows 10 (1809 or later), if winget isn’t found, install App Installer from the Microsoft Store.
📖 Want the details? Microsoft’s docs: https://learn.microsoft.com/en-us/windows/package-manager/winget/
Installing it
① Make sure WinGet works:
winget --version
If it prints a version (for example v1.8.1911), you’re set. If it says the command isn’t found, install App Installer from the Microsoft Store first — it takes a minute.
② Confirm the package ID:
winget search --id Microsoft.PowerShell --exact
③ Install it:
winget install --id Microsoft.PowerShell --source winget --installer-type wix
WinGet downloads the latest PowerShell 7 and installs it for you.
I recommend the wix (MSI) installer: it installs to
C:\Program Files\PowerShell\7\pwsh.exe. The MSIX package lands underC:\Program Files\WindowsApps\Microsoft.P…, and some tools only look forC:\Program Files\PowerShell\7\pwsh.exe.
④ Already installed and need an upgrade?
# Check whether an update is available
winget list --id Microsoft.PowerShell --upgrade-available
# If so, upgrade
winget upgrade --id Microsoft.PowerShell
⑤ Verify:
Close the terminal, open a new one and type:
pwsh
Once you’re in PowerShell 7, run:
$PSVersionTable.PSVersion
Major version 7? Done.
💡 Bonus: what else WinGet can do
With PowerShell 7 in place, you’ve also unlocked a superpower — you can install pretty much anything with WinGet:
winget search <keyword> # search
winget install <app> # install
winget upgrade --all # upgrade everything at once
winget --help # see what else it can do
Need VS Code? winget install Microsoft.VisualStudioCode. Git? winget install Git.Git. No more visiting download pages one by one.
🥈 Option B: the MSI package (enterprise / offline)
Download the .msi from GitHub Releases, double-click it and follow the setup wizard.
Or install silently with one command (handy for fleet deployments):
msiexec.exe /package PowerShell-7.6.4-win-x64.msi /quiet ADD_PATH=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ENABLE_PSREMOTING=1
📖 Full docs: https://learn.microsoft.com/en-us/powershell/scripting/install/install-powershell?view=powershell-7.6
🥉 Option C: everything else (for reference)
- MSIX: search for “PowerShell” in the Microsoft Store — good if you’d rather avoid the command line.
- ZIP: unzip and run — useful if you want several versions side by side or a copy on a USB stick.
- .NET global tool:
dotnet tool install --global PowerShell— for developers.
For most people, Option A is all you need.
Step 3: the three-point check
After installing, close and reopen your terminal, type pwsh to enter PowerShell 7, and check:
# 1. Version — should be 7.x
$PSVersionTable.PSVersion
# 2. Edition — should be Core
$PSVersionTable.PSEdition
# 3. Install path — should point to the PowerShell 7 directory
$PSHOME
pwsh not found? Troubleshoot in three steps:
- Restart your terminals — Windows Terminal, VS Code, Cursor, your AI client. Close them all and reopen.
- In cmd, run
where.exe pwshto see whether Windows can find it. - In PowerShell, run
Get-Command pwsh -Allto confirm.
Most of the time, restarting the terminal fixes it.
Step 4: make your AI agent actually use pwsh (the key step)
Installing PowerShell 7 is only half the job. Your AI agent may not know it’s there.
Many AI coding tools — Codex, Cursor, Claude Code — still call powershell.exe (5.1) on Windows by default, which means you installed PowerShell 7 for nothing.
Check by asking the tool itself:
Run the following commands and tell me the current PowerShell version and executable path:
$PSVersionTable.PSVersion
(Get-Process -Id $PID).Path
If it reports 5.1, you need to tell it explicitly: use pwsh.
Add this to the project root or your global config file (for Codex, that’s AGENTS.md):
## Windows shell rules
- PowerShell 7 is installed on this system.
- Run every PowerShell command with `pwsh.exe`.
- Do not use the legacy `powershell.exe`.
- Run PowerShell commands in this form:
pwsh.exe -NoLogo -NoProfile -Command "<command>"
- Before the first command, run:
pwsh.exe -NoLogo -NoProfile -Command "$PSVersionTable.PSVersion"
- If PowerShell 7 is unavailable, stop and tell the user. Do not fall back to Windows PowerShell 5.1.
Now your agent actually knows about PowerShell 7.
Step 5: level up with agent-skills
At this point your agent is no longer a fish out of water. But there’s one more piece that makes things noticeably better.
The open-source repo agent-skills collects reusable skill configurations for AI agents. One of them, powershell-safe-invocation, sets rules for exactly the traps AI agents fall into when calling PowerShell on Windows:
- Passing arguments to native commands correctly (no more
cmd /cworkarounds) - Quoting and escaping paths (spaces and backslashes in Windows paths stop being a nightmare)
- Forcing UTF-8 to get rid of garbled text for good
- Starting processes and handling exit codes properly
- PowerShell-specific details such as how
foreachpipelines are parsed
Installing it is simple. For Codex:
$repo = (Get-Location).Path # the directory where you cloned the repo
$target = "$env:USERPROFILE\.codex\skills"
New-Item -ItemType Directory -Force -Path $target | Out-Null
Copy-Item -LiteralPath "$repo\skills\powershell-safe-invocation" -Destination $target -Recurse -Force
Using another agent? Point $target at its skills directory.
The repo also has a bilibili-page-reader skill that lets an AI read Bilibili video pages and subtitles — worth a look while you’re there.
Step 6: install coreutils so Windows speaks Linux
Your shell is now up to date. But a deeper problem remains: the commands themselves.
Remember the start of this article: AI training data is full of Linux/macOS commands. ls, grep, cat, find, sort are part of the AI’s native vocabulary, but on Windows they either don’t exist or behave differently.
The good news is that Microsoft noticed too. It open-sourced Coreutils for Windows, which brings the core Linux command-line tools to Windows, faithfully.
What it is
Coreutils for Windows builds on uutils/coreutils, a Rust rewrite, packaged as a single multi-call binary. Once installed, dozens of everyday Linux commands — ls, cp, mv, rm, cat, grep, find, wc, sort, echo, tee — work on Windows with the same flags and behavior as on Linux.
What does that mean in practice? You no longer have to translate the AI’s commands. It says ls -la, Windows runs ls -la. It says grep -r "error" ., Windows runs grep -r "error" .. That fixes the problem at its root better than any shell setting, because it closes the gap in the command language itself.
How to install
WinGet again, one line:
winget install Microsoft.Coreutils
Things to know
It’s still a preview project, so keep a few details in mind:
- It needs PowerShell 7.4+ (which you now have); 7.6+ is recommended for full
~path support. - Some commands clash with PowerShell’s built-in aliases —
ls,cpandrmalready map to native cmdlets in pwsh. After installing coreutils, PATH precedence makes the Linux versions take precedence, which is exactly what we want. - Purely POSIX commands such as
chmodandchownaren’t included, since Windows doesn’t have a matching permission model. That’s a sensible trade-off.
If a command doesn’t behave the way you expect, manage it with coreutils-manager:
coreutils-manager disable <command> # disable a tool
coreutils-manager --help # list all management commands
Wrapping up
Here’s what you did:
- ✅ Replaced the 2016-era Windows PowerShell 5.1 with modern PowerShell 7
- ✅ Configured your AI agent to always use pwsh
- ✅ Added agent-skills to standardize how the AI calls PowerShell
- ✅ Installed coreutils so Windows natively understands Linux commands
Four things, about 15 minutes. What you get back: an AI agent that runs as smoothly on Windows as it does on a Mac. No more mysterious encoding errors, no more “command not found,” no more tokens burned on compatibility problems.
So stop envying Mac users’ AI experience. Go upgrade 😎
Originally published in Chinese on Zhihu by the author, 滴滴点到 (Liang Cui), and adapted for AI SI Daily.
Related
Cline: What It Is, Key Capabilities, and Getting Started
An introduction to Cline, an open-source AI agent for your IDE, CLI, and desktop that coordinates code changes and executes terminal workflows.
Aider: Terminal AI Pair Programming and Quickstart Guide
An introduction to Aider, the open-source terminal tool for AI pair programming, codebase mapping, Git integration, and multi-model code editing.
NotebookLM Guide: What the AI Research Tool Is and How to Use It
Discover how NotebookLM works as an AI research assistant, explore its source-grounded features, and learn how to get started with your Google Account.