Prompt & Context Engineering
Make every AI request precise and evidence-based: clear instructions, the right context, structured outputs, task decomposition, long-context compression, reading documents and scans, citing sources and organising knowledge.
Prompt & Context Engineering
Make every AI request precise and evidence-based: clear instructions, the right context, structured outputs, task decomposition, long-context compression, reading documents and scans, citing sources and organising knowledge.
In one line
Prompt engineering is how you ask; context engineering is what the AI gets to see when it answers: your instructions, examples, documents, data, memory and tools. Getting both right is the first and most useful AI skill.
The 8 classes
From prompts to context
See why the information you give the AI matters more than clever wording.
- Context (documents, data, examples) usually matters more than wording.
- Goal, audience, context, constraints, format, quality bar.
- Ask for citations and 'not in data' when unsure.
Prompt patterns that work
Use proven patterns: examples, step-by-step, roles, critique and iteration.
- Show examples of what good looks like.
- Separate instructions from data with clear delimiters.
- Version and test prompts like product features.
Structured outputs: JSON, tables and fixed sections
Get predictable output other tools and people can use directly.
- Structure makes outputs reusable and testable.
- Give a schema plus an example.
- Validate and spot-check structured output.
Task decomposition and chaining
Break big jobs into steps the AI can do reliably.
- Big tasks → small steps with checkable outputs.
- Pass only needed context between steps.
- Insert review steps before sharing.
Long context: compression, summaries and memory
Keep long projects accurate when chats and documents get large.
- Long chats drift; summarise and restart.
- Pin a project brief; retrieve documents instead of pasting.
- Compression must keep numbers, names and decisions exact.
Documents, PDFs, scans and OCR
Get reliable information out of PDFs, slides, spreadsheets and images.
- AI reads PDFs, slides and images; tables need checking.
- Ask for 'UNREADABLE' instead of guesses.
- Cross-check totals and spot-check samples.
Source attribution, fact-checking and knowledge graphs
Make AI outputs traceable to evidence and organise knowledge by relationships.
- Every important claim should point to evidence.
- Use SUPPORTED / NOT FOUND / CONTRADICTED checks.
- Knowledge graphs capture relationships that plain search misses.
Context engineering for products and agents
Design what your AI feature or agent sees, and test it.
- Design every layer the model sees.
- Less but relevant context beats more context.
- Measure context changes with evals.
Interview questions
Prompt vs context engineering?
Prompting is the wording of the request; context engineering is designing all information the model sees: instructions, documents, data, memory, tools and examples.
How do you reduce hallucinations?
Provide sources, restrict answers to them, ask for citations and 'not in data', use retrieval, and verify with fact-check evals.
Why use structured output?
It makes outputs predictable, machine-readable, comparable and easy to grade; useful for dashboards, automation and evals.
What is task decomposition?
Breaking a complex task into smaller steps with clear inputs and outputs, often chained, with review steps.
How do you handle very long chats?
Summarise decisions and facts, start fresh with the summary, pin a project brief and retrieve documents instead of pasting everything.
How do you extract data reliably from PDFs or scans?
Ask for a fixed schema, 'UNREADABLE' instead of guessing, arithmetic cross-checks, and measure accuracy on a sample.
What is a knowledge graph?
A store of entities and their relationships that answers connected questions plain keyword or vector search may miss.
How do you decide how much context to give?
Test variants against an eval set and choose the smallest context that meets quality, cost and latency bars.
