A Python status line script for Claude Code that displays your current model, API usage limits, and working directory.
- Model Display: Shows the currently active Claude model
- Usage Tracking: Real-time 5-hour and 7-day API usage limits with color-coded alerts
- 🟢 Green: < 50% usage
- 🟡 Yellow: 50-80% usage
- 🔴 Red: > 80% usage
- Directory Info: Displays current working directory
- OAuth Integration: Automatically reads credentials from Claude Code
- Python 3.10 or higher
- Claude Code with OAuth authentication configured
- Supported platforms: macOS, Linux (Windows not supported)
-
Clone or download this repository
git clone <repository-url> cd claude-code-statusline
-
Configure Claude Code
Add the following to your
.claude/settings.json:{ "statusLine": { "type": "command", "command": "python3 /path/to/statusline.py", "padding": 0 } }Replace
/path/to/statusline.pywith the absolute path to this script. -
Restart Claude Code
The script:
- Receives session data from Claude Code via stdin (JSON format)
- Retrieves your OAuth access token:
- macOS: From Keychain using
security find-generic-password - Linux: From
~/.claude/.credentials.json - Windows: Not supported (returns empty)
- macOS: From Keychain using
- Fetches current usage data from Anthropic's API
- Outputs a formatted status line with ANSI colors
Sonnet 4.5 | 5h: 23% | 7d: 45% | Dir: /Users/you/projects/myapp
- "No credentials" message: Ensure you're logged in to Claude Code with OAuth
- "Usage: N/A" message: API request failed (check network connection)
- Script not updating: Verify the path in
.claude/settings.jsonis absolute and executable
For more information about status lines in Claude Code, see the official documentation.