# setup-account-routing

Adopt this skill: https://proskills.md/skills/other/andrewtkent-statusline-claude-skills-setup-account-routing

Page: https://proskills.md/skills/other/andrewtkent-statusline-claude-skills-setup-account-routing
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: .claude/skills/setup-account-routing/SKILL.md
size: 3764
sha: 2be9084ffbdbc6932ab5774410e355cf2c1422b3
upstream: https://github.com/andrewtkent/statusline/blob/main/.claude/skills/setup-account-routing/SKILL.md

````text
---
name: setup-account-routing
description: Set up native-profile multi-account routing for Claude Code — account labels, isolated config profiles, quota-aware live handoffs, and the supervised launcher.
---

# Setup: account routing (accounts)

Multi-account routing for Claude Code. Each account gets an isolated native
`CLAUDE_CONFIG_DIR`. The supervisor chooses by quota headroom and resumes the
same conversation under another profile when the active account is blocked.
Run `/setup-statusline` first — both tools share `~/.claude/statusline.conf`.

## Hard rules

- Interactive routing uses Claude's native OAuth credentials, not setup-token
  injection or global credential replacement.
- Never display or log credential values. `~/.accounts/` stays out of transcripts
  and commits.
- `accounts mint` is only for headless jobs.

## Steps

1. **Label the accounts** in `~/.claude/statusline.conf`:

   ```bash
   ACCOUNT_LABELS="gmail:me@gmail.com work:me@corp.com|org-uuid"
   LABEL_COLORS="gmail:magenta work:cyan"   # optional
   ACCOUNTS_EXCLUDE=""                      # labels excluded from automatic routing
   ACCOUNTS_HIDE=""                         # labels hidden from the statusline board, still routed
   ACCOUNTS_HIDE_OTHERS=0                   # 1: this session's account is the only local row
   SHOW_ACCOUNT_RESETS=1
   ```

   To prevent routed sessions from consuming paid overage after the five-hour
   window reaches 100%, opt in locally:

   ```bash
   ACCOUNTS_HARD_SESSION_LIMIT=1
   ```

   Labels must match the email address shown by Claude. Same email in two
   organizations requires `|org-uuid` suffixes.

2. **Install the supervised launcher:**

   ```bash
   cd "$REPO"
   ./install-account-router.sh
   export PATH="$HOME/.accounts/bin:$PATH"
   ```

   The installer keeps the native Claude binary at `~/.local/bin/claude`, links
   the router tools under `~/.local/bin`, and places the supervised `claude`
   launcher first on `PATH`.

3. **Seed each account into the store.** Run the native binary directly, `/login`
   as the account, exit Claude, then run:

   ```bash
   ~/.local/bin/claude
   accounts status
   ```

   Repeat for each account. `accounts status` captures Claude's default-profile
   login into `~/.accounts/blobs.json`; routed launches subsequently keep refreshed
   credentials synchronized from their native profiles.

4. **Pick a mode:**

   ```bash
   accounts auto           # route supervised sessions by general quota headroom
   accounts fable          # switch live supervised sessions by Fable, weekly, and 5h headroom
   accounts set <label>    # force every supervised session to this account
   ```

   Mode changes are detected by running supervisors. Handoffs preserve the exact
   session ID and do not return control to the shell. Source changes to either
   router module reload the supervisor in place. New launches default to
   high effort and an invisible Claude session name unless explicitly set.

   Pin one launch with `ACCOUNTS_PIN=<label> claude`.

5. **Optional headless-job tokens:**

   ```bash
   accounts mint <label>
   accounts tokens
   accounts sync
   ```

## Verify

```bash
accounts poll
accounts ls
accounts status
ACCOUNTS_PIN=<label> accounts pick-env
```

`pick-env` should emit `CLAUDE_CONFIG_DIR=~/.accounts/profiles/<label>` and no
`CLAUDE_CODE_OAUTH_TOKEN` export.

## When routing misbehaves

1. `accounts status` shows the mode and next selected account.
2. `accounts auto` releases a persistent pin.
3. `accounts poll` refreshes the headroom board; `accounts refresh <label>`
   refreshes an expired access token.
4. `accounts status` reports a forced `set` target even when its cached quota is
   exhausted; the runtime follows the same rule.
````

## File: README.md
upstream: https://github.com/andrewtkent/statusline/blob/main/README.md

````text
<h1 align="center">statusline</h1>

<p align="center">
  <em>Terminal status bars and account tooling for AI coding CLIs —<br>cost, context, rate limits, burn-down, and multi-account routing, at a glance.</em>
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/@andrewkent/claude-statusline"><img alt="npm" src="https://img.shields.io/npm/v/@andrewkent/claude-statusline?color=cb3837&logo=npm&label=npm"></a>
  <a href="https://github.com/AndrewTKent/statusline/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/AndrewTKent/statusline/actions/workflows/ci.yml/badge.svg"></a>
  <img alt="platform" src="https://img.shields.io/badge/platform-macOS%20%C2%B7%20Linux%20%C2%B7%20Windows%20%28Git%20Bash%29-blue">
  <img alt="dependencies" src="https://img.shields.io/badge/deps-jq-lightgrey">
  <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-green"></a>
</p>

<p align="center">
  <a href="#quick-start">Quick start</a> &middot;
  <a href="#claude-code-status-line">Claude Code</a> &middot;
  <a href="#codex-status-line">Codex</a> &middot;
  <a href="#accounts">Accounts</a> &middot;
  <a href="#token-scanning">Token scanning</a> &middot;
  <a href="#agent-metrics">Agent Metrics</a> &middot;
  <a href="#macos-apps">macOS apps</a> &middot;
  <a href="#how-it-works">How it works</a>
</p>

---

Five tools, one repo, shared data files:

- **Claude Code status line** (`bin/statusline.sh`): the multi-line dashboard below.
- **Codex status line** (`bin/codex-statusline`, `codex-top`): the same idea for the Codex CLI.
- **`accounts`** (`bin/accounts.py`): native-profile account routing and a headroom board.
- **Token scanning** (`bin/scan-tokens*`): attributes every token to work/personal and to a payer.
- **Agent Metrics** (`bin/agent-metrics`): opt-in local telemetry and dashboard.

```
model   Fable 5.ultracode
time    ⏱ 2:29:20
account you@example.com
repo    my-project feature/fix-the-thing (v1.2.0*)
pr      #N Fix The Thing The Session Is Working On
context ●●●●●●●○○○○○○○○ 49%
session ●●●●●●●●●○○○○○○ 60.2%   resets 10:00pm PDT
weekly  ●●●●○○○○○○○○○○○ 31.07%  resets jul 27, 12:00pm PDT
fable   ●●●●○○○○○○○○○○○ 33%
usage   today 5.57M · session 1.16M · lifetime 593.31M
  acct        5h   reset   week   fable   reset
· Work       84%   2h15m    51%     80%      2d
· Work-Max   25%   2h25m    68%    100%      2d
* Personal   60%   3h45m    31%     33%      6d
· Side        0%       —   100%     16%      2d
```

The Claude status line is one bash script with no dependency beyond `jq`.

## Quick start

```bash
curl -fsSL https://raw.githubusercontent.com/AndrewTKent/statusline/main/install.sh | bash
```

Restart Claude Code. Requires [`jq`](https://jqlang.github.io/jq/) and a logged-in Claude Code; [`gh`](https://cli.github.com/) is optional, for PR badges. On Windows, see [Windows (Git Bash)](docs/statusline.md#windows-git-bash).

Other ways in: `npx @andrewkent/claude-statusline install`, or copy `bin/statusline.sh` to `~/.claude/statusline.sh` and point `statusLine` at it ([docs/statusline.md](docs/statusline.md#install)).

## Claude Code status line

Claude Code pipes a JSON status blob to the script, and it prints one labeled row per fact: model, session time, account, repo, branch, PR, context fill, the 5-hour and weekly windows, and token totals. Rows appear only when their data exists. Rate limits refresh in the background, so a render never waits on the network except to validate a changed credential.

Reference: [docs/statusline.md](docs/statusline.md) (every row, PR badges, files written).

### Formats

Set `FORMAT=` in `~/.claude/statusline.conf` or the `STATUSLINE_FORMAT` env var. Details: [docs/formats.md](docs/formats.md).

| Format | What it renders |
|--------|-----------------|
| `default` | The multi-line dashboard above; falls through to `narrow` below `NARROW_THRESHOLD` (60) columns |
| `compact` | Only the `context` and `session` rows |
| `narrow` | The `default` facts with short labels and bars scaled to the width |
| `sigil` | One dense, width-adaptive line, for tmux status bars |
| `sparkline` | `default` plus cost and 5h-rate trend charts over the last 15 sessions |
| `rprompt` | Writes a zsh right-prompt to `~/.claude/rprompt.txt` |
| `iterm2` | Pushes values to the iTerm2 status bar, or the Kitty window title |

### Configuration

`~/.claude/statusline.conf` is sourced by bash, and every setting is optional. Full list: [docs/configuration.md](docs/configuration.md); annotated example: [`config/statusline.conf.example`](config/statusline.conf.example).

| Key | Effect |
|-----|--------|
| `FORMAT` | Render mode (table above) |
| `DAILY_BUDGET` | Daily cost ceiling; adds the `budget` row |
| `ACCOUNT_LABELS`, `LABEL_COLORS` | Email pattern → short account tag, and its color |
| `SHOW_ACCOUNT_RESETS` | Adds the per-account board |
| `SHARED_ACCOUNT_SNAPSHOT` | Read account and quota rows only from the `accounts` snapshot |
| `WORK_PATHS`, `PERSONAL_PATHS`, `WORK_KEYWORDS`, `PERSONAL_KEYWORDS` | Work/personal token classifier |

## Codex status line

`codex-statusline` launches Codex with a fixed bottom pane showing the model, elapsed time, routed account, repo, context, tokens, permissions, and each Codex account's weekly quota. `codex-top` is the live view of every parent and subagent session. Both read local state only and call no API. Requires the Codex CLI, Python 3, `~/.local/bin` on `PATH`, and `tmux` for the multi-line footer.

```bash
./install-codex.sh
codex-statusline
```

Reference: [docs/codex.md](docs/codex.md) (scrolling, native mode, permissions default, settings).

## Accounts

`accounts` routes each Claude Code session to one of several subscription accounts, each in its own native profile under `~/.accounts/profiles/<label>`; `codex-accounts` does the same for Codex. A supervisor resumes a session on another account before a window is exhausted. When no safe account is left, the overage guard (on by default) stops it at 100% of a window, before extra usage starts.

```bash
./install-account-router.sh
accounts status
```

| Command | What it does |
|---------|--------------|
| `accounts status` | Mode + per-account 5h/7d/Fable headroom |
| `accounts auto` | Clear global and pane pins, then route supervised sessions to the freshest account |
| `accounts set <label>` | Force every supervised session onto `<label>` |
| `accounts pane set <label>` | Pin only the current terminal pane |
| `accounts fable` | Switch live supervised sessions to Fable while headroom is available |
| `accounts poll` | Refresh dormant stored/native profiles, then poll every routable account |
| `accounts move <label> --to <host>` | Move an account to another machine (`--from <host>` pulls one here) |
| `accounts login --box <host> <label>` | Log a box in to `<label>` with its own `/login` there; the browser step runs here and no credential leaves either machine |

A machine that should never pin, such as a box of unattended sessions, sets `ACCOUNTS_PINS=0` in `~/.claude/statusline.conf`. There `accounts set` and `accounts pane set` refuse, and any pin already stored is ignored, so every launch and every handoff goes to the account with headroom.

A login lives on one machine. Claude's OAuth refresh rotates the refresh token, so two machines holding one login race: the first to refresh wins and the other is signed out. `accounts export` and `accounts import` therefore run only inside `accounts move`, which forgets the source; a second machine that needs the same account gets its own login with `accounts login --box`, a separate lineage on the same quota.

A session named for a lane (`claude --name infra`, or `/rename infra`) shows that lane and its open PRs on one row, most pressing first and colored by state, and the unattended jobs working them. `lane-own give infra meetsol/iris#8987 IRI-12283` hands items to a lane.

Reference: [docs/accounts.md](docs/accounts.md) (all commands, Codex setup, the o
````
