2026-01-02 13:28:13 +11:00
# CLAUDE.md
2026-01-03 14:29:58 +11:00
This file provides guidance to Claude Code when working with this repository.
2026-01-02 13:28:13 +11:00
## Project Overview
2026-01-03 14:29:58 +11:00
Claude HUD is a Claude Code plugin that displays a real-time multi-line statusline. It shows context health, tool activity, agent status, and todo progress.
2026-01-02 13:28:13 +11:00
## Build Commands
```bash
2026-01-02 17:09:39 +11:00
bun install # Install dependencies
2026-01-03 14:29:58 +11:00
bun run build # Build TypeScript to dist/
# Test with sample stdin data
echo '{"model":{"display_name":"Opus"},"context_window":{"current_usage":{"input_tokens":45000},"context_window_size":200000}}' | node dist/index.js
2026-01-02 13:28:13 +11:00
```
## Architecture
### Data Flow
```
2026-01-03 14:29:58 +11:00
Claude Code → stdin JSON → parse → render lines → stdout → Claude Code displays
↘ transcript_path → parse JSONL → tools/agents/todos
2026-01-02 13:28:13 +11:00
```
2026-01-03 14:29:58 +11:00
**Key insight**: The statusline is invoked every ~300ms by Claude Code. Each invocation:
1. Receives JSON via stdin (model, context, tokens - native accurate data)
2. Parses the transcript JSONL file for tools, agents, and todos
3. Renders multi-line output to stdout
4. Claude Code displays all lines
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
### Data Sources
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
**Native from stdin JSON** (accurate, no estimation):
- `model.display_name` - Current model
- `context_window.current_usage` - Token counts
- `context_window.context_window_size` - Max context
- `transcript_path` - Path to session transcript
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
**From transcript JSONL parsing**:
- `tool_use` blocks → tool name, input, start time
- `tool_result` blocks → completion, duration
- Running tools = `tool_use` without matching `tool_result`
- `TodoWrite` calls → todo list
- `Task` calls → agent info
2026-01-03 10:23:30 +11:00
2026-01-03 14:29:58 +11:00
**From config files**:
- MCP count from `~/.claude/.mcp.json`
- Rules count from CLAUDE.md files
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
### File Structure
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
```
src/
├── index.ts # Entry point
├── stdin.ts # Parse Claude's JSON input
├── transcript.ts # Parse transcript JSONL
├── config-reader.ts # Read MCP/rules configs
├── types.ts # TypeScript interfaces
└── render/
├── index.ts # Main render coordinator
├── session-line.ts # Line 1: model, context, rules, MCPs
├── tools-line.ts # Line 2: tool activity
├── agents-line.ts # Line 3: agent status
├── todos-line.ts # Line 4: todo progress
└── colors.ts # ANSI color helpers
```
2026-01-02 17:09:39 +11:00
2026-01-03 14:29:58 +11:00
### Output Format
2026-01-02 13:28:13 +11:00
2026-01-03 14:29:58 +11:00
```
[Opus] ████████░░ 45% | 📋 3 rules | 🔌 5 MCPs | ⏱️ 12m
◐ Edit: auth.ts | ✓ Read × 3 | ✓ Grep × 2
◐ explore [haiku]: Finding auth code (2m 15s)
▸ Fix authentication bug (2/5)
```
2026-01-02 13:28:13 +11:00
2026-01-03 14:29:58 +11:00
Lines are conditionally shown:
- Line 1 (session): Always shown
- Line 2 (tools): Shown if any tools used
- Line 3 (agents): Shown only if agents active
- Line 4 (todos): Shown only if todos exist
2026-01-02 13:28:13 +11:00
2026-01-03 14:29:58 +11:00
### Context Thresholds
2026-01-03 14:24:45 +11:00
2026-01-03 14:29:58 +11:00
| Threshold | Color | Action |
|-----------|-------|--------|
| <70% | Green | Normal |
| 70-85% | Yellow | Warning |
| >85% | Red | Show token breakdown |
| >95% | Red | Show ⚠️ COMPACT |
2026-01-03 14:24:45 +11:00
2026-01-03 14:29:58 +11:00
## Plugin Configuration
2026-01-03 10:05:07 +11:00
2026-01-03 14:29:58 +11:00
The plugin is configured in `.claude-plugin/plugin.json` :
2026-01-03 10:05:07 +11:00
```json
{
2026-01-03 14:29:58 +11:00
"statusLine": {
"type": "command",
"command": "node ${CLAUDE_PLUGIN_ROOT}/dist/index.js"
}
2026-01-03 10:05:07 +11:00
}
```
2026-01-02 13:28:13 +11:00
## Dependencies
2026-01-03 14:29:58 +11:00
- **Runtime**: Node.js 18+ or Bun
2026-01-02 17:09:39 +11:00
- **Build**: TypeScript 5, ES2022 target, NodeNext modules