What is Context Engineering?
The evolution from prompt engineering to context operations.
Context engineering is the emerging discipline of designing, compressing, and managing the full information environment that AI coding agents operate in.
Prompts alone aren't enough
Prompt engineering optimized the input. Context engineering optimizes the environment.
When AI agents were limited to single-turn interactions, prompt engineering was sufficient. You crafted the right instruction, the model returned a useful response, and the workflow ended.
Modern AI coding agents operate differently. They run multi-step workflows across dozens of files, maintain state across sessions, and make decisions that compound over time. The prompt is no longer the bottleneck — the context is.
A coding agent with a perfect prompt but poor context will hallucinate file paths, lose track of prior decisions, and repeat work it already completed. The failure mode isn't bad instructions — it's an incomplete picture of the codebase.
Context window limits
Models have finite context windows. A medium-sized codebase exceeds them. Without compression, agents see fragments, not structure.
Session amnesia
Every new conversation starts from zero. Decisions, discoveries, and patterns from prior sessions are lost unless explicitly persisted.
Unstructured information
Raw file contents waste tokens on syntax noise. Agents need semantic structure — dependency graphs, API surfaces, change deltas — not raw text.
Three shifts from prompt to context engineering
Context engineering represents a fundamental change in how we think about AI agent inputs.
Static prompts → Dynamic context pipelines
Instead of a fixed system prompt, context engineering builds a pipeline that assembles the right context for each task — reading only what's relevant, at the right compression level, with the right metadata.
Manual curation → Automated compression
Rather than hand-picking which files to include, context engineering uses AST parsing, entropy filtering, and semantic chunking to automatically compress information to its essential signal.
Single-shot → Persistent memory across sessions
Context engineering introduces session persistence, knowledge graphs, and handoff protocols so that agents accumulate understanding over time instead of starting fresh every conversation.
What context engineering includes
Context engineering spans four interconnected domains, each addressing a different aspect of the agent's information environment.
Fit more signal into fewer tokens
Multiple read modes (full, map, signatures, entropy, aggressive), tree-sitter AST parsing across 18+ languages, and semantic chunking reduce file content by 60–99% while preserving the information agents need to make decisions.
Persist understanding across sessions
Session snapshots, knowledge graphs, handoff ledgers, and prospective memory allow agents to recall prior decisions, avoid repeated work, and transfer context between team members or agent instances.
Control what agents can access
Role-based access policies, token budgets, SLO enforcement, and path sandboxing ensure agents operate within defined boundaries — reading only what they should, spending only what's allocated.
Prove compression didn't lose information
Output validation, proof artifacts, path and identifier preservation checks, and information-loss scoring give measurable confidence that compressed context retains the semantic content the agent requires.
How LeanCTX implements context engineering
LeanCTX is an open-source context engineering runtime that brings these principles into production for AI coding agents.
58+ MCP tools
A comprehensive tool surface for reading, searching, compressing, and managing context — all exposed via the Model Context Protocol.
10 read modes
From full cached reads to entropy-filtered compression, each mode is optimized for a specific task: editing, exploring, reviewing, or referencing.
95+ shell patterns
Pattern-based compression for git, cargo, npm, docker, and other CLI output — reducing verbose command results to structured, token-efficient summaries.
Zero network calls
Runs entirely local. No telemetry, no cloud dependencies, no data leaving your machine. Open-source under Apache-2.0.
Start engineering your context
LeanCTX is free, open-source, and installs in under a minute. See what context engineering can do for your AI workflow.