# Codex Token Usage

> 查询本机 Codex 各任务的 token 用量、缓存输入与输出明细，按任务名称或 ID 筛选并生成排名。适用于任务 token 统计，不用于推算账号订阅剩余额度或账单。

- Skill: `cosmosmount/codex-token-usage` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add cosmosmount/codex-token-usage`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cosmosmount/codex-token-usage/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: CosmosMount (https://skillmd.com/u/cosmosmount)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/cosmosmount/codex-token-usage

---


# Codex task token usage

Run `python <skill-directory>/scripts/token_usage.py --top 20` to report local tasks. Use `--query <title-or-id>` to filter, `--top 0` for all tasks, and `--output <absolute-json-path>` to save the complete result. `--codex-home` overrides CODEX_HOME or ~/.codex.

The script reads only local session logs and read-only task metadata. Explain coverage: this is the local profile, not verified current-account-wide accounting; other devices, remote hosts, cloud-only and deleted records may be absent. Do not read credentials to identify an account. Missing usage is unknown, never zero.

Report latest recorded cumulative counters per task, with snapshot time and warnings. Never sum successive cumulative events. Cached input is part of input, and reasoning output is part of output; do not add either again. Repeated context across requests counts repeatedly. Counter decreases are flagged, not silently reconstructed. Forked histories may include inherited counters, so do not claim a sum across tasks equals unique account consumption. Subagents remain separate rows; do not add them to parents without verified attribution.

Use exact saved titles. Present a compact table in the user's language with input, cached input, output and total; provide reasoning detail when requested. An active task's final answer may not yet be included. Do not label a last-seen model as the model responsible for all historical tokens. Do not estimate cost or quota percentage without independently verified applicable accounting rules.

If no usable records are found, report the missing source and limits; do not fabricate counts. For remaining account limits use the available Codex usage-limits tool instead.

