In the print dialog, choose “Save as PDF”.
Adservio

Context Engineering: How to Give AI Exactly What It Needs

Skeleton trimming, relevance-based file selection, progressive contextualization: three context engineering techniques for faster, cheaper, sharper LLMs.

ADSERVIO INSIGHTS · AI STRATEGY

CATEGORYAI Strategy
READING TIME8 min
DATE19 September 2025
FORMATAdservio Insights article
CONTACThello@adservio.fr

KEY POINTS

  • Context engineering replaces simple prompting: it is about intelligently curating what you send the model rather than piling in as much as possible.
  • Even with the one-million-token windows of 2026, overloading the context slows inference, drives up costs and blurs the useful signal, that is "context rot".
  • Skeleton trimming keeps only the essential structure of the code (signatures, annotations, class declarations): a prompt drops from 10,000 to roughly 300 tokens.
  • Relevance-based file selection separates must-have inputs, conditional extras and files to ignore; progressive contextualization delivers context in three stages.
  • Combined with MCP, automatic compaction and the just-in-time retrieval of modern agents, these techniques cut latency and costs while improving accuracy.

SECTION 1

From prompt engineering to context engineering: the real performance lever for LLMs

If you have been following AI development circles closely, you have noticed the shift: the conversation has moved from simple prompting to what practitioners now call "context engineering". Writing a good instruction is no longer enough; what makes the difference is everything surrounding that instruction, code, documentation, conversation history, tool results, and the way it is assembled before being sent to the model.

Whether you work with Claude Fable 5, GPT-5.6 or Gemini 3.5, the difference between mediocre and outstanding results often comes down to a single factor: how you design the context window. Mid-2026 models routinely accept one million tokens of input, but that abundance is a trap: it moves the problem instead of solving it, because the capacity to absorb context grows faster than the capacity to exploit it correctly. A bigger window raises the ceiling; it does not raise the quality of what you put inside it.

This article explains why "more context" often degrades results, then details three proven techniques drawn from hands-on experimentation in back-end code generation, skeleton trimming, relevance-based file selection and progressive contextualization. They come from the Java/Spring Boot world, but the patterns adapt to most systems built on LLMs.

SECTION 2

What is context engineering? Curation rather than accumulation

Context engineering is not about cramming more information into the prompt: it is about smarter curation. Think of it as the art of structuring, optimizing and trimming information so language models respond faster, cheaper and better. Instead of dumping an entire codebase or dataset into the context window, you strategically feed the model only what matters, the right information, in the right format, at the right time.

### An engineering discipline in its own right

The discipline has taken shape since 2025: the major model providers now publish their own context engineering guides for agents, and the role appears explicitly on AI team org charts. The guiding principle remains constant: treat the context window as a scarce resource, with a budget, a structure and governance rules, exactly the way memory or bandwidth is treated in a distributed system. Every token admitted into the window must earn its place, and everything else stays out.

The tooling has followed. The Model Context Protocol (MCP) connects data sources to models in a standardized way, code-as-context approaches turn codebases into living documentation, and context engines produce structured summaries from complex projects. These building blocks make curation systematic and reproducible, where it used to be a craft.

@cite:le-protocole-model-context-au-dela-de-la-tendance

SECTION 3

The context paradox: why a one-million-token window is not enough

Overloading your AI with information often makes it perform worse. That may sound counterintuitive, but it is the measured reality of building AI systems. Imagine asking an LLM to generate a UserService in Spring Boot: the classic beginner mistake is dumping the entire codebase, controllers, full repository logic, configuration classes, utility layers, down to the README files, into the prompt.

The result is threefold. Token consumption: more than 10,000 tokens for largely irrelevant data, billed on every call. Slower inference: long inputs mechanically increase latency. Confused outputs: the model struggles to separate signal from noise and produces less coherent code than if it had been given ten times less. In practice, teams discover this the hard way: the bill grows with every call while the quality of the generated code quietly declines.

### Context rot: the silent degradation of long windows

Needle-in-a-haystack benchmarks and context rot studies have confirmed it: a model's ability to exploit a piece of information declines as the window fills up, particularly for elements sitting in the middle of the context. A one-million-token window is therefore not an invitation to fill it: it is a safety margin that should remain largely unused. The best teams monitor how full their windows get the same way they monitor memory pressure on a server. It is not about having less context, but about having the right context, strategic inclusion rather than a dump.

@cite:pourquoi-le-context-engineering-est-comme-apprendre-a-l-ia

SECTION 4

Skeleton trimming: shrinking a prompt from 10,000 to 300 tokens

Skeleton trimming consists of keeping only the essential structure of the code, method signatures, class declarations, annotations, and stripping out implementation bodies. The intuition is simple: to generate a coherent service, the model does not need to know how each method is implemented; it needs to know the contract its code will have to honor. Signatures, types and annotations carry almost all of the architectural information, for a tiny fraction of the tokens.

### Before/after on a Spring Boot controller

Before trimming: a complete controller, with the @RestController annotation, the base @RequestMapping("/users") mapping, service injection through the constructor, then each method, createUser under @PostMapping, getUser under @GetMapping, carrying its full implementation body, which calls the service and builds the ResponseEntity that gets returned.

After: only the class-level annotations and method signatures remain, @PostMapping createUser(...), @GetMapping getUser(...),with no bodies and no dependency-injection declaration, much like an interface that describes the API contract without exposing its internals. To generate a UserService, all you then need is the user model (fields only), the repository interface signature and the controller endpoint patterns: roughly 300 tokens instead of 10,000, with better results. It is the best effort-to-gain trick in the whole toolbox, and the easiest one to automate in a pre-processing step.

SECTION 5

Relevance-based file selection: three categories of inputs

The second technique comes upstream: before even preparing the LLM inputs, you identify only the files directly relevant to the task, sorting them into three sharply bounded categories. The goal is to build the smallest set of files that fully specifies the task, nothing less, nothing more.

### Must-have inputs, conditional extras, files to ignore

Must-have inputs directly define the task: to generate an OrderService, you will always need the OrderRepository interface (method declarations only), the Order model (fields and annotations) and the OrderController endpoint mappings. Conditional extras are included only if the task depends on them: the OrderNotFoundException class if the service throws it, the CreateOrderRequest DTO if it uses it. Irrelevant files, finally, must be set aside without hesitation: SecurityConfig, Application.java or service classes unrelated to the logic at hand bring nothing but noise.

In 2026, this selection is largely automatable: semantic search over the codebase, import-graph analysis to follow real dependencies, or specialized MCP servers that expose only the relevant files to the agent. But automation does not replace discipline: it is the taxonomy, must-have, conditional, ignore, that guarantees a minimal, sufficient context, whatever tool applies it.

SECTION 6

Progressive contextualization: delivering context in stages

Instead of providing all the context at once, progressive contextualization delivers it in stages, each containing only the information relevant to that point in the process. It is, in fact, the principle modern coding agents apply natively, exploring the codebase as the task unfolds rather than loading everything upfront. Each stage narrows the field of possibilities before the next one adds precision.

### Three beats: setup, structure, detail

Setup defines the high-level goal and constraints, for example "implement CRUD operations for OrderService". Structure provides only the skeletons needed to sketch out the solution, the order model fields, the repository interface, the DTOs. Detail finally adds the specific implementation elements: exception classes, constants, edge cases. By pacing the flow of information this way, you guide the model's attention step by step, toward clearer, more coherent outputs.

These three techniques are not official standards: they come from hands-on experimentation in back-end code generation. Treat them as adaptable patterns, their combination matters more than any one of them in isolation, because they act on three different moments: what you include, in what form, and at what pace.

@cite:du-vibe-coding-au-context-engineering-2025

SECTION 7

Tooling up context engineering in 2026: MCP, compaction and just-in-time retrieval

These manual techniques now combine with mature tooling. MCP standardizes access to data sources and avoids ad hoc integrations. Agents practice automatic compaction, summarizing the conversation history when the window nears saturation, and rely on persistent memories stored outside the context, reloaded on demand. Just-in-time retrieval has replaced exhaustive loading: the agent fetches information at the precise moment it needs it, rather than carrying everything from the start. Sub-agents push the same logic further: each one works with its own clean, dedicated window before reporting back a summary.

Effective context management has thus become a cornerstone of building high-performing AI systems. By providing only the most relevant information, you reduce latency, control costs and improve the accuracy of results, three benefits that require not a bigger model, but a better-designed context. That is also why context engineering pays off regardless of which model provider you choose.

The underlying rule has not changed: the quality of your LLM's output is only as good as the context you feed it. Treat your token budget like premium real estate and fill it with high-value content, not clutter. An earlier version of this article was published on Medium. Disclaimer: the statements and opinions expressed in this article are those of the authors and do not necessarily reflect Adservio's positions.

FAQ

Frequently asked questions

What is context engineering, in practical terms?

It is the art of structuring, optimizing and trimming the information sent to a language model so it responds faster, cheaper and better, by feeding it only what matters, in the right format, at the right time, rather than dumping an entire codebase or dataset into the prompt.

Why can giving an LLM more context make its answers worse?

An overloaded context increases token consumption, slows inference and blurs the model's ability to separate signal from noise. Context rot studies show that the exploitation of a piece of information declines as the window fills up, even with the one-million-token windows of 2026 models.

What is skeleton trimming?

A technique that keeps only the essential structure of the code, method signatures, class declarations, annotations, and strips out implementation bodies. A service-generation prompt can thus drop from roughly 10,000 tokens to 300, with better results, because the model receives the contract without the noise.

How do you choose which files to include in an LLM's context?

By sorting them into three categories: must-have inputs that define the task (model, repository interface, endpoint mappings), conditional extras included only if the task depends on them (exceptions, DTOs), and irrelevant files to set aside (configuration, classes unrelated to the logic at hand).

Which tools make context engineering easier in 2026?

The Model Context Protocol (MCP) to standardize access to data sources, code-as-context approaches that turn codebases into living documentation, automatic history compaction, persistent out-of-context memories and the just-in-time retrieval practiced by modern agents.

ABOUT ADSERVIO

Adservio is an AI-native digital transformation partner: AI-augmented IT departments, software engineering, DevOps, MLOps, cybersecurity and AI governance.

Let's talk about your project: hello@adservio.fr · adservio.fr/contact