Session 4 Slides: Context Engineering

--:-- --
↓ Scroll for more

Session 4

Context Engineering

AI Product Engineering

Block 1: Foundations & The Exocortex

Prompt vs. Context Engineering

Prompt Engineering

How you instruct the model

Role, Task, Format, Constraints

Context Engineering

The information you feed the model

Knowledge quality, structure, relevance

Garbage in, garbage out — at scale.

The Context Window Constraint

TokensWordsEquivalent
4,000~3,000Short essay
32,000~24,000Short report
128,000~96,000Small book
1,000,000~750,000Large textbook

You cannot dump your entire knowledge base into every prompt. You must retrieve, format, and fit.

Four Principles of Good Context

  1. Remove Redundancy — duplicate facts waste tokens and confuse the model
  2. Be Explicit About Structure — labelled headings and bullets outperform prose
  3. Include Metadata — date, source, and relevance signals help the model weight information
  4. Chunk Logically — each chunk should answer a specific type of question

The Context Template Pattern

---
topic: [Topic Name]
type: concept | procedure | example
---
## Core Idea
One-sentence summary.

## Explanation
2–4 paragraphs.

## Key Terms
- **Term:** Definition

## Common Mistakes
What people misunderstand.

Every note in this format is a high-quality, retrievable RAG chunk.

Lab: Format Web Content

  1. Find a relevant article or documentation page
  2. Remove navigation, footers, and noise
  3. Structure with clear Markdown headings
  4. Add frontmatter: topic, type, source
  5. Test: ask a question with and without context — compare results

Session 4 Summary

  • Context engineering = designing the information fed to AI
  • Context window limits require deliberate content selection
  • Structured Markdown with metadata improves output quality
  • Templates ensure consistent, high-quality knowledge base entries

Next Session: AI-Assisted Software Engineering