Spotify Open-Sources Portal: Cut Claude Code Token Usage by 90%

Spotify's open-source Portal tool reduces Claude Code token consumption by up to 90% through smart context management.
AI coding assistants like Claude Code, Cursor, and GitHub Copilot boost productivity but come with significant hidden token costs — models repeatedly stuff large code files and conversation history into context windows, generating massive redundant overhead. Spotify's open-source Portal tool addresses this directly through on-demand code retrieval, context caching, and history trimming, achieving roughly 90% token reduction in real-world testing. For individual developers, this can mean dropping monthly API costs by an order of magnitude; for large engineering teams, it represents substantial savings at scale. Portal reflects a broader trend: as AI coding tools mature into production infrastructure, "middleware" optimizing efficiency and cost will become just as important as model capability itself.
The Hidden Cost of AI Coding Assistants
As AI coding tools like Claude Code, Cursor, and GitHub Copilot become mainstream, more and more developers have deeply integrated large language models (LLMs) into their daily workflows. But alongside the productivity gains, a often-overlooked issue is quietly coming to the surface — token consumption costs.
Recently, a developer shared their hands-on experience on Hacker News: by using Portal, an open-source tool released by Spotify, they managed to reduce their Claude Code token usage by 90%. The figure quickly sparked significant discussion in the community. This article dives into the technical reasoning behind this, and what it means for AI-assisted development in practice.
Why Claude Code Consumes So Many Tokens
To understand how Portal saves tokens, you first need to understand where all those tokens actually go when using an AI coding assistant.
The Context Bloat Problem
When you use a tool like Claude Code on a real project, the model needs to "understand" your codebase before it can offer meaningful suggestions. To provide accurate context, these tools typically:
- Stuff large numbers of source files into the model's context window
- Repeatedly pass project structure and file contents with each conversation turn
- Carry the full conversation history to maintain continuity
This means that even a simple question might require the model to process tens of thousands — or even hundreds of thousands — of tokens. For API users billed per token, this translates directly into real money. For subscription users, it can mean hitting usage limits much faster.
Token is the basic unit LLMs use to process text, roughly corresponding to half an English word or one Chinese character. Most models charge based on total input + output tokens. For example, the Claude 3.5 Sonnet API is priced at approximately $3/million tokens for input and $15/million tokens for output. A medium-sized code file can contain thousands of tokens, and all the source files in a full project can easily exceed a million tokens combined. This is why the "stuff the context window" approach becomes a significant financial burden at scale.
The Cost of Redundant Information
In many interaction scenarios, a large portion of the context passed to the model is redundant. The same code files get sent over and over; irrelevant conversation history eats up window space — these are all areas ripe for optimization. Portal is designed precisely to address this pain point.
What Is Portal, and How Does It Work?
Portal is an open-source tool from Spotify, with one core goal: optimizing how context is passed between AI coding assistants and LLMs.
Core Idea: Intelligent Context Management
Based on user feedback from real-world testing, Portal achieves dramatic token savings through several mechanisms:
- On-demand context retrieval: Instead of dumping the entire codebase into the model, Portal intelligently selects only the code snippets genuinely relevant to the current task
- Context caching and reuse: Avoids re-transmitting the same information, reducing redundant overhead in each conversation turn
- Condensed history: Compresses or trims conversation history, retaining only the essential information
This "precision feeding" strategy lets the model receive sufficient context while eliminating wasteful token overhead. The 90% reduction may vary by project and use case, but it powerfully illustrates just how much room for optimization exists.
The technical foundation of "on-demand context retrieval" typically leverages the RAG (Retrieval-Augmented Generation) approach: pre-building a vector index of the codebase, then using semantic search at query time to retrieve the most relevant code snippets to inject into the context — rather than blindly passing in the entire repository. "Context caching" takes advantage of the Prompt Caching feature offered by some LLM APIs — for repeated prefix content across multi-turn conversations (such as system instructions or fixed files), the content is cached and only billed once, with subsequent cache hits charged at a significantly reduced rate (Anthropic's cache hit price is roughly 10% of the standard input price). Combining both mechanisms can dramatically compress the effective billable token count without sacrificing critical information.
Engineering Practice from Spotify
Interestingly, Portal comes from Spotify. As a tech company with a massive engineering team and codebase, Spotify has had to confront token costs head-on when deploying AI coding tools at scale internally. Open-sourcing an internal tool is both a contribution to the community and a reflection of the hard-won practical experience large enterprises accumulate as they bring AI into production engineering workflows.
What Does 90% Token Savings Actually Mean?
For Individual Developers
For independent developers and small teams paying for API usage, a 90% reduction in token costs is nearly equivalent to dropping their monthly AI coding expenses by an order of magnitude. What was previously a few hundred dollars a month could shrink to just a few dozen, making AI-assisted development far more accessible.
For Enterprise-Scale Adoption
When a company has hundreds or thousands of engineers simultaneously using AI coding tools, token costs scale linearly or even exponentially. At that scale, any meaningful optimization translates into substantial savings — which is exactly why companies like Spotify invest resources in building tools like this.
Balancing Cost and Quality
Saving tokens can't come at the expense of output quality. Truly valuable optimization means reducing consumption while maintaining or even improving response accuracy. Portal's intelligent retrieval mechanism theoretically offers an additional benefit — less but more relevant context can sometimes lead to more focused answers, free from distraction by irrelevant information.
Community Reaction and a Balanced Perspective
The post gained notable attention on Hacker News, but developers should approach claims of "dramatic results" with appropriate skepticism:
- 90% is a result from a specific scenario — actual savings depend on codebase size, usage patterns, and task type
- Test it yourself — it's best to verify on your own real projects rather than taking a single case study at face value
- Tool compatibility — how seamlessly it integrates with your existing workflow is also an important consideration
An Inevitable Trend in AI Engineering
Portal's emergence isn't an isolated event — it's a reflection of AI coding tools maturing into serious engineering infrastructure. As LLMs evolve from "novelty toys" into "productivity infrastructure," the surrounding engineering challenges of efficiency optimization, cost control, and context management become central industry concerns.
Going forward, we'll likely see more tools like Portal emerge — tools that don't directly enhance model capabilities, but instead use a smarter "middleware layer" to make existing models more economical and effective. For every developer who relies on AI-assisted coding, paying attention to and making smart use of these tools will become an increasingly important competitive edge.
If you've been worried about your Claude Code token bills, it's worth giving Portal a try — put the "90%" claim to the test with your own project and see what it's really worth.
Related articles

Insufficient Source Material to Generate a Valid Article
The provided source material is a single unrelated tweet with no AI or tech relevance — insufficient to support a complete, valid technical article.

Insufficient Source Material to Generate a Valid AI/Tech Article
This source material is a tweet about the ages of Underworld members — unrelated to AI or tech, and insufficient to support a full article.

Insufficient Material: Unable to Generate a Valid AI/Tech Article
The provided material is a condolence tweet about a San Diego mosque attack — unrelated to AI/tech and too limited to generate a valid technical article.