Back to all articles
AI Engineering

We all know what prompt engineering is, but why "engineering" in the first place?

Prompt engineering is not merely about writing a good prompt; it is a process that relies on experimentation, system design, context management, and continuous testing and refi

By Mohamed AlawakeySeptember 9, 2026
An explanation of prompt engineering, communicating with LLMs, designing system prompts, and using RAG.

Everyone knows what Prompt Engineering is, but perhaps not everyone understands why it is actually called "Engineering."

First, Prompt Engineering is essentially the method of communication between us and the LLM to achieve the best possible results.

The "Engineering" aspect comes from several factors, such as:

Trial and Error

A key advantage of LLMs is the ability to restart and begin again from scratch—unlike humans. This allows us to test numerous solutions without previous attempts affecting the new ones. This capacity for experimentation and design lies at the very heart of engineering.

Systems Thinking

We don't just write a prompt and call it a day; we must consider how it integrates with our existing system. In a SaaS context, for instance, there are multiple approaches and prompts involved in managing the final configuration of a "Prompt Builder." This builder constructs the final system prompt. When a user interacts with the model within our system, their query is incorporated into this system prompt to create a complete prompt, which the LLM then processes to generate a response.

Model programming and systems design

It requires more than just writing prompts and integrating them into the system. Engineers must also consider data sources—leading us to techniques like RAG—and address critical challenges such as latency and the volume of data flowing into and out of the LLM.

Code discipline

Just as we use version control to track code, we should apply similar practices to prompts and their versions. Documenting observations and experiments for every prompt is crucial for quickly identifying issues and solutions. Furthermore, if a problem arises, we can easily revert to the best-performing prompt and resume from there.

So, how do you become a skilled Prompt Engineer? - Your writing for the LLM must be clear, effectively conveying the intended outcome. By the way, just because you are articulate doesn't mean the LLM will understand you better than anyone else; success depends on clarity and descriptive precision, not just general writing ability.

  • You need the patience and capacity for iteration, as you likely won't craft the perfect prompt on the very first try.
  • Anticipate worst-case and edge-case scenarios. For instance, if you ask the LLM to extract words starting with the letter "M" from the input, try sending it sentences that don't start with "M" to observe the output; this helps you identify and resolve potential issues.
  • Put yourself in the user's shoes to understand real-world behavior. Users rarely send perfectly formatted text to an LLM—often omitting punctuation—so you must account for this reality.
  • Approach this like a machine learning engineer. Before training a model, you carefully curate and validate the data to ensure it is accurate and high-quality; the same applies to prompt engineering. When evaluating the LLM's output—such as when a user asks it to "think step-by-step"—you must verify the result: Did it actually reason step-by-step correctly? Is the final answer accurate, and is the underlying logic and flow sound?

Theory of Mind

People think differently; a common mistake is assuming the LLM possesses the same knowledge you do. This is the "Curse of Knowledge" in action: you expect the LLM to respond exactly as your own mind envisions, even though you haven't actually provided it with the necessary source information. It doesn't rely solely on its internal data; if you want a response tailored to your specific needs, you need to provide your own sources. This is actually part of the RAG (Retrieval-Augmented Generation) approach, which addresses this very issue—a topic we’ll cover in detail here click here to go straight there.

Here are some very useful techniques to handle errors:

  • Ask the LLM to critique the prompt you created. Instead of having it generate an answer or result immediately, ask it to identify any ambiguous points or parts it doesn't understand.
  • Have the LLM learn from its mistakes. If the output contains an error, ask the model to modify the original prompt so it avoids that same issue in the future. Surprisingly, this often solves the problem.

So, should I trust the LLM's response?

Certainly not. You need to push it and test it thoroughly to ensure reliability, especially in "out-of-distribution" scenarios (situations outside its standard training data).

Different Approaches

Adopting a Persona

There are various schools of thought here. Some suggest assigning the LLM a role—like "Senior Software Engineer"—to guide its assistance. Others prefer communicating directly, given how advanced LLMs have become at understanding context. Personally, I prefer asking the model something like, "If you were a Senior Software Engineer, how would you handle this situation?" or "How would you go about identifying the problems here?" I have the LLM operate in a simulation mode—effectively adopting a persona, but doing so indirectly.

A Very Important Note:

  • Be aware of a very common mistake: forcing the LLM to make a choice. It is always better to instruct the LLM that if it encounters an unexpected situation or is uncertain, it should simply state that it is unsure. This preserves data quality and helps us identify issues—applying the principles we discussed earlier.
#Prompt Engineering#LLM#RAG (Retrieval Augmented Generation)#AI Engineering#Machine Learning#Systems Design

Written by

Mohamed Alawakey

ML & AI Engineer documenting practical decisions from building RAG, LLM, machine-learning, and FastAPI systems.

Let's connect
The main types of Machine Learning: Supervised, Unsupervised, and Reinforcement Learning
Machine LearningOctober 15, 2026

Types of Machine Learning

A simple guide to the main types of Machine Learning, including Supervised, Unsupervised, Reinforcement, Semi-Supervised, and Self-Supervised Learning, with their common algorithms and use cases.

Read article