Complete AI Training

Prompt

Build a Developer Status Bar Script for Claude Code

Use this when you need to generate a highly-optimised Python script that displays developer-critical information (model, workspace, git status, cost) in Claude Code's status line.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a systems programmer creating a single-file Python script for Claude Code's status line. The script must be extremely performant (<100ms execution), use only standard library, and output exactly one line with ANSI colour codes.

Context you provide

  • Model display name {{the name of the AI model, e.g., 'Opus', 'Sonnet', 'Haiku'}} (optional, default 'Claude')
  • Workspace directory {{the project directory path}} (optional, will read from environment or CWD)

Instructions

  1. If no workspace directory is provided, use the current working directory. If missing, ask.
  2. Write a Python script saved to ~/.claude/statusline.py that reads JSON from stdin with fields: model, workspace, output_style, cost.
  3. The script must:
  • Parse the JSON and handle missing fields gracefully (omit that section, do not crash).
  • Display model name (orange), project directory basename (blue), git branch (green), git status (clean ● dim gray, modified ~N yellow, added +N yellow, uncommitted !N red), and API ratio (dim gray).
  • Use ANSI 256-colour codes for high contrast. Visible text width ≤80 characters (exclude ANSI codes).
  • Read git info efficiently: branch from .git/HEAD directly, file counts from git status --porcelain with a cache in /tmp/claude_statusline_cache.json (TTL 5 seconds or on .git/index mtime change).
  • Use only sys, json, os, pathlib, subprocess, time.
  • On any error, return empty string.
  1. Meet all constraints: <100 lines, type hints, docstrings, one function per concern.
  2. Output the final script with integration instructions (save, chmod, add to settings.json).

Output format

# Full script code

Guardrails

  • Do not include external dependencies; only standard library.
  • Ensure the script does not produce side effects beyond writing cache file.
  • Verify that ANSI codes do not count toward the 80-character visible width limit.

Example Input: {"model":{"display_name":"Opus"},"workspace":{"current_dir":"/home/user/project"},"cost":{"total_cost_usd":0.12,"total_duration_ms":1500,"total_api_duration_ms":1200}} Output (with ANSI): Opus project ● A:80%