# SmartStack status line

Deployed by `ss install` to `~/.claude/scripts/statusline/index.js` and wired into
`~/.claude/settings.json`. Renders a 2-line Claude Code status line:

```
CTX <bar> N% │ 5h <bar> N% (Nh) │ 7d <bar> N% (Nj)
<model> │ <dir> │ ⎇ <branch> │ +added/-removed │ $cost
```

- **L1 — gauges**: context window + the 5-hour and 7-day (weekly) rate limits, each
  with a 10-char bar. Context colors by usage (<30 green / 30-40 orange / >40 red).
  The rate-limit gauges color by **pace**: green while consumption% stays below the %
  of the window still remaining, orange once consumption catches up to it, red when it
  overshoots by 20 points. Both show the time until reset as a bare value in parens —
  hours for 5h (`Nh`), days for the weekly 7d (`Nj`), no "reset" label.
- **L2 — session**: model, working dir, git branch, lines changed, session cost.
- Pure Node, **zero dependencies** (runs on the Node that ships with the CLI).
- Reads the Claude Code session JSON from stdin (`context_window`, `rate_limits`,
  `cost`, …), writes up to two lines to stdout. Any segment whose data is absent is
  dropped, so older Claude Code builds (no `rate_limits`) degrade cleanly.
- Reads the git branch directly from `.git/HEAD` (no `git` subprocess).
- Honors `NO_COLOR`.

## settings.json wiring

`ss install` adds (with the path resolved to the real install location):

```json
{
  "statusLine": {
    "type": "command",
    "command": "node \"<claudeDir>/scripts/statusline/index.js\"",
    "padding": 0
  }
}
```

It is set **only if you have no status line yet**. If a custom `statusLine` already
exists it is left untouched — run `ss install --force` to replace it (the previous
`settings.json` is backed up to `settings.backup-<timestamp>.json` first).

## Editing

Edit the source at `templates/scripts/statusline/index.js` in the CLI repo, then
re-run `ss install`. **Never** edit the deployed copy under `~/.claude/` — it is
overwritten on every install/upgrade.
