codex-usage-api
GitHub用于通过Codex Usage Tracker API或MCP工具分析、比较和解释Codex使用数据。支持隐私保护查询、仪表盘查看及聚合统计,确保不泄露敏感信息,仅在用户明确要求时检查本地日志。
Trigger Scenarios
Install
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, or explain Codex usage using the Codex Usage Tracker API or MCP tools."
}
Codex Usage API Companion
Use this companion skill as a conversational analyst for Codex Usage Tracker data. Prefer aggregate-only MCP JSON payloads, answer from evidence, and keep the user-facing output crisp instead of narrating tool discovery or local file spelunking.
Privacy Boundary
Normal usage answers must use aggregate-only API data. Do not expose prompts, assistant messages, tool output, pasted secrets, or raw transcript snippets.
When the user plans to share JSON, CSV, dashboards, screenshots, or support bundles, prefer privacy_mode="strict" MCP calls or the CLI global option --privacy-mode strict before the subcommand. Configured project aliases are explicit display opt-ins.
The only exception is usage_call_context, which reads one selected record's local source JSONL on demand. Use it only when the user explicitly asks to inspect actual logged context. State that returned text is local, redacted, size-limited, and not persisted by the tracker.
First Steps
- For "Open dashboard" or similar requests, start the live localhost dashboard with
codex-usage-tracker serve-dashboard --context-api explicit --open. Refresh is the default for dashboard launch commands; use--no-refreshonly when the user explicitly asks for a cached snapshot. Useopen-dashboardonly for explicit static/offline snapshots or when the environment cannot keep a server alive; say the result is static and Live requiresserve-dashboard. - For "Heaviest thread?", "Thread leaderboard", or similar ranking requests, refresh aggregate data first, then call
usage_summary(group_by="thread", limit=10, response_format="json"). - For normal usage questions, start with MCP tools. If MCP tools are unavailable, use the CLI JSON fallback commands below.
- Refresh analysis with
refresh_usage_indexunless the user asks for a static historical snapshot. Keep archived sessions excluded unless explicitly requested. - Use
usage_status()for dashboard/index freshness and row counts. Useusage_doctor(response_format="json")when setup, indexing, pricing, MCP discovery, or dashboard freshness is uncertain. - Prefer structured MCP payloads:
usage_calls(...)usage_call_detail(record_id=...)usage_threads(...)usage_report_pack(...)usage_dashboard_recommendations(...)usage_summary(..., response_format="json")session_usage(..., response_format="json")most_expensive_usage_calls(..., response_format="json")usage_recommendations(..., response_format="json")usage_pricing_coverage(..., response_format="json")usage_query(...)
- Check the top-level
schemafield before interpreting structured output. Known schema ids are documented indocs/cli-json-schemas.md. - If MCP tools are unavailable, fall back to CLI equivalents:
refresh --json,summary --json,query,session --json,expensive --json,recommendations --json, andpricing-coverage --json. - If
codex-usage-trackeris missing but you are inside the source checkout, usePYTHONPATH=src .venv/bin/python -m codex_usage_tracker.cli <command>. Do not usePYTHONPATH=srcoutside that checkout.
Routing Questions To API Calls
- "What used most?" Use
usage_summary(group_by="thread", response_format="json")for thread totals, thenmost_expensive_usage_calls(response_format="json")for supporting calls. - "Which project/thread/model is driving usage?" Use
usage_summarygrouped byproject,thread, ormodel. - "Show/filter the calls table" Use
usage_calls(...)withlimit,offset,search,since,model,effort,thread,pricing_status, orcredit_confidence. Reportrow_count,total_matched_rows, andhas_more. - "Open/investigate this call" Use
usage_call_detail(record_id=...)for the aggregate call investigator payload. Useusage_call_contextonly if the user explicitly asks for raw local context. - "Show threads" Use
usage_threads(...), sorted by token impact by default. - "Give me dashboard report evidence" Use
usage_report_pack(...)for report cards and compact evidence rows. Useusage_dashboard_recommendations(...)when the user specifically wants the dashboard recommendation payload. - "Is my dashboard/index stale?" Use
usage_status()first, thenusage_doctor(response_format="json")if status suggests missing rows, stale refresh, or setup problems. - "Can I share this?" Use redacted or strict privacy mode and avoid
usage_call_context. - "Why did usage spike?" Use
usage_recommendations(response_format="json")for ranked causes, thenusage_queryorusage_callswith focused filters for supporting rows. - "What is unpriced or estimated?" Use
usage_pricing_coverage(response_format="json")andusage_query(pricing_status="unpriced")orusage_query(credit_confidence="estimated"). - "How does this affect my allowance?" Use rows from
usage_queryorusage_callsand summarizeusage_credits,usage_credit_confidence, and allowance annotations. Explain that remaining allowance is only as accurate as the user's local allowance config. - "What happened in this session?" Use
session_usage(session_id=..., response_format="json"). - "What should I inspect next?" Use
usage_report_pack(...)orusage_recommendations(response_format="json"), then explain the primary recommendation, secondary signals, and row scope.
Suggested Investigation Ideas
When the user asks what they can look into, offer a short menu of concrete aggregate-only investigations rather than a generic list.
- "Look through my usage for token waste." Use
usage_report_pack(...), thenusage_calls(sort="tokens", direction="desc", limit=10)and call out high-token calls, low cache ratios, high context-window percent, expensive estimates, or repeated same-thread spikes. - "Find calls where context got bloated." Use
usage_calls(...)sorted by tokens or filtered to recent rows, then rank bycontext_window_percent,input_tokens, and lowcache_ratio. - "Show me where caching failed." Use
usage_calls(...)andusage_report_pack(...); prioritize rows with highinput_tokens, lowcached_input_tokens, or lowcache_ratio. - "Which threads are draining the most?" Use
usage_threads(limit=10)andusage_summary(group_by="thread", response_format="json"); include total tokens, estimated cost or credits, and whether archived rows are excluded. - "What changed recently?" Use
usage_status()for freshness, thenusage_calls(since=..., limit=...)orusage_summary(group_by="date", response_format="json")for recent movement. - "Find expensive calls worth opening." Use
most_expensive_usage_calls(response_format="json")orusage_calls(sort="tokens", direction="desc"); suggestusage_call_detail(record_id=...)for the top few aggregate records. - "Check whether model or effort choice is wasting tokens." Use
usage_summary(group_by="model", response_format="json"),usage_summary(group_by="effort", response_format="json"), and supportingusage_calls(...)rows. - "Can I share this safely?" Use
privacy_mode="strict"and avoidusage_call_context.
Answer Style
- Lead with the direct answer and key metric.
- Use at most one short progress update such as "Refreshing aggregate usage, then ranking threads."
- Name data scope, time window, project, thread, model, row count, and whether rows are truncated or paginated.
- Separate exact facts from estimates. Call out
pricing_estimated, missingpricing_model,usage_credit_confidence, and missing allowance windows. - Include the next useful investigation when the answer depends on unclear pricing, stale allowance values, or a broad time window.
- Keep explanations tied to aggregate fields. Do not guess conversation content.
Version History
- 2e3e744 Current 2026-07-05 10:45


