01 Prompting and Context 3 min read 615 words

Prompt Engineering Fundamentals

Prompt engineering is the design of inputs to steer LLM behavior. In 2025, it has evolved from "trial and error" to a disciplined architectural practice.

promptingfundamentalsintro
01+ constraint

The Core Philosophy: Intent + Constraint

Effective prompting is about maximizing Intent Disclosure while minimizing Output Variance.

  1. Intent: Precisely what the model should do.
  2. Constraint: Exactly what the model should avoid (Safety, Tone, Format).

2025 Principle: "Prompting is Programming in Natural Language." Treat your prompts like code (Version control, Unit tests).

02hierarchy

The Instruction Hierarchy

Production systems use a tiered message structure:

RoleResponsibility2025 Nuance
SystemHigh-level rules, persona, safety.Stickiest for frontier models (H-rank).
DeveloperTechnical overrides (e.g., formatting).Newest role for "un-opinionated" models.
UserThe specific, dynamic query.Susceptible to injection; must be isolated.
AssistantHistory of previous turns.Source of "recency bias."
03dec standard

Role Prompting (Dec 2025 Standard)

Assigning a persona is no longer just "You are a teacher." It is a Capabilities Anchor.

  • Weak: "You are a coder."
  • Strong: "You are a Staff Software Engineer at a Tier-1 tech company specializing in high-concurrency Rust systems. You prioritize memory safety and zero-cost abstractions."

Why it works: It focuses the model's attention on the specific subset of its training data related to that high-level expertise, reducing irrelevant hallucinations.

04clarity delimiters

Instruction Clarity and Delimiters

Models in 2025 process massive contexts. Delimiters help the model distinguish between instructions and data.

Markdownmarkdown · 10 lines
12345678910
# Instructions
Analyze the following text for PII.

# Data to Analyze
--- START OF USER DATA ---
$USER_INPUT_HERE
--- END OF USER DATA ---

# Output Schema
{ "pii_found": boolean, "types": [] }

Delimiters to use: XML tags (<context>, </context>), Markdown headers (#), or triple quotes (""").

05few-shot efficiency

Zero-Shot vs. Few-Shot Efficiency

AspectZero-ShotFew-Shot
LatencyLowest (Short prompt)Higher (Example tokens)
AccuracyVariableHigh (Format stability)
Use CaseSimple chat, SummarizationSpecific formatting, Subtle logic

2025 Strategy: If the model is a "Frontier Reasoning" model (o1, DeepSeek-R1), use Zero-Shot + Clear Chain-of-Thought. If it's a small model (8B), use Few-Shot to ground it.

06questions

Interview Questions

Q: Why do system prompts carry more weight than user prompts in modern LLMs?

Strong answer: System prompts are typically prioritized by the model's architectural training (RLHF) and may be injected into a special "instruction-only" embedding space in some architectures. From a design perspective, the system prompt defines the "Constitution" of the interaction. If a user prompt contradicts a system prompt (e.g., asking for a bomb recipe), a well-aligned model is trained to prioritize the system's "Safety Constraint" over the user's "Task Intent."

Q: What is the "Step-by-Step" prompt optimization?

Strong answer: In 2022, "Think step by step" was a magic phrase to trigger Chain-of-Thought (CoT). In 2025, we use Programmatic CoT. Instead of a vague phrase, we provide explicit reasoning milestones: "1. Identify the core problem. 2. List the constraints. 3. Propose 3 solutions. 4. Select the best one and justify." This provides a "deterministic path" for the model's internal attention, leading to much more reliable outputs for production agents.

07references

References

  • OpenAI. "Prompt Engineering Guide" (2024-2025)
  • Anthropic. "Claude Prompt Engineering Documentation" (2024)
  • Google DeepMind. "The Power of Prompting" (2023)

Next: Few-Shot and In-Context Learning

summary · added by this rebuild

Key takeaways

01

Four roles with different stickiness

System carries rules and persona, developer carries technical overrides, user is the injection-prone dynamic input, and assistant history is where recency bias enters the conversation.

02

A persona is a capabilities anchor

You are a coder is weak; naming seniority, domain and priorities such as high-concurrency Rust, memory safety and zero-cost abstractions narrows which training data the model draws on.

03

Delimiters separate instruction from data

XML tags, markdown headers or explicit start and end markers around user input are what stop a long context from letting the data read as further instructions.

04

Few-shot is mainly for small models

The page's rule is zero-shot plus clear chain-of-thought for frontier reasoning models and few-shot examples to ground an 8B one, trading prompt tokens for format stability.

05

Replace the magic phrase with milestones

Instead of think step by step, enumerate the steps: identify the problem, list constraints, propose three solutions, pick one and justify it. That gives the model a deterministic path.