SLOPSHOPPER

whoami

Claude Code mod: shows which Claude account, organization and plan the session uses and how much of the usage limit is left, and holds prompts in a folder…

panebandspinnercommandtoastprompt
v0.3.1MITupdated 2026-10-26tornikegomareli/claude-whoami
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · whoami
│ ┃ account ✕ › fix the failing auth test and add an audit log call │ ┃ ▾ │ ┃ Enter switches this session. Esc closes. ⏺ Read(src/auth.ts) │ ⎿ Read 6 lines │ ⏺ Update(src/auth.ts) │ ⎿ Added 2 lines, removed 1 line │ ⏺ Bash(bun test) │ ⎿ 3 pass, 1 fail │ │ ● Done. refresh now rejects expired claims and logs an audit event. │ │ ✻ Worked for 42s · done 4:20 PM │ │ › /whoami │ ⎿ whoami: Signed in: account unknown. │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · account
▾ Enter switches this session. Esc closes.
README

whoami

Release License: MIT Claude Code 2.1.296+

A Claude Code mod that shows which Claude account you are signed in to: the organization, the email, the plan and how much of your usage limit is left, in one quiet line under the prompt. It also stops you from working in a folder on the wrong account.

<img src="docs/footer.png" alt="The prompt footer with the whoami line: Personal, the account email, Max 20x, and 5h 41%, resets 20:30" width="760">

<a href="#install">Install</a> · <a href="#what-you-see">What you see</a> · <a href="#pin-an-account-to-a-folder">Pin an account</a> · <a href="#settings">Settings</a> · <a href="#what-it-can-reach">What it can reach</a>

Why

With a personal account and one or more work organizations, Claude Code does not show which one the session runs on. You find out from a bill, an empty limit, or an admin. whoami keeps the answer on screen.

Install

Inside Claude Code (2.1.296 or later):

/plugin install whoami --marketplace tornikegomareli/claude-whoami
/reload-plugins
claude plugin marketplace add tornikegomareli/claude-whoami
claude plugin install whoami@claude-whoami

Or load it from a clone for one session:

git clone https://github.com/tornikegomareli/claude-whoami
claude --plugin-dir ./claude-whoami

The installer may say that 2 config options are not set. The defaults are fine, and /config changes them.

Mods are an early-access Claude Code feature, and their API can change between releases.

What you see

One line at the bottom of the prompt footer, each part in a soft color from your theme:

PartExampleColor
AccountAcme · me@acme.com, or Personal · me@gmail.comblue
PlanMax 20x, Proorange
Usage5h 41%, resets 20:30green under 50%, yellow from 50%, red from 80%

5h 41% means you have used 41% of your current 5-hour usage limit, and resets 20:30 is when it starts over. It is the same figure as /usage. The weekly limit joins the line once it is half used: 7d 63%, resets Fri.

If the session runs on an API key, the line says API key from ANTHROPIC_API_KEY and shows no plan or usage.

/whoami prints the account, and the pin that covers the folder, if one does.

Pin an account to a folder

Run /whoami pin in a folder to expect the current account there and in its subfolders. If a later session in that folder runs on another account:

  • A red band above the prompt names both accounts.
  • Prompts you type are held, and stay in the box.

<img src="docs/guard.png" alt="A prompt held in a folder pinned to Acme Inc while the session is signed in to a personal account, with the red band above the prompt" width="760">

Run /login to switch, or /whoami ok to continue on the current account for this session.

CommandAction
/whoamiShow the account, and the pin that covers this folder
/whoami pinExpect the current account in this folder and its subfolders
/whoami unpinRemove the pin that covers this folder
/whoami okContinue on the current account for this session

Slash commands, and prompts from plugins or other sessions, are never held.

Switch the account of a running session

This works with the Claude Accounts menu bar app, which keeps one Claude Code config folder per account and the list in ~/.claude-accounts/accounts.json. The footer then shows the name and emoji you gave the account, such as 💼 Work · me@acme.com.

Run /account to open a picker of your accounts. Arrows move, Enter switches this session, Esc closes. /account work or /account 2 switches without the picker.

CommandAction
/accountPick an account for this session
/account <name or number>Switch this session to that account

The switch sets CLAUDE_SECURESTORAGE_CONFIG_DIR in the session, so Claude Code reads the other folder's Keychain login. Claude Code keeps the login it read for 30 seconds, so the switch then runs /reload-plugins, which drops that copy: the next request goes out on the new account. Only the login changes: the transcript stays in the folder the session started in. An account with no login is refused, so the session keeps a working one. The variable is internal to Claude Code and can change in a later version.

Settings

Change them in /config (search for whoami), or with /plugin configure whoami@claude-whoami.

SettingDefaultWhat it does
fiveHourLimittrueOn: show how much of the 5-hour usage limit is used, and when it resets.
weeklyLimitover-halfalways: always show the weekly usage limit. over-half: only once it is 50% used. never: do not show it.
emailfullfull: show the whole email. name: only the part before @. hidden: no email, only the account or organization name.

What it can reach

whoami makes no network requests and calls no model.

It reads or doesThrough
Runs claude auth status --json for the account, organization and plan$.process.run
Reads organizationRateLimitTier (the 20x) and the email from ~/.claude.json, or <config folder>/.claude.json$.fs.read, $.env.get
Reads the account names and emoji in ~/.claude-accounts/accounts.json$.fs.read
Sets CLAUDE_SECURESTORAGE_CONFIG_DIR when you switch with /account, then runs /reload-plugins$.env.set, $.command.run, $.clock
Asks whether the session uses a login or an API key. It reads only the credential's kind, never the credential$.session.authorize
Reads the usage-limit figures that /usage showssession.measure, $.session.usage
Keeps your pins (folder and account) between sessions, in its own store under the Claude Code configuration folder$.store
Drops a typed prompt while the folder's pin does not matchprompt.submit
Draws the footer line, the red band, and the /account pickerui.render, $.ui.open

claude auth status reports ANTHROPIC_API_KEY even when the session declined that key and uses the login, so whoami asks the session which credential it uses before it trusts that report.

claude plugin validate . prints every hook and call.

Develop

claude --plugin-dir .   # load it; saving a file reloads it
claude plugin validate .
claude plugin test .

License

MIT

Source 3 files
hooks/register.tsx 236 lines
1import type { EngineInterface, Register } from 'claude-code'
2import { UNKNOWN, accountOf, nameAndEmail, orgOf, parseStatus, pinFor, planOf, usageOf } from './account'
3import type { Account, AuthStatus, Limit, Pins, Show } from './account'
4import { configFile, loginDir, parseSaved, pick, storageValue, titleOf } from './saved'
5import type { Saved } from './saved'
6
7const USAGE = '/whoami shows the account. /whoami pin expects it in this folder, /whoami unpin stops that, /whoami ok continues on a wrong one.'
8
9let account: Account = UNKNOWN
10let plan = '' // "Max 20x"
11let limits: readonly Limit[] = []
12let show: Show = { fiveHour: true, weekly: 'over-half', email: 'full' }
13let pin: { dir: string; account: Account } | undefined
14let isAllowed = false // `/whoami ok` was run in this session
15let home = ''
16let dir = '' // the folder whose login the session uses
17let email = ''
18let org: string | undefined
19let saved: readonly Saved[] = [] // the accounts of the Claude Accounts menu bar app
20let emails: Record<string, string> = {} // folder to the email of its login, for the picker
21
22const PICKER = 'account'
23const ACCOUNT_USAGE = '/account opens a picker. /account <name or number> switches this session to that account.'
24
25const isWrong = () => !!pin && pin.account.id !== account.id && !isAllowed
26
27// The global config file of a folder holds the login's email and the plan's size ("20x").
28type OAuthAccount = { organizationRateLimitTier?: string; emailAddress?: string; organizationName?: string; organizationUuid?: string }
29
30async function oauthAccount($: EngineInterface, folder: string) {
31  const text = await $.fs.read(configFile(folder, home)).catch(() => '')
32  try {
33    return (JSON.parse(text) as { oauthAccount?: OAuthAccount }).oauthAccount
34  } catch {
35    return undefined
36  }
37}
38
39async function readSaved($: EngineInterface) {
40  home = (await $.env.get('HOME')) ?? ''
41  dir = loginDir({ storage: await $.env.get('CLAUDE_SECURESTORAGE_CONFIG_DIR'), config: await $.env.get('CLAUDE_CONFIG_DIR'), home })
42  saved = parseSaved(await $.fs.read(`${home}/.claude-accounts/accounts.json`).catch(() => ''))
43}
44
45async function pins($: EngineInterface) {
46  return ((await $.store.get('pins')) ?? {}) as Pins
47}
48
49// `claude auth status` takes the email and organization from the config folder's profile, which names
50// another account once the session reads the login of another folder. The login folder's own profile
51// names the account of the login, so it wins.
52function withLogin(status: AuthStatus | undefined, login: OAuthAccount | undefined): AuthStatus | undefined {
53  if (!status?.email || !login?.emailAddress) return status
54  return { ...status, email: login.emailAddress, orgName: login.organizationName ?? status.orgName, orgId: login.organizationUuid ?? status.orgId }
55}
56
57// Reads the account and this folder's pin, then redraws the footer label and the band.
58async function check($: EngineInterface) {
59  // `claude auth status` reports ANTHROPIC_API_KEY even when the session declined it and uses the login.
60  const usesLogin = (await $.session.authorize().catch(() => null))?.kind === 'bearer'
61  const env = usesLogin ? { ANTHROPIC_API_KEY: '' } : undefined
62  const r = await $.process.run(['claude', 'auth', 'status', '--json'], { env, timeoutMs: 10000 }).catch(() => undefined)
63  await readSaved($).catch(() => {}) // without the list the footer shows the organization
64  const login = await oauthAccount($, dir)
65  const status = withLogin(r && parseStatus(r.stdout), login)
66  account = status ? accountOf(status) : UNKNOWN
67  email = status?.email ?? ''
68  org = status && orgOf(status)
69  plan = usesLogin ? planOf(status?.subscriptionType, login?.organizationRateLimitTier) : ''
70  pin = pinFor(await pins($), await $.session.cwd())
71  // Figures the session had before this mod loaded never raise a `session.measure` of their own.
72  limits = (await $.session.usage().catch(() => undefined))?.rateLimits ?? limits
73  $.ui.invalidate('ui.render')
74}
75
76async function command($: EngineInterface, arg: string) {
77  await check($)
78  const cwd = await $.session.cwd()
79  const all = await pins($)
80  if (arg === 'pin') {
81    await $.store.set('pins', { ...all, [cwd]: account })
82    await check($)
83    return `Pinned ${account.label} to ${cwd} and its subfolders.`
84  }
85  if (arg === 'unpin') {
86    if (!pin) return 'No pin covers this folder.'
87    const { [pin.dir]: _, ...rest } = all
88    const dir = pin.dir
89    await $.store.set('pins', rest)
90    await check($)
91    return `Removed the pin of ${dir}.`
92  }
93  if (arg === 'ok') {
94    isAllowed = true
95    await check($)
96    return `Continuing on ${account.label} for this session.`
97  }
98  if (arg) return USAGE
99  const expected = pin ? `\n${pin.dir} expects ${pin.account.label}.` : ''
100  return `Signed in: ${account.label}.${expected}`
101}
102
103// Points the session at the login of another account; a login with no Keychain item is refused first,
104// so the session never loses its own. Claude Code keeps the login it read for 30 seconds, and
105// /reload-plugins drops that copy, so the next request already goes out on the new account.
106// A command hook cannot start another command, so the reload runs from a timer, once this one is done.
107async function switchTo($: EngineInterface, target: Saved) {
108  await readSaved($)
109  if (target.configDir === dir) return `This session already uses ${titleOf(target)}.`
110  const value = storageValue(target.configDir, home)
111  const r = await $.process.run(['claude', 'auth', 'status', '--json'], { env: { CLAUDE_SECURESTORAGE_CONFIG_DIR: value, ANTHROPIC_API_KEY: '' }, timeoutMs: 10000 }).catch(() => undefined)
112  if (!(r && parseStatus(r.stdout))?.loggedIn) return `${titleOf(target)} has no login yet. Log in to it from the Claude Accounts menu bar app first.`
113  const set = await $.env.set('CLAUDE_SECURESTORAGE_CONFIG_DIR', value)
114  if (set.deny) return `Could not switch to ${titleOf(target)}: ${set.deny}`
115  $.clock.after(0, () => void $.command.run({ command: 'reload-plugins' }).catch(() => {}))
116  await check($)
117  return `Switched this session to ${titleOf(target)}${email ? ` (${email})` : ''}.`
118}
119
120async function accountCommand($: EngineInterface, arg: string) {
121  await readSaved($)
122  if (!saved.length) return 'No accounts yet. Add them in the Claude Accounts menu bar app.'
123  if (!arg) {
124    emails = {}
125    for (const a of saved) emails[a.configDir] = (await oauthAccount($, a.configDir))?.emailAddress ?? ''
126    await $.ui.open({ id: PICKER, title: 'Switch account', focus: true, closeOnEscape: true, rows: saved.length + 2 })
127    return undefined
128  }
129  const target = pick(saved, arg)
130  if (!target) return `No account "${arg}". ${saved.map((a, i) => `${i + 1} ${titleOf(a)}`).join(', ')}.`
131  return switchTo($, target)
132}
133
134export const register: Register = (on, options) => {
135  show = {
136    fiveHour: options.fiveHourLimit !== false,
137    weekly: options.weeklyLimit === 'always' || options.weeklyLimit === 'never' ? options.weeklyLimit : 'over-half',
138    email: options.email === 'name' || options.email === 'hidden' ? options.email : 'full',
139  }
140
141  on('session.start', async ($, e, next) => {
142    await $.command.register({ name: 'whoami', description: `Which Claude account this session uses. ${USAGE}` }).catch(() => {})
143    await $.command.register({ name: 'account', description: `Switch this session to another Claude account. ${ACCOUNT_USAGE}` }).catch(() => {})
144    void check($).catch(() => {})
145    return next(e)
146  })
147
148  on('command.run', { command: 'whoami' }, async ($, e) => ({ text: await command($, e.args.trim()) }))
149
150  on('command.run', { command: 'account' }, async ($, e) => ({ text: await accountCommand($, e.args.trim()) }))
151
152  // The picker `/account` opens: arrows move, Enter switches, Esc closes.
153  on('ui.render', { component: 'Pane', requestId: PICKER }, async ($, e, next) => {
154    const elements = $.ui.resolve(e)
155    if (!('Select' in elements)) return next(e)
156    const { Box, Select, Text } = elements
157    const options = saved.map(a => ({
158      value: a.configDir,
159      label: [titleOf(a), emails[a.configDir] || 'no login', a.configDir === dir ? 'this session' : ''].filter(Boolean).join(' · '),
160    }))
161    return (
162      <Box flexDirection="column">
163        <Select
164          key="account"
165          options={options}
166          value={dir}
167          autoFocus
168          onSelect={async value => {
169            const target = saved.find(a => a.configDir === value)
170            const text = target ? await switchTo($, target) : 'That account is gone from the list.'
171            await $.ui.close({ id: PICKER })
172            $.ui.toast(text, { timeoutMs: 8000 })
173          }}
174        />
175        <Text dimColor>Enter switches this session. Esc closes.</Text>
176      </Box>
177    )
178  })
179
180  // A prompt typed in a folder pinned to another account is dropped; the engine puts it back in the box.
181  on('prompt.submit', async ($, e, next) => {
182    if (e.origin.kind !== 'composer' || e.text.trimStart().startsWith('/')) return next(e)
183    if (isWrong()) await check($) // after /login the account may be right now
184    if (!isWrong()) {
185      void check($).catch(() => {})
186      return next(e)
187    }
188    return { drop: `Signed in to ${account.label}, but this folder expects ${pin?.account.label}. Run /login to switch, or /whoami ok to continue.` }
189  })
190
191  on('session.measure', async ($, e, next) => {
192    if (e.changed.includes('rateLimits')) {
193      limits = e.rateLimits
194      $.ui.invalidate('ui.render')
195    }
196    return next(e)
197  })
198
199  // The footer's mode labels (`focus`), redrawn on the left with the account, plan and usage after them.
200  on('ui.render', { component: 'SessionMode' }, async ($, e, next) => {
201    const elements = $.ui.resolve(e)
202    if (account === UNKNOWN || !('Box' in elements)) return next(e)
203    const { Box, Text } = elements
204    const usage = usageOf(limits, show)
205    const mine = saved.find(a => a.configDir === dir)
206    const parts = [
207      { text: email ? nameAndEmail(mine ? titleOf(mine) : org, email, show.email) : account.label, color: 'suggestion' },
208      { text: plan, color: 'claude' },
209      { text: usage.text, color: usage.used >= 80 ? 'error' : usage.used >= 50 ? 'warning' : 'success' },
210    ].filter(p => p.text)
211    return (
212      <Box width="100%" justifyContent="flex-start">
213        <Text>
214          {e.props.modes.length ? <Text dimColor>{e.props.modes.join(' & ')} & </Text> : null}
215          {parts.map((p, i) => <Text key={p.color}>{i ? <Text dimColor> · </Text> : null}<Text color={p.color}>{p.text}</Text></Text>)}
216        </Text>
217      </Box>
218    )
219  })
220
221  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
222    if (!isWrong() || e.props.hasSurvey) return next(e)
223    const elements = $.ui.resolve(e)
224    if (!('Box' in elements)) return next(e)
225    const { Box, Text } = elements
226    return (
227      <Box flexDirection="column" borderStyle="round" borderColor="error" paddingX={1}>
228        <Text color="error" bold>Wrong Claude account for this folder</Text>
229        <Text>Signed in: {account.label}</Text>
230        <Text>{pin?.dir} expects: {pin?.account.label}</Text>
231        <Text dimColor>Run /login to switch, or /whoami ok to continue on this account.</Text>
232      </Box>
233    )
234  })
235}
236
hooks/account.ts 89 lines
1// What `claude auth status --json` prints. Fields absent for a login method are left out.
2export type AuthStatus = {
3  loggedIn?: boolean
4  authMethod?: string
5  apiProvider?: string
6  apiKeySource?: string
7  email?: string
8  orgId?: string
9  orgName?: string
10  subscriptionType?: string
11}
12
13// One usage-limit window, as `session.measure` reports it.
14export type Limit = { kind: string; percentUsed: number; resetsAt?: string }
15
16// `id` is what a pin compares; `label` is what the person reads.
17export type Account = { id: string; label: string }
18
19// Folder path to the account expected there.
20export type Pins = Record<string, Account>
21
22export const UNKNOWN: Account = { id: 'unknown', label: 'account unknown' }
23
24// The organization as the footer names it: a personal account's generated name reads as "Personal".
25export const orgOf = (s: AuthStatus) => (s.email && s.orgName === `${s.email}'s Organization` ? 'Personal' : s.orgName)
26
27export function accountOf(s: AuthStatus): Account {
28  if (s.apiProvider && s.apiProvider !== 'firstParty') return { id: `provider:${s.apiProvider}`, label: s.apiProvider }
29  if (s.authMethod === 'api_key') return { id: 'api-key', label: `API key from ${s.apiKeySource ?? 'unknown source'}` }
30  if (!s.loggedIn) return { id: 'none', label: 'not signed in' }
31  const label = [orgOf(s), s.email].filter(Boolean).join(' · ')
32  return { id: s.orgId ?? s.email ?? UNKNOWN.id, label: label || UNKNOWN.label }
33}
34
35export function parseStatus(stdout: string): AuthStatus | undefined {
36  try {
37    return JSON.parse(stdout) as AuthStatus
38  } catch {
39    return undefined
40  }
41}
42
43// `max` and `default_claude_max_20x` read as "Max 20x".
44export function planOf(subscriptionType?: string, rateLimitTier?: string) {
45  if (!subscriptionType) return ''
46  const size = rateLimitTier?.match(/_(\d+x)$/)?.[1]
47  return [subscriptionType[0]!.toUpperCase() + subscriptionType.slice(1), size].filter(Boolean).join(' ')
48}
49
50const pad = (n: number) => String(n).padStart(2, '0')
51const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
52
53// Which windows the footer shows: the fiveHourLimit and weeklyLimit settings.
54export type Show = { fiveHour: boolean; weekly: 'always' | 'over-half' | 'never'; email: 'full' | 'name' | 'hidden' }
55
56// The footer's account part: the account's name, then the email as the email setting asks.
57export function nameAndEmail(name: string | undefined, email: string, show: Show['email']) {
58  const shown = show === 'hidden' ? '' : show === 'name' ? email.split('@')[0] : email
59  return [name, shown].filter(Boolean).join(' · ')
60}
61
62type Windows = Pick<Show, 'fiveHour' | 'weekly'>
63
64const isShown = (l: Limit, show: Windows) =>
65  l.kind === 'five_hour' ? show.fiveHour
66  : l.kind === 'seven_day' && (show.weekly === 'always' || (show.weekly === 'over-half' && l.percentUsed >= 50))
67
68// "5h 42%, resets 18:30 · 7d 63%, resets Fri", and the highest percent shown, for its color.
69export function usageOf(limits: readonly Limit[], show: Windows) {
70  const parts: string[] = []
71  let used = 0
72  for (const l of limits) {
73    if (!isShown(l, show)) continue
74    const at = l.resetsAt ? new Date(l.resetsAt) : undefined
75    const resets = at ? `, resets ${l.kind === 'five_hour' ? `${pad(at.getHours())}:${pad(at.getMinutes())}` : DAYS[at.getDay()]}` : ''
76    parts.push(`${l.kind === 'five_hour' ? '5h' : '7d'} ${Math.round(l.percentUsed)}%${resets}`)
77    used = Math.max(used, l.percentUsed)
78  }
79  return { text: parts.join(' · '), used }
80}
81
82// The pin of `dir` or of its nearest parent folder.
83export function pinFor(pins: Pins, dir: string): { dir: string; account: Account } | undefined {
84  for (let d = dir; d; d = d.slice(0, d.lastIndexOf('/'))) {
85    const account = pins[d]
86    if (account) return { dir: d, account }
87  }
88}
89
hooks/saved.ts 38 lines
1// An account of the Claude Accounts menu bar app: a name, an emoji, and the
2// config folder whose Keychain login it uses. The app keeps the list in
3// ~/.claude-accounts/accounts.json.
4export type Saved = { name: string; configDir: string; emoji?: string }
5
6export function parseSaved(text: string): Saved[] {
7  try {
8    const list = JSON.parse(text) as unknown
9    if (!Array.isArray(list)) return []
10    return list.filter((a): a is Saved => typeof a?.name === 'string' && typeof a?.configDir === 'string')
11  } catch {
12    return []
13  }
14}
15
16// "💼 Work", or the name alone.
17export const titleOf = (a: Saved) => (a.emoji ? `${a.emoji} ${a.name}` : a.name)
18
19// The account a `/account` argument names: its number in the list, its name, or the start of its name.
20export function pick(list: readonly Saved[], arg: string): Saved | undefined {
21  if (/^\d+$/.test(arg)) return list[Number(arg) - 1]
22  const q = arg.toLowerCase()
23  return list.find(a => a.name.toLowerCase() === q) ?? list.find(a => a.name.toLowerCase().startsWith(q))
24}
25
26// Claude Code names the Keychain item of a login after CLAUDE_SECURESTORAGE_CONFIG_DIR, and reads that
27// variable each time it reads the login. Empty means the default folder, whose item name has no hash.
28export const storageValue = (dir: string, home: string) => (dir === `${home}/.claude` ? '' : dir)
29
30// The folder whose login the session uses: the switched one, else the folder it started with.
31export function loginDir(env: { storage?: string; config?: string; home: string }) {
32  if (env.storage !== undefined) return env.storage || `${env.home}/.claude`
33  return env.config || `${env.home}/.claude`
34}
35
36// Where Claude Code keeps the global config, with the login's email and plan size, for a folder.
37export const configFile = (dir: string, home: string) => (dir === `${home}/.claude` ? `${home}/.claude.json` : `${dir}/.claude.json`)
38