Token monitor for coding agents — like htop for AI spend
Project description
tktop
Token monitor for coding agents. Like htop for your AI spend.
Features
- Live dashboard — real-time token usage breakdown (input/output/cache)
- Token flow graph — sparkline showing output tokens per turn
- Tool stats — see which tools consume the most calls
- Drift detection — 9 algorithms detecting loops, thrashing, runaway sessions
- Cost tracking — per-session cost estimates by model
- Turn drill-down — inspect individual turns with token split and content preview
- Coach screen — local feedback on prompt scope, validation habits, checkpoints, and agent workflow smells
- LLM analysis — on-demand optimization suggestions via Ollama/Anthropic/Vertex AI/OpenAI
Install
Requires Python 3.10 or newer.
# From PyPI
pip install tktop
# Upgrade to the latest release
pip install -U tktop
Usage
tktop # launch interactive session list
tktop -h # show help
tktop -v # show version
tktop info # print environment summary for bug reports
tktop doctor # diagnose local setup
tktop doctor checks the settings file, Claude/Codex data directories, adapter
discovery, and selected LLM provider configuration without contacting external
LLM APIs.
Keybindings
| Key | Action |
|---|---|
↑/↓ or j/k |
Navigate |
enter |
Select / drill-down |
a |
Run LLM analysis |
c |
Open Coach for the current session |
L |
Enhance Coach suggestions with the configured LLM |
r |
Refresh |
escape |
Back |
q |
Quit |
Supported Agents
- Claude Code
- Codex
- Cursor (planned)
- Aider (planned)
Coach And LLM Analysis
The Coach screen is available from a session dashboard with c. It renders a
scrollable Markdown report with local, deterministic guidance about how the
developer used the coding agent: prompt scope, validation requests, checkpoint
habits, exploration before edits, and repeated tool usage.
Coach does not call an LLM by default. Press L inside Coach to enhance the
local findings with the configured analysis provider and model. Enhanced
suggestions are cached in memory for the running TUI session, so leaving and
reopening Coach shows the same result until the session changes, the app closes,
or you regenerate it.
LLM analysis remains available from a session dashboard with a. Analysis
focuses on token, cost, drift, and tool optimization; Coach focuses on improving
developer workflow with agentic coding tools.
The settings file is created at ~/.tktop/settings.json the first time tktop
loads its configuration. View its path and resolved values with:
tktop config path
tktop config show
Example configuration:
{
"session_adapter": "auto",
"default_provider": "ollama",
"ui": {
"show_token_flow": false
},
"agents": {
"claude": {
"dir": "~/.claude"
},
"codex": {
"dir": "~/.codex"
}
},
"providers": {
"ollama": {
"host": "http://localhost:11434",
"model": "llama3"
},
"anthropic": {
"api_key": "",
"model": "claude-sonnet-4-6"
},
"vertex": {
"project": "",
"region": "us-east5",
"model": "claude-sonnet-4-6"
},
"openai": {
"base_url": "https://api.openai.com/v1",
"api_key": "",
"model": "gpt-4o"
}
}
}
session_adapter accepts auto, claude, or codex. Supported analysis
providers are ollama, anthropic, vertex, and openai.
Environment variables override settings.json. Common overrides are:
TKTOP_SESSION_ADAPTER=codex
TKTOP_CODEX_DIR=~/.codex
TKTOP_LLM_PROVIDER=openai
TKTOP_OPENAI_API_KEY=sk-...
TKTOP_OPENAI_MODEL=gpt-4o
For source checkouts, .env.example lists all supported environment variables.
Prefer environment variables for API keys instead of storing secrets in JSON.
Development
make install # install in dev mode
make test # run tests
make clean # clean build artifacts
Local development still uses an editable install:
pip install -e ".[dev]"
Use these commands while developing:
make run # run directly from the editable source checkout
make check # lint, security scan, and full tests
make package-test # build and install the wheel in an isolated local venv
make package-run # launch the locally built wheel
make package-test uses .venvs/package-test, which is ignored by git. It
tests the same wheel artifact that would be uploaded to PyPI, without publishing
anything.
For maintainers, a versioned release can be prepared with:
make release VERSION=0.1.1
Devbox
If you have the Devbox CLI installed, you can bootstrap the repo with:
devbox shell
On first entry, the shell creates .venv, installs .[dev], and activates the
environment for the session.
License: MIT. See LICENSE.
Repository instructions for Codex are in AGENTS.md. The current
design is documented in
docs/specs/2026-06-08-tktop-design.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tktop-1.1.0.tar.gz.
File metadata
- Download URL: tktop-1.1.0.tar.gz
- Upload date:
- Size: 99.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cddbe0c0a1f76de5435c668baf969d5720b26994866aae07e50c5c3146d36ec
|
|
| MD5 |
18244dadc29252f443b3f66cdb898a00
|
|
| BLAKE2b-256 |
bffdbf5137f732a4d7de940b890235b585aa8cb162a15ca164c875b82cf4ce47
|
Provenance
The following attestation bundles were made for tktop-1.1.0.tar.gz:
Publisher:
release.yml on chanilharisankar/tktop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tktop-1.1.0.tar.gz -
Subject digest:
1cddbe0c0a1f76de5435c668baf969d5720b26994866aae07e50c5c3146d36ec - Sigstore transparency entry: 1844444969
- Sigstore integration time:
-
Permalink:
chanilharisankar/tktop@51250d9e215e80118175f364517769ab12b3b1d4 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/chanilharisankar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@51250d9e215e80118175f364517769ab12b3b1d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tktop-1.1.0-py3-none-any.whl.
File metadata
- Download URL: tktop-1.1.0-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bcdba1c56fb6f68b775bde4983ea5f7a6a28c79e9af5c074606b716ff6403ba
|
|
| MD5 |
f0718dcf959244e89418eb53f69db514
|
|
| BLAKE2b-256 |
c45a04ce979ad22e9ae79ec71a5194476fdad72616ef2d6bf6e5d9474084473c
|
Provenance
The following attestation bundles were made for tktop-1.1.0-py3-none-any.whl:
Publisher:
release.yml on chanilharisankar/tktop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tktop-1.1.0-py3-none-any.whl -
Subject digest:
5bcdba1c56fb6f68b775bde4983ea5f7a6a28c79e9af5c074606b716ff6403ba - Sigstore transparency entry: 1844445049
- Sigstore integration time:
-
Permalink:
chanilharisankar/tktop@51250d9e215e80118175f364517769ab12b3b1d4 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/chanilharisankar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@51250d9e215e80118175f364517769ab12b3b1d4 -
Trigger Event:
push
-
Statement type: