Communicating effectively with large language models (LLMs) requires more than just asking questions. The way you phrase your requests significantly impacts the quality and usefulness of the responses you receive.
What Makes a Good Prompt
A good prompt clearly states what you want, provides enough context for the model to understand your intent, and sets appropriate boundaries. The three key elements are:
- Clarity: State the task directly without ambiguity
- Context: Provide necessary background information or examples
- Constraints: Specify format, length, tone, or other boundaries
When any of these elements is missing, the model must guess at your intent, and different runs can produce wildly different outputs. A vague prompt like "Tell me about AI" leaves too many degrees of freedom—does the user want a history, a technical explanation, business applications, or ethical considerations? A clearer version would be "Explain the transformer architecture used in modern LLMs, focusing on the attention mechanism, in about 300 words for a technical audience."
Structuring Your Prompts
Effective prompts follow a consistent structure. Start with a role or persona if it helps set expectations, then state your task, provide context or examples, and specify the desired output format. For example:
You are a helpful assistant. Write a 150-word summary of climate change impacts for high school students. Use bullet points and keep it simple.
This structure tells the model exactly what to do, who it's for, and how to format the response. The role ("helpful assistant") sets a cooperative tone. The task ("write a 150-word summary") is specific and measurable. The context ("climate change impacts for high school students") defines the audience and scope. The format instruction ("use bullet points and keep it simple") constrains the output structure.
I've found that explicitly delimiting context from instructions helps the model parse what's what. Using clear separators like "Context:" and "Task:" or code fences for source material makes a noticeable difference in consistency.
Zero-Shot, Few-Shot, and Chain-of-Thought
Different prompting techniques suit different tasks. Zero-shot prompting asks the model to perform a task with no examples—it works well for general knowledge, creative writing, and open-ended summarization. For instance, "Write a haiku about debugging code" needs no examples; the model knows what a haiku is and what debugging means.
Few-shot prompting provides examples within the prompt. Use it when you need the model to match a specific format, tone, or classification scheme. I recently needed to convert informal customer feedback into structured categories. Rather than describing the categories, I showed the model three examples:
Feedback: "The app crashes when I upload photos" Category: Bug Report
Feedback: "I wish there was a dark mode" Category: Feature Request
Feedback: "Your support team was really helpful" Category: Positive Feedback
Feedback: "The search function is slow and misses results" Category:
The model correctly output "Bug Report" for the last example. The tradeoff is a longer prompt, which consumes more context and may increase latency, but for structured tasks it's often worth it.
Chain-of-thought prompting asks the model to "think step by step" before giving a final answer. This is particularly useful for math word problems, logical reasoning, and multi-step analysis. The model produces its reasoning as text, which you can inspect for errors before accepting the conclusion. For example, instead of asking "What's 15% of 240?" you might ask "Calculate 15% of 240 step by step." The model will show the intermediate steps (10% is 24, 5% is 12, sum is 36), making it easier to verify.
Common Mistakes to Avoid
Being Too Vague
The most common mistake is under-specifying the task. "Tell me about AI" produces a generic overview. "Explain how attention mechanisms work in transformer models, with a focus on multi-head attention, in 400 words for a machine learning practitioner" produces a targeted, useful response. Always ask yourself: would a human colleague understand exactly what I want from this prompt?
Overloading with Information
While context is necessary, too much context dilutes the signal. I once pasted an entire 50-page technical specification into a prompt and asked for a summary. The model missed key details because the relevant information was buried. Instead, extract the relevant sections or provide a focused summary yourself, then ask the model to refine or reformat it.
Not Specifying Format
Always indicate if you want bullet points, paragraphs, code, JSON, a table, or any other specific structure. The model defaults to conversational prose unless told otherwise. I've learned to be explicit: "Return a JSON object with keys 'summary', 'key_points', and 'action_items'" rather than "Give me a structured response."
Ignoring Constraints
Specify word limits, required elements, tone, audience, and what to exclude. Constraints act as guardrails that make outputs more predictable across repeated attempts. For recurring tasks, I create prompt templates with all constraints filled in, then only change the variable parts.
Example: From Weak to Strong
Let's walk through a real example from my work. I needed a product description for a new feature.
Weak prompt: "Write a product description for our new dashboard feature."
Problems: No length, no audience, no key features to highlight, no tone guidance, no call to action.
Strong prompt: "Write a 200-word product description for the 'Insights Dashboard' feature in our analytics platform. Target audience: marketing managers at mid-size companies. Key features to highlight: real-time data visualization, customizable widgets, and automated weekly reports. Tone: professional and confident. Include a clear call to action to start a free trial. Format as two paragraphs followed by three bullet points for the key features."
The strong version specifies every decision the model would otherwise have to guess at. The first attempt with the strong prompt produced usable copy that needed only minor edits.
Iterative Refinement
Prompt engineering is iterative. Your first prompt rarely produces perfect output. Treat it as a starting point, then refine based on what the model produces. If the response is too verbose, add "Be concise" or specify a word count. If the tone is wrong, add "Use a more formal tone" or "Write as if explaining to a colleague." If the format is off, provide an example of the exact structure you want.
I keep a library of prompt templates for recurring tasks—code review, content summarization, email drafting, data extraction. Each template has evolved through multiple iterations. When a new variation of a task comes up, I copy the closest template and adjust rather than starting from scratch.
Working with Code
For coding tasks, the prompt structure matters even more. Instead of "Fix this bug," provide:
- The relevant code (or a minimal reproducible example)
- The error message or unexpected behavior
- The expected behavior
- What you've already tried
- Any constraints (language version, framework, performance requirements)
Example:
The following Python function raises a TypeError when called with a list of strings. Fix the function so it handles both strings and lists of strings. Return only the corrected function, with a one-line comment explaining the change.
def process(items):
return items.upper()
Error: TypeError: 'list' object has no attribute 'upper'
Expected: process(["a", "b"]) returns ["A", "B"]
This gives the model everything it needs to produce a correct fix on the first try.
Limitations to Keep in Mind
Even the best prompt cannot overcome fundamental model limitations. LLMs do not know facts they were not trained on, cannot browse the internet unless given tools to do so, and may confidently state incorrect information. They also lack memory of past conversations unless the conversation history is included in each prompt.
Prompting is not programming. The same prompt can produce different outputs on different runs, especially with temperature settings above zero. For deterministic results, you need structured output formats, validation, and human review—not just better prompt wording.
Finally, prompts should never include secrets, passwords, or private data unless you understand how that data will be stored and used by the model provider. Treat prompts as potentially logged input.
Conclusion
Writing effective prompts is a skill that improves with practice. Start with clear, structured prompts, iterate based on the model's responses, and always verify the output before using it. The better your prompt, the more reliable and useful the LLM's response will be. Keep a prompt library for recurring tasks, experiment with different techniques, and don't be afraid to over-specify—the model can always ignore constraints that don't apply, but it can't guess constraints you never stated.
This post complements our guide on Writing Effective Prompts for Large Language Models.