SuperAPIAI Directory

ctx-receipt

github.com · AI coding

ctx-receipt is a local command-line tool for estimating the number of tokens that AI coding assistants (such as Claude Code, Codex CLI, Cursor, and Gemini CLI) preload into context before user input. It scans the project and user configuration to find preloaded content such as rule files, skill descriptions, and MCP server definitions, and generates a "token receipt." All counts are offline estimates using the o200k_base tokenizer and differ from the results of each assistant's own tokenizer. The tool supports generating SVG cards, Markdown reports, or JSON output, and can check context budgets in CI. It is read-only, does not access the network, collects no telemetry, and does not print secrets from MCP configurations.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

ctx-receipt is a command-line tool for inspecting the preloaded context of AI coding assistants. It helps developers understand what assistants such as Claude Code, Codex CLI, Cursor, and Gemini CLI have already loaded before the first prompt is entered, and how many tokens that content consumes.

Purpose

AI coding assistants preload instruction files, skill descriptions, and MCP tool definitions at startup. When a project uses multiple assistants and multiple MCP servers, it is difficult to see the cost of this preloaded content in one place. ctx-receipt scans the project directory and the user home directory configuration, finds what each assistant will load, and prints a receipt showing token estimates for each item.

Key capabilities

  • Unified cross-assistant view: Displays the preloaded content of Claude Code, Codex CLI, Cursor, and Gemini CLI side by side.
  • Pre-session and CI integration: Can be run before starting a session, or in CI so that a growing CLAUDE.md or a newly added MCP server becomes visible in pull requests.
  • Comprehensive counting: Counts rule files and their imports, skill lists, custom agents, automatic memory, and MCP tools, and distinguishes between always-loaded and on-demand content.
  • Calibration against Claude Code's /context: Provides rough Claude tokenizer estimates based on comparisons with real projects.
  • Shareable output: Supports --svg to generate receipt cards,--md to generate reports, and--json to generate JSON.
  • Secret safety: MCP configurations often contain API keys; ctx-receipt never prints them, and tests verify this.

Usage

Requires Node.js 20 or later. You can use npx ctx-receipt directly without installation, or install it via npm and then use it. Common commands include scanning the current folder and home directory configuration, and using --mcp to start and measure MCP servers.

Example:

npx ctx-receipt

In CI, you can use the GitHub Action to write the receipt to the job summary and fail the step when the total loaded amount exceeds the budget. You can also check with a one-line command:

npx ctx-receipt --no-user --budget 8000

Use cases

  • Developers want to understand the context overhead of multiple AI coding assistants in a project.
  • Teams monitor context budgets in pull requests to prevent rule files or MCP servers from bloating the context.
  • Need to generate shareable context receipt cards or reports.

Limitations

  • All token counts are offline estimates using the o200k_base tokenizer and differ from the results of each assistant's own tokenizer.
  • Does not include each assistant's own system prompt and built-in tools.
  • Cannot read settings stored inside the application rather than in files (such as Cursor's user rules and in-app toggles).
  • Behavior is based on each assistant's official documentation (checked on 2026-11-12 and 2026-11-13); assistant updates may cause differences.
  • Using --mcp starts MCP servers, which may use the network; by default no servers are started.
  • Only measures; does not rewrite or compress anything.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools