claude-dash-cli

πŸ—οΈ Architecture

How the TUI, daemon, and Claude Code hooks talk to each other over two Unix sockets.

claude-dash is split into three cooperating parts: the TUI you interact with, a background daemon that holds session state, and lightweight hook processes that Claude Code fires on every tool use.

🌳 File tree

claude-dash-cli/
β”œβ”€β”€ Cargo.toml
└── src/
    β”œβ”€β”€ main.rs         # CLI dispatch (clap), TUI event loop, daemon spawn
    β”œβ”€β”€ app.rs          # TUI app state, key handling, usage cache
    β”œβ”€β”€ types.rs        # Shared domain types
    β”œβ”€β”€ daemon.rs       # Unix socket client (TUI ↔ daemon)
    β”œβ”€β”€ usage.rs        # ccusage + Anthropic API rate limits
    β”œβ”€β”€ utils.rs        # Formatting helpers
    β”œβ”€β”€ cmd/
    β”‚   β”œβ”€β”€ daemon.rs   # Daemon process β€” two Unix socket servers, state machine
    β”‚   β”œβ”€β”€ hook.rs     # Claude Code hook handler β€” reads stdin, fires events
    β”‚   └── install.rs  # Hook installer β€” writes ~/.claude/settings.json
    └── ui/
        β”œβ”€β”€ mod.rs          # Layout
        β”œβ”€β”€ header.rs       # Top bar
        β”œβ”€β”€ footer.rs       # Key hints bar
        β”œβ”€β”€ session_list.rs # Agent list with status groups
        β”œβ”€β”€ usage_panel.rs  # Cost/token/chart panel
        └── overlays.rs     # Permission modal, new session, rename

πŸ”Œ The two sockets

Two Unix sockets connect the pieces:

  • /tmp/claude-dash.sock β€” hook processes send events here (fire-and-forget, or await a decision for a PermissionRequest).
  • /tmp/claude-dash-tui.sock β€” the TUI connects here to receive state snapshots/deltas and to send permission decisions.

βš™οΈ Event flow

Claude Code hooks trigger claude-dash hook on every tool use. The hook reads the event from stdin and forwards it to the daemon over /tmp/claude-dash.sock. The daemon tracks session state and pushes updates to all connected TUI clients over /tmp/claude-dash-tui.sock as newline-delimited JSON.

For a PermissionRequest, the hook process blocks awaiting the daemon's decision: the TUI surfaces a permission modal, your keypress (a / s / d) travels back to the daemon, and the daemon replies to the waiting hook β€” which allows or denies the tool call in Claude Code.