Skip to content
/

Context-Engineering Handbook

context-engineering-handbook · davidkimai/Context-Engineering · ★ 9.0k · last commit 2026-02-27

Primitive shape 16 total
Commands 16
00

Summary

Context-Engineering Handbook — Summary

The Context-Engineering Handbook (github.com/davidkimai/Context-Engineering) is a first-principles methodology handbook for designing, orchestrating, and optimizing the complete information payload provided to LLMs — going beyond prompt engineering to manage examples, memory, retrieval, tools, state, and control flow. With 9,009 stars, it is by far the most-starred framework in this batch. The handbook organizes context engineering along a biological metaphor: atoms (single prompts) → molecules (few-shot) → cells (memory+state) → organs (multi-agent) → neural systems (cognitive tools) → neural fields (continuous meaning, attractors) → protocol shells → meta-recursive systems. It ships 16 agent command files, 14 foundation documents, templates, example code, and a growing course structure. It is grounded in 2025-2026 research papers from MIT, IBM Zurich, Princeton/ICML, and others.

Distribution type: methodology-doc. This is a handbook for practitioners, not an installable framework. Its value is in the conceptual vocabulary and structured learning path it provides, plus the 16 Claude Code agent commands for domain-specific agents (research, security, marketing, etc.).

Compared to seeds: no seed is a pure methodology handbook — the closest in spirit is agent-os (structured guidance files) but agent-os is project-scaffolding tooling while this is an academic-practitioner synthesis. Unlike any seed, this handbook explicitly cites and operationalizes cutting-edge research (IBM Zurich's cognitive tools paper, Princeton's emergent symbolics, etc.) as engineering primitives.

01

Overview

Context-Engineering Handbook — Origin & Philosophy

Origin

Created by David Kimai (@davidkimai), 13 contributors, MIT license. Python-primary (GitHub language classification). 9,009 stars as of 2026-05-26. Last commit 2026-02-27.

Founding Quote

"Context engineering is the delicate art and science of filling the context window with just the right information for the next step." — Andrej Karpathy (cited in the README)

Definition

"Context is not just the single prompt users send to an LLM. Context is the complete information payload provided to a LLM at inference time, encompassing all structured informational components that the model needs to plausibly accomplish a given task." — Definition from A Systematic Analysis of Over 1400 Research Papers (arXiv:2507.13334)

Philosophy

The handbook argues that prompt engineering is a subset of a broader discipline:

Prompt Engineering  │  Context Engineering
       ↓            │          ↓                      
"What you say"      │  "Everything else the model sees"
(Single instruction)│  (Examples, memory, retrieval,
                    │   tools, state, control flow)

The fundamental formula: C = A(c₁, c₂, ..., cₙ) — context is a function of all its components.

Biological Metaphor (Core Organizing Structure)

atoms → molecules → cells → organs → neural systems → neural & semantic field theory
  │        │         │         │             │                         │        
single    few-     memory +   multi-   cognitive tools +     context = fields +
prompt    shot     agents     agents   operating systems     persistence & resonance

Research Grounding

Explicitly operationalizes:

  • IBM Zurich (arXiv:2506.12115) — "Cognitive tools" that increase GPT-4.1 AIME2024 from 26.7% to 43.3%
  • MIT/Singapore MEM1 (arXiv:2506.15841) — Efficient memory for long-horizon agents
  • Princeton/ICML Emergent Symbolics — Neural field theory
  • Indiana University Quantum Semantics (arXiv:2506.10077) — Meaning as emergent phenomenon
  • Survey of 1400+ papers (arXiv:2507.13334) — July 2025 systematic review

Key Insight

"Providing 'cognitive tools' to GPT-4.1 increases its pass@1 performance on AIME2024 from 26.7% to 43.3%, bringing it very close to the performance of o1-preview." — IBM Zurich

02

Architecture

Context-Engineering Handbook — Architecture

Distribution Type

methodology-doc — not an installable framework. Value is in the documents, templates, and examples.

Repository Structure

Context-Engineering/
├── .claude/
│   └── commands/          # 16 agent command .md files
├── 00_COURSE/             # Structured course (under construction)
├── 00_EVIDENCE/           # Supporting evidence and citations
├── 00_foundations/        # 14 conceptual foundation documents
│   ├── 01_atoms_prompting.md
│   ├── 02_molecules_context.md
│   ├── 03_cells_memory.md
│   ├── 04_organs_applications.md
│   ├── 05_cognitive_tools.md
│   ├── 06_advanced_applications.md
│   ├── 07_prompt_programming.md
│   ├── 08_neural_fields_foundations.md
│   ├── 09_persistence_and_resonance.md
│   ├── 10_field_orchestration.md
│   ├── 11_emergence_and_attractor_dynamics.md
│   ├── 12_symbolic_mechanisms.md
│   ├── 13_quantum_semantics.md
│   └── 14_unified_field_theory.md
├── 10_guides_zero_to_hero/
├── 20_templates/
├── 30_examples/
├── 40_reference/
├── 50_contrib/
├── 60_protocols/
├── 70_agents/
├── 80_field_integration/
├── NOCODE/
├── SECURITY_RESEARCH/
├── cognitive-tools/
├── context-schemas/
├── masterclass_content/
├── CLAUDE.md
├── GEMINI.md
├── Complete_Guide.md
└── CITATIONS.md / CITATIONS_v2.md / CITATIONS_v3.md

Required Runtime

None — reading only. The agent commands require Claude Code.

Target AI Tools

  • Claude Code (agent commands in .claude/commands/)
  • OpenCode (mentioned in README)
  • Amp (mentioned)
  • Kiro (mentioned)
  • Codex (mentioned)
  • Gemini CLI (GEMINI.md provided)

Install

No install required. Clone or read on GitHub. CLAUDE.md and GEMINI.md provide the handbook content as agent context instructions.

03

Components

Context-Engineering Handbook — Components

Agent Commands (16, in .claude/commands/)

Command Purpose
alignment.agent.md Alignment-focused agent
cli.agent.md CLI tool-focused agent
comms.agent.md Communications-focused agent
data.agent.md Data analysis agent
deploy.agent.md Deployment agent
diligence.agent.md Due diligence / research agent
doc.agent.md Documentation agent
legal.agent.md Legal analysis agent
lit.agent.md Literature review agent
marketing.agent.md Marketing agent
meta.agent.md Meta-level orchestration agent
monitor.agent.md Monitoring agent
optimize.agent.md Optimization agent
research.agent.md Research agent
security.agent.md Security analysis agent
test.agent.md Testing agent

Foundation Documents (14, in 00_foundations/)

Structured learning progression from basic to frontier:

Level Document Concept
1 01_atoms_prompting.md Single instructions
1 02_molecules_context.md Few-shot patterns
1 03_cells_memory.md Persistent memory + state
1 04_organs_applications.md Multi-step flows
2 05_cognitive_tools.md Reasoning frameworks (IBM Zurich)
2 06_advanced_applications.md Advanced context patterns
2 07_prompt_programming.md Algorithmic prompt design
2 08_neural_fields_foundations.md Continuous meaning fields
3 09_persistence_and_resonance.md Cross-session context
3 10_field_orchestration.md Coordinated field operations
3 11_emergence_and_attractor_dynamics.md Attractor states
3 12_symbolic_mechanisms.md Symbolic residue
4 13_quantum_semantics.md Superposition in meaning
4 14_unified_field_theory.md Complete theoretical synthesis

Supporting Structures

  • cognitive-tools/ — IBM Zurich-inspired cognitive tool definitions
  • context-schemas/ — Standardized context structure formats
  • 20_templates/ — Reusable context templates
  • 30_examples/ — Example implementations
  • 60_protocols/ — Protocol shell definitions
  • 70_agents/ — Agent pattern implementations
  • CLAUDE.md — Claude Code context instructions for the handbook
  • GEMINI.md — Gemini CLI context instructions
  • Complete_Guide.md — Unified single-document version
05

Prompts

Context-Engineering Handbook — Prompt Files (Verbatim Excerpts)

Excerpt 1: Foundation 01 — Atoms: The Fundamental Unit

Source: 00_foundations/01_atoms_prompting.md

Prompting technique described: Atomic prompt decomposition — breaking a prompt into TASK + CONSTRAINTS + OUTPUT FORMAT as the baseline measurement primitive.

## The Anatomy of an Atomic Prompt

Let's break down what makes an effective atomic prompt:

┌─────────────────────────────────────────────────────────────┐ │ │ │ ATOMIC PROMPT = [TASK] + [CONSTRAINTS] + [OUTPUT FORMAT] │ │ │ └─────────────────────────────────────────────────────────────┘


## The Limitations of Atoms

While atomic prompts are the building blocks of LLM interactions, they quickly reveal fundamental limitations:

┌──────────────────────────────────────┐ │ LIMITATIONS OF ATOMIC PROMPTS │ ├──────────────────────────────────────┤ │ ✗ No memory across interactions │ │ ✗ Limited demonstration capability │ │ ✗ No complex reasoning scaffolds │ │ ✗ Prone to ambiguity │ │ ✗ High variance in outputs │ └──────────────────────────────────────┘


Excerpt 2: Foundation 05 — Cognitive Tools (IBM Zurich-Inspired)

Source: 00_foundations/05_cognitive_tools.md

Prompting technique described: Cognitive tool patterns — structured prompt templates that function as reasoning tool calls, analogous to human heuristics. The IBM Zurich paper showed these increase GPT-4.1 AIME2024 performance from 26.7% to 43.3%.

### From Biology to Cognition

Our journey through context engineering has followed a biological metaphor:

┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ │ │ Atoms │────►│ Molecules│────►│ Cells │────►│ Organs │ │ │ │ │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │ │ ▼ ▼ ▼ ▼ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ │ │ Prompts │ │ Few-shot │ │ Memory │ │ Multi │ │ │ │ │ │ │ │ -agent │ └──────────┘ └──────────┘ └──────────┘ └──────────┘


### Cognitive Tools?

"Cognitive tools" encapsulate reasoning operations within the LLM itself — IBM Zurich

These cognitive tools (structured prompt templates as tool calls) break down the problem by identifying the main concepts at hand, extracting relevant information in the question, and highlighting meaningful properties, theorems, and techniques that might be helpful in solving the problem.

Excerpt 3: Foundation 03 — Cells: Memory Management

Source: 00_foundations/03_cells_memory.md

Prompting technique described: Context window budgeting — modeling how conversation history consumes token budget and designing strategies (sliding window, summarization, selective retention) to manage it.

## The Cell Solution: Conversation Memory

The simplest cell structure adds conversation history to the context:

┌───────────────────────────────────────────────────────────────────────┐ │ │ │ SYSTEM PROMPT: "You are a helpful assistant..." │ │ │ │ CONVERSATION HISTORY: │ │ User: "My name is Alex." │ │ Assistant: "Hello Alex, nice to meet you." │ │ │ │ CURRENT INPUT: "What's my name?" │ │ │ └───────────────────────────────────────────────────────────────────────┘


## The Memory Token Budget Problem

As conversations grow, context windows fill up. We need memory management strategies:
      [Context Window Tokens]
      ┌─────────────────────────────────────────────┐

Turn 5 │ History 2-4 User Input 5 │ │ │ └─────────────────────────────────────────────┘ ▲ │ Eventually, something has to go


Excerpt 4: Biological Metaphor — Main Framework

Source: README.md

Prompting technique described: Progressive abstraction framing — the biological metaphor organizes complex engineering concepts into a memorable, hierarchical mental model.

## Why This Repository Exists

This repository provides a progressive, first-principles approach to context engineering, built around a biological metaphor:

atoms → molecules → cells → organs → neural systems → neural & semantic field theory │ │ │ │ │ │
single few- memory + multi- cognitive tools + context = fields + prompt shot agents agents operating systems persistence & resonance


Mathematical Foundations:
C = A(c₁, c₂, ..., cₙ)
09

Uniqueness

Context-Engineering Handbook — Uniqueness & Positioning

differs_from_seeds

No seed framework is a pure methodology handbook. The closest in spirit is agent-os (structured guidance files for agents) but agent-os is project-scaffolding tooling while this is an academic-practitioner synthesis. Unlike any seed, the Context-Engineering Handbook explicitly cites and operationalizes cutting-edge 2025-2026 research (IBM Zurich arXiv:2506.12115, Princeton/ICML, Singapore-MIT MEM1, Indiana University Quantum Semantics) as engineering primitives. The biological metaphor (atoms → molecules → cells → organs → neural systems → neural fields) is a unique organizing framework not present in any seed. The 9,009 stars make it the most-starred framework in this batch by a factor of 10x.

Positioning

The handbook occupies a unique position as a practitioner-facing research synthesis — it bridges academic papers and engineering practice, giving developers vocabulary (cognitive tools, neural fields, attractor dynamics, semantic resonance) and structured learning paths. It does not install, does not generate artifacts, and does not automate — it teaches.

At 9,009 stars, it suggests the field was hungry for a structured vocabulary and learning path for "everything beyond prompt engineering."

Observable Failure Modes

  • No executable deliverables: The handbook describes patterns but doesn't enforce or automate them. Practitioners must implement what they learn.
  • Frontier content is speculative: Foundations 13-14 (quantum semantics, unified field theory) are more theoretical than engineering-practical — risk of practitioners applying speculative models inappropriately.
  • Rapid obsolescence risk: Grounded in papers from 2025-2026; the field moves fast. The handbook's value depends on staying current.
  • Length vs depth tradeoff: 14 foundation documents + course + examples + reference = significant reading investment before actionable takeaways.

Most Interesting Finding

The handbook is the only framework in this batch (and possibly the entire catalog) that explicitly operationalizes dynamical systems theory (attractors, resonance) as a context engineering primitive — not as metaphor but as a concrete design pattern (Foundation 11). This represents a genuinely novel contribution to the field.

Cross-References

  • Cites and builds on: MIT RLM paper (also implemented by rlm-claude in this batch)
  • Cites and builds on: IBM Zurich cognitive tools (arXiv:2506.12115)
  • Conceptually upstream of: all other frameworks in this batch (they implement what this handbook theorizes)
04

Workflow

Context-Engineering Handbook — Workflow

This is a methodology handbook, not a workflow framework. There are no enforced phases, approval gates, or generated artifacts. The "workflow" is a learning progression:

Learning Progression

Level 1 — Basic (Weeks 1-4)

  • Atoms (01): Understand single-instruction limitations
  • Molecules (02): Master few-shot patterns and example selection
  • Cells (03): Build memory management into context
  • Organs (04): Orchestrate multi-step, multi-agent flows

Artifact: Understanding of fundamental context primitives

Level 2 — System Implementation (Weeks 5-8)

  • Cognitive Tools (05): Implement IBM Zurich-style reasoning scaffolds
  • Prompt Programming (07): Build algorithmic context structures
  • Neural Fields (08): Model context as continuous semantic fields

Artifact: Working implementations of cognitive tools

Level 3 — Integration (Weeks 9-10)

  • Persistence and Resonance (09)
  • Field Orchestration (10)
  • Emergence and Attractors (11)
  • Symbolic Mechanisms (12)

Artifact: Multi-agent context engineering systems

Level 4 — Frontier (Weeks 11-12)

  • Quantum Semantics (13)
  • Unified Field Theory (14)
  • Meta-Recursive Frameworks

Artifact: Self-improving context systems

Approval Gates

None — this is self-paced study material.

Artifacts

Phase Artifact
All The practitioner's ability to design effective context windows
Agent commands Specialized agents (research, security, etc.) for Claude Code
06

Memory Context

Context-Engineering Handbook — Memory & Context

Memory as a Core Subject

The entire handbook is about memory and context design. Key memory-related content:

Foundation 03 (Cells): Memory Types Covered

  • Conversation history — sliding window, summarization, selective retention
  • External memory — retrieval-augmented generation (RAG)
  • Working memory — what fits in the current context window
  • Long-term memory — external stores queried on demand

Foundation 09 (Persistence and Resonance)

  • Cross-session persistence patterns
  • Semantic resonance (how meaning persists across context updates)
  • Attractor states that maintain semantic coherence across compaction

Foundation 11 (Emergence and Attractor Dynamics)

  • Dynamical systems theory applied to context
  • Attractor states in semantic fields
  • How coherent meaning "emerges" from context components

Memory Storage in the Handbook Itself

The handbook uses CLAUDE.md and GEMINI.md as its own memory mechanism — instructing agents to treat the handbook contents as operational guidance. This is consistent with agent-os and related frameworks.

Research Papers on Memory

The handbook surveys recent memory research:

  • MEM1 (Singapore-MIT, arXiv:2506.15841) — Efficient memory for long-horizon agents
  • MemOS (Shanghai) — Operating system for AI memory
  • MAGMA — Memory-augmented generation
  • Context Rot (Chroma Research) — Context degradation over long windows
  • RLM paper (MIT CSAIL) — Recursive Language Models for memory

Compaction Handling

Foundation 03 addresses the memory token budget problem directly, providing strategies for graceful context management:

  • Sliding window (drop oldest)
  • Summarization (compress history)
  • Selective retention (keep high-importance items)
  • External retrieval (offload to RAG)
07

Orchestration

Context-Engineering Handbook — Orchestration

Multi-Agent Coverage

Yes (as methodology) — Foundation 04 (Organs) and Foundation 10 (Field Orchestration) address multi-agent systems as an architectural pattern. The 16 agent commands are specialized agent definitions.

Orchestration Patterns Described

The handbook covers:

  • Sequential agents (pipeline)
  • Parallel fan-out (Map-Reduce)
  • Hierarchical (queen+workers)
  • Consensus mechanisms
  • Emergence-based coordination (novel — from neural field theory)

Execution Mode

methodology-doc — describes patterns, doesn't enforce them.

Agent Commands

The 16 .claude/commands/ files are domain-specific agents that can be invoked in Claude Code. They follow the agent-development patterns described in the handbook itself.

Multi-Model

Not a primary topic — the handbook is model-agnostic. Discussion of routing models to roles appears in advanced orchestration sections.

Key Orchestration Insight

The handbook's distinctive contribution is framing multi-agent coordination not as software engineering (task queues, message buses) but as field theory — agents as resonant nodes in a semantic field, with emergent coordination from shared context attractors.

This is conceptually novel vs all seed frameworks which treat orchestration as pure software coordination.

08

Ui Cli Surface

Context-Engineering Handbook — UI & CLI Surface

Dedicated CLI Binary

None — this is a documentation/methodology repository.

Local Web Dashboard

None — the repository is browsable on GitHub.

Agent Commands

16 specialized agent command files in .claude/commands/ — invocable via Claude Code as /research, /security, /test, etc.

Supplementary Access Points

Multi-Platform Agent Instructions

  • CLAUDE.md — Claude Code/Code context
  • GEMINI.md — Gemini CLI context
  • Structured for: Claude Code, OpenCode, Amp, Kiro, Codex, Gemini CLI

Observability

None as infrastructure — the handbook itself is the deliverable.

Related frameworks

same archetype · same primary tool · same memory type

walkinglabs/learn-harness-engineering ★ 6.6k

Teach harness engineering from first principles (12 lectures + 6 projects) and provide a scaffolding skill (harness-creator) that…

Awesome Harness Engineering (walkinglabs) ★ 2.7k

Curate the authoritative reference list of articles, benchmarks, and tools for harness engineering — the practice of shaping the…

cline-memory-bank (nickbaumann98) ★ 581

Custom instructions + 6-file hierarchical Markdown memory bank so Cline maintains full project context across sessions, with a…

FPF (First Principles Framework) ★ 372

Provides a formal pattern language for making reasoning explicit, traceable, and publishable in mixed human/AI engineering work —…

nexu-io/harness-engineering-guide ★ 134

Provide a practical, code-first reference guide to harness engineering — from first principles to production patterns —…

knowhub ★ 40

Synchronize AI coding-agent knowledge files (rules, guidelines, templates) from a central source to multiple AI-tool-specific…