Claude Code Statusline on Windows: A Setup That Works
For a Claude Code statusline on Windows, use a small Node script and point statusLine at it with forward slashes. Save it as .cjs, call it from ~/.claude/, and it costs about 46 ms per refresh. PowerShell works too, but only if you read stdin as raw UTF-8: with a non-ASCII folder name, the usual $input | ConvertFrom-Json hands git a garbled path, and the status line looks fine while the branch silently goes missing.
The Short Answer
This is the setting, from the Claude Code docs. The script below it is the one I timed on Windows 11 with Claude Code 2.1.302 and Node 25.2.1.
{
"statusLine": {
"type": "command",
"command": "node C:/Users/you/.claude/statusline.cjs"
}
}
The measured cost of one refresh, median of five runs, including a git call where noted:
runtime median per run
node 46 ms (with git)
cmd .bat 13 ms (cannot parse JSON)
powershell.exe 5.1 265 ms (git call failed, see below)
pwsh 7 380 ms (git call failed, see below)
Git Bash script 711 ms (with git)
What I Did and Did Not Run
I did not start a Claude Code session. There is no non-interactive command that renders a status line, and I will not run a model call to find out. So I fed each script the JSON that the docs say Claude Code sends, through a pipe, from a Node launcher that measures the wall time. The sample payload used only documented fields, with a Windows path that contains an accent: café-proj.
Everything about how Claude Code schedules, cancels and draws the line comes from the docs and is labelled that way below. Everything about what the scripts print, how fast they run and what the encoding does is measured.
What Claude Code Does, From the Docs
From the statusline docs, read on 2026-10-19:
- Claude Code runs your command, sends a JSON object on stdin and shows what the command prints to stdout. Several lines make several rows, and ANSI colours work.
- It runs at session start, after each new assistant message and after a few other events, with a 300 ms debounce. A new trigger cancels the run that is still going.
- The line only shows if the command exits with 0. A non-zero exit or empty output gives a blank status line.
- On Windows the command goes through Git Bash if it is installed, or PowerShell if not. In Git Bash, backslashes act as escapes, so write forward slashes.
- The JSON has no git branch field, so a branch segment needs its own
gitcall. It does have the model name, the folder andcontext_window.used_percentage. - The docs give no timeout. Keep the script fast, because a slow script holds up the line.
The Node Script
This is the script I timed. It reads stdin, parses the JSON, takes the folder name, asks git for the branch and prints one line.
const { execFileSync } = require('child_process');
const path = require('path');
let raw = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', c => (raw += c));
process.stdin.on('end', () => {
const j = JSON.parse(raw);
const dir = (j.workspace && j.workspace.current_dir) || j.cwd || '';
const leaf = path.win32.basename(dir);
const pct = j.context_window && j.context_window.used_percentage;
let branch = '';
try {
branch = execFileSync('git', ['-C', dir, 'branch', '--show-current'],
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
} catch (e) {}
const out = `[${j.model.display_name}] ${leaf}`
+ (branch ? ` (${branch})` : '')
+ (pct != null ? ` ctx ${pct}%` : '');
process.stdout.write(out + '\n');
});
With my sample payload it printed [Opus] café-proj in 45 to 50 ms, five runs in a row. The reason to prefer Node is not the speed alone. In my code page 850 console, Node still wrote UTF-8 bytes, so the accent and an emoji came out as valid UTF-8.
One trap. Name the file .cjs. A parent folder with a package.json that says "type": "module" turns a .js file into an ES module, and require then fails with ReferenceError: require. I hit it in my own scratch tree.
The PowerShell Trap With Non-ASCII Paths
The docs show PowerShell reading the JSON with $input | Out-String. That works until the path has a character outside plain ASCII. My console used code page 850, which is the default on a Western European Windows install. Both powershell.exe 5.1 and pwsh 7 decoded the path as caf├®-proj.
The damage is easy to miss. The printed line still looked right, because the output went back through the same code page. But git -C failed with fatal: cannot change to and exit 128, so the branch vanished from the line with no error on screen.
What I tried, and what happened:
[Console]::InputEncoding = UTF8at the top. Fixedpwsh7. Did not fixpowershell.exe5.1, and made its output worse.- Reading raw stdin as UTF-8. Worked on both. This is the one I recommend.
chcp 65001before the script. Also worked on both, but it means wrapping the command incmd /c.
The script that passed on both PowerShell versions starts like this, and the rest is the same as the docs example:
$utf8 = [System.Text.UTF8Encoding]::new($false)
[Console]::OutputEncoding = $utf8
$reader = [System.IO.StreamReader]::new(
[Console]::OpenStandardInput(), $utf8)
$raw = $reader.ReadToEnd()
try { $j = $raw | ConvertFrom-Json } catch { exit 1 }
$dir = $j.workspace.current_dir
if (-not $dir) { $dir = $j.cwd }
$leaf = Split-Path $dir -Leaf
$pct = $j.context_window.used_percentage
$branch = (git -C $dir branch --show-current 2>$null)
$s = "[$($j.model.display_name)] $([char]::ConvertFromUtf32(0x1F4C1)) $leaf"
if ($branch) { $s += " ($branch)" }
if ($null -ne $pct) { $s += " ctx $pct%" }
Write-Host $s
That is the script as I ran it, with a folder emoji in front of the name. With OutputEncoding set it printed [Opus] 📁 café-proj as valid UTF-8 on both versions. In a separate test without it, the accent became the single byte 0x82 under code page 850, and an emoji became ??.
About the timings: in the PowerShell runs the git call failed fast because of this very bug, so the 265 and 380 ms figures leave out most of the cost of a real git call. Node and the bash script include one. Even so, Node was the quickest of the scripts that can parse JSON, by a wide margin. Use it unless you need PowerShell for other reasons. The .bat file was faster still, but cmd has no JSON parser, so it could only show the start of the input.
Want more like this?
New posts in your inbox, a few a month.
Path Rules When Git Bash Is Installed
The docs say Git Bash runs the command when it is installed. I did not run Claude Code, so I simulated that route with bash -c. A backslash path lost its separators and Node reported Cannot find module. The same path with forward slashes ran fine.
So the rule is simple. Use forward slashes in the command, and quote any path that has a space. Two GitHub issues report a status line that never appears: #88256 for a path with spaces and no Git Bash, closed as not planned, and #93635 for a native Windows install without Git for Windows, still open. I did not reproduce either.
What Makes the Line Go Blank or Half Empty
- Non-zero exit. The docs say the line goes blank. My Node script exits 1 on empty or invalid JSON, so it blanks. That is the behaviour I want.
- A forgiving script. The PowerShell and bash scripts exited 0 on empty stdin and printed a half-empty line such as
[]. If you prefer a blank line to a broken one, exit non-zero when the input is bad. - Several lines. Each printed line is a row, according to the docs. My script printed three lines with exit 0 and I did not see how Claude Code draws them.
Open Problems I Did Not Fix
Cancelled runs can leave processes behind on Windows. The GitHub issues #98976 and #102907 were both open on 2026-10-19. The changelog through 2.1.303 has one related Windows fix, in 2.1.293, for a stop that could end an unrelated process with the same PID. I did not reproduce the leak.
My advice is to keep the script short and quick, avoid refreshInterval unless you need it, and check Task Manager for stray pwsh.exe or node.exe processes after a long session.
What I Did Not Test
- Any run inside Claude Code: rendering, the trust prompt, the 300 ms debounce, cancellation and
--debugoutput. - Whether Claude Code sends backslashes escaped in the JSON. My sample used escaped backslashes, which is standard JSON.
- A machine without Git for Windows, where the docs say PowerShell runs the command.
- Code pages other than 850. The 850 results will differ on a UTF-8 system.
- Claude Code versions other than 2.1.302.
FAQ
How do I set up a Claude Code statusline on Windows?
Add a statusLine entry to ~/.claude/settings.json with type command and a command such as node C:/Users/you/.claude/statusline.cjs. Use forward slashes. The script reads the JSON from stdin and prints one line.
Why is my Claude Code statusline not showing on Windows?
Per the docs, the line stays blank when the command exits non-zero or prints nothing. Test it by piping a sample JSON into the script. Also check for backslashes in the command under Git Bash and for a .js file inside a folder whose package.json says type module.
Should I use Node or PowerShell for the Claude Code statusline?
Node. In my test it ran in a median of 46 ms against 265 ms for Windows PowerShell 5.1 and 380 ms for PowerShell 7, and in my code page 850 console it still wrote valid UTF-8.
Why does my PowerShell statusline show the wrong git branch for some folders?
With a non-ASCII character in the path, PowerShell can decode stdin with the console code page, so git receives a garbled folder name and fails. Read stdin as raw UTF-8 with a StreamReader, as shown in the post.
Does the Claude Code statusline JSON include the git branch?
No. According to the docs it has no branch field outside worktree sessions, so run git branch --show-current from your script.
Related Articles
- Running Claude Code as an always-on agent on Windows
- Fixing the Claude Code Chrome extension on Windows
- Diagnosing Windows with Claude Code
- XNDR work: projects built with AI agents.
Liked this one? Get the next in your inbox.
New posts and the odd product note, a few emails a month. Easy to leave.