A working reference implementation of context engineering — the discipline of designing, retrieving, and injecting the information an AI system needs to produce accurate, organization-specific outputs.
This repo is the code companion to What Is Context Engineering? on outcomeops.ai. The glossary defines the concepts; this repo shows them running end-to-end against a real corpus on Amazon Bedrock.
Context engineering treats context as a first-class engineering artifact — version-controlled, retrievable, and enforceable — rather than as prompts typed into a chat window.
A context engineering system has five components. Each folder implements one against the same running example (a Spring PetClinic codebase with ADRs):
| # | Component | What it does | Folder |
|---|---|---|---|
| 1 | Corpus | The organizational material that defines how you think, build, and decide | 01-corpus/ |
| 2 | Retrieval | Identifies which portions of the corpus are relevant to a given request | 02-retrieval/ |
| 3 | Injection | Gets retrieved context into the model's working memory at decision time | 03-injection/ |
| 4 | Output | Produces reviewable artifacts (code, PRs, docs) shaped by that context | 04-output/ |
| 5 | Enforcement | Ensures the generated output actually reflects the retrieved context | 05-enforcement/ |
Plus comparisons/ — the same task run with and without context engineering, plus how CE differs from RAG, Copilot, and agent frameworks.
A system with only components 1–3 is a RAG system. The output and enforcement layers are what make CE different — they make the generated content reviewable and governable.
All examples use Amazon Bedrock with Claude. Each folder has its own requirements.txt and README.md with a runnable command.
Prerequisites:
- Python 3.11+
- AWS account with credentials configured (
aws configureor env vars) - AWS region that supports Claude and Titan (e.g.
us-east-1,us-west-2)
This repo uses Anthropic Claude for generation and Amazon Titan for embeddings. Titan and most Bedrock foundation models are auto-enabled on first invocation — no action needed.
Anthropic Claude requires a one-time First Time Use (FTU) form per AWS account. If your account has never used Anthropic models on Bedrock, the first script run will fail with AccessDeniedException. To fix:
- Open any Anthropic Claude model in the Bedrock model catalog
- Fill the First Time Use form (company, use case — about a minute)
- Submit — access is granted immediately, no review queue
If you're in an AWS Organization child account, the form must be submitted from the management account to inherit access.
Quickstart:
git clone https://github.com/outcomeops/context-engineering.git
cd context-engineering/01-corpus
pip install -r requirements.txt
python ingest_adrs.py ./sample-adrsSet the model via environment variable if you want to override the default:
export BEDROCK_MODEL_ID="us.anthropic.claude-sonnet-4-5-20250929-v1:0"
export AWS_REGION="us-east-1"Most AI coding assistants produce generic output. An engineer using a generic assistant still has to adapt the output to local patterns — the assistant doesn't know what your team decided last quarter, what your compliance framework requires, or why you picked one library over another.
A context-engineered system produces output that already conforms to local patterns, because the retrieval layer has fed the model the relevant ADRs, code, and standards at decision time. The enforcement layer ensures the output actually cites what it relied on.
This repo exists to show the pattern in code, end-to-end, so teams can build it themselves or evaluate commercial tools that claim to do it.
The five-component model is the technical frame. Teams that actually deploy it consistently discover the harder shift is organizational. Roles, KPIs, and decision rights in a traditional software org were shaped by a world where AI could not read the corpus. Once it can, the middle layers of that structure start to look different — and the repo above is only useful in the first place because of those changes.
- The rise of the outcome engineer — the emerging role
- Engineers who own the outcome — the operating model
- OutcomeOps and context engineering: the next corporate evolution beyond DevOps — what comes after DevOps
- Death of the traditional product owner — the product-side role shift
- Measuring what actually matters — the KPI shift
Foundational articles, reference guides, and practitioner writeups on context engineering as a discipline:
- Effective context engineering for AI agents (Anthropic, Sep 2025) — curating and limiting what an agent sees
- The rise of context engineering (LangChain, Jun 2025) — the article that made the term widely used
- Context engineering for agents (LangChain, Jul 2025) — write/select/compress/isolate framing
- Context Engineering: Bringing Engineering Discipline to Prompts (Addy Osmani, Jul 2025) — engineering-discipline framing
- Context Engineering Guide (PromptingGuide.ai) — reference entry
- Documenting Architecture Decisions (Michael Nygard, 2011) — the original ADR essay; the format used throughout this repo
- OutcomeOps and context engineering: the next corporate evolution beyond DevOps (OutcomeOps) — the organizational thesis behind this repo
- OutcomeOps: self-documenting architecture — when code becomes queryable (OutcomeOps) — how ADR corpora compound as code evolves
- The real cost of knowledge: why most AI engineering platforms over-engineer RAG (OutcomeOps) — against premature retrieval infrastructure
- What AI-assisted development actually looks like in two years (OutcomeOps) — the working developer's view
- bonigarcia/context-engineering — book companion from Boni García; organized by chapter with polyglot examples
- davidkimai/Context-Engineering — concepts, patterns, and techniques
- Meirtz/Awesome-Context-Engineering — curated list of papers, tools, and articles
- joelparkerhenderson/architecture-decision-record — the definitive ADR resource list
Each folder's README has its own curated reading list; the quick index:
- Corpus — see
01-corpus/— ADR formats, corpus bootstrapping, self-documenting architecture - Retrieval — see
02-retrieval/— FAISS, "Lost in the Middle," retrieval economics - Injection — see
03-injection/— prompt structure, token budgets, inference cost - Output — see
04-output/— JSON Schema, Bedrock tool-use, the outcome engineer - Enforcement — see
05-enforcement/— LLM-as-judge research, PR-as-guardrail - Comparisons — see
comparisons/— CE vs RAG vs agents vs enterprise search
Built by Brian Carpio at OutcomeOps. Questions, corrections, or contributions welcome via issues and PRs.
MIT — see LICENSE.