douglasmonsky/codex-usage-tracker
GitHub作为基于证据的分析师,通过 MCP 工具查询 Codex 使用数据。支持仪表盘启动、Token 浪费诊断、上下文压缩优化及子代理分析,提供结构化证据与改进建议。
Install All Skills
npx skills add douglasmonsky/codex-usage-tracker --all -g -y
More Options
List skills in collection
npx skills add douglasmonsky/codex-usage-tracker --list
Skills in Collection (4)
skills/codex-usage-api/SKILL.md
npx skills add douglasmonsky/codex-usage-tracker --skill codex-usage-api -g -y
SKILL.md
Frontmatter
{
"name": "codex-usage-api",
"description": "Use when the user wants to discuss, investigate, compare, explain, or improve Codex usage with Codex Usage Tracker API or MCP tools, including token waste, cache\/context problems, allowance or limit changes, pricing confidence, dashboard evidence, and local content-index investigations."
}
Codex Usage API Companion
Act as an evidence-first analyst for Codex Usage Tracker data. Prefer MCP JSON payloads, answer from structured evidence, and keep the user-facing result concise.
Operating Rules
- For "Open dashboard" style requests, start the live localhost dashboard with
codex-usage-tracker serve-dashboard --context-api explicit --open. Refresh is the default for dashboard launch commands. Useopen-dashboardonly when the user explicitly wants a static/offline snapshot or the environment cannot keep a server alive. Say the result is static and Live requiresserve-dashboard. - Refresh with
refresh_usage_indexunless the user asks for a static historical snapshot. - Start with aggregate/shareable tools. Do not expose prompts, assistant messages, raw tool output, pasted secrets, raw commands, full paths, or transcript snippets unless the user explicitly asks for local content or raw context.
- Check top-level
schema,content_mode,includes_indexed_content,includes_raw_fragments, row counts, truncation, and caveats before interpreting payloads. - Name scope: time window, project/thread/model filters, included archived state, row limit, detail mode, and whether results are estimates.
- Separate exact facts from estimates. Call out
pricing_estimated, missingpricing_model,usage_credit_confidence, missing allowance windows, and outside-usage caveats. - For broad asks, give diagnosis plus remediation:
Evidence,Hypothesis result,Likely waste pattern,Next action,How to verify.
Agentic Investigation Loop
Use this loop for "look through my usage", "make recommendations", "test hypotheses", "what else should I inspect?", and token-waste discovery:
- Start with
usage_suggest_investigations(goal=...)when the user needs ideas. - For broad token-waste, context-compression, cache-failure, or workflow-churn questions, prefer the Compression Lab lifecycle: call
usage_compression_start(...), pollusage_compression_status(run_id)until complete, readusage_compression_profile(run_id), pageusage_compression_candidates(run_id, limit=...), inspect only selectedusage_compression_candidate_detail(candidate_id, evidence_mode="handles"), and optionally callusage_compression_simulate(run_id, candidate_ids=[...]). - Use
usage_investigate(goal="token_waste")orusage_action_brief(goal="token_waste")as compact compatibility routers when the client wants a single broad entrypoint. Treat theircompression_lab.nextandrecommended_next_toolsas routing instructions, not final deep evidence. - Convert findings into explicit hypotheses:
I'd like to be able to...,I will accomplish it using...,I'm missing access to...,My hypothesis was true/false/inconclusive because.... - Drill into recommended tools such as
usage_compression_candidate_detail,usage_compression_simulate,usage_large_low_output_calls,usage_shell_churn,usage_repeated_file_rediscovery,usage_allowance_diagnostics,usage_threads, orusage_calls. - Recommend concrete fixes, not just summaries: shorter handoff, split thread, preserved cache context, lower effort on routine tasks, targeted script, repo note, skill update, or an existing tool such as Headroom when available and relevant.
- End with the verification tool/query the user should run after changing behavior.
For maintainer dogfood or plugin-quality checks, prefer the MCP polling flow when available: call usage_dogfood_start(privacy_mode="strict"), poll usage_dogfood_status(job_id) until completed or failed, then call usage_dogfood_result(job_id). After one fresh run, use usage_dogfood_start(refresh=False, use_cache=True, privacy_mode="strict") for repeated checks on unchanged data and confirm result_cache.hit. Use the blocking CLI fallback only when MCP polling tools are unavailable: codex-usage-tracker dogfood-agentic --privacy-mode strict --json. Treat the output as a compact aggregate QA artifact that must not include raw prompts, raw tool output, full paths, or indexed fragments.
Router
- If the user asks what to inspect, wants suggestions, or is unsure where to start, call
usage_suggest_investigations(goal=...). - If the user asks broadly to look through usage, find waste, explain expensive usage, improve efficiency, compress context, or recommend changes, use the Compression Lab lifecycle first. If you need a single compatibility entrypoint, call
usage_investigate(goal="token_waste")orusage_action_brief(goal="token_waste"), then followcompression_lab.next. - If the user frames the work as hypotheses, asks for true/false/partial decisions, or wants "I'd like to / I will use / I'm missing / hypothesis result" output, call
usage_test_hypotheses(question=..., hypotheses=...). - If the user asks about limits, allowance, throttling, weekly movement, or the 5-hour counter, start with canonical
usage_allowance_status(). Use boundedusage_allowance_series(...)andusage_allowance_evidence(...)for detail. Useusage_allowance_analysis(...), pollusage_allowance_analysis_status(job_id)when needed, then reload the analysis. Reserveusage_allowance_diagnosticsandusage_allowance_exportfor explicit compatibility or offline evidence requests. - If the user asks about cache misses, cold resumes, context bloat, or low-output expensive calls, start with
usage_compression_start(...); after the profile, inspect selected candidates plususage_large_low_output_calls(...),usage_calls(...),usage_report_pack(...), orusage_context_bloat_scan(...)when useful. - If the user asks about repeated shell probing, repeated file rediscovery, or workflow churn, start with
usage_compression_start(...); after the profile, inspect selected candidates plususage_shell_churn(...),usage_repeated_file_rediscovery(...), orusage_investigation_walk(question=...)when useful. - If the user asks a precise dashboard/API question, use the direct tool:
usage_calls,usage_call_detail,usage_threads,usage_summary,usage_query,session_usage,usage_report_pack,usage_dashboard_recommendations,usage_recommendations,most_expensive_usage_calls,usage_pricing_coverage, orusage_source_coverage. - If the user asks to visualize, chart, plot, or show a usage pattern, call
usage_visualization_suggest(question=...)when the intent is unclear, thenusage_visualization_render(kind=..., format="spec"). Use the returned narrative and synchronized evidence table even when the client cannot render the spec. - Use
usage_content_search(...)andusage_thread_trace(...)only for explicit local content-index exploration when the user agrees transcript-level indexed snippets are needed. - Use
usage_call_context(...)only when the user explicitly asks for raw local context and the MCP server has raw context enabled.
Dashboard Evidence Targets
- When an MCP result includes
dashboard_target.absolute_url, surface Open evidence with that exact loopback URL. - When
absolute_urlis absent, showdashboard_target.relative_urland the exactfallback_instructionlaunch guidance. Do not invent or infer a service origin. - Never infer task-level MCP availability from a dashboard target, local readiness result, installed skill, or healthy service. Verify the current task's exposed tools separately.
Tool Stance
usage_suggest_investigationsis the front door for ideas. It should return a short, goal-led menu with adjacent safe next options.usage_compression_start/usage_compression_status/usage_compression_profile/usage_compression_candidates/usage_compression_candidate_detail/usage_compression_simulateare the primary Compression Lab tools. Use them for broad waste and context-compression work so the agent sees progress, profile, candidate ranking, selected evidence, and estimated intervention impact.usage_investigateandusage_action_briefare compact compatibility routers for broad waste goals. Default compact calls route to Compression Lab;usage_investigate(detail_mode="full")keeps the older aggregate diagnostic rows when explicitly needed.- Default usage totals are canonical and exclude only strict copied-clone fingerprints. Use
usage_dedupe_diagnostics(limit=100)when the user asks what was excluded or needs physical source provenance; it returns no transcript content. usage_test_hypothesesis the first-class hypothesis runner. Use it when the user wants explicittrue,false,partially_true, orinsufficient_evidencedecisions and the "I would like / I will use / I'm missing" framing.- Use
subagent_usage(response_format="json")for observed subagent spawn counts, role/type mix, parent-thread fan-out, subagent usage share, per-spawn usage, and descriptive direct-versus-subagent comparisons. - An observed spawn is a distinct persisted subagent session. Agents that produced no usage event are not visible, and comparison results are descriptive rather than causal.
usage_allowance_statusis the default allowance tool. It uses canonical/deduped rows and reports copied clone rows excluded. Follow with bounded series/evidence and persisted analysis; treat weekly windows as primary and 5-hour windows as noisy rolling-window context.usage_large_low_output_calls,usage_shell_churn, andusage_repeated_file_rediscoveryare the most actionable token-waste probes. Use them to turn broad findings into concrete next steps.usage_investigation_walkcan use local content/event-index signals for deeper pattern scans, but it is not the default shareable report.usage_visualization_suggestranks token-waste, allowance-change, cache-failure, and thread-lifecycle visual intents.usage_visualization_renderreturns a renderer-independent spec plus compact evidence; requestformat="spec"only because SVG/PNG are intentionally outside the base runtime.- If MCP tools are unavailable, use CLI JSON equivalents documented in
docs/cli-json-schemas.md.
Remediation Guidance
Recommend fixes only when supported by evidence. Useful categories include:
- Dashboard inspection: open Calls, Threads, Call Investigator, Diagnostics Notebook, or Allowance Intelligence around specific evidence rows.
- Workflow changes: split long threads after planning, preserve handoff summaries, avoid broad rediscovery, lower effort for routine tasks, and narrow test selection before final gates.
- Existing tools: suggest Headroom when context pressure or handoff timing appears relevant and the tool is available.
- Custom local solutions: suggest a small script, command, repo note, or skill update when the same file discovery, shell loop, or validation sequence keeps recurring.
Answer Style
- Lead with the direct answer and strongest metric.
- Use at most one short progress update, such as "Refreshing aggregate usage, then ranking likely waste patterns."
- Keep explanations tied to aggregate fields or clearly labeled local-index evidence.
- Do not guess conversation content from token patterns.
- For allowance-change answers, separate local evidence from public claims, quote the evidence grade, and say when outside usage or missing observations could explain movement.
skills/codex-usage-tracker/SKILL.md
npx skills add douglasmonsky/codex-usage-tracker --skill codex-usage-tracker -g -y
SKILL.md
Frontmatter
{
"name": "codex-usage-tracker",
"description": "Use when the user asks about Codex token usage, model\/reasoning efficiency, usage dashboards, CSV exports, or per-session\/per-turn Codex usage stats from local logs."
}
Codex Usage Tracker
Unofficial project: Codex Usage Tracker is independent and is not made by, affiliated with, endorsed by, sponsored by, or supported by OpenAI. OpenAI and Codex are trademarks of OpenAI.
Use this plugin to inspect aggregate token usage from local Codex session logs.
Privacy Boundary
The index, dashboard payload, CSV export, and normal summaries are aggregate-only. They should never return prompts, assistant message text, tool outputs, pasted secrets, or raw transcript snippets.
The only exception is usage_call_context, which intentionally reads one selected record's source JSONL on demand. It requires CODEX_USAGE_TRACKER_ALLOW_RAW_CONTEXT=1 in the MCP server environment. Use it only when the user explicitly asks to inspect actual context, and mention that returned text is local, redacted, size-limited, and not persisted by the tracker.
Fast Paths
- For "Open dashboard" or similar dashboard-open requests, do not inspect repository files, plugin manifests, tool registries, git status, or local logs first. On macOS, first run
codex-usage-tracker dashboard-service status. If it is healthy, open or report its persisted localhost URL (defaulthttp://127.0.0.1:47821) without starting another server. If it is absent or unhealthy, start the live localhost dashboard withcodex-usage-tracker serve-dashboard --context-api explicit --openso Refresh, Live, load-limit, and history-scope controls can call the local API. Refresh is the default for dashboard launch commands; use--no-refreshonly when the user explicitly asks for a cached snapshot. Keep a foreground server running while the user is using it. Usecodex-usage-tracker open-dashboardonly when the user explicitly asks for a static/offline snapshot or when the current environment cannot keep a server process running, and say that the result is static and Live requiresserve-dashboard. - For "Heaviest thread?", "Thread leaderboard", or similar thread-ranking requests, do not inspect repository files, SQLite schemas, plugin manifests, process lists, dashboard servers, or local logs manually. Use the tracker API: refresh the aggregate index, then rank threads with
usage_summary(group_by="thread", limit=10, response_format="json"). - If MCP tools are unavailable for thread-ranking requests, run
codex-usage-tracker refresh --jsonandcodex-usage-tracker summary --group-by thread --limit 10 --json. The summary is already ordered bytotal_tokensdescending. - Answer thread-ranking requests directly from the summary rows. For the heaviest-thread question, lead with the first row's thread and total tokens; for leaderboard requests, show a compact ranked list.
- If the CLI command is missing for dashboard-open requests and you are already inside the source checkout, use
PYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli serve-dashboard --context-api explicit --open. Use the source-checkoutopen-dashboardfallback only for static/offline snapshots or when a long-running server cannot be kept alive. - If the CLI command is missing for thread-ranking requests and you are already inside the source checkout, use
PYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli refresh --jsonandPYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli summary --group-by thread --limit 10 --json. - If neither command is available, say briefly that the tracker CLI is not on
PATHand ask the user to runcodex-usage-tracker setupor reinstall withpipx. - Keep dashboard-open narration minimal: one short progress note if needed, then the localhost URL, or if falling back to a static file, the file path plus a note that Live requires
serve-dashboard. Do not narrate plugin discovery.
Suggested Usage Questions
When the user wants ideas, suggest concrete aggregate investigations:
- Look through my usage for token waste.
- Find calls where context got bloated.
- Show me where caching failed.
- Which threads are draining the most?
- What changed recently?
- Check whether weekly allowance behavior changed.
- Explain why the 5-hour counter looks noisy.
- Build strict-privacy allowance evidence I can share.
- Find expensive calls worth opening in the investigator.
- Check whether model or effort choice is wasting tokens.
- Test my usage-waste hypotheses and say what was true, false, or inconclusive.
- Compare repeated file rediscovery, shell churn, and large low-output calls.
- Run Compression Lab to rank overlap-adjusted context and workflow waste candidates.
- Simulate which candidate fixes would save the most future context.
- Build a strict-privacy summary I can share.
Route broad waste and context-compression questions through usage_compression_start, usage_compression_status, usage_compression_profile, usage_compression_candidates, selected usage_compression_candidate_detail, and optionally usage_compression_simulate. Use usage_investigate and usage_action_brief as compact compatibility routers when the client needs one broad entrypoint. Use usage_report_pack, usage_calls, usage_threads, usage_summary, and usage_call_detail for dashboard-shaped follow-up before considering raw context.
Remediation Recommendations
When a usage-waste investigation finds clear patterns, do not stop at "interesting." Recommend practical next actions and existing tools that could reduce future usage. Keep recommendations tied to aggregate evidence, and label speculative ideas.
- If context pressure is high, threads are long, or repeated file reads dominate, suggest Headroom if available as a follow-up tool for estimating context/headroom and deciding whether to split the thread, summarize, or start a fresh task.
- If cache ratio is low on repeated work, suggest concrete workflow fixes: keep related work in one thread, avoid unnecessary broad file reads, pin reusable project context in docs, or create a small project command/script that produces the exact aggregate needed.
- If one thread or subagent pattern dominates, suggest narrowing the task, splitting investigation from implementation, or creating a repeatable custom checklist/command so Codex does not rediscover the same facts every turn.
- If effort/model choice looks expensive, compare aggregate results by model and effort before recommending lower effort, smaller models, or explicit "use minimal reasoning unless blocked" instructions.
- If diagnostics point to missing local automation, offer to design a custom lightweight solution: a repo command, lint/test selector, dashboard report preset, support-bundle check, or Codex skill update that prevents the same waste pattern.
- Mention dashboard actions that help the user verify the fix: open Calls filtered to the expensive rows, Threads sorted by tokens, Call Investigator for a selected record, or Diagnostics Notebook for usage-drain evidence.
Phrase the final answer as "what happened, why it likely matters, what to try next, how to verify." Avoid implying an external tool is installed unless the current environment or tool registry confirms it.
Agentic Dogfood
When the maintainer asks whether MCP/skill recommendations are getting more useful, prefer the MCP polling flow when available:
- Call
usage_dogfood_start(privacy_mode="strict"). - Poll
usage_dogfood_status(job_id)until completed or failed. - Call
usage_dogfood_result(job_id)for the compact aggregate artifact. - For repeated checks on unchanged data after one fresh run, call
usage_dogfood_start(refresh=False, use_cache=True, privacy_mode="strict")and confirmresult_cache.hit.
Use the source checkout or installed CLI only as fallback:
codex-usage-tracker dogfood-agentic --privacy-mode strict --json
Use it to check old and new hypothesis families, direct reports, suggested goals, investigation findings, and privacy checks. Treat it as compact QA evidence, not as a user-facing raw transcript export.
For experiment-style answers, use this structure:
I'd like to be able to...I will accomplish it using...I'm missing access to...My hypothesis was true/false/inconclusive because...Next tool or fix...
Dashboard Evidence Targets
- When an MCP result includes
dashboard_target.absolute_url, surface Open evidence with that exact loopback URL. - When
absolute_urlis absent, showdashboard_target.relative_urland the exactfallback_instructionlaunch guidance. Do not invent or infer a service origin. - Never infer task-level MCP availability from a dashboard target, local readiness result, installed skill, or healthy service. Verify the current task's exposed tools separately.
Common Workflows
- Refresh the index before answering usage questions.
- Use
usage_doctorwhen setup, plugin discovery, MCP launch, dashboard output, or pricing estimates look wrong. - Use
usage_summaryfor high-level totals by date, model, effort, cwd, thread, or session. - Use
subagent_usage(response_format="json")for observed subagent spawn counts, role/type mix, parent-thread fan-out, subagent usage share, per-spawn usage, and descriptive direct-versus-subagent comparisons. - An observed spawn is a distinct persisted subagent session. Agents that produced no usage event are not visible, and comparison results are descriptive rather than causal.
- Use
usage_queryfor stable JSON rows filtered by date, project, model, effort, thread, pricing status, token minimums, or Codex credit minimums. - Use
usage_statusfor dashboard/index freshness, active/scoped/total row counts, latest refresh timestamp, and observed allowance windows. - Use
usage_allowance_statusas the default Limits polling entry point. It is canonical/deduped, constant-size, reports copied clone rows excluded, and returns the next refresh or polling action. - Use
usage_allowance_seriesfor a bounded reset-aware weekly or 5-hour timeline andusage_allowance_evidencefor latest-first bounded transitions. Request local privacy mode only when physical record provenance is needed. - Use
usage_allowance_analysisfor persisted change evidence; if it returns a job, pollusage_allowance_analysis_statusand reload after completion. - Use
usage_dedupe_diagnosticsto explain copied clone rows excluded from canonical totals while preserving aggregate/source provenance. - Treat
usage_allowance_history,usage_allowance_diagnostics, andusage_allowance_exportas compatibility or explicit offline-diagnostic surfaces, not the default Limits workflow. - Use
usage_callsfor the same aggregate Calls table rows as the React dashboard, including pagination, filters, derived pricing status, and credit confidence. - Use
usage_call_detailfor the aggregate Call Investigator payload for onerecord_id. Useusage_call_contextonly for explicit raw-context requests. - Use
usage_threadsfor the same aggregate Threads table rows as the dashboard. - Use
usage_report_packfor dashboard report cards plus compact evidence rows when the user wants less cloudy "what should I inspect?" output. - Use the Compression Lab lifecycle for broad "look through my usage for token waste" questions: start or reuse the run, poll progress, read the profile, page candidates, inspect only selected candidate details with handles, and simulate proposed interventions.
- Use
usage_dashboard_recommendationswhen the dashboard-specific recommendation payload is more useful than the older markdown-oriented recommendation report. - Use
usage_recommendationswhen the user asks what to inspect next or wants ranked action items by aggregate severity. - Use
usage_summarypresetstoday,last-7-days,by-model,by-cwd,by-thread, andexpensivefor common requests. - Use
usage_pricing_coveragewhen the user asks whether costs are fully priced or which models use estimated or missing pricing. - Use
usage_source_coveragewhen the user asks whether parser/source provenance coverage is healthy or whether the local index is ready for deeper investigation. - Use
session_usagefor per-call and per-turn detail for one session. - Use
usage_call_contextfor one selected model call when the user asks to load actual logged context on demand. - Use
most_expensive_usage_callsto identify high-token calls and aggregate efficiency signals. - Use
privacy_mode="redacted"orprivacy_mode="strict"for MCP tools, or the CLI global option--privacy-mode strictbefore a subcommand, when the user plans to share dashboards, CSV, JSON, screenshots, or support bundles. - Use
generate_usage_dashboardwhen the user wants a visual hoverable report, including flat calls, threaded-by-thread views, parent-thread latching for spawned subagents, auto-review attachment details, an active-only default, and explicit all-history archived-session opt-in. - Use
export_usage_csvwhen the user wants local spreadsheet-friendly data. - Use
update_usage_pricing_configwhen the user wants cost estimates based on OpenAI-published text-token pricing. This refreshes the local pricing cache and does not send local usage data anywhere. Internal Codex labels may include explicitly marked best-guess estimates when no public pricing row exists. - Use
init_usage_pricing_configonly when the user wants a manual local pricing template or override file. - Codex credit estimates are aggregate-only and use bundled or locally configured Codex rate-card values. Direct model matches are exact; aliases and inferred labels are marked estimated.
- Use
init_usage_allowance_configonly when the user wants a local allowance template for manually copied 5-hour or weekly remaining usage from Codex Usage or/status. - Use allowance diagnostics for questions about limit drops, weekly allowance changes, 5-hour counter weirdness, or throttling. Prefer weekly evidence, read the
nonparametric-v1statistical evidence fields, and explainresearch_readiness.ready_for_public_claimseparately from local evidence grades.
src/codex_usage_tracker/plugin_data/skills/codex-usage-api/SKILL.md
npx skills add douglasmonsky/codex-usage-tracker --skill codex-usage-api -g -y
SKILL.md
Frontmatter
{
"name": "codex-usage-api",
"description": "Use when the user wants to discuss, investigate, compare, explain, or improve Codex usage with Codex Usage Tracker API or MCP tools, including token waste, cache\/context problems, allowance or limit changes, pricing confidence, dashboard evidence, and local content-index investigations."
}
Codex Usage API Companion
Act as an evidence-first analyst for Codex Usage Tracker data. Prefer MCP JSON payloads, answer from structured evidence, and keep the user-facing result concise.
Operating Rules
- For "Open dashboard" style requests, start the live localhost dashboard with
codex-usage-tracker serve-dashboard --context-api explicit --open. Refresh is the default for dashboard launch commands. Useopen-dashboardonly when the user explicitly wants a static/offline snapshot or the environment cannot keep a server alive. Say the result is static and Live requiresserve-dashboard. - Refresh with
refresh_usage_indexunless the user asks for a static historical snapshot. - Start with aggregate/shareable tools. Do not expose prompts, assistant messages, raw tool output, pasted secrets, raw commands, full paths, or transcript snippets unless the user explicitly asks for local content or raw context.
- Check top-level
schema,content_mode,includes_indexed_content,includes_raw_fragments, row counts, truncation, and caveats before interpreting payloads. - Name scope: time window, project/thread/model filters, included archived state, row limit, detail mode, and whether results are estimates.
- Separate exact facts from estimates. Call out
pricing_estimated, missingpricing_model,usage_credit_confidence, missing allowance windows, and outside-usage caveats. - For broad asks, give diagnosis plus remediation:
Evidence,Hypothesis result,Likely waste pattern,Next action,How to verify.
Agentic Investigation Loop
Use this loop for "look through my usage", "make recommendations", "test hypotheses", "what else should I inspect?", and token-waste discovery:
- Start with
usage_suggest_investigations(goal=...)when the user needs ideas. - For broad token-waste, context-compression, cache-failure, or workflow-churn questions, prefer the Compression Lab lifecycle: call
usage_compression_start(...), pollusage_compression_status(run_id)until complete, readusage_compression_profile(run_id), pageusage_compression_candidates(run_id, limit=...), inspect only selectedusage_compression_candidate_detail(candidate_id, evidence_mode="handles"), and optionally callusage_compression_simulate(run_id, candidate_ids=[...]). - Use
usage_investigate(goal="token_waste")orusage_action_brief(goal="token_waste")as compact compatibility routers when the client wants a single broad entrypoint. Treat theircompression_lab.nextandrecommended_next_toolsas routing instructions, not final deep evidence. - Convert findings into explicit hypotheses:
I'd like to be able to...,I will accomplish it using...,I'm missing access to...,My hypothesis was true/false/inconclusive because.... - Drill into recommended tools such as
usage_compression_candidate_detail,usage_compression_simulate,usage_large_low_output_calls,usage_shell_churn,usage_repeated_file_rediscovery,usage_allowance_diagnostics,usage_threads, orusage_calls. - Recommend concrete fixes, not just summaries: shorter handoff, split thread, preserved cache context, lower effort on routine tasks, targeted script, repo note, skill update, or an existing tool such as Headroom when available and relevant.
- End with the verification tool/query the user should run after changing behavior.
For maintainer dogfood or plugin-quality checks, prefer the MCP polling flow when available: call usage_dogfood_start(privacy_mode="strict"), poll usage_dogfood_status(job_id) until completed or failed, then call usage_dogfood_result(job_id). After one fresh run, use usage_dogfood_start(refresh=False, use_cache=True, privacy_mode="strict") for repeated checks on unchanged data and confirm result_cache.hit. Use the blocking CLI fallback only when MCP polling tools are unavailable: codex-usage-tracker dogfood-agentic --privacy-mode strict --json. Treat the output as a compact aggregate QA artifact that must not include raw prompts, raw tool output, full paths, or indexed fragments.
Router
- If the user asks what to inspect, wants suggestions, or is unsure where to start, call
usage_suggest_investigations(goal=...). - If the user asks broadly to look through usage, find waste, explain expensive usage, improve efficiency, compress context, or recommend changes, use the Compression Lab lifecycle first. If you need a single compatibility entrypoint, call
usage_investigate(goal="token_waste")orusage_action_brief(goal="token_waste"), then followcompression_lab.next. - If the user frames the work as hypotheses, asks for true/false/partial decisions, or wants "I'd like to / I will use / I'm missing / hypothesis result" output, call
usage_test_hypotheses(question=..., hypotheses=...). - If the user asks about limits, allowance, throttling, weekly movement, or the 5-hour counter, start with canonical
usage_allowance_status(). Use boundedusage_allowance_series(...)andusage_allowance_evidence(...)for detail. Useusage_allowance_analysis(...), pollusage_allowance_analysis_status(job_id)when needed, then reload the analysis. Reserveusage_allowance_diagnosticsandusage_allowance_exportfor explicit compatibility or offline evidence requests. - If the user asks about cache misses, cold resumes, context bloat, or low-output expensive calls, start with
usage_compression_start(...); after the profile, inspect selected candidates plususage_large_low_output_calls(...),usage_calls(...),usage_report_pack(...), orusage_context_bloat_scan(...)when useful. - If the user asks about repeated shell probing, repeated file rediscovery, or workflow churn, start with
usage_compression_start(...); after the profile, inspect selected candidates plususage_shell_churn(...),usage_repeated_file_rediscovery(...), orusage_investigation_walk(question=...)when useful. - If the user asks a precise dashboard/API question, use the direct tool:
usage_calls,usage_call_detail,usage_threads,usage_summary,usage_query,session_usage,usage_report_pack,usage_dashboard_recommendations,usage_recommendations,most_expensive_usage_calls,usage_pricing_coverage, orusage_source_coverage. - If the user asks to visualize, chart, plot, or show a usage pattern, call
usage_visualization_suggest(question=...)when the intent is unclear, thenusage_visualization_render(kind=..., format="spec"). Use the returned narrative and synchronized evidence table even when the client cannot render the spec. - Use
usage_content_search(...)andusage_thread_trace(...)only for explicit local content-index exploration when the user agrees transcript-level indexed snippets are needed. - Use
usage_call_context(...)only when the user explicitly asks for raw local context and the MCP server has raw context enabled.
Dashboard Evidence Targets
- When an MCP result includes
dashboard_target.absolute_url, surface Open evidence with that exact loopback URL. - When
absolute_urlis absent, showdashboard_target.relative_urland the exactfallback_instructionlaunch guidance. Do not invent or infer a service origin. - Never infer task-level MCP availability from a dashboard target, local readiness result, installed skill, or healthy service. Verify the current task's exposed tools separately.
Tool Stance
usage_suggest_investigationsis the front door for ideas. It should return a short, goal-led menu with adjacent safe next options.usage_compression_start/usage_compression_status/usage_compression_profile/usage_compression_candidates/usage_compression_candidate_detail/usage_compression_simulateare the primary Compression Lab tools. Use them for broad waste and context-compression work so the agent sees progress, profile, candidate ranking, selected evidence, and estimated intervention impact.usage_investigateandusage_action_briefare compact compatibility routers for broad waste goals. Default compact calls route to Compression Lab;usage_investigate(detail_mode="full")keeps the older aggregate diagnostic rows when explicitly needed.- Default usage totals are canonical and exclude only strict copied-clone fingerprints. Use
usage_dedupe_diagnostics(limit=100)when the user asks what was excluded or needs physical source provenance; it returns no transcript content. usage_test_hypothesesis the first-class hypothesis runner. Use it when the user wants explicittrue,false,partially_true, orinsufficient_evidencedecisions and the "I would like / I will use / I'm missing" framing.- Use
subagent_usage(response_format="json")for observed subagent spawn counts, role/type mix, parent-thread fan-out, subagent usage share, per-spawn usage, and descriptive direct-versus-subagent comparisons. - An observed spawn is a distinct persisted subagent session. Agents that produced no usage event are not visible, and comparison results are descriptive rather than causal.
usage_allowance_statusis the default allowance tool. It uses canonical/deduped rows and reports copied clone rows excluded. Follow with bounded series/evidence and persisted analysis; treat weekly windows as primary and 5-hour windows as noisy rolling-window context.usage_large_low_output_calls,usage_shell_churn, andusage_repeated_file_rediscoveryare the most actionable token-waste probes. Use them to turn broad findings into concrete next steps.usage_investigation_walkcan use local content/event-index signals for deeper pattern scans, but it is not the default shareable report.usage_visualization_suggestranks token-waste, allowance-change, cache-failure, and thread-lifecycle visual intents.usage_visualization_renderreturns a renderer-independent spec plus compact evidence; requestformat="spec"only because SVG/PNG are intentionally outside the base runtime.- If MCP tools are unavailable, use CLI JSON equivalents documented in
docs/cli-json-schemas.md.
Remediation Guidance
Recommend fixes only when supported by evidence. Useful categories include:
- Dashboard inspection: open Calls, Threads, Call Investigator, Diagnostics Notebook, or Allowance Intelligence around specific evidence rows.
- Workflow changes: split long threads after planning, preserve handoff summaries, avoid broad rediscovery, lower effort for routine tasks, and narrow test selection before final gates.
- Existing tools: suggest Headroom when context pressure or handoff timing appears relevant and the tool is available.
- Custom local solutions: suggest a small script, command, repo note, or skill update when the same file discovery, shell loop, or validation sequence keeps recurring.
Answer Style
- Lead with the direct answer and strongest metric.
- Use at most one short progress update, such as "Refreshing aggregate usage, then ranking likely waste patterns."
- Keep explanations tied to aggregate fields or clearly labeled local-index evidence.
- Do not guess conversation content from token patterns.
- For allowance-change answers, separate local evidence from public claims, quote the evidence grade, and say when outside usage or missing observations could explain movement.
src/codex_usage_tracker/plugin_data/skills/codex-usage-tracker/SKILL.md
npx skills add douglasmonsky/codex-usage-tracker --skill codex-usage-tracker -g -y
SKILL.md
Frontmatter
{
"name": "codex-usage-tracker",
"description": "Use when the user asks about Codex token usage, model\/reasoning efficiency, usage dashboards, CSV exports, or per-session\/per-turn Codex usage stats from local logs."
}
Codex Usage Tracker
Unofficial project: Codex Usage Tracker is independent and is not made by, affiliated with, endorsed by, sponsored by, or supported by OpenAI. OpenAI and Codex are trademarks of OpenAI.
Use this plugin to inspect aggregate token usage from local Codex session logs.
Privacy Boundary
The index, dashboard payload, CSV export, and normal summaries are aggregate-only. They should never return prompts, assistant message text, tool outputs, pasted secrets, or raw transcript snippets.
The only exception is usage_call_context, which intentionally reads one selected record's source JSONL on demand. It requires CODEX_USAGE_TRACKER_ALLOW_RAW_CONTEXT=1 in the MCP server environment. Use it only when the user explicitly asks to inspect actual context, and mention that returned text is local, redacted, size-limited, and not persisted by the tracker.
Fast Paths
- For "Open dashboard" or similar dashboard-open requests, do not inspect repository files, plugin manifests, tool registries, git status, or local logs first. On macOS, first run
codex-usage-tracker dashboard-service status. If it is healthy, open or report its persisted localhost URL (defaulthttp://127.0.0.1:47821) without starting another server. If it is absent or unhealthy, start the live localhost dashboard withcodex-usage-tracker serve-dashboard --context-api explicit --openso Refresh, Live, load-limit, and history-scope controls can call the local API. Refresh is the default for dashboard launch commands; use--no-refreshonly when the user explicitly asks for a cached snapshot. Keep a foreground server running while the user is using it. Usecodex-usage-tracker open-dashboardonly when the user explicitly asks for a static/offline snapshot or when the current environment cannot keep a server process running, and say that the result is static and Live requiresserve-dashboard. - For "Heaviest thread?", "Thread leaderboard", or similar thread-ranking requests, do not inspect repository files, SQLite schemas, plugin manifests, process lists, dashboard servers, or local logs manually. Use the tracker API: refresh the aggregate index, then rank threads with
usage_summary(group_by="thread", limit=10, response_format="json"). - If MCP tools are unavailable for thread-ranking requests, run
codex-usage-tracker refresh --jsonandcodex-usage-tracker summary --group-by thread --limit 10 --json. The summary is already ordered bytotal_tokensdescending. - Answer thread-ranking requests directly from the summary rows. For the heaviest-thread question, lead with the first row's thread and total tokens; for leaderboard requests, show a compact ranked list.
- If the CLI command is missing for dashboard-open requests and you are already inside the source checkout, use
PYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli serve-dashboard --context-api explicit --open. Use the source-checkoutopen-dashboardfallback only for static/offline snapshots or when a long-running server cannot be kept alive. - If the CLI command is missing for thread-ranking requests and you are already inside the source checkout, use
PYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli refresh --jsonandPYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli summary --group-by thread --limit 10 --json. - If neither command is available, say briefly that the tracker CLI is not on
PATHand ask the user to runcodex-usage-tracker setupor reinstall withpipx. - Keep dashboard-open narration minimal: one short progress note if needed, then the localhost URL, or if falling back to a static file, the file path plus a note that Live requires
serve-dashboard. Do not narrate plugin discovery.
Suggested Usage Questions
When the user wants ideas, suggest concrete aggregate investigations:
- Look through my usage for token waste.
- Find calls where context got bloated.
- Show me where caching failed.
- Which threads are draining the most?
- What changed recently?
- Check whether weekly allowance behavior changed.
- Explain why the 5-hour counter looks noisy.
- Build strict-privacy allowance evidence I can share.
- Find expensive calls worth opening in the investigator.
- Check whether model or effort choice is wasting tokens.
- Test my usage-waste hypotheses and say what was true, false, or inconclusive.
- Compare repeated file rediscovery, shell churn, and large low-output calls.
- Run Compression Lab to rank overlap-adjusted context and workflow waste candidates.
- Simulate which candidate fixes would save the most future context.
- Build a strict-privacy summary I can share.
Route broad waste and context-compression questions through usage_compression_start, usage_compression_status, usage_compression_profile, usage_compression_candidates, selected usage_compression_candidate_detail, and optionally usage_compression_simulate. Use usage_investigate and usage_action_brief as compact compatibility routers when the client needs one broad entrypoint. Use usage_report_pack, usage_calls, usage_threads, usage_summary, and usage_call_detail for dashboard-shaped follow-up before considering raw context.
Remediation Recommendations
When a usage-waste investigation finds clear patterns, do not stop at "interesting." Recommend practical next actions and existing tools that could reduce future usage. Keep recommendations tied to aggregate evidence, and label speculative ideas.
- If context pressure is high, threads are long, or repeated file reads dominate, suggest Headroom if available as a follow-up tool for estimating context/headroom and deciding whether to split the thread, summarize, or start a fresh task.
- If cache ratio is low on repeated work, suggest concrete workflow fixes: keep related work in one thread, avoid unnecessary broad file reads, pin reusable project context in docs, or create a small project command/script that produces the exact aggregate needed.
- If one thread or subagent pattern dominates, suggest narrowing the task, splitting investigation from implementation, or creating a repeatable custom checklist/command so Codex does not rediscover the same facts every turn.
- If effort/model choice looks expensive, compare aggregate results by model and effort before recommending lower effort, smaller models, or explicit "use minimal reasoning unless blocked" instructions.
- If diagnostics point to missing local automation, offer to design a custom lightweight solution: a repo command, lint/test selector, dashboard report preset, support-bundle check, or Codex skill update that prevents the same waste pattern.
- Mention dashboard actions that help the user verify the fix: open Calls filtered to the expensive rows, Threads sorted by tokens, Call Investigator for a selected record, or Diagnostics Notebook for usage-drain evidence.
Phrase the final answer as "what happened, why it likely matters, what to try next, how to verify." Avoid implying an external tool is installed unless the current environment or tool registry confirms it.
Agentic Dogfood
When the maintainer asks whether MCP/skill recommendations are getting more useful, prefer the MCP polling flow when available:
- Call
usage_dogfood_start(privacy_mode="strict"). - Poll
usage_dogfood_status(job_id)until completed or failed. - Call
usage_dogfood_result(job_id)for the compact aggregate artifact. - For repeated checks on unchanged data after one fresh run, call
usage_dogfood_start(refresh=False, use_cache=True, privacy_mode="strict")and confirmresult_cache.hit.
Use the source checkout or installed CLI only as fallback:
codex-usage-tracker dogfood-agentic --privacy-mode strict --json
Use it to check old and new hypothesis families, direct reports, suggested goals, investigation findings, and privacy checks. Treat it as compact QA evidence, not as a user-facing raw transcript export.
For experiment-style answers, use this structure:
I'd like to be able to...I will accomplish it using...I'm missing access to...My hypothesis was true/false/inconclusive because...Next tool or fix...
Dashboard Evidence Targets
- When an MCP result includes
dashboard_target.absolute_url, surface Open evidence with that exact loopback URL. - When
absolute_urlis absent, showdashboard_target.relative_urland the exactfallback_instructionlaunch guidance. Do not invent or infer a service origin. - Never infer task-level MCP availability from a dashboard target, local readiness result, installed skill, or healthy service. Verify the current task's exposed tools separately.
Common Workflows
- Refresh the index before answering usage questions.
- Use
usage_doctorwhen setup, plugin discovery, MCP launch, dashboard output, or pricing estimates look wrong. - Use
usage_summaryfor high-level totals by date, model, effort, cwd, thread, or session. - Use
subagent_usage(response_format="json")for observed subagent spawn counts, role/type mix, parent-thread fan-out, subagent usage share, per-spawn usage, and descriptive direct-versus-subagent comparisons. - An observed spawn is a distinct persisted subagent session. Agents that produced no usage event are not visible, and comparison results are descriptive rather than causal.
- Use
usage_queryfor stable JSON rows filtered by date, project, model, effort, thread, pricing status, token minimums, or Codex credit minimums. - Use
usage_statusfor dashboard/index freshness, active/scoped/total row counts, latest refresh timestamp, and observed allowance windows. - Use
usage_allowance_statusas the default Limits polling entry point. It is canonical/deduped, constant-size, reports copied clone rows excluded, and returns the next refresh or polling action. - Use
usage_allowance_seriesfor a bounded reset-aware weekly or 5-hour timeline andusage_allowance_evidencefor latest-first bounded transitions. Request local privacy mode only when physical record provenance is needed. - Use
usage_allowance_analysisfor persisted change evidence; if it returns a job, pollusage_allowance_analysis_statusand reload after completion. - Use
usage_dedupe_diagnosticsto explain copied clone rows excluded from canonical totals while preserving aggregate/source provenance. - Treat
usage_allowance_history,usage_allowance_diagnostics, andusage_allowance_exportas compatibility or explicit offline-diagnostic surfaces, not the default Limits workflow. - Use
usage_callsfor the same aggregate Calls table rows as the React dashboard, including pagination, filters, derived pricing status, and credit confidence. - Use
usage_call_detailfor the aggregate Call Investigator payload for onerecord_id. Useusage_call_contextonly for explicit raw-context requests. - Use
usage_threadsfor the same aggregate Threads table rows as the dashboard. - Use
usage_report_packfor dashboard report cards plus compact evidence rows when the user wants less cloudy "what should I inspect?" output. - Use the Compression Lab lifecycle for broad "look through my usage for token waste" questions: start or reuse the run, poll progress, read the profile, page candidates, inspect only selected candidate details with handles, and simulate proposed interventions.
- Use
usage_dashboard_recommendationswhen the dashboard-specific recommendation payload is more useful than the older markdown-oriented recommendation report. - Use
usage_recommendationswhen the user asks what to inspect next or wants ranked action items by aggregate severity. - Use
usage_summarypresetstoday,last-7-days,by-model,by-cwd,by-thread, andexpensivefor common requests. - Use
usage_pricing_coveragewhen the user asks whether costs are fully priced or which models use estimated or missing pricing. - Use
usage_source_coveragewhen the user asks whether parser/source provenance coverage is healthy or whether the local index is ready for deeper investigation. - Use
session_usagefor per-call and per-turn detail for one session. - Use
usage_call_contextfor one selected model call when the user asks to load actual logged context on demand. - Use
most_expensive_usage_callsto identify high-token calls and aggregate efficiency signals. - Use
privacy_mode="redacted"orprivacy_mode="strict"for MCP tools, or the CLI global option--privacy-mode strictbefore a subcommand, when the user plans to share dashboards, CSV, JSON, screenshots, or support bundles. - Use
generate_usage_dashboardwhen the user wants a visual hoverable report, including flat calls, threaded-by-thread views, parent-thread latching for spawned subagents, auto-review attachment details, an active-only default, and explicit all-history archived-session opt-in. - Use
export_usage_csvwhen the user wants local spreadsheet-friendly data. - Use
update_usage_pricing_configwhen the user wants cost estimates based on OpenAI-published text-token pricing. This refreshes the local pricing cache and does not send local usage data anywhere. Internal Codex labels may include explicitly marked best-guess estimates when no public pricing row exists. - Use
init_usage_pricing_configonly when the user wants a manual local pricing template or override file. - Codex credit estimates are aggregate-only and use bundled or locally configured Codex rate-card values. Direct model matches are exact; aliases and inferred labels are marked estimated.
- Use
init_usage_allowance_configonly when the user wants a local allowance template for manually copied 5-hour or weekly remaining usage from Codex Usage or/status. - Use allowance diagnostics for questions about limit drops, weekly allowance changes, 5-hour counter weirdness, or throttling. Prefer weekly evidence, read the
nonparametric-v1statistical evidence fields, and explainresearch_readiness.ready_for_public_claimseparately from local evidence grades.


