How to Write AI Prompts

Wikis.ai

Learn how to structure AI prompts with clear instructions, useful context, constraints, and examples. Find out how to refine a prompt when the response misses the mark.

Overview

An AI prompt is the input that tells a generative model what task to perform and what information to use. To write a good AI prompt, state the task directly, supply the context the model needs, define what a successful answer should look like, and then review and refine the result. Examples and structured formatting can help when a task has a specific style or output pattern, but no template guarantees correctness. Prompting works best as a short cycle of instruction, review and adjustment—not as a search for magic words. How do I create a good prompt for an AI model? | OpenAI Help Center, Prompting best practices - Claude Platform Docs and Overview of prompting strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation share these practical themes.

What an AI prompt does

A prompt can contain a question, command, context, examples, source material, or a combination of these. In a chat interface, it may be a single message or a sequence of follow-up messages. In an application, prompts can also include system-level instructions, retrieved documents, images, audio or other inputs supported by the model. The model uses that supplied context to generate a response; it does not necessarily verify that the response is true.

Prompting became a prominent way to adapt general-purpose language models to specific tasks without retraining them. In a 2020 NeurIPS paper, researchers evaluated GPT-3 using zero-shot prompts (instructions without demonstrations), one-shot prompts (one example), and few-shot prompts (several examples). They found strong results on many language tasks but also reported areas where the model struggled and methodological concerns related to training data. Language Models are Few-Shot Learners. The field has since accumulated many techniques and inconsistent terminology; a 2024 survey catalogued 58 text-based LLM prompting techniques and 40 techniques for other modalities. The Prompt Report: A Systematic Survey of Prompting Techniques.

“Prompt engineering” usually refers to the practical design and refinement of those inputs. For everyday use, it does not require specialized syntax or programming. In application development, it can also include reusable templates, examples, retrieved context, evaluation tests and safeguards.

How to write an effective AI prompt

1. State the task as an action

Begin with a concrete verb: summarize, compare, extract, draft, classify, explain, translate or generate. Name the subject and intended result. “Help me with this report” leaves the model to guess what help means; “Summarize the report’s three main findings for a non-specialist in five bullet points” identifies a task, audience and format.

OpenAI recommends identifying the task, providing necessary context and specifying tone or style. Google’s documentation similarly advises describing the precise operation needed, especially when working with images or other media. A request to “describe this image” might produce a general description, whereas “read the departure times and destinations from this board and return them as a list” narrows the task. How do I create a good prompt for an AI model? | OpenAI Help Center; Design multimodal prompts | Gemini Enterprise Agent Platform | Google Cloud Documentation.

2. Add only the context that changes the answer

Supply relevant facts such as the audience, purpose, timeframe, jurisdiction, source material, existing work or constraints. If the answer must be based on a document, include or attach it and tell the model to use that material. For example: “Use only the policy excerpt below. If it does not answer a question, say that the excerpt does not specify.” Including reference material is especially useful when the task depends on information outside the model’s training data or on a particular source. Prompt engineering | OpenAI API.

For lengthy documents, identify what matters and what to extract; do not assume that adding more text automatically improves the result. Models have finite context limits, and the usable limits differ by model. If a task involves several distinct jobs—such as summarizing, translating and drafting a reply—split it into stages when one combined request makes the desired output unclear. OpenAI recommends right-sizing and prioritizing complex requests, while Google identifies overly bundled tasks and missing information as common design problems. How do I create a good prompt for an AI model? | OpenAI Help Center; Overview of prompting strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation.

3. Define the output and constraints

Specify the format and the properties that matter: length, audience, tone, sections, number of options, fields, units or level of detail. Prefer measurable directions to vague terms. “Use no more than 120 words” is clearer than “keep it short.” For machine-readable results, ask for a defined structure such as JSON or a table; if a particular schema is required, provide it or show the keys and value types.

Use constraints that are compatible with each other. A request for “a complete explanation in two sentences” may conflict unless the scope is narrow. If the task depends on facts that could be missing or uncertain, say how to handle that case—for instance, “mark missing values as ‘not provided’ rather than inferring them.” Google’s documentation specifically recommends explicit output formats, handling missing data and removing contradictory or redundant directions. Overview of prompting strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation.

4. Use examples when they communicate a pattern better than prose

A zero-shot prompt gives instructions without examples. A one-shot or few-shot prompt includes one or several sample input-and-output pairs. Examples can clarify a response format, classification boundary, tone or recurring transformation. Use examples that resemble the real task and include meaningful variation; a single misleading example can teach the wrong pattern. Anthropic recommends relevant, diverse and clearly separated examples, and OpenAI describes few-shot examples as a way to show a model the desired input-output pattern. Prompting best practices - Claude Platform Docs; Prompt engineering | OpenAI API.

Examples are optional. A simple, well-defined request may need none. For complex prompts, headings or clear delimiters can separate instructions, source text and examples. XML-style tags are one possible convention for applications, particularly when prompts mix long documents and different kinds of information; Markdown headings or quoted sections can work for ordinary tasks. Formatting is a clarity aid, not a guarantee that the model will follow every instruction.

5. Provide a role only when it adds useful context

A role can help describe the perspective or expertise expected—“Act as a copy editor for a general audience”—but it does not make the model an actual professional or remove its limits. The task, evidence and criteria still need to be explicit. A useful role describes how to approach the work; it should not replace the work instructions.

6. Make the request specific without overloading it

More words do not necessarily make a better prompt. Each additional instruction should resolve a real ambiguity, add necessary context or specify a requirement. Avoid contradictory directions, needless repetition, undefined jargon and artificial pressure such as threats or flattery. Google’s troubleshooting guidance identifies these as potential prompt defects and suggests removing irrelevant instructions and examples. Overview of prompting strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation.

A reusable prompt structure

This structure is a checklist rather than a formula. Omit parts that do not matter for the task.

text
Task: [What should the model do?]
Context: [Relevant background, audience, purpose, or source material]
Requirements: [Scope, constraints, and how to handle uncertainty or missing data]
Output: [Format, length, tone, and required fields]
Input: [Text, data, image, or other material to work on]

For example:

text
Task: Summarize the meeting notes below.
Context: The summary is for a project manager who did not attend.
Requirements: Include decisions, owners, deadlines, and unresolved questions. Do not infer an owner or deadline if none is stated.
Output: Use four headings and concise bullet points.
Input: [Paste meeting notes here]

The central idea is to tell the model what outcome is needed, what it should base the answer on, and how the answer will be judged. OpenAI, Anthropic and Google each recommend clarity, relevant context and explicit output preferences, while treating iteration and task-specific testing as part of prompt design. How do I create a good prompt for an AI model? | OpenAI Help Center; Prompting best practices - Claude Platform Docs; Prompt iteration strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation.

How to improve a prompt after the first response

Treat an unsatisfactory answer as evidence about what was unclear or missing. Identify the actual defect—wrong scope, unsupported claim, poor format, omitted detail or incorrect interpretation—and change the instruction that addresses it. Changing one important feature at a time makes it easier to see what helped. If the response missed the point, restate the task; if it used the wrong structure, give a concrete output format; if it guessed missing information, instruct it to report unknowns instead.

Rendered mermaid figure

Prompt iteration cycle. The steps reflect Google’s recommendation to refine prompts incrementally, observe which aspects of an output fit the use case, and test the revised prompt again. Prompt iteration strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation.

For repeated or business-critical tasks, define success before optimizing: for example, whether every required field is present, whether facts match a trusted source, or how often a classification agrees with a human-reviewed label set. Try the same prompt on representative normal cases and edge cases. In an application, record model/version and prompt changes so a change in output can be investigated. These are practical evaluation methods; there is no universal prompt-quality score or single best prompt across tasks and models.

Research supports testing rather than assuming that wording and layout never matter. An ICLR 2024 study found that subtle formatting choices could cause performance differences of up to 76 accuracy points for LLaMA-2-13B in the study’s few-shot benchmark settings. The authors also reported sensitivity across several open-source models. That result is evidence that prompt format can affect performance under tested conditions; it is not an estimate of the improvement an ordinary user should expect, nor a result for every current commercial model. Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting.

Prompt examples for common tasks

Writing and editing

Less specific: “Write a blog post about recycling.”

More specific: “Draft a 500-word introductory blog post for renters in apartment buildings about separating household recycling. Explain three common mistakes, use a practical and neutral tone, and do not invent local rules. End with a short checklist.”

The revised request names the audience, subject, scope, tone, length and factual boundary. For accuracy, provide the local recycling guidance or ask the model to identify which details need confirmation rather than presenting jurisdiction-specific rules as universal.

Summarization

text
Summarize the report below for a nontechnical reader in five bullet points.
Separate the report's findings from its recommendations. Include page or section references when available. If a detail is not in the report, do not infer it.

This establishes source, audience, format and a rule against filling gaps with guesses. For a consequential summary, compare the output with the source document.

Data extraction

text
From the text below, extract each invoice number, date, supplier, and total.
Return one JSON object per invoice using these keys: invoice_number, date, supplier, total.
Use null for a field that is absent. Do not calculate or infer missing values.

Specifying keys and the missing-value convention reduces ambiguity. If software will consume the output, validate that it actually parses and conforms to the needed schema; a natural-language instruction alone is not a technical guarantee.

Image or other multimodal input

Name the media and the operation: “Read the product names and prices from this menu image and return them as a two-column table. Mark text that cannot be read as unclear.” For audio, specify whether the task is transcription, speaker-separated transcription, a summary or extraction of particular facts. Google’s multimodal guidance notes that models can accept inputs such as text, images and video, but the available modalities and limits depend on the selected model. Design multimodal prompts | Gemini Enterprise Agent Platform | Google Cloud Documentation.

Common prompt-writing errors

ProblemWhy it causes troubleBetter approach
“Make it better”Leaves the goal and criteria unstatedSay what to improve and for whom
Missing contextThe model must guess background or audienceSupply the relevant information or source
Vague constraints“Short,” “detailed” or “professional” can mean different thingsUse a length, structure or concrete tone description
Too many jobs at onceSeveral distinct tasks may compete for attentionSplit the work into steps or label each deliverable
Conflicting instructionsThe model cannot satisfy incompatible requirementsResolve the conflict and prioritize requirements
Treating fluent text as verifiedConfidence and detail do not establish truthCheck claims against reliable sources

These failure patterns align with provider troubleshooting guidance, which highlights underspecified tasks, unclear formats, conflicting instructions, missing context and unnecessary complexity. Overview of prompting strategies | Gemini Enterprise Agent Platform | Google Cloud Documentation; How do I create a good prompt for an AI model? | OpenAI Help Center.

Limits and safe use

A prompt cannot guarantee factual accuracy

Language models can generate fluent but false statements, misread source material, invent citations or contradict information in the conversation. NIST calls confidently stated erroneous or false content “confabulation” and notes that it can occur across contexts, especially in open-ended, long-form or expert-domain tasks. Asking the model to say when it is uncertain or to cite supplied sources can make checking easier, but neither instruction proves an answer is true. Verify important facts, calculations and citations against authoritative sources; use qualified human review for consequential medical, legal, financial or safety decisions. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile.

Prompting is model- and task-dependent

The same prompt can produce different answers across model versions or runs, and a technique that helps one task may not help another. Current vendor documentation includes model-specific advice, so a template should be tested on the model and use case where it will be used. Even advice to request step-by-step reasoning is not universal: OpenAI notes that such instructions may not enhance performance for some reasoning models and may sometimes hinder it. For many tasks, ask for a concise explanation, evidence or a result check rather than requiring a particular hidden reasoning format. Prompting best practices - Claude Platform Docs; Reasoning best practices | OpenAI API.

Keep sensitive information and external actions in view

Do not paste personal, confidential or regulated information into a service unless its data handling terms and your organization’s policies permit it. A prompt is not a privacy control. In AI applications connected to documents or tools, external content can contain malicious instructions—known as prompt injection—that attempt to change the model’s behavior. OWASP advises that security cannot rely on prompt wording or labels alone: applications need controls such as limiting tool permissions, validating proposed actions and outputs, and requiring approval for high-risk operations. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile; LLM Prompt Injection Prevention - OWASP Cheat Sheet Series.

A practical checklist

Before sending a prompt, check that it:

  • names the task and intended result;
  • includes the context or source material needed to do the work;
  • identifies the audience and relevant constraints;
  • specifies a format when the shape of the output matters;
  • explains how to handle missing or uncertain information;
  • uses examples only when they clarify a pattern;
  • avoids contradictory, irrelevant or redundant instructions;
  • will be checked against suitable criteria, with greater verification for higher-stakes use.

To prompt AI effectively, describe the work as clearly as you would brief a capable colleague who lacks your background knowledge. Give it the information and criteria it needs, inspect what it returns, and refine the part that failed. Clear prompts improve direction; they do not replace verification or model and application safeguards.