Skip to content

Latest commit

 

History

History
119 lines (90 loc) · 4.37 KB

scripts.md

File metadata and controls

119 lines (90 loc) · 4.37 KB

Available Scripts

Overview

Script Platform Requirements State Writes Features
statusline.py All Python 3 Yes Cross-platform, full-featured

Installation Methods

Method Statusline Command Context Stats Command
pip install context-stats claude-statusline context-stats

statusline.py

Python implementation. Works on Windows, macOS, and Linux without additional dependencies beyond Python 3.

Features:

  • Writes state files for context-stats CLI
  • Duplicate-entry deduplication
  • State file rotation (10k/5k threshold)
  • Model Intelligence (MI) with per-model profiles
  • Context zones with pacman icon
  • Session cost, reasoning effort, PR number, and tok/s throughput segments
  • Multi-line reflow on narrow terminals (wraps instead of dropping elements)
  • 5-second git command timeout

Context Stats CLI

The context-stats command is installed as part of the context-stats Python package (pip install context-stats). See Context Stats for details.

Output Format

Segments assemble in priority order (each is toggleable via ~/.claude/statusline.conf):

project | branch [changes] | PR# | tokens_free (%)·Zone·pacman | MI:0.XXX | tok/s | +delta | $cost | Model·effort | session_id

Example:

my-project | main [3] | #42 | 64,000 free (32.0%)·Code·ᗤ | MI:0.918 | 42.5 tok/s | +2,500 | $0.42 | Opus 4.6·high | abc-123

On a narrow terminal the statusline wraps onto additional lines instead of dropping elements. See Configuration for every segment's toggle key and default.

Architecture

graph LR
    A[Claude Code] -->|JSON stdin| B[Statusline Script]
    B -->|Parse| C[Model Info]
    B -->|Parse| D[Context Info]
    B -->|Check| E[Git Status]
    B -->|Read| F[Config File]
    B -->|Write| G[State File]
    C --> H[Format Output]
    D --> H
    E --> H
    F --> H
    H -->|stdout| A
Loading

Input Format

Scripts receive JSON via stdin from Claude Code:

{
  "model": {
    "display_name": "Opus 4.5"
  },
  "cwd": "/path/to/project",
  "session_id": "abc123",
  "context": {
    "tokens_remaining": 64000,
    "context_window": 200000,
    "autocompact_buffer_tokens": 45000
  }
}

Color Codes

The script uses consistent ANSI colors (defaults, overridable via ~/.claude/statusline.conf):

Per-Property Colors

Each statusline element has its own configurable color with a fallback chain:

Element Default Config Key Fallback
Context length Bold White color_context_length MI-based color
Project name Cyan color_project_name color_blue
Git branch Green color_branch_name color_magenta
MI score Yellow color_mi_score MI-based color
Zone indicator (zone color) color_zone Dynamic zone color
Model name Dim color_model color_separator
Throughput Dim color_tps color_separator
Token delta Dim color_delta color_separator
Session ID Dim color_session color_separator
Separator/dim Dim color_separator —

Base Colors

Color Code Usage Config Key
Cyan \033[0;36m Changes count color_cyan
Green \033[0;32m MI-based (good) color_green
Yellow \033[0;33m MI-based (warning) color_yellow
Red \033[0;31m MI-based (critical) color_red
Bold White \033[1;97m Context length default —
Dim \033[2m Separator default —
Reset \033[0m Reset formatting —

See Configuration for details on overriding colors with named colors or hex codes.