CLI AI

Same workflow on Windows: PowerShell and cmd parity

2026-03-03

CliAI started on Linux and macOS, where the assumption is bash or zsh and a Unix-style fork-exec for handoff. The Windows path is genuinely different: there is no $SHELL, the shell launcher comes from $COMSPEC (or your terminal explicitly opens pwsh.exe), and the commands themselves are different. We treated parity as a real product goal, not a checkbox.

What "parity" means here

It does not mean translating Unix commands to Windows. It means the same English prompt produces the right command for whichever shell you're standing in. Ask for "list listening ports" on Linux and you'll see ss -ltnp; ask the same on Windows in PowerShell and you'll see Get-NetTCPConnection.

PowerShell
PS C:\> clai list listening TCP ports with the process name→ Get-NetTCPConnection -State Listen `    | Select-Object LocalAddress, LocalPort,                    @{N='Process';E={(Get-Process -Id $_.OwningProcess).ProcessName}}LocalAddress  LocalPort  Process0.0.0.0       80         nginx0.0.0.0       443        nginx

Three more PowerShell examples

Find files larger than 100 MB

PowerShell
PS C:\> clai find files larger than 100 MB under D:\projects→ Get-ChildItem -Path D:\projects -Recurse -File `    | Where-Object { $_.Length -gt 100MB } `    | Sort-Object Length -Descending `    | Select-Object FullName, Length

Kill the process holding a port

PowerShell
PS C:\> clai kill the process listening on port 8080→ Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess -Force[Safety: CAUTION] — sends SIGKILL equivalent.

Tail a log file

PowerShell
PS C:\> clai tail the last 100 lines of C:\app\error.log and follow→ Get-Content -Path C:\app\error.log -Tail 100 -Wait

What's different under the hood

When you press Enter to run, CliAI:

  1. Reads $COMSPEC (defaults to cmd.exe) on Windows, falls back to pwsh.exe if you're in a PowerShell host.
  2. Spawns the shell with the generated command as an argument — there's no fork/exec model on Windows.
  3. The command runs in your current console, with your environment, working directory, and PSReadLine history.

What still doesn't work the same

  • Stdin piping into clai itself has minor differences; in particular, ANSI color stripping behaves differently in legacy cmd. Use Windows Terminal or pwsh for the smoothest experience.
  • Path expansion. Drag-and-dropped paths with spaces still need quoting. CliAI quotes the generated command but you should pass the source path quoted.

See also