---
title: "04 — Prompt vs Context Engineering: The System Prompt, the Role, the Constraints"
uid: prompt-vs-context-engineering
tags: ["prompt-engineering", "llm", "structured-output", "system-prompt", "roadmap:ai-engineer", "context-engineering"]
excerpt: "'Writing good prompts' bundles two different skills. The split that mattered: prompt engineering crafts the instructions, context engineering builds the whole information environment around the model."
date: 2026-08-13T03:28:39+0000
source: https://www.aveshina.my.id/en/blog/prompt-vs-context-engineering
---

Two phrases I kept treating as one — prompt engineering and context engineering — finally separated when I saw them as different targets: **prompt engineering crafts the instructions; context engineering builds the entire information environment around the model.** [1] One shapes what you _say_; the other shapes everything the model _sees_.

The framing that finally landed is a layering. Prompt engineering is the innermost layer — the actual words of the instruction, their format, the examples embedded in them. Context engineering is the outer frame — what else is in the context window besides the instruction, how it's ordered, what's retrieved, what's filtered out, what gets summarized. The prompt is a component of the context; the context is the whole payload the model reasons over.

```figure
<svg viewBox="0 0 680 320" xmlns="http://www.w3.org/2000/svg" class="my-6 w-full max-w-2xl" role="img" aria-label="Context engineering as nested layers around a model. Outermost box: context engineering (assembles the whole environment). Inside it: retrieved documents, conversation history, examples. At the center: prompt engineering (the crafted instruction). An arrow from the center instruction points into a small model core.">
  <g font-family="ui-sans-serif, system-ui, sans-serif" text-rendering="geometricPrecision">

    <!-- outer: context engineering -->
    <rect x="20" y="30" width="640" height="270" rx="12" fill="#e0e7ff" stroke="#6366f1" stroke-width="2"/>
    <text x="340" y="54" font-size="13" font-weight="700" fill="#1e1b4b" text-anchor="middle">Context engineering — the whole environment</text>

    <!-- retrieved docs -->
    <rect x="40" y="76" width="150" height="44" rx="6" fill="#fef9c3" stroke="#ca8a04" stroke-width="1"/>
    <text x="115" y="94" font-size="10.5" font-weight="700" fill="#422006" text-anchor="middle">retrieved docs</text>
    <text x="115" y="108" font-size="9" fill="#422006" text-anchor="middle">filtered, ranked</text>

    <!-- history -->
    <rect x="40" y="132" width="150" height="44" rx="6" fill="#fce7f3" stroke="#db2777" stroke-width="1"/>
    <text x="115" y="150" font-size="10.5" font-weight="700" fill="#500724" text-anchor="middle">conversation history</text>
    <text x="115" y="164" font-size="9" fill="#500724" text-anchor="middle">summarized if long</text>

    <!-- examples -->
    <rect x="40" y="188" width="150" height="44" rx="6" fill="#dcfce7" stroke="#16a34a" stroke-width="1"/>
    <text x="115" y="206" font-size="10.5" font-weight="700" fill="#052e16" text-anchor="middle">few-shot examples</text>
    <text x="115" y="220" font-size="9" fill="#052e16" text-anchor="middle">curated</text>

    <!-- center: prompt -->
    <rect x="240" y="110" width="400" height="130" rx="10" fill="#fff" stroke="#6366f1" stroke-width="1.5" stroke-dasharray="5 3"/>
    <text x="440" y="134" font-size="12" font-weight="700" fill="#1e1b4b" text-anchor="middle">Prompt engineering — the crafted instruction</text>

    <rect x="260" y="148" width="360" height="30" rx="5" fill="#f1f5f9" stroke="#94a3b8"/>
    <text x="270" y="167" font-size="10" font-family="ui-monospace, monospace" fill="#1e293b">system: "You are a precise code reviewer…"</text>

    <rect x="260" y="184" width="360" height="44" rx="5" fill="#f8fafc" stroke="#94a3b8"/>
    <text x="270" y="201" font-size="10" font-family="ui-monospace, monospace" fill="#1e293b">role + constraints + output format</text>
    <text x="270" y="217" font-size="10" font-family="ui-monospace, monospace" fill="#1e293b">+ structured-output schema</text>

    <!-- arrow into model -->
    <text x="340" y="280" font-size="10" font-style="italic" fill="#475569" text-anchor="middle">the model sees all of this as one token stream</text>
  </g>
</svg>
```

## The boundary, stated plainly

**Prompt engineering** focuses on crafting the instruction itself — the words, the layout, the in-line examples — to elicit a specific kind of output [1]. **Context engineering** is the broader practice of strategically curating, formatting, and refining _all_ the information provided to the model so it has exactly what it needs and nothing it doesn't [2]. The prompt is the seed; the context is the soil, the water, and the light.

The mistake I made for a while was treating "context engineering" as a rebrand of "prompt engineering." It isn't. When I rewrite a system prompt to be clearer, that's prompt engineering. When I decide which three paragraphs of retrieved documentation to inject before that prompt, that's context engineering. They're different skills, and conflating them is why my early attempts at "better prompting" produced inconsistent gains — I was polishing the seed and ignoring the soil.

## Input format: how the instruction is laid out

The first layer of prompt engineering is **input format** — the structure and presentation of the prompt itself [3]. Format has measurable impact: the same instruction phrased as a clean numbered list versus a wall of text produces noticeably different adherence. Key moves:

- **Separate instructions from data** — wrap the user's input in delimiters so the model knows what's rule and what's payload.
- **Order matters** — putting the instruction after a long retrieved block can bury it; the model pays more attention to the start and end of the context.
- **Whitespace and labels** carry weight. A clear Instructions:, Context:, Output: skeleton outperforms prose.

This layer alone catches a surprising number of "the model isn't following my instructions" problems — the instructions were there, just badly formatted [3].

## System prompting: setting the operating frame

A **system prompt** sets the overall context, purpose, and behavioral rules for the entire session [4]. It's the highest-authority instruction — everything that follows is interpreted through it. The system prompt defines:

- The model's **role** and persona.
- The **behavioral constraints** — what it must and must not do.
- The **output format** requirements.
- The **safety guardrails**.

Because it sits at the top and colors every subsequent turn, the system prompt is where I spend the most effort. A weak system prompt means every user turn fights against an ambiguous frame; a strong one makes the whole conversation more consistent.

## Role and behavior: giving the model a persona

Within the system prompt, defining a **role** shapes behavior more than I expected [5]. "You are a careful code reviewer who explains every suggestion" produces structurally different output than a generic "review this code." The role isn't decoration — it primes the model toward the distribution associated with that persona's writing in its training data. Combined with explicit behavior constraints ("always cite the line number," "never apologize"), the role becomes a precise behavioral lever rather than a vibe.

## Contextual prompting: situational detail

Distinct from the system prompt, **contextual prompting** provides task-specific background that changes per request [6]. Where the system prompt is stable across a session, contextual prompts are dynamic: "Context: this is for a blog about retro arcade games — suggest three article topics." The contextual detail anchors the response to the immediate situation. The art is choosing _only_ the relevant detail — too much context is the same problem as too little signal.

## Constraining prompts: drawing the fences

**Constraints** are explicit boundaries on what the model may do [7]. They are the cheapest safety and quality lever available, because they cost nothing at inference time and prevent whole categories of failure:

- "Only answer using the provided documents. If the answer isn't there, say you don't know." (This single constraint is the backbone of reliable RAG.)
- "Do not speculate about the user's personal information."
- "Respond in under 100 words."

Constraints work best when they're stated as _positive_ instructions where possible ("answer only from the documents") and _negative_ only when necessary ("do not speculate"). Models follow positive framing more reliably than a list of don'ts.

## Structured outputs: forcing a parseable shape

The last lever is the one that makes LLM output safe to wire into a downstream system. **Structured output** means designing the prompt — and using the model's structured-output mode — so the response comes back in a predefined format like JSON, rather than free text [8][9].

```
{
  "summary": "string",
  "action_items": ["string"],
  "confidence": "number"
}
```

Why this matters: free text needs fragile parsing. A declared schema, enforced by the model's structured-output mode, gives me a guaranteed shape I can deserialize directly. The model is constrained at the token level to produce valid JSON matching the schema, which removes a whole class of integration bugs. For any feature where the model's output feeds another component — a database write, an API call, a UI render — structured output is now my default, not an option.

## How I use this

The split gives me a checklist for any new feature. First I write the system prompt: role, constraints, output format. Then I decide the context layer: what does the model need to see per request, where will it come from, how will I keep it lean. Then I lock the output to a schema if anything downstream consumes it. Only after those three are in place do I start tuning the wording of the instruction itself. Treating prompt and context as separate concerns — instead of one fuzzy "prompting" — is what made my results repeatable instead of lucky.

## References

[1] Elastic, "Context engineering vs. prompt engineering," 2024. [Online]. Available: [https://www.elastic.co/search-labs/blog/context-engineering-vs-prompt-engineering](https://www.elastic.co/search-labs/blog/context-engineering-vs-prompt-engineering)

[2] Anthropic, "Effective context engineering for AI agents," 2025. [Online]. Available: [https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)

[3] "Does Prompt Formatting Have Any Impact on LLM Performance?," arXiv:2411.10541, 2024. [Online]. Available: [https://arxiv.org/html/2411.10541v1](https://arxiv.org/html/2411.10541v1)

[4] Regie.ai, "User prompts vs. system prompts: What's the difference?," 2024. [Online]. Available: [https://www.regie.ai/blog/user-prompts-vs-system-prompts](https://www.regie.ai/blog/user-prompts-vs-system-prompts)

[5] M. Desai, "Beyond Basics: Contextual & Role Prompting That Actually Works," Medium, 2024. [Online]. Available: [https://medium.com/@the_manoj_desai/beyond-basics-contextual-role-prompting-that-actually-works-bd75a0c5086b](https://medium.com/@the_manoj_desai/beyond-basics-contextual-role-prompting-that-actually-works-bd75a0c5086b)

[6] CodeSignal, "Introduction: The Power of Clear Instructions," 2024. [Online]. Available: [https://codesignal.com/learn/courses/prompting-foundations/lessons/defining-constraints-and-requirements-for-effective-prompts](https://codesignal.com/learn/courses/prompting-foundations/lessons/defining-constraints-and-requirements-for-effective-prompts)

[7] J. Abdullin, "Structured Output," 2024. [Online]. Available: [https://abdullin.com/structured-output/](https://abdullin.com/structured-output/)

[8] Cohere, "How do Structured Outputs Work?," 2024. [Online]. Available: [https://docs.cohere.com/docs/structured-outputs](https://docs.cohere.com/docs/structured-outputs)

[9] "System Prompt Fundamentals," YouTube, 2024. [Video]. Available: [https://www.youtube.com/watch?v=RMR0Y8esSmE](https://www.youtube.com/watch?v=RMR0Y8esSmE)

```quiz
Q: The core difference between prompt engineering and context engineering is…
- there is no real difference; they are synonyms
- prompt engineering crafts the instruction; context engineering builds the entire information environment the model sees
correct: 1
explain: The prompt is one component of the context. Context engineering also covers retrieved docs, history, examples, ordering, and what gets filtered out.

Q: A system prompt's main job is to…
- provide one-off task detail that changes per request
- set the role, constraints, output format, and guardrails for the whole session
correct: 1
explain: The system prompt is the stable, highest-authority instruction that frames every subsequent turn. Per-request detail belongs in contextual prompts.

Q: "Answer only from the provided documents; if the answer isn't there, say you don't know" is an example of…
- a sampling parameter
- a constraint
correct: 1
explain: Constraints are explicit boundaries on what the model may do. This one is the backbone of reliable RAG behavior.

Q: Why prefer structured outputs (e.g. a JSON schema) over free text when the output feeds a database write?
- it makes the response shorter
- the model is constrained to produce a guaranteed, parseable shape, removing fragile parsing
correct: 1
explain: Structured-output modes enforce a schema at the token level, so downstream code can deserialize the result without brittle regex parsing.

Q: You rewrite the wording of your instruction but leave retrieval unchanged. That's mainly…
- context engineering
- prompt engineering
correct: 1
explain: Rewording the instruction is prompt engineering. Changing what docs are retrieved, or summarizing history, would be context engineering.
```
