A local-only Windows desktop app that shows every Claude Code session on your machine: live token usage, model, duration, and one-click session management.
🧭 Part of Abdul Raqeeb Khatri's portfolio: 📂 Hub · 🌐 Site · 💼 Experience
Overview
Running several Claude Code sessions (plus the subagents they spawn) at once makes it hard to know what is still running, which model each one is on, and where the tokens are going. The CLI keeps all of this in local files under ~/.claude/, but there is no overview.
Claude Sessions Tracker reads those files directly and presents them in a tabbed desktop UI. It needs no network access and no API key: token counts are summed from the message.usage fields in each session's JSONL transcript, never estimated. Closing the window shuts everything down.
💡 Why I Built It
Running several Claude Code sessions and their subagents at once made it hard to see what was still running, which model each used and where the tokens were going. The CLI has no overview.
📈 Impact
- One screen shows every session with live token usage summed from the transcripts, never estimated.
- Kill, rename and delete sessions without hunting through terminals and folders.
- Fully local: no network access and no API key.
32 commits in ~5 hours · 30 tests
Features
- Sessions table: every session with status dot, type (main or agent), name, session ID, project directory, start time, duration, model, and input/output/cache-read/cache-creation tokens.
- Session management: rename a session (names persist in SQLite), kill an active session's process, or delete a session's transcript after confirmation.
- Auto-naming: sessions without a custom name take the first user message as their name.
- Subagent detection: agent sessions are flagged and linked to their parent session ID.
- Model tracking: the model (Opus / Sonnet / Haiku) is extracted from assistant entries in the transcript.
- Dashboard: period selector, stat cards, daily bar and line charts (Matplotlib), and a per-session breakdown.
- Live updates: a watchdog observer on
~/.claude/plus a 60-second poll and a manual Refresh Now button. Rows update in place, so the table does not flicker. - Sort and filter: click a column header to sort; filter by name, session ID, or directory.
- Standalone
.exe: one-file PyInstaller build, with an automatic backup of the previous exe.
Tech Stack
| Area | Choice |
|---|---|
| UI | CustomTkinter 5.2 |
| Charts | Matplotlib (embedded FigureCanvasTkAgg) |
| File watching | watchdog |
| Process control | psutil |
| Persistence | SQLite (sqlite3, custom names only) |
| Packaging | PyInstaller 6.6 |
| Tests | pytest (30 tests) |
Architecture
flowchart LR
subgraph FS["~/.claude/ (read-only)"]
S["sessions/*.json<br/>active PIDs, cwd, start"]
P["projects/<dir>/<id>.jsonl<br/>messages + token usage"]
H["history.jsonl<br/>session → project"]
end
W["core/watcher.py<br/>watchdog observer"] -- change events --> Q[(thread-safe queue)]
FS --> PR["core/parser.py<br/>Session / TokenUsage models"]
Q --> ST["core/store.py<br/>in-memory store + SQLite names"]
PR --> ST
ST -- "after() poll, main thread" --> UI["ui/app.py"]
UI --> T1["Sessions tab"]
UI --> T2["Dashboard tab"]
The watcher runs on a background thread and only signals changes; all parsing results flow through the store, which the Tk main loop polls, so no widget is touched off the UI thread.
claude-sessions-tracker/
├── main.py # entry point: store + watcher + app
├── claude-tracker.spec # PyInstaller spec (relative paths)
├── build/build.py # scripted one-file build with exe backup
├── core/
│ ├── models.py # Session, TokenUsage, DailyStats dataclasses
│ ├── parser.py # reads ~/.claude/ files into models
│ ├── store.py # thread-safe store, period/daily aggregation
│ └── watcher.py # watchdog observer
├── ui/
│ ├── app.py # window, tabs, 60 s poll
│ ├── sessions_tab.py # table, rename/kill/delete, sort, filter
│ ├── dashboard_tab.py # period selector, stat cards, breakdown
│ └── widgets/charts.py # Matplotlib bar/line widgets
├── tests/ # pytest: models, parser, store
└── docs/ # design spec + implementation plans used to build it
Getting Started
Requirements: Windows 10/11, Python 3.10+, and Claude Code installed (sessions must exist under ~/.claude/). The core modules are cross-platform; the kill/console-hiding code is Windows-specific.
git clone https://github.com/Ark310/claude-sessions-tracker.git
cd claude-sessions-tracker
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python main.py
Run the tests:
python -m pytest -q
Build the standalone executable:
python build/build.py # -> dist/claude-tracker.exe (previous exe moved to dist/backup/)
# or
pyinstaller claude-tracker.spec
build/build.py builds in C:\BuildTemp\claude-tracker and copies the exe back, because Windows Defender blocked PyInstaller output written inside a synced (OneDrive) folder.
Configuration
None required. The app locates ~/.claude/ from the current user's home directory. Custom session names are stored in a local SQLite file (tracker.db), which is git-ignored.
Project Journey
All 32 original commits were made on a single day (20 May 2026), in three planned iterations. The design spec and the three implementation plans are in docs/.
| Version | Time (EDT) | What changed |
|---|---|---|
| v1.0 | 10:56 to 11:54 | Scaffold, dataclasses, JSONL parser, SQLite-backed store, watchdog observer, chart widgets, Sessions tab (kill/delete/rename/sort/filter), Dashboard tab, app wiring, PyInstaller build script. Each feature commit was followed by a review-driven fix: commit (parser performance, safe store copies, poll crash on close, rename race). |
| v1.2 | 12:34 to 13:23 | Subagent detection (parent_session_id, is_subagent), auto-naming from the first user message, a Type column, two-axis scrolling, poll interval cut to 60 s with a Refresh Now button, automatic exe backup before each build, both tabs refreshed on every poll. |
| v1.3 | 14:03 to 15:50 | Model field extracted from assistant entries, a Model column, and incremental in-place row updates to stop the table flickering on refresh. |
What didn't work
- Windowed PyInstaller build: the
--windowedbootloader (runw.exe) was flagged by Windows Defender as a trojan. The fix was a--consolebuild that hides its console window at startup viactypes(seemain.py). - Building inside a OneDrive folder: Defender kept blocking the output. The build now runs in
C:\BuildTempand copies the exe back, with a guard for a missing exe. - StringVar per status cell: replaced with static text, because the status dot is redrawn on update anyway.
- Date-bound tests: two store tests hard-coded May 2026 dates and started failing once those dates fell outside the 7- and 30-day windows. They now use dates relative to today (September 2026 fix).
🤖 Built with AI
This tool was built with Claude Code using a spec-first workflow (the superpowers brainstorm, plan, and execute skills):
- Spec → plan → tasks: one approved design spec and three implementation plans (1,675, 877 and 703 lines) were written with Claude before any code, then executed task by task with test-driven development. They ship in
docs/. - 32 commits in about 5 hours: 18
feat:, 13fix:and 1chore:commit, most of the fixes coming from Claude's code-review pass after each task. 7 of the original commits carried an explicitCo-Authored-By: Claude Sonnet 4.6trailer. Every commit in this repo now carries a Claude co-author trailer. - 30 pytest tests across models, parser, and store, all passing.
- The Claude Code transcripts from that day have since been cleared from
~/.claude/projects, so session counts are not available.
I wrote the requirements, reviewed the specs and plans, tested each build on real session data, and chose the Defender workarounds. Claude wrote most of the code and tests under that direction.
License
MIT © 2026 Abdul Raqeeb Khatri
← Back to the portfolio hub · Interactive site · Experience
Related projects: Knowledge Base Assistant · BLNS: Sanctions Screening RAG · Local LLM Setup
Author
Abdul Raqeeb Khatri · github.com/Ark310
