{
"$type": "site.standard.document",
"description": "feat: add a two-line statusline to Claude Code with context usage, cost, and git info",
"path": "/posts/custom-claude-code-statusline/",
"publishedAt": "2026-02-27T00:00:00.000Z",
"site": "https://read.ryancowl.es",
"tags": [
"Code"
],
"textContent": "I've been using Claude Code as my primary terminal-based coding assistant, and one thing that bugged me was not having a quick read on session state: context window usage, session cost, current branch, that kind of thing.\n\nClaude Code has a setting that lets you run a shell script and display the output at the bottom of the terminal. I put together a two-line statusline that gives me all of that at a glance:\n\n \n\nWhat It Shows\n\nLine 1: user@host, model name, current folder, git branch with a dirty indicator ( for uncommitted changes), and mode flags (, ) that only appear when you're in a non-default mode.\n\nLine 2: A color-coded context window bar (green under 50%, yellow under 75%, red above) with token counts, background task count (only when tasks are running), conversation turn count, session cost, and elapsed time.\n\nEverything conditional hides itself when there's nothing to show, so it stays clean during a simple session and surfaces more info as complexity grows.\n\n \n\nHow It Works\n\nClaude Code's setting runs a shell script and pipes session data as JSON to stdin. The script parses it with , formats with ANSI colors, and prints two lines.\n\nAdd this to your :\n\nThen create the script at and make it executable ().\n\nThe Script\n\n \n\nOne Gotcha\n\nIf your statusline shows up once and then disappears, check your calls. Using will break if the line contains (like from the context bar). Use instead. That one took me longer to figure out than I'd like to admit.\n\n \n\nResources\nClaude Code Documentation\nClaude Code Hooks\njq Manual",
"title": "A Custom Two-Line Statusline for Claude Code"
}