larsderidder/context-lens

See what your AI sees. Framework-agnostic LLM context window visualizer.

What it solves

Context Lens addresses the "black box" problem of LLM context windows in AI coding tools. Developers often find their sessions becoming unexpectedly expensive or hitting token limits without knowing exactly what is consuming the space. Because many of these tools are closed-source binaries, developers cannot instrument them with traditional SDKs to see a detailed breakdown of the prompt composition.

How it works

It operates as a local transparent proxy that sits between the coding tool and the LLM API (such as Anthropic, OpenAI, or Google).

  1. Proxy: It intercepts HTTP requests, forwards them to the actual API, and saves the request/response pairs to disk.
  2. Analysis Server: It parses these captures to estimate tokens, group requests into conversations, and calculate costs.
  3. Web UI: It provides a visual dashboard where users can analyze the data.

It integrates with tools like Claude Code, Aider, and Cline by setting environment variables (e.g., ANTHROPIC_BASE_URL) or using MITM (Man-in-the-Middle) proxying for tools that cannot be redirected via base URLs.

Who it’s for

It is designed for developers using AI coding agents and tools who want to optimize their token usage, understand the cost of their sessions, and identify inefficient patterns in how their tools use the context window.

Highlights

  • Composition Treemap: Visual breakdown of context usage by category (system prompts, tool definitions, conversation history, tool results, and thinking blocks).
  • Cost Tracking: Per-turn and per-session cost estimates across different models.
  • Context Diff: A turn-to-turn delta view showing exactly what grew, shrank, or appeared in the context.
  • Findings Panel: Automatically flags context overflow risks, large tool results, and unused tool definitions.
  • Zero Code Changes: Works with closed-source tools without requiring SDKs or modifications to the tool's source code.
  • Local-First: All data is stored and processed on the user's machine; no cloud accounts are required.

Related

  • Project
  • Project
  • Project
  • Project
  • Project