Understand and reduce token usage with ContextSpy context profiler ContextSpy, a context window profiler for large language models and AI coding agents, launched to help developers visualize and reduce token usage. The tool intercepts LLM API requests to analyze prompt composition and track context changes, addressing rising costs from input tokens that can outnumber output tokens by 20-50x in agentic workloads. It supports agents like GitHub Copilot, Claude Code, and opencode, offering a dashboard for live breakdowns of token categories. Quick start quick-start | | why-should-i-care Motivation | /RimantasZ/contextspy/blob/main/docs/changelog.md What's new | /RimantasZ/contextspy/blob/main/docs/install.md Install guide | /RimantasZ/contextspy/blob/main/docs/cloud-mode.md Coding agent setup | /RimantasZ/contextspy/blob/main/docs/faq.md FAQ Supported agents ContextSpy is a context window profiler for large language models and common agentic AI coding tools. It is used to intercept requests to an LLM API, analyze and visualize prompt composition, and track context changes between multiple requests in the same session. Modern AI coding agents GitHub Copilot, Claude Code, opencode, etc. pack a lot into each LLM request: system prompts, tool definitions and results, file contents, conversation history. It's often unclear why a session is slow, expensive, or hitting the context limit. ContextSpy makes the invisible visible - you see a live breakdown of every token category for every request, across sessions, over time. Think of your favorite CPU or memory profiler, just applied to the contents of the context of an AI agent. While you can optimize performance just by reviewing code, having a profiler to capture and visualise snapshot data helps a lot. Same with LLM context optimisation. Quick setup for macOS Apple Silicon — see install guide /RimantasZ/contextspy/blob/main/docs/install.md for Linux, Windows, and PyPI options: install latest binary release with Homebrew brew tap RimantasZ/contextspy brew install contextspy Install CA certificate into system trust store one-time, cloud mode only sudo contextspy install-cert Start the proxy keep this terminal open contextspy start In a new terminal: launch your coding agent through the proxy contextspy run sets required environment variables, so LLM requests are routed through the proxy contextspy run claude