SE Hub
AI Fundamentals

Context

Working with AI means managing context — system and user prompts, included context, and context limits.

Working with AI is largely about managing context.

The model can only answer from what it knows through training and what it can see in the current interaction. You improve the answer by giving it the right context at the right time.

System and user prompts

Most AI tools use more than one kind of instruction.

The system prompt defines the model's role, constraints, and high-level behavior. You usually do not edit it directly in product tools, but it shapes how the assistant behaves.

The user prompt is what you write. This is where you describe the task, constraints, desired output, and relevant background.

For coding agents, there may also be repository instructions such as AGENTS.md, tool descriptions, file contents, terminal output, and previous messages.

Include the right context

A weak prompt asks the model to guess:

Fix the checkout bug.

A better prompt gives useful context:

The checkout total is wrong when a percentage discount and a fixed discount are both applied.
Look at src/services/PricingService.ts and the failing test in src/services/PricingService.test.ts.
Preserve the current public API.

The second prompt gives the model a target, relevant files, an observed failure, and a constraint.

Context is not infinite

Models have context limits. Long conversations, pasted files, logs, and generated output all consume space.

When the context gets crowded, the model may stop paying attention to older details or the tool may compress them. This can make the assistant repeat mistakes or forget constraints.

If a task changes direction, start a new conversation. If the model is confused, restate the important facts and remove irrelevant history.

Context quality beats context quantity

More context is not always better. A hundred irrelevant files can make the model worse, not better.

Good context is:

  • Relevant to the task.
  • Concrete enough to verify.
  • Small enough to reason about.
  • Clear about constraints and desired behavior.

The skill is not dumping everything into the prompt. The skill is deciding what information would change the model's answer.

On this page