0PricingLogin
AI Prompt Engineering · Lesson

What Context Means in AI Prompting

How background information shapes the model's response direction.

Context: The Model's Background Briefing

Context is the background information that allows the model to give a relevant, accurate, and appropriately calibrated response.

Without context, the model guesses who you are, what you need, what domain you work in, and what level of detail is appropriate. Those guesses are based on the most statistically average interpretation — not your actual situation.

What Happens Without Context

Compare these two requests about the same topic:

Without context: 'What should I do about the database issue?'
The model has no idea which database, what the issue is, or what 'do' means in your situation.

With context: 'We are running PostgreSQL 15 on AWS RDS. Our query response time spiked from 20ms to 800ms after a schema migration yesterday. The migration added 3 new indexes. What should I investigate first?'

The second question contains domain, technology, timeline, symptoms, and a recent change — everything needed for a useful answer.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

no_context = 'What should I do about the database issue?'

with_context = (
    'We are running PostgreSQL 15 on AWS RDS. '
    'Query response time spiked from 20ms to 800ms after a schema migration yesterday. '
    'The migration added 3 new indexes on the orders table (500M rows). '
    'No other infrastructure changes were made. '
    'What should I investigate first to diagnose the slowdown?'
)

for label, prompt in [('NO CONTEXT', no_context), ('WITH CONTEXT', with_context)]:
    response = client.messages.create(
        model='claude-opus-4-5',
        max_tokens=200,
        messages=[{'role': 'user', 'content': prompt}]
    )
    print(f'--- {label} ---')
    print(response.content[0].text[:300])
    print()

All lessons in this course

  1. What Context Means in AI Prompting
  2. Providing Background Information
  3. Setting the Scene Effectively
  4. Context Length and Relevance
← Back to AI Prompt Engineering