infrapal-token-advisor
Health Uyari
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 7 GitHub stars
Code Gecti
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Understand Claude Code token usage, spot inefficiencies and optimise your AI workflows with a local-first dashboard.
Less token waste. Better AI workflows.
Get clearer insights into what is driving token usage across your Claude Code workflows, so you can spot inefficiencies and optimise with confidence.
Runs locally. No InfraPal account or hosted dashboard required.
Install · What it finds · How it works · Commands · Privacy · FAQ · Docs
Why
Claude Code provides visibility into session costs, but understanding what drives those costs can take more investigation.
Token Advisor helps you explore where your tokens go considering factors such as repeated file reads and commands to model choices and growing context. It highlights potential inefficiencies and suggests practical improvements, whether that's a setting to review or a workflow habit to change.
Get started
brew install --cask infrapalhq/tap/infrapal-token-advisor
token-advisor init
token-advisor ui
Restart any running Claude Code sessions, and use them as normal. Not on
Homebrew? See other ways to install.
What you get
|
Sessions Explore sessions by project, review usage and costs, and see which findings deserve attention first.
|
Step-by-step timeline See context grow step by step, with each issue marked where it happened.
|
|
Fixes Review suggested improvements, track the changes you've made and monitor usage trends over time.
|
Numbers you can check Findings are classified as Measured, Likely or Estimated. The methodology is documented so you can evaluate findings with confidence. Ask Claude Connect it to Claude Code and run /infrapal-token-advisor:review for
more suggestions. It uses your Claude Code plan, so there's no API key to add.
|
What it finds
| Issue | What it means | What you get |
|---|---|---|
| Re-read files | The same lines read again in one prompt with nothing changed | Suggestions for reducing repeated file reads |
| Repeated commands | A command run again with nothing changed | A suggested change to review and apply |
| Repeated approvals | A pattern you keep approving by hand | A suggested permission rule for eligible read-only commands |
| Compactions | A session filled its context | Suggestions for managing growing context |
| Failing MCP servers | A server whose calls keep failing | Troubleshooting guidance |
| Oversized model | A higher-capability model used for a task that may not require it. | Suggestions for reviewing model choice |
How it works
flowchart LR
A[Claude Code] -- OpenTelemetry --> B[Collector<br>127.0.0.1:4318]
B --> C[(SQLite<br>on your machine)]
C --> D[Dashboard<br>127.0.0.1:4319]
init turns on the telemetry Claude Code already supports. A small background
service receives it and writes it to SQLite, and the dashboard reads from there.
token-advisor is one Go binary with the dashboard built in. It isn't a proxy, so
it doesn't sit between Claude Code and the API.
Install
You need macOS or Linux, and Claude Code.
macOS, with Homebrew:
brew install --cask infrapalhq/tap/infrapal-token-advisor
Linux, with your package manager. Download the package for your system from the
latest release,
then install it:
sudo apt install ./infrapal-token-advisor_*_amd64.deb # Debian, Ubuntu
sudo dnf install ./infrapal-token-advisor-*.x86_64.rpm # Fedora, RHEL
sudo pacman -U ./infrapal-token-advisor-*-x86_64.pkg.tar.zst # Arch
On ARM, use the arm64 or aarch64 file instead.
Linux or macOS, with the install script. This installs to ~/.local/bin, or toINSTALL_DIR if you set it, and checks the download's checksum. It works with
curl or wget:
curl -fsSL https://raw.githubusercontent.com/infrapalhq/infrapal-token-advisor/main/scripts/install.sh | sh
wget -qO- https://raw.githubusercontent.com/infrapalhq/infrapal-token-advisor/main/scripts/install.sh | sh
Packagers can set DESTDIR to stage the binary under another directory, such asDESTDIR=./pkg INSTALL_DIR=/usr/local/bin.
Every release is signed. See checking a release.
Then start collecting. This patches ~/.claude/settings.json, keeping a backup,
and installs a background service:
token-advisor init
Restart any running Claude Code sessions so they pick up the new settings, then
open the dashboard at http://127.0.0.1:4319, or run:
token-advisor ui
Note: init turns on Claude Code's prompt and tool-content logging, so the
database holds your prompts, responses, shell commands and file paths. Read
what's stored first.
Commands
| Command | What it does |
|---|---|
token-advisor init |
Patch settings.json, create the database, install the service |
token-advisor status |
Show the service, database, retention and recent errors |
token-advisor doctor |
Work out why data isn't arriving, or why the service won't come back |
token-advisor ui |
Open the dashboard |
token-advisor mcp |
Serve metrics to Claude Code over MCP (stdio); see below |
token-advisor logs |
Show the log (-n 100, --errors, -f) |
token-advisor start |
Run the collector and dashboard in the foreground |
token-advisor stop |
Stop the service until your next login |
token-advisor restart |
Restart the service, for example after an upgrade |
token-advisor export |
Export data (--format jsonl|csv --since 7d) |
token-advisor purge |
Delete data (--before 30d, --session <id> or --all) |
token-advisor update |
Install the latest release (--check only reports it) |
token-advisor uninstall |
Restore settings.json and delete the service and data (--keep-db keeps the data) |
token-advisor version |
Print the version |
Run token-advisor <command> -h for a command's flags.
Update
token-advisor update --check # is there a newer release?
token-advisor update # install it and restart the service
With Homebrew, use brew upgrade --cask infrapal-token-advisor. With a Linux
package, install the new release's package the same way as the first. Then runtoken-advisor restart. The database is backed up before any schema upgrade.
Uninstall
token-advisor uninstall # restores settings.json and deletes all data
token-advisor uninstall --keep-db # the same, keeping ~/.infrapal-token-advisor
This doesn't remove the binary. Delete it, or remove the package: runbrew uninstall --cask infrapal-token-advisor, or remove infrapal-token-advisor
with apt, dnf or pacman. Run token-advisor uninstall first, so the background
service is removed too.
Ask Claude about your data (MCP)
token-advisor mcp serves the data to Claude Code over stdio. The
Fixes page shows the exact command for your install, or run:
claude mcp add --scope user infrapal-token-advisor -- "$(command -v token-advisor)" mcp
Then start a new Claude Code session and run one of its slash commands, or just
ask about your usage in your own words:
| Command | What Claude does |
|---|---|
/infrapal-token-advisor:review |
Reviews token usage and highlights the highest-priority opportunities for improvement. |
/infrapal-token-advisor:session <id> |
Explains why one session cost what it did |
/infrapal-token-advisor:compare |
Compares the last 7 days with the 7 days before |
Behind these are four read-only tools: get_schema, run_sql (limited tov_* views), get_findings and get_overview. Claude runs them on your
Claude Code plan, so there's no separate API key.
Ask for an overview, and apps that support
MCP Apps, such as
Claude, show it as an interactive view: spend, tokens, cache reuse, a daily
chart, spend by model and the top findings, with a range switch. Claude Code in
a terminal shows the same numbers as text.
Once you enable it, what these tools return goes to Anthropic with your
conversation. They return metrics and ids only. Prompts, responses, file paths,
commands, error text and user identity are withheld.
Privacy
Local by default. Token Advisor collects and analyses Claude Code telemetry on your machine. The collector and dashboard communicate through localhost.
External connections. If you enable the optional MCP integration, selected metrics and identifiers can be shared with Anthropic through your Claude Code conversation. Running token-advisor update connects to GitHub to retrieve release files.
Token Advisor does not include its own usage telemetry, automatic update checks or crash reporting.
See SECURITY.md for details about stored data, external connections and known security limitations.
Data older than 6 months is deleted automatically. You can change that, and token-advisor purge deletes data on demand.
FAQ
Does Token Advisor send my prompts anywhere?Token Advisor collects and stores Claude Code telemetry locally. It does not independently upload your prompts or responses.
If you enable the optional MCP integration, selected metrics and identifiers can be included in your Claude Code conversations and sent to Anthropic. The MCP tools are designed not to expose prompt or response text.
See SECURITY.md for details.
Will it slow Claude Code down?It isn't in the path of your API calls. Claude Code exports telemetry alongside its normal work, and the collector only receives it. What happens if the collector isn't running?
Claude Code keeps working normally, but telemetry from that time isn't captured. The service restarts on its own and comes back when you log in. I'm on a subscription. Is the cost still useful?
Yes, as a measure of relative usage. The cost is what Claude Code calculates per request, so it won't match a subscription bill. See how accurate the numbers are. How much disk space does it use?
It depends on how much you use Claude Code. Data older than 6 months is deleted automatically, and
token-advisor status shows the database size.
Does it work on Windows?
Not at the moment. It supports macOS and Linux.
Documentation
- Operating guide: the service, logs, settings, retention
and troubleshooting - How accurate the numbers are
- Architecture
- Database schema and migrations
- Adding an agent and adding a detector
- Security and the security assurance case
- Contributing and governance
- Roadmap and changelog
Build from source
You need Go, at the version in go.mod, and Node.js 24 for the
dashboard.
git clone https://github.com/infrapalhq/infrapal-token-advisor.git
cd infrapal-token-advisor
scripts/build-web.sh
go build ./cmd/token-advisor
./token-advisor init
The service keeps running that exact file, so keep it where it is, or copy it
somewhere stable before running init. See CONTRIBUTING.md
for tests and how to send a change.
Contributing
Bug fixes, new insight checks and dashboard improvements are welcome. Start with
CONTRIBUTING.md. For security problems, follow
SECURITY.md instead of opening an issue.
License
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi