# mcpysup-netizen/claude-ai-accounts architecture

> Architecture diagram of the GitHub repository mcpysup-netizen/claude-ai-accounts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mcpysup-netizen/claude-ai-accounts
- Repository: https://github.com/mcpysup-netizen/claude-ai-accounts

## Overview

claude-ai-accounts lets engineers select separate Claude Code and Codex subscription accounts per session, inspect shared usage limits, and switch accounts without repeatedly logging in. The main workflow is account selection at launch, followed by limit collection and status display; the plugin adds in-session switching, including resuming Claude in the same tmux pane. The README documents account setup, shared settings with isolated authentication, Codex companion routing, and usage reporting. Source excerpts establish the usage and switching paths; other CLI account-management details are documented but unsampled.

Main entry points: [`bin/ai_usage_lib.py`](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_lib.py) (Usage service), [`mod/hooks/register.tsx`](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/mod/hooks/register.tsx) (Plugin controls), [`bin/ai`](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai) (Account CLI), [`bin/ai_usage_line.py`](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_line.py) (Usage recorder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Account launch"]
  node_cli["Account CLI"]
  node_claude["Claude sessions"]
  node_codex["Codex sessions"]
  node_swap["Pane swap<br/>[ai_swap.py]"]
end

subgraph group_usage["Usage reporting"]
  node_claude_status["Claude status input"]
  node_record["Usage recorder<br/>[ai_usage_line.py]"]
  node_usage_lib["Usage service<br/>[ai_usage_lib.py]"]
  node_codex_server["Codex app-server"]
  node_codex_rollouts["Codex run history"]
  node_statusline["Statusline display<br/>[ai-statusline.sh]"]
end

subgraph group_plugin["Session plugin"]
  node_plugin["Plugin controls<br/>[register.tsx]"]
end

subgraph group_state["Account state"]
  node_registry[("Account registry")]
  node_usage_cache[("Usage cache")]
end

node_user(("Engineer"))

node_user -->|"select account"| node_cli
node_cli -->|"launches"| node_claude
node_cli -->|"launches"| node_codex
node_plugin -->|"reads accounts"| node_cli
node_plugin -->|"requests switch"| node_swap
node_swap -->|"resumes session"| node_claude
node_plugin -->|"sets session account"| node_codex
node_claude_status -->|"records limits"| node_record
node_record -->|"records usage"| node_usage_lib
node_usage_lib -->|"queries limits"| node_codex_server
node_usage_lib -->|"reads fallback"| node_codex_rollouts
node_usage_lib -->|"reads accounts"| node_registry
node_usage_lib -->|"reads and writes"| node_usage_cache
node_plugin -->|"requests snapshot"| node_usage_lib
node_statusline -.->|"records limits"| node_record
node_user -.->|"views usage"| node_statusline

click node_cli "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai"
click node_swap "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_swap.py"
click node_plugin "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/mod/hooks/register.tsx"
click node_record "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_line.py"
click node_usage_lib "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_lib.py"
click node_statusline "https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/statusline/ai-statusline.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_claude,node_codex,node_swap toneBlue
class node_claude_status,node_record,node_usage_lib,node_codex_server,node_codex_rollouts,node_statusline toneAmber
class node_plugin toneMint
class node_registry,node_usage_cache toneRose
class node_user toneIndigo
```

## Components

### Account launch

- [Account CLI](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai): `bin/ai`
- **Claude sessions**
- **Codex sessions**
- [Pane swap](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_swap.py): `bin/ai_swap.py`

### Usage reporting

- **Claude status input**
- [Usage recorder](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_line.py): `bin/ai_usage_line.py`
- [Usage service](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/bin/ai_usage_lib.py): `bin/ai_usage_lib.py`
- **Codex app-server**
- **Codex run history**
- [Statusline display](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/statusline/ai-statusline.sh): `statusline/ai-statusline.sh`

### Session plugin

- [Plugin controls](https://github.com/mcpysup-netizen/claude-ai-accounts/blob/main/mod/hooks/register.tsx): `mod/hooks/register.tsx`

### Account state

- **Account registry**
- **Usage cache**

### Other components

- **Engineer**

## Connections

- Engineer → Account CLI: select account (evidence: `README.md`)
- Account CLI → Claude sessions: launches (evidence: `README.md`)
- Account CLI → Codex sessions: launches (evidence: `README.md`)
- Plugin controls → Account CLI: reads accounts (evidence: `mod/hooks/register.tsx`)
- Plugin controls → Pane swap: requests switch (evidence: `mod/hooks/register.tsx`)
- Pane swap → Claude sessions: resumes session (evidence: `bin/ai_swap.py`)
- Plugin controls → Codex sessions: sets session account (evidence: `README.md`)
- Claude status input → Usage recorder: records limits (evidence: `README.md`)
- Usage recorder → Usage service: records usage (evidence: `bin/ai_usage_line.py`)
- Usage service → Codex app-server: queries limits (evidence: `bin/ai_usage_lib.py`)
- Usage service → Codex run history: reads fallback (evidence: `bin/ai_usage_lib.py`)
- Usage service → Account registry: reads accounts (evidence: `bin/ai_usage_lib.py`)
- Usage service → Usage cache: reads and writes (evidence: `bin/ai_usage_lib.py`)
- Plugin controls → Usage service: requests snapshot (evidence: `mod/hooks/register.tsx`)
- Statusline display → Usage recorder: records limits
- Engineer → Statusline display: views usage
