Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Awesome Context Engineering

Awesome GitHub stars GitHub forks

A curated collection of resources, papers, tools, and best practices for Context Engineering in AI agents and Large Language Models (LLMs).

Context engineering is the art and science of filling the context window with just the right information at each step of an agent's trajectory.

ไธญๆ–‡็‰ˆๆœฌ | English

๐Ÿ“š Table of Contents

What is Context Engineering?

Context Engineering is the systematic optimization of information payloads for Large Language Models (LLMs). It encompasses:

  • Context Retrieval & Generation: Selecting and creating relevant information
  • Context Processing: Organizing and structuring context for optimal consumption
  • Context Management: Handling context windows, memory, and state across interactions
  • Context Compression: Reducing token usage while preserving essential information
  • Context Isolation: Separating concerns across different context spaces

๐Ÿ“– Featured Articles

Context Rot: How Increasing Input Tokens Impacts LLM Performance

Manus Context Engineering

Context Engineering for AI Agents: Lessons from Building Manus

Key insights from building a production AI agent:

  • Design around KV-Cache for performance optimization
  • Mask, don't remove tools for better action selection
  • Use file system as external context memory
  • Manipulate attention through recitation techniques

Claude Code Best Practices

Claude Code Best Practices

Anthropic / Claude

LangChain Context Engineering

Context Engineering for Agents

Comprehensive guide covering four key strategies:

  • Write Context: Saving information outside context window
  • Select Context: Pulling relevant information into context
  • Compress Context: Retaining only necessary tokens
  • Isolate Context: Splitting context across different spaces

dbreunig Context Engineering Series

How Long Contexts Fail and How to Fix Them

Deep dive into context failure modes and management strategies:

  • Context poisoning, distraction, confusion, and clash patterns
  • RAG, tool loadout, context quarantine, pruning, summarization, and offloading techniques

Advanced Context Engineering for Coding Agents

Guide for using AI to solve hard problems in complex codebases.

Don't Build Multi-Agents (Cognition)

Principles for building reliable agents: share full context and avoid fragile parallel multi-agent architectures.

The New Skill in AI is Not Prompting, It's Context Engineering (Philipp Schmid)

Argues most agent failures stem from poor context, not the model; breaks context into instructions, history, long-term memory, RAG, tools, and output format.

Context Engineering (Simon Willison)

Why "context engineering" is a better framing than "prompt engineering", curating the foundational discussion of the term.

Wide Research: Beyond the Context Window (Manus)

Parallel sub-agent architecture that avoids fabrication when processing many items, by decomposing tasks across dedicated sub-agents instead of one overloaded context window.

SWE-grep: RL for Fast Context Retrieval (Cognition)

RL-trained models that run up to 8 parallel searches per turn to retrieve code context an order of magnitude faster while minimizing context pollution.

๐Ÿ“‘ Research Papers

Survey Papers

A Survey of Context Engineering for Large Language Models

  • ๐Ÿ“„ arXiv: 2507.13334
  • ๐Ÿ“Š Comprehensive analysis of 1400+ research papers
  • ๐ŸŽฏ Establishes formal taxonomy of context engineering components

The performance of Large Language Models (LLMs) is fundamentally determined by the contextual information provided during inference. This survey introduces Context Engineering, a formal discipline that transcends simple prompt design to encompass the systematic optimization of information payloads for LLMs.

Harness Engineering for Language Agents: The Harness Layer as Control, Agency, and Runtime

  • ๐Ÿ“„ Preprints: 202603.1756
  • ๐Ÿ“Š Audits 63 harness-relevant works across academia and public engineering practice
  • ๐ŸŽฏ Decomposes the agent harness layer into Control, Agency, and Runtime (CAR); proposes HarnessCard as a reporting artifact

Situates harness engineering in the arc from software engineering through prompt and context engineering, arguing that the harness โ€” the runtime loop wrapping tool execution, control, and agency around an LLM โ€” is a first-class layer whose effects are often mistaken for model-driven gains.

Context Engineering 2.0: The Context of Context Engineering

  • ๐Ÿ“„ arXiv: 2510.26493
  • ๐ŸŽฏ Traces context engineering back two decades and proposes a systematic definition and design principles across the human-computer to human-agent evolution

Agentic Context Engineering: Evolving Contexts for Self-Improving Language Models

  • ๐Ÿ“„ arXiv: 2510.04618
  • ๐ŸŽฏ Treats context as an evolving playbook (Generator/Reflector/Curator) to prevent context collapse; reports +10.6% on agents and +8.6% on finance tasks (ICLR 2026)

Memory in the Age of AI Agents: A Survey

  • ๐Ÿ“„ arXiv: 2512.13564
  • ๐ŸŽฏ A "forms-functions-dynamics" taxonomy of agent memory, distinguishing it from RAG and context engineering

Core Research Areas

๐Ÿ› ๏ธ Tools & Projects

Comprehensive Resources

  1. Prompt Engineering Guide

    • Comprehensive guide to prompt engineering, context engineering, RAG, and AI agents
    • Covers techniques, papers, tools, and best practices
    • Widely-used educational resource
  2. Awesome Context Engineering Survey

    • Comprehensive survey of context engineering techniques
    • Methodologies and applications overview
    • Academic research focus
  3. Context Engineering Intro

    • Practical guide for AI coding assistants
    • Claude Code centered approach
    • Hands-on implementation strategies
  4. Context-Engineering (davidkimai)

    • First-principles handbook for context engineering
    • From foundations to advanced techniques
  5. Context-Engineering (jasontang-ai)

    • Karpathy-inspired first-principles handbook
    • From prompt engineering toward context design, orchestration, and optimization
  6. The Context Course (HuggingFace)

    • HuggingFace course on context engineering for code agents
    • Covers skills, MCP, plugins, subagents, hooks, and building your own agent
    • Reference agents: Claude Code, Codex, OpenCode
  7. Agent Systems Handbook

    • Practical AI agents handbook covering agentic workflows and multi-agent architecture
    • Spans LangGraph, MCP/A2A, context engineering, agent memory, evaluation, and observability

Context Engineering Systems & Kits

  • Prompt Engineering Guide โญ76.1k: Comprehensive guide and resources for prompt engineering, context engineering, RAG, and AI agents
  • get-shit-done (GSD) โญ64.5k: Meta-prompting, context engineering and spec-driven development system for Claude Code
  • Agent Skills for Context Engineering โญ16.7k: Collection of Agent Skills for context engineering and multi-agent architectures
  • Context Engineering Intro โญ13.5k: Context engineering introduction and methodology for AI coding assistants
  • Context-Engineering (jasontang-ai) โญ9.1k: Karpathy-inspired first-principles handbook for context engineering
  • GSD-2 โญ7.7k: Meta-prompting / context engineering system enabling long-running autonomous agent work
  • MineContext โญ5.4k: Volcengine's proactive, context-aware AI companion
  • Awesome-Context-Engineering (Meirtz) โญ3.2k: Comprehensive survey of context engineering
  • how-claude-code-works โญ2.7k: Deep dive into Claude Code source: architecture, agent loop, and context engineering
  • pro-workflow โญ2.3k: Self-correcting memory Claude Code workflow, including context engineering
  • Advanced Context Engineering for Coding Agents โญ1.7k: Advanced context engineering techniques for coding agents
  • Context Engineering Kit โญ1.2k: A context engineering skills toolkit
  • ACE (Agentic Context Engineering) โญ1.2k: Evolving language agents through agentic context engineering (ACE)
  • context-space โญ812: Context engineering infrastructure built from MCPs and integrations
  • Practical Guide to Context Engineering โญ708: A practical, hands-on guide (in Chinese) to context engineering for LLM applications
  • get-shit-done (GSD): Meta-prompting and spec-driven development / context engineering system for Claude Code
  • GSD-2: Meta-prompting / context engineering system enabling long-running autonomous agent work
  • how-claude-code-works: Deep dive into Claude Code source: architecture, agent loop, and context engineering
  • Agent Skills for Context Engineering: Collection of Agent Skills for context engineering and multi-agent architectures
  • Advanced Context Engineering for Coding Agents: Advanced context engineering techniques for coding agents
  • ax: Local telemetry and recall graph for AI coding-agent sessions, costs, skills, routing, and hooks
  • ACE (Agentic Context Engineering): Evolving language agents through agentic context engineering
  • Context Engineering Kit: A toolkit for context engineering
  • MineContext: Volcengine's proactive, context-aware AI companion
  • pro-workflow: Self-correcting memory system that lets Claude Code learn from its mistakes, covering context engineering, parallel worktrees, agent teams, and 17 skills
  • kit: Context engineering toolkit for AI dev tools, providing codebase mapping, symbol extraction, and code search
  • RepoPrompt CE: Community edition of RepoPrompt, a native macOS context engineering app for AI coding agents, with an MCP CLI
  • context-engineering (outcomeops): Working reference implementation of context engineering with five components (corpus, retrieval, injection, output, enforcement), running end-to-end on Amazon Bedrock
  • Project Context Records (PCR): A context-engineering methodology that keeps a durable, repo-versioned archive of a project's meta-context (the why, architecture, and maintainer decisions) so AI collaborators inherit its judgment instead of re-deriving it
  • interview-prep-template: A three-layer context-engineering template (immutable sources โ†’ agent-maintained wiki โ†’ operating-manual file) where the agent synthesizes raw material into reusable answers, frameworks, and scored debriefs that compound over time
  • Practical Guide to Context Engineering: A practical, hands-on guide (in Chinese) to context engineering for LLM applications
  • MFS: A context harness that unifies code, docs, chat, databases, and object stores into one file-like, searchable namespace (ls/cat/grep + hybrid semantic search), so agents pull context incrementally instead of injecting it all up front; self-hosted and local-first (local ONNX embeddings + Milvus, no API key)

Development Frameworks

  • LangGraph: Low-level orchestration framework for context management
  • LangSmith: Agent tracing and evaluation platform
  • LangMem: Memory management abstractions

Memory & Compression

  • claude-mem: Persistent cross-session memory for Claude Code that automatically captures, compresses, and re-injects context across sessions
  • LeanCTX (lean-ctx): Context intelligence layer for AI agents โ€” a single local Rust binary that decides what agents read, remember, and save; 60โ€“90% fewer tokens, with 76 MCP tools and local-first design
  • headroom: Compresses tool outputs/logs before they reach the LLM, saving 60-95% of tokens
  • Accordion: A pi extension that renders an agent's entire context window as a live "map" and folds (reversibly compacts) less-relevant blocks in the background via pluggable "conductors" that rank block relevance, instead of lossy all-or-nothing compaction
  • Letta (MemGPT): Framework for building stateful agents with long-term memory
  • Mem0: Memory layer for AI agents and assistants
  • Vestige: "Local-first MCP memory server (single ~23MB Rust binary, data stays on-device) with entity/causal retrieval โ€” links memories by shared file/env-var/service/symbol to recall the earlier change behind a later failure that similarity search can miss"
  • LLMLingua: Prompt compression for accelerated and cost-efficient LLM inference
  • Cognee: Open-source AI memory platform giving agents persistent long-term memory via a self-hosted knowledge-graph engine
  • Graphiti: Framework for building real-time, temporal knowledge graphs for AI agents (the engine behind Zep's memory)
  • Supermemory: Fast, scalable memory + context engine with a single Memory API; supports fully local runs

Production Tools

  • Claude Code: Auto-compact context management
  • ChatGPT: Long-term cross-session memory
  • Cursor: Rules-based context engineering
  • Windsurf: Advanced code context retrieval

๐Ÿ’ก Expert Insights

Industry Leaders

Andrej Karpathy (OpenAI)

+1 for "context engineering" over "prompt engineering".

People associate prompts with short task descriptions you'd give an LLM in your day-to-day use. When in every industrial-strength LLM app, context engineering is the delicate art and science of filling the context window with just the right information for the next step. Science because doing this right involves task descriptions and explanations, few shot examples, RAG, related (possibly multimodal) data, tools, state and history, compacting... Too little or of the wrong form and the LLM doesn't have the right context for optimal performance. Too much or too irrelevant and the LLM costs might go up and performance might come down. Doing this well is highly non-trivial. And art because of the guiding intuition around LLM psychology of people spirits.

On top of context engineering itself, an LLM app has to:
- break up problems just right into control flows
- pack the context windows just right
- dispatch calls to LLMs of the right kind and capability
- handle generation-verification UIUX flows
- a lot more - guardrails, security, evals, parallelism, prefetching, ...

So context engineering is just one small piece of an emerging thick layer of non-trivial software that coordinates individual LLM calls (and a lot more) into full LLM apps. The term "ChatGPT wrapper" is tired and really, really wrong.

Key Principles

  1. KV-Cache Optimization: Design for cache hit rates to reduce latency and cost
  2. Append-Only Context: Avoid modifying previous context to maintain cache validity
  3. External Memory: Use file systems and databases as extended context storage
  4. Error Preservation: Keep failure traces for model learning and adaptation
  5. Diversity Over Uniformity: Avoid repetitive patterns that lead to model drift

๐Ÿ”— Model Context Protocol (MCP)

Context7 MCP Server

Up-to-date code documentation for LLMs and AI code editors

  • ๐Ÿ”— Repository: upstash/context7
  • ๐ŸŽฏ Real-time code context for development workflows
  • ๐Ÿš€ Integration with popular AI coding assistants

MCP Ecosystem

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

How to Contribute

  1. Add Resources: Submit papers, tools, or articles related to context engineering
  2. Improve Translations: Help translate content to different languages
  3. Share Insights: Contribute expert opinions and best practices
  4. Report Issues: Help us maintain accuracy and relevance

Contribution Categories

  • ๐Ÿ“„ Research Papers
  • ๐Ÿ› ๏ธ Tools & Libraries
  • ๐Ÿ“– Articles & Tutorials
  • ๐Ÿ’ก Expert Insights
  • ๐Ÿ”ง Implementation Examples
  • ๐ŸŒ Translations

โญ Star History

Star History Chart

๐Ÿ“„ License

This project is licensed under the CC0 1.0.

๐Ÿ™ Acknowledgments

Special thanks to all contributors and the research community advancing the field of context engineering.


Maintained by: yzfly | ไบ‘ไธญๆฑŸๆ ‘๏ผˆๅพฎไฟกๅ…ฌไผ—ๅท: ไบ‘ไธญๆฑŸๆ ‘๏ผ‰

If you find this repository helpful, please consider giving it a โญ!

About

A curated collection of resources, papers, tools, and best practices for Context Engineering in AI agents and Large Language Models (LLMs).

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors