Building a Custom Status Line for Claude Code

I spend most of my day in Claude Code. It acts as my programmer and reviewer.

After a few days, I noticed a problem. I did not know how many tokens I used. I did not know my session cost. I did not know how much context was left.

I do not want to run a command to check these facts. I want to see them in real time. I want to glance at my terminal and know my status.

So I built a custom status line.

I focused on three main things:

  • Session Cost: Claude Opus is not free. Seeing the cost live helps me decide when to wrap up a task.
  • Context Window: I want to see the percentage of context left. This helps me decide when to start a fresh session.
  • Project Info: I need to see my current directory, git branch, and the model I use.

The status line API is simple. You point Claude Code to a shell script. The tool sends a JSON document to your script via stdin. Your script prints the result to stdout.

It uses no SDK and no framework. It just uses stdin and stdout. It runs locally and costs nothing.

How to set it up:

  1. Create a script at ~/.claude/statusline.sh.
  2. Use jq to parse the JSON data.
  3. Format the output to show your path, branch, model, tokens, and cost.
  4. Add the script to your ~/.claude/settings.json file.

You can set the refresh interval to 1 second. This gives you a real-time dashboard.

If you do not want to write code, Claude Code has a shortcut. Run: /statusline show me model, branch, token counts, context percentage, and cost

This generates a line for you automatically.

Customizing your tools with simple shell scripts changes how you work. You stop waiting for features and start building your own automation.

Source: https://dev.to/ndrone/building-a-custom-status-line-for-claude-code-5822

Optional learning community: https://t.me/GyaanSetuAi