MCP Hub
Back to servers

context-engineering

[WIP] Context engineering: the art and science of shaping context-aware AI systems

GitHub
Stars
60
Forks
11
Updated
May 8, 2026
Validated
May 11, 2026

Context engineering

Context engineering can be defined as the practice of designing systems that provide a Large Language Model (LLM) and AI agents with all the necessary information to complete a task effectively. It goes beyond prompt engineering since it focuses on building a comprehensive and structured context from various sources like system instructions, external knowledge, memory, tools, and state. The central idea is that the success of a complex LLM-based system depends more on the quality and completeness of the context provided than on the specific wording of the prompt itself.

Tobi Lütke, the CEO of Shopify, coined the term context engineering in a tweet on June 19, 2025. He defined context engineering as the art of providing all the context for the task to be plausibly solvable by the LLM. This novel concept captures the essence of the current evolution of LLM-based systems, inspiring others (like me) to understand and define this emerging engineering discipline. Since then, I've been working on a book entitled Context engineering: the art and science of shaping context-aware AI systems, to be published by Manning in 2026.

This GitHub repository is intended to be a companion resource for this book and a reference for practitioners looking to understand and adopt the context engineering principles.

Warning: This repository is a work in progress, so content and structure may change.

Table of contents

This book aims to provide a strong, general-purpose theoretical foundation for context engineering, supported by hands-on examples. Its table of contents is the following:

  1. Introduction to context engineering
  2. System instructions and user prompts
  3. External knowledge and retrieval
  4. Tools and memory in AI agents
  5. State and orchestration in agentic systems
  6. Context management, evaluation, and observability
  7. AI frameworks for context engineering
  8. Context engineering in real-world environments
  9. Context engineering through the software development lifecycle
  10. State of the art on context engineering
    Appendix A. The AI ecosystem
    Appendix B. References and further reading

Each chapter of this book starts by explaining the underlying principles and patterns of each thematic block. Then, the final part of each chapter is devoted to presenting specific examples. This GitHub repository contains all these examples. Moreover, I will include new examples and maintain the existing ones even after the book is published. The goal is to provide an open-source, updated reference for everyone interested in context engineering.

Examples

This repository organizes examples by chapter to help you explore context engineering concepts in practice.

Chapter 1. Introduction to context engineering

This chapter provides the foundations for interacting with different model providers:

Chapter 2. System instructions and user prompts

This chapter covers the definition and usage of system instructions (persona, tone, constraints) and user prompts to shape the model behavior. It also introduces programmatic prompting using DSPy (Chain-of-Thought and ReAct):

Chapter 3. External knowledge and retrieval

This chapter explores different patterns for providing external knowledge to the model. It covers Retrieval-Augmented Generation (RAG) using different retrievers and models, Cache-Augmented Generation (CAG), and context stuffing (injecting data directly into the prompt):

Chapter 4. Tools and memory for AI agents

This chapter focuses on extending AI capabilities through tools and memory. It covers tool use (function calling), the Model Context Protocol (MCP) for standardized tool integration, and various memory patterns to maintain context over time:

Online resources

This repository includes interactive web pages that complement the book and help you apply context engineering concepts in practice.

1. Context-aware Prompt Builder

🔗 https://bonigarcia.dev/context-engineering/context-aware-prompt-builder.html

Design, compare, and reuse structured prompts across multiple frameworks and AI models.

Key capabilities:

  • Build prompts using established frameworks (10-step, COSTAR, CRISPE, RTF, etc.)
  • Switch frameworks dynamically while preserving intent
  • Import/export prompts as JSON
  • Measure approximate context usage for different models
  • Load curated prompt samples for common SDLC roles

This tool is especially useful for creating and iterating on prompts in a structured, repeatable way.


2. SDLC Prompt Library

🔗 https://bonigarcia.dev/context-engineering/sdlc_prompt_library.html

Browse a curated library of prompts organized around the software development lifecycle (SDLC).

Included roles:

  • Architect
  • Developer
  • Debugger
  • Reviewer
  • Refactorer
  • Tester
  • Documenter

Key capabilities:

  • Explore prompts visually using a card-based interface
  • Filter by framework (10-step, COSTAR, CRISPE, RTF)
  • Inspect full structured prompts for each role
  • Copy prompts directly for reuse or adaptation

This tool is designed as a reference library, helping you understand how structured prompts vary across roles and frameworks.


3. Further reading

🔗 https://bonigarcia.dev/context-engineering/references.html

Curated, searchable catalog of articles, books, repositories, tutorials, and other references related to context engineering, prompting, agents, and AI engineering.

Included categories:

  • Context engineering
  • AI agents
  • Machine learning
  • Prompt engineering
  • RAG
  • Generative AI
  • MCP
  • AI-assisted development
  • LLMs
  • Memory
  • Retrieval
  • Multi-agent systems

Contributing

If you think something should be improved or want to contribute to this repo, please open a pull request. Any comments or feedback are welcome.

About

context-engineering (Copyright © 2025-2026) is an open-source project created and maintained by Boni Garcia, licensed under the terms of Apache 2.0 License.

Reviews

No reviews yet

Sign in to write a review