Patterns
Prompt Engineering
Evolving Engineering in AI / Prompt Engineering

Prompt Engineering: English Is a New Programming Language

Limitation it addressedGeneral-purpose LLMs arrived with no task-specific tuning. The same model produced wildly different quality depending purely on how a request was phrased, with no formal way to specify intent.
Why it emergedNatural language became the only interface to this new class of model. There was no compiler, no schema, no fine-tuning step available to most users β€” precision had to live in the wording itself.
Impact on AI / agent evolutionProved in-context instruction could substitute for fine-tuning in many cases, making LLMs usable off-the-shelf. Its single-turn scope hit a ceiling the moment tasks needed more than one step, which is what pushed the field toward harness and loop engineering.

Prompt engineering is the second-oldest discipline here and the most misunderstood, mostly because it’s been declared dead more times than any term should survive.

Understanding Prompt Engineering, Step by Step

Step 1: Grasp the core insight

Natural language became an interface you could program against. Precision in English β€” specifying format, constraints, examples, and reasoning steps β€” started producing the same kind of leverage that precision in syntax used to produce in a compiled language. That insight, popularized in the early LLM era, still holds.

Step 2: Understand what changed since then

What’s changed is scope, not validity. Prompt engineering optimizes a single turn: the wording, structure, and examples inside one call to one model. That’s genuinely useful and still underrated β€” most quality gaps in production AI trace back to underspecified instructions, not model limitations.

Step 3: See where the ceiling is

A single well-crafted prompt was never going to be sufficient to run a multi-step, tool-using, long-horizon agent. Trying to make it do that job is exactly what pushed the field toward the next layer up β€” harness engineering.

Step 4: Learn what separates a good prompt from a mediocre one

The patterns haven’t changed much:

  • Be explicit rather than implicit
  • Show the model what “good” looks like rather than describing it abstractly
  • Ask for reasoning before the final answer on non-trivial tasks
  • Specify structure (format, length, tags) instead of hoping the model infers it

Step 5: Recognize the anti-pattern

Treating prompt engineering as the whole job β€” polishing the wording of an instruction while the actual failure lives in the missing tool, the absent memory, or the nonexistent stopping condition. That gap is precisely what the next discipline exists to close.

Core Patterns

Explicit Specification

  • Clear instructions: State exactly what you want, not what you don’t want
  • Format constraints: Specify output structure (JSON, CSV, markdown, XML)
  • Length limits: Set explicit word or character counts
  • Role definition: Tell the model what persona to adopt
  • Scope boundaries: Define what’s in-scope and out-of-scope

In-Context Learning

  • Few-shot examples: Provide 3-5 examples of input-output pairs
  • Chain-of-thought: Ask the model to show reasoning before answering
  • Step-by-step decomposition: Break complex tasks into sequential steps
  • Contrastive examples: Show both good and bad outputs
  • Negative constraints: Explicitly list what to avoid

Structural Prompting

  • Section-based prompts: Separate instructions, examples, and input
  • Delimiters: Use clear markers (###, —, XML tags) to separate sections
  • Template patterns: Use fill-in-the-blank structures for consistency
  • Hierarchical prompting: Break complex tasks into sub-prompts
  • Variable substitution: Use placeholders for dynamic content

Anti-Patterns

Prompt Engineering Anti-Patterns
Vague instructions: “Make it better” vs. “Improve clarity by shortening sentences”
Implicit assumptions: Assuming the model knows your domain context
Over-prompting: Writing 2000-word prompts when 200 words would suffice
Inconsistent examples: Mixing different formats or styles in examples
No format specification: Leaving output structure ambiguous
Ignoring reasoning: Skipping chain-of-thought for complex problems
Prompt as control: Using stronger wording instead of programmatic constraints

Advanced Techniques

Chain-of-Thought Prompting

For complex reasoning tasks:

  • Explicit reasoning: “Think step by step before answering”
  • Decomposition: Break problems into sub-problems
  • Self-consistency: Generate multiple reasoning paths and vote
  • Tree-of-thoughts: Explore multiple reasoning branches
  • Annotated reasoning: Ask the model to explain each step

Few-Shot Learning Strategies

Effective example selection:

  • Representative diversity: Cover edge cases and typical scenarios
  • Clear patterns: Make the input-output relationship obvious
  • Consistent formatting: Keep examples uniform in structure
  • Progressive complexity: Start simple, add complexity gradually
  • Negative examples: Show what shouldn’t be done

Format Control

Enforcing output structure:

  • JSON schema: Specify exact JSON structure required
  • XML tags: Use XML-like delimiters for structured data
  • Markdown templates: Provide fill-in-the-blank templates
  • Code blocks: Use ```language for code outputs
  • Field validation: Specify constraints per field (type, length, regex)

Evaluation and Iteration

Quality Metrics

  • Task completion: Does the output satisfy the requirements?
  • Format adherence: Does it match the specified structure?
  • Consistency: Are similar inputs handled consistently?
  • Reasoning quality: Is the logic sound and traceable?
  • Edge case handling: How does it perform on unusual inputs?

A/B Testing

  • Prompt variants: Test different phrasings and structures
  • Example selection: Compare different few-shot examples
  • Instruction clarity: Vary explicit vs. implicit instructions
  • Format specifications: Test different output formats
  • Temperature sensitivity: Check robustness across temperatures

Common Failure Modes

  • Instruction following: Model ignores explicit constraints
  • Format breaking: Output doesn’t match required structure
  • Reasoning shortcuts: Model skips requested chain-of-thought
  • Context window overflow: Prompt too long for the model
  • Example bias: Model overfits to provided examples

Best Practices

Prompt Structure

[Role/Context]
You are a [specific role] with expertise in [domain].

[Task Description]
Your task is to [clearly stated objective].

[Constraints]
- Constraint 1
- Constraint 2
- Constraint 3

[Examples]
Example 1:
Input: [example input]
Output: [example output]

Example 2:
Input: [example input]
Output: [example output]

[Input]
[Actual input to process]

Iterative Refinement

  1. Start simple: Begin with basic instructions
  2. Add examples: Include 2-3 representative examples
  3. Specify format: Define output structure explicitly
  4. Test edge cases: Validate on unusual inputs
  5. Add constraints: Incorporate negative constraints
  6. Iterate based on failures: Address specific failure modes

When to Move Beyond Prompt Engineering

Prompt engineering hits limits when:

  • Multi-step workflows: Tasks requiring sequential decisions
  • Tool integration: Need to call external APIs or databases
  • State persistence: Need memory across interactions
  • Complex logic: Require programmatic control flow
  • High reliability: Need deterministic, auditable outputs

This is precisely where harness engineering takes over β€” treating the prompt as one component in a larger system rather than the entire solution.

Key Takeaway

Prompt engineering remains foundational β€” it’s the syntax of natural language programming. But like any programming language, it’s just one layer in the stack. The mastery comes from knowing when a well-crafted prompt is sufficient, and when you need to build a harness around it.

Interactive Tools

Practical tools to help you think systematically, build better AI agents, and master prompt engineering.

Software Engineering Playbooks

Practical, End-to-End implementation guides for building Production-ready Software. Each playbook includes working code, architecture diagrams, and step-by-step instructions.

πŸ€–

Research Agent with Gateway

Build a production-ready AI research agent using Agent Gateway for unified traffic management, authentication, and observability across LLM providers.

Agent Gateway A2A Protocol Multi-Agent
πŸ”—

RAG Pipeline with Vector Database

Implement a complete Retrieval-Augmented Generation pipeline with vector embeddings, semantic search, and context injection for accurate AI responses.

RAG Vector DB Embeddings
πŸ”„

Multi-Agent Orchestration

Create a coordinated multi-agent system with specialized agents, task distribution, and result synthesis for complex problem-solving.

Orchestration Task Distribution Synthesis
1 / 2

Future References

Explore these resources for deeper learning on AI agent development, spec-driven development, and prompt engineering tools.

Spec-Driven Development

Comprehensive guide on Spec-Driven Development practices and methodologies.

Awesome Copilot

Curated list of GitHub Copilot resources, extensions, and best practices.

Promptfoo

Tool for testing, evaluating, and improving LLM prompts and applications.

Prompts.chat

Collection of prompt engineering resources and templates.

Agent Skills

Agent skills resources and documentation for building AI agent skills.

Awesome Skills

Curated list of awesome skill repositories and collections.

Agent Skills Topic

GitHub topic for discovering agent-related skills and repositories.

AI Agent Topic

Trendshift topic for discovering AI agents.

AI Skills Topic

Trendshift topic for discovering AI skills.

Agent Governance Toolkit

Agent governance toolkit.

Pattern Sources

Our patterns are curated from industry-leading sources with proper attribution and licensing compliance.

Refactoring.Guru

Classic GoF design patterns, code smells catalog, and refactoring techniques (https://refactoring.guru).

Enterprise Integration Patterns

65 messaging patterns for integrating enterprise applications by Gregor Hohpe and Bobby Woolf (CC BY 4.0).

Microservices.io

Comprehensive patterns for microservice architectures by Chris Richardson.

Agent Catalog Patterns

Patterns for agentic systems from agentpatternscatalog.org (CC BY 4.0).

OWASP Foundation

Security patterns from OWASP Top 10 for Web Applications, LLM Applications, and Agentic Applications (CC BY-SA 4.0).

Industry Research

ML/AI patterns from Microsoft, Google, Anthropic, and academic research.

AI Agent Patterns

Spec-driven development patterns from Claude, Gemini, OpenAI, and GitHub Copilot on github/spec-kit and OpenSpec.

Data Engineering Leaders

Data platform patterns from Martin Fowler (Data Mesh), Kimball Group (Dimensional Modeling), and cloud providers.

MLOps Best Practices

Data science patterns from MLflow, Great Expectations, and MLOps practitioners.

Streaming & Analytics

Real-time patterns from Confluent/Kafka, Apache projects, and serverless analytics platforms.

Academic Papers

Rigorous ML patterns from peer-reviewed research including data leakage prevention and active learning.

5-Day AI Agents Course

Intensive Vibe Coding Course With Google by Brenda Flynn et al. (2026) on Kaggle.

The Agent Loop

Foundational Agent Definition (Perceive + Act):
Russell, S. J., & Norvig, P. (1995). Artificial Intelligence: A Modern Approach. Prentice Hall. (Current edition: 4th Ed., Pearson, 2020)

Modern Iterative LLM Agent Loop:
Yao, S., Zhao, J., Yu, D., et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629.

Historical Context:
Incorporating AIMA's perceive/act model, Classical robotics' Sense-Plan-Act loop (Brooks, 1986), and ReAct's Thought→Action→Observation cycle.