Understanding Context Costs in AI Coding Tools: MCP, Skills, Workflows, Rules, and Memories
This article breaks down five mechanisms used to extend AI coding tools—MCP, Skills, Workflows, Rules, and Memories—from a context-cost perspective. It explains what question each mechanism answers, how each one consumes the context window, and what a real token-usage comparison reveals about tool definitions versus redundant return payloads. You will also find a selection table, practical optimization techniques for managing context budgets, and common mistakes to avoid.
1. Why Extension Mechanisms Suddenly Multiply
In an AI coding tool, the model itself is just a function that predicts the next token. Its real capability boundary is determined by what is placed in the context window on each request. To fit external knowledge, external actions, and fixed procedures into that window, the industry has gradually evolved five mechanisms that are easy to confuse: Skills, MCP, Workflows, Rules, and Memories.
The confusion exists because all five look the same in the product UI: they “give the agent more capability.” From a context economics perspective, however, they answer four completely different questions: what action to take this time, what steps to follow, what constraints must be obeyed, and what happened before. Once these four questions are separated, choosing between them no longer relies on guesswork.
2. What Each Mechanism Actually Does
1. MCP: A Standard Socket for Capabilities, With Upfront and Persistent Cost
The Model Context Protocol (MCP) solves the standardization problem: it exposes external systems such as databases, code hosting, ticketing, and file systems to the model as “tools” in a unified way. Its value is connect once, reuse everywhere.
The price is upfront cost. Tool definitions must be sent with the request body on every request, and are billed as input tokens. A fully featured code-hosting server often registers dozens of tools by default, adding tens of thousands of tokens to the context. The more hidden problem is that these definitions are almost never used during the entire session, yet they keep occupying space.
2. Skill: Fold Knowledge Into a Pointer
A Skill uses lazy loading. It puts only a short description in the context (name plus when to use it); the detailed playbook, scripts, and templates are read only when the model decides they are needed.
This yields two direct benefits: extremely low upfront cost, and knowledge that can be organized by directory instead of being laid out all at once. The risk is “failing to load when it should,” which shows up as the model skipping key steps. Whether the description is written precisely therefore directly determines the hit rate.
3. Workflow: Give Determinism to Code, Not to the Model
A Workflow hard-codes a reusable sequence of steps, schedules it with a program, and lets the model intervene only at nodes that require judgment. Its point is trading determinism for stability: no need to re-reason the process every time, and no drift caused by wording changes. For tasks with fixed steps—format conversion, batch fixes, pre-release checks—a Workflow usually offers the best cost-performance ratio.
4. Rules: Persistent Hard Constraints
Rules describe “what must always be obeyed,” for example code style, directory conventions, forbidden dependencies, and checks that must run before committing. They are small but persistent in the context, a fixed cost that must be paid. Rules that are too long eat into the budget; rules that are too loose are useless. The ideal state is to keep only items that can be mechanically verified.
5. Memories: State Carried Across Sessions
Memories store facts and preferences across sessions, so the tool does not have to rediscover the project structure every time. The difference from Rules is that Rules say “what should be” while Memories say “what is.” The main risk with Memories is staleness and contamination: once a wrong conclusion is written in, it gets amplified in later sessions, so periodic review and invalidation mechanisms are needed.
3. A Real Test: Where Do the Tokens Actually Go
A public analysis from a cloud vendor ran a representative controlled experiment: the same code-hosting task was completed using a protocol-based tool server, a command-line approach, and a skill-based approach, across models of several different tiers.
On one mid-tier model, all three approaches produced the correct answer, but input token usage differed sharply: about 1.4 thousand for the command line, about 3.3 thousand for the skill, and nearly 5.9 thousand for the protocol server loading the default tool set. The 46 tool definitions registered by default alone contributed about 1.9 thousand tokens; and a single release object returned by one tool consumed about 20 thousand tokens—one redundant return cost more than all the tool definitions combined.
Further, after introducing server-side tool retrieval, the upfront cost of the 46 tools was compressed to under 600 tokens; but the total cost of the whole task only approached a halving on high-tier models, and actually rose on low-tier models. The reason is not hard to understand: retrieval requires an extra round of judgment, and weaker models are more likely to retrieve the wrong thing or retrieve repeatedly.
The conclusion can be abstracted into three cost laws:
- Definition cost scales linearly with the number of requests, and becomes more damaging the longer the session;
- Return cost depends on structural redundancy, not on the number of tools;
- On-demand retrieval cost depends on the model’s judgment, and is not a universal optimization.
4. How to Choose: Match Four Dimensions
| Mechanism | Context Form | Main Cost | Suitable Scenario |
|---|---|---|---|
| MCP | Persistent definitions | Fixed cost per request | Integrating many heterogeneous systems |
| Skill | Pointer plus lazy loading | One-time read | Long-process knowledge, domain manuals |
| Workflow | Programmatic steps | Almost no context usage | Repetitive tasks with fixed steps |
| Rules | Persistent short text | Small fixed cost | Style, security, compliance baselines |
| Memories | Summary injected on demand | Storage and governance | Cross-session project context |
The recommended practical order is: first use a Workflow to lock down deterministic processes, then use Skills to carry long knowledge, keep only hard constraints in Rules, control the size of Memories, and only then consider expanding the persistent tool set.
5. Engineering Context Budget Optimization
- Subtract from the tool set: disable default full registration, keep only high-frequency tools, and retrieve the rest on demand.
- Compress return structures: add field trimming and pagination to tool returns, as illustrated below:
Original return: full object (with labels/assignees/timestamps/...) → about 20k tokensTrimming strategy: keep only title/state/number + pagination limit of 5 items → around 1k tokens
- Load knowledge in layers: level one holds only trigger descriptions, level two holds operation steps, level three holds scripts and examples.
- Build a budget dashboard: track the input token composition per session (definitions / history / returns / retrieval) to locate the real hotspots.
- Configure per model tier: more capable models can trade retrieval for cost, while weaker models are better suited to a lean tool set provided directly.
6. Common Mistakes
- Using Memories as Rules, so constraints appear only intermittently;
- Writing a Workflow as an overly long prompt, losing the determinism advantage;
- Optimizing only tool retrieval while ignoring the size of a single returned object;
- Looking only at single-request cost while ignoring cumulative amplification in long sessions.
7. Conclusion
Skills, MCP, Workflows, Rules, and Memories are not five “stronger capabilities,” but five different context delivery strategies: persistent, lazy, programmatic, constraint, and continuity. Understanding where tokens flow matters more than memorizing the names. In engineering practice on platforms such as Baidu AI Cloud, governing the context as a limited budget—trimming definitions, trimming returns, loading in layers, and configuring per model tier—is the key to making AI coding tools both accurate and economical.
