KnightCode Docs
Run KnightCode

Run KnightCode on Windows

Run KnightCode either as a native Windows process or inside Windows Subsystem for Linux (WSL). Native Windows uses Git Bash by default for Bash commands and can optionally...


Run KnightCode either as a native Windows process or inside Windows Subsystem for Linux (WSL). Native Windows uses Git Bash by default for Bash commands and can optionally expose PowerShell to the model. KnightCode inside WSL uses the Linux environment and its Bash installation.

Follow the main Quickstart to install and authenticate KnightCode. Use this page to choose and configure its command environment.

Choose native Windows or WSL

EnvironmentCommand environmentUse it when
Native Windows with Git BashGit Bash for the built-in bash tool and ! commandsYour files and development tools primarily live on Windows
Native Windows with the powershell toolPowerShell for model tool calls; Bash remains available for ! commandsThe task depends on PowerShell modules or Windows-native commands
WSLLinux Bash and tools inside the selected WSL distributionYour files and toolchain already live in Linux or WSL

Use Git Bash on native Windows

For most native Windows users, installing Git for Windows is sufficient.

KnightCode resolves Bash in this order:

  1. shellPath from ~/.knightcode/agent/settings.json
  2. Git Bash at %ProgramFiles%\Git\bin\bash.exe
  3. Git Bash at %ProgramFiles(x86)%\Git\bin\bash.exe
  4. bash.exe on PATH, including Cygwin, MSYS2, or legacy WSL Bash

Start KnightCode and enter this command to verify the shell:

!printf 'Bash is working\n'

If KnightCode cannot find Bash, it reports the locations it checked. Install Git for Windows, put another Bash executable on PATH, or configure shellPath.

Let the model use PowerShell

The optional powershell tool runs commands through pwsh.exe when available, then falls back to Windows PowerShell. It starts PowerShell with -NoProfile -NonInteractive -ExecutionPolicy Bypass. Administrator-enforced execution policies can still take precedence.

PowerShell discovery checks these locations in order:

  1. pwsh.exe on PATH
  2. %ProgramFiles%\PowerShell\7\pwsh.exe
  3. powershell.exe on PATH
  4. %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe

To replace the model-facing bash tool with powershell, add this to ~/.knightcode/agent/settings.json:

{
  "defaultTools": ["read", "powershell", "edit", "write"]
}

["-bash", "+powershell"] does the same while keeping any other default tools you configured.

Restart KnightCode, then ask it to run a harmless PowerShell command. The ! and !! editor commands continue to use Bash. The powershell tool is available only when KnightCode runs as a native Windows process.

See Settings for other tool combinations.

WSL

WSL path conversion on Windows and extra Git branch polling in WSL recognize /mnt/<drive>, not custom mount roots.

When using the legacy WSL bash.exe launcher from Windows, KnightCode sends commands over stdin to avoid command-line quoting problems.

Use a custom Bash executable

Set shellPath when Bash is installed somewhere KnightCode does not discover automatically:

{
  "shellPath": "C:\\cygwin64\\bin\\bash.exe"
}

JSON uses backslashes for escape sequences. When you write a Windows path with backslashes, write each backslash twice, as shown above.

See Configure shell commands for command prefixes, aliases, and the complete shell-resolution behavior.

Configure Windows Terminal

Windows Terminal reserves or rewrites some modified keys. See Windows Terminal to configure Shift+Enter and Alt+Enter, and Keybindings for KnightCode's Windows and WSL shortcut defaults.