# Status Line Scripts ## Overview Two scripts that power a persistent status bar at the bottom of Claude Code, showing the current session topic, model name, and context window usage. ## Files - **`scripts/statusline.sh`** — Status line renderer. Receives session JSON on stdin from Claude Code, outputs formatted text. Also writes the session ID to `/tmp/claude-session-id-` so Claude can discover it. - **`scripts/set-topic.sh`** — Helper to write the topic file for a session. Usage: `set-topic.sh "topic text"`. - **`~/.claude/status/`** — Symlinks back to the canonical scripts. Claude Code's `settings.json` points here. - **`~/.claude/status//claude-topic.txt`** — Per-session topic files, written by `set-topic.sh`. ## Setup The `statusLine` config in `~/.claude/settings.json`: ```json { "statusLine": { "type": "command", "command": "~/.claude/status/statusline.sh" } } ``` Symlinks in `~/.claude/status/`: - `statusline.sh` → `~/dev/claude/projects/claude-foundations/scripts/statusline.sh` - `set-topic.sh` → `~/dev/claude/projects/claude-foundations/scripts/set-topic.sh` ## How It Works 1. Claude Code runs `statusline.sh` after each assistant message (debounced 300ms) 2. The script receives session JSON on stdin with `session_id`, `model`, `context_window`, `cwd`, etc. 3. It writes the session ID to `/tmp/claude-session-id-` so Claude can discover its own session 4. It reads the topic from `~/.claude/status//claude-topic.txt` if it exists 5. Outputs: `[Model Name] topic text | N% context` (or without topic if not set) ## Early Topic Setting If `set-topic.sh` is called before the status line has run (e.g., on the first message), the topic is written to a pending file (`/tmp/claude-pending-topic-`). On its next run, `statusline.sh` picks up the pending file and moves it into the correct session topic location. No error is raised — the topic just appears on the next response. ## Dependencies - `jq` — for parsing the session JSON - `md5sum` — for hashing the cwd to a predictable filename