Jonatan Matajonmatum.com
conceptsnotesexperimentsessays
© 2026 Jonatan Mata. All rights reserved.v2.1.1
Concepts

Prompt Engineering

The discipline of designing effective instructions for language models, combining clarity, structure, and examples to obtain consistent, high-quality responses.

growing#prompt-engineering#llm#anthropic#openai#google#meta#best-practices#ai-tools

Prompt engineering is the process of designing instructions that guide a language model to generate responses meeting specific requirements for format, tone, accuracy, and content. It is not simply "asking an AI questions" — it is a discipline combining clear communication, structured thinking, and iterative experimentation.

What it is

A prompt is the text input a language model receives. Prompt engineering is the optimization of that input to maximize output quality. Since models are non-deterministic, achieving consistent results requires specific techniques that go beyond intuition.

Each model provider publishes official guides with recommendations tailored to their models' strengths. While fundamental techniques are universal, implementation details vary.

Universal principles

These techniques work with any modern language model:

Be clear and direct

Specific instructions produce better results than vague ones. Instead of "write something about X," specify format, length, tone, and audience.

Provide context

Include the relevant information the model needs to solve the problem. Do not assume the model has all necessary context — treat it as a brilliant but new collaborator who does not know the details of your project.

Use examples (few-shot prompting)

Show the model what a correct response looks like. Between 3 and 5 diverse examples are usually sufficient to establish the desired pattern. Examples are one of the most reliable ways to control format, tone, and structure.

Structure the prompt

Separate instructions, context, examples, and input data using clear delimiters — whether XML tags, Markdown headings, or text separators. This reduces ambiguity and improves interpretation.

Assign a role

Defining who the model is in the system prompt focuses its behavior and tone. Even a single sentence makes a difference.

Break down complex tasks

Instead of a monolithic prompt, split into sequential steps (prompt chaining) or parallel subtasks that aggregate at the end.

Iterate

Prompt design is iterative. Rephrase, change content order, try different levels of detail, and measure results.

Provider-specific guidance

Anthropic (Claude)

Anthropic emphasizes structure and clarity as foundational pillars. Key recommendations:

  • XML tags: Claude responds especially well to prompts structured with tags like <instructions>, <context>, <examples>. Use descriptive, consistent names.
  • Adaptive thinking: for complex tasks, enabling adaptive thinking mode lets Claude calibrate its reasoning based on each query's complexity.
  • Long context: place lengthy documents at the top of the prompt and instructions at the end — this can improve quality by up to 30%.
  • Anchor in quotes: for long-document tasks, ask the model to cite relevant parts before responding.
  • Agentic systems: for long-running autonomous tasks, include explicit instructions about persistence, progress verification, and state management. Use git to track state across sessions.
  • Avoid over-engineering: Claude 4.x models follow instructions with high fidelity — simpler, more direct prompts often work better than overly elaborate ones.

OpenAI (GPT)

OpenAI distinguishes between GPT models and reasoning models, each requiring different strategies:

  • Message roles: use the instructions parameter or message roles (developer, user) to establish instruction authority hierarchy.
  • Markdown and XML: combine Markdown headings for sections and XML tags to delimit context data. Recommended structure: identity, instructions, examples, context.
  • GPT vs reasoning models: GPT models benefit from precise, explicit instructions (like a junior collaborator). Reasoning models work better with high-level goals (like a senior collaborator).
  • Reusable prompts: OpenAI offers stored prompt templates that accept variables, useful for standardizing prompts in production.
  • Evaluations: build evals that measure prompt behavior to monitor performance when iterating or changing model versions.

Google (Gemini)

Google promotes the PTCF framework (Persona, Task, Context, Format) and emphasizes examples:

  • PTCF framework: structure each prompt with persona (who the model is), task (what it should do), context (relevant information), and format (how it should respond).
  • Partial completion: provide the beginning of the desired response to guide the model in the right direction — especially useful for controlling output format.
  • Model parameters: experiment with temperature, topK, and topP. For Gemini 3, keeping temperature at its default value of 1.0 is recommended.
  • System instructions: place critical behavioral constraints and role definitions in system instructions, not in the user prompt.
  • Long context: for large data volumes, place all context first and instructions at the end. Use a transition phrase like "based on the information above" to anchor the query.
  • Explicit reasoning: for complex tasks, ask the model to plan in subtasks and self-critique before giving the final answer.

Meta (Llama)

Llama models are open-source and require special attention to token formatting:

  • Special tokens: Llama uses control tokens like <|begin_of_text|>, <|start_header_id|>, and <|eot_id|> to delimit roles and conversation turns.
  • Positive instructions: state what the model should do, not what it should avoid. Positive instructions produce better results.
  • Response priming: start the prompt with the first word or sentence of the desired response to guide the model's direction.
  • Simple iteration: start with a simple, concise prompt, then refine. Place instructions at the beginning or end of the prompt where the model pays most attention.

Amazon Bedrock

Bedrock is a platform offering access to multiple models, with additional management tools:

  • Prompt management: Bedrock Prompt Management allows versioning, optimizing, and collaborating on prompts within a structured workflow.
  • RAG for reducing hallucinations: combine prompts with Retrieval Augmented Generation to provide the model access to relevant, up-to-date data.
  • Prompt caching: for repeated prompt prefixes, caching reduces latency and costs by reusing previous processing.
  • Guardrails: a deterministic safety layer that complements probabilistic prompt engineering techniques with content filtering and automated verification.

Advanced techniques

TechniqueMechanismWhen to use
Chain-of-ThoughtAsk "think step by step" before respondingReasoning, math, logic
Prompt chainingOutput of one prompt feeds the nextComplex tasks with sequential steps
Self-consistencyGenerate multiple responses and select the most frequentReduce reasoning errors
RAGCombine prompt with information from external sourcesReduce hallucinations, keep responses current
Few-shotInclude input/output examples in the promptControl response format and style

Why it matters

Input quality determines output quality. As language models integrate into more tools and workflows — from code assistants to autonomous agents — the ability to communicate effectively with them becomes a fundamental skill.

It is not about memorizing tricks, but about developing a mental model of how these systems process information and using that understanding to obtain predictable, high-quality results.

References

  • Prompting best practices — Anthropic. Official best practices guide for Claude.
  • Prompt engineering overview — Anthropic. Introduction to prompt engineering with Claude.
  • Prompt engineering guide — OpenAI. Official guide for GPT and reasoning models.
  • Best practices for prompt engineering — OpenAI. Quick reference for best practices.
  • Prompt design strategies — Google. Official strategies for Gemini models.
  • Prompt engineering whitepaper — Google, 2025. 68-page playbook on prompt engineering.
  • Prompt engineering concepts — AWS. Official Amazon Bedrock guide.
  • Best prompting practices for Meta Llama 3 — AWS, 2024. Best practices for Llama models on SageMaker.

Related content

  • Artificial Intelligence

    Field of computer science dedicated to creating systems capable of performing tasks that normally require human intelligence, from reasoning and perception to language generation.

  • AI Agents

    Autonomous systems that combine language models with reasoning, memory, and tool use to execute complex multi-step tasks with minimal human intervention.

  • Model Context Protocol (MCP)

    Open protocol created by Anthropic that standardizes how AI applications connect with external tools, data, and services through a universal interface.

  • Tool Use Patterns

    Design strategies and patterns for AI agents to select, invoke, and combine external tools effectively to complete complex tasks.

  • Context Windows

    The maximum number of tokens an LLM can process in a single interaction, determining how much information it can consider simultaneously to generate responses.

  • Takeaways: Why 2026 Is the Year to Build a Second Brain

    Key takeaways from Nate B Jones' second brain series — from the original 8 building blocks to Open Brain (Postgres + MCP), the two-door principle, and the implementation gap.

  • Large Language Models

    Massive neural networks based on the Transformer architecture, trained on enormous text corpora to understand and generate natural language with emergent capabilities like reasoning, translation, and code generation.

  • Chain-of-Thought

    Prompting technique that improves LLM reasoning by asking them to decompose complex problems into explicit intermediate steps before reaching a conclusion.

  • AI Coding Assistants

    Tools using LLMs to help developers write, understand, debug, and refactor code, from autocomplete to agents that implement complete features.

Concepts