How to Write Better AI Prompts: 30 Examples You Can Copy

Most bad AI output starts with a bad prompt. A vague request forces the model to guess your goal, format, audience, and constraints. It fills the gaps with the most statistically average answer. This guide gives you a repeatable framework, 30 tested prompt templates, and working API code so you can get precise, usable output on the first try.

Quick Takeaways

  • Structure beats cleverness. A prompt with role, context, task, format, and constraints outperforms a short “smart” prompt almost every time.
  • Examples steer output better than adjectives. Two few-shot examples lock in tone and format more reliably than a paragraph of style instructions.
  • Lower temperature for facts, raise it for ideas. Use temperature 0 to 0.3 for extraction and code. Use 0.7 to 1.0 for brainstorming.
  • Iterate in small steps. Change one variable per revision so you know what moved the result.
Technique Best For Effort Typical Gain
Role + context Tone and domain accuracy Low High
Few-shot examples Format consistency Medium Very high
Chain-of-thought Math, logic, multi-step tasks Low High
Structured output (JSON/XML) Pipelines and automation Medium Very high
Self-critique loop Quality control on drafts Medium Medium

Why Most Prompts Fail

A language model predicts the next token based on everything in its context window. Your prompt is the only steering signal. When it is thin, the model defaults to generic patterns from its training data.

Three failure modes cause most weak output:

  1. Missing context. The model does not know your audience, goal, or constraints.
  2. Ambiguous task scope. “Write about marketing” has thousands of valid interpretations.
  3. Unspecified output format. Without a format, you get a wall of prose when you wanted a table.

Fix these three and your results improve immediately.

The RCTFC Prompt Framework

Use five components in this order. Skip any that are irrelevant, but check each one every time.

Component Question It Answers Example
Role Who is the model acting as? “You are a senior data analyst.”
Context What is the situation? “We sell B2B SaaS to logistics firms.”
Task What exactly must it do? “Summarize churn drivers from this survey.”
Format How should the output look? “A table with three columns.”
Constraints What are the limits? “Under 200 words. No jargon.”

Template

You are [ROLE].

Context: [BACKGROUND, AUDIENCE, GOAL]

Task: [SPECIFIC ACTION]

Format: [STRUCTURE, LENGTH, STYLE]

Constraints: [WHAT TO AVOID, HARD LIMITS]

Before and After

Weak prompt:

Write a product description for headphones.

Strong prompt:

You are a senior e-commerce copywriter.

Context: Our noise-canceling headphones target remote workers. Key features: 40-hour battery, multipoint Bluetooth 5.3, 30 mm drivers.

Task: Write a product description.

Format: One 40-word hook paragraph, then 4 bullet points (max 12 words each).

Constraints: No superlatives like "best." Use second person. Avoid clichés.

The second version removes nearly every decision the model would otherwise guess at.

Core Techniques You Should Know

Zero-Shot vs. Few-Shot Prompting

Zero-shot gives the model a task with no examples. Few-shot adds 2 to 5 input-output pairs. Few-shot is the strongest lever for format and tone consistency.

Classify the sentiment as Positive, Negative, or Neutral.

Review: "Battery lasts all week."
Sentiment: Positive

Review: "Arrived broken."
Sentiment: Negative

Review: "It works as described."
Sentiment: Neutral

Review: "The screen is gorgeous but the app crashes constantly."
Sentiment:

Chain-of-Thought (CoT)

Ask the model to reason before answering. This improves accuracy on arithmetic, logic, and planning tasks.

Solve this step by step. Show your reasoning, then give the final answer on its own line prefixed with "Answer:".

Note that modern reasoning models (such as OpenAI’s o-series and Claude with extended thinking) reason internally. For those, a simple direct prompt often works better than forcing explicit steps.

Prompt Chaining

Break one large task into sequential prompts. Feed the output of step one into step two. This improves reliability and makes debugging easy.

  1. Extract key facts from a document.
  2. Organize facts into an outline.
  3. Draft each section from the outline.
  4. Run a final edit pass.

Structured Output

Request JSON or XML when output feeds code. Claude handles XML tags especially well for separating instructions from data.

Extract the data below. Return only valid JSON matching this schema:
{"name": string, "company": string, "intent": "buy" | "browse" | "support"}

<email>
{{EMAIL_TEXT}}
</email>

Key Parameters That Change Output

Parameter Typical Range Use Low When Use High When
temperature 0.0 to 1.0 (some APIs to 2.0) Extraction, code, classification Brainstorming, creative writing
top_p 0.1 to 1.0 You need deterministic output You want varied phrasing
max_tokens 1 to model limit You need short answers You need long-form output
stop sequences Custom strings You must cut off at a marker Not needed

Adjust temperature or top_p, not both at once. Changing both makes results hard to attribute.

Implementation: Calling an LLM With a Structured Prompt

Install the SDK:

pip install anthropic

Run a framework-based prompt:

import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from env

system_prompt = (
    "You are a senior B2B copywriter. "
    "Write in plain US English. No clichés."
)

user_prompt = """Context: We sell invoice automation software to accounting firms.

Task: Write 3 email subject lines for a cold outreach campaign.

Format: Numbered list. Each under 55 characters.

Constraints: No emojis. No exclamation marks."""

response = client.messages.create(
    model="claude-sonnet-4-6",   # swap for your preferred model
    max_tokens=500,
    temperature=0.7,              # moderate creativity
    system=system_prompt,
    messages=[{"role": "user", "content": user_prompt}],
)

print(response.content[0].text)

The equivalent call with OpenAI:

from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4o",
    temperature=0.7,
    max_tokens=500,
    messages=[
        {"role": "system", "content": "You are a senior B2B copywriter."},
        {"role": "user", "content": "Write 3 cold email subject lines under 55 characters."},
    ],
)

print(response.choices[0].message.content)

Model Comparison for Prompting

Model Family Access Prompting Strength Watch Out For
Claude (Anthropic) Closed, API Follows long instructions; strong with XML tags Verbose by default; set length limits
GPT (OpenAI) Closed, API Strong tool use and JSON mode Can over-explain without format limits
Gemini (Google) Closed, API Very long context window; multimodal Test format adherence on complex schemas
Llama (Meta) Open weights Self-hostable; fine-tunable Needs clearer, more explicit prompts at smaller sizes

Pricing and limits change often. Check each provider’s current pricing page before budgeting.

30 Copy-Paste Prompt Examples

Replace anything in [BRACKETS] with your own details.

Writing and Editing (1 to 6)

1. Rewrite for clarity

Rewrite the text below for a general audience at an 8th-grade reading level. Keep the meaning. Cut length by 30%.

[TEXT]

2. Tone shift

Rewrite this email to sound warm but professional. Keep it under 120 words. Preserve all dates and numbers.

[EMAIL]

3. Blog outline

You are an SEO editor. Create a blog outline for the keyword "[KEYWORD]". Include H2s and H3s, a suggested word count per section, and 4 FAQ questions.

4. Headline generator

Write 10 headline options for an article about [TOPIC]. Mix formats: how-to, list, question, contrarian. Keep each under 65 characters.

5. Line edit

Edit the draft below. Remove filler words, passive voice, and repeated ideas. Return the edited text, then a bullet list of the 5 most important changes you made.

[DRAFT]

6. Style matching

Here are two samples of my writing:

<sample1>[SAMPLE 1]</sample1>
<sample2>[SAMPLE 2]</sample2>

Describe my style in 5 bullet points. Then write a 150-word post about [TOPIC] in that style.

Research and Analysis (7 to 12)

7. Summarize a document

Summarize the document below in 5 bullet points for a busy executive. Then list 3 open questions the document does not answer.

<document>
[TEXT]
</document>

8. Compare options

Compare [OPTION A], [OPTION B], and [OPTION C] for [USE CASE]. Output a Markdown table with rows for cost, setup time, scalability, and main risk. End with one recommendation and your reasoning.

9. Devil’s advocate

Here is my plan: [PLAN]. Argue against it. List the 5 strongest objections ranked by severity, and suggest a mitigation for each.

10. Data interpretation

You are a data analyst. Review the dataset below. Identify the 3 most important trends, any outliers, and one limitation of this data.

[PASTED DATA]

11. Explain like a mentor

Explain [CONCEPT] to someone with [BACKGROUND]. Use one analogy and one concrete example. Then ask me 2 questions to check my understanding.

12. Source-grounded answer

Answer using only the text provided. If the answer is not in the text, say "Not found in the source." Quote the supporting sentence.

<source>[TEXT]</source>
Question: [QUESTION]

Coding and Technical Work (13 to 18)

13. Code review

You are a senior [LANGUAGE] engineer. Review this code for bugs, security issues, and performance problems. Return findings as a table: Severity | Line | Issue | Fix.

[CODE]

14. Write a function

Write a [LANGUAGE] function that [BEHAVIOR]. Include type hints, a docstring, input validation, and 3 unit tests. Do not use external libraries.

15. Debug with context

This code throws the error below. Explain the root cause first. Then give the minimal fix.

Code: [CODE]
Error: [ERROR MESSAGE]
Environment: [LANGUAGE/VERSION/OS]

16. Refactor

Refactor the code below for readability. Keep behavior identical. List each change and why you made it.

[CODE]

17. SQL generation

Given this schema:
[SCHEMA]

Write a PostgreSQL query that returns [GOAL]. Explain the query in 3 sentences. Flag any performance concerns.

18. Regex helper

Write a regex that matches [PATTERN]. Give 5 strings it should match and 5 it should reject. Explain each part of the pattern.

Business and Marketing (19 to 24)

19. Customer persona

Create a customer persona for [PRODUCT]. Include role, goals, top 3 pain points, objections to buying, and where they get information.

20. Landing page copy

You are a conversion copywriter. Write landing page copy for [PRODUCT]. Include a headline, subheadline, 3 benefit blocks, and a CTA. Audience: [AUDIENCE]. Tone: [TONE].

21. Cold email

Write a cold email to [ROLE] at [COMPANY TYPE]. Open with a specific observation, state one clear benefit, and end with a low-friction question. Max 90 words.

22. Meeting notes to actions

Convert these notes into: (1) a 3-sentence summary, (2) a decisions list, (3) an action-item table with Owner | Task | Deadline.

[NOTES]

23. SWOT analysis

Run a SWOT analysis for [BUSINESS/IDEA] in [MARKET]. Give 4 items per quadrant. Mark the single most important item in each quadrant with **bold**.

24. Social post variants

Turn this article into 5 LinkedIn posts, each with a different hook: stat, question, story, contrarian take, and checklist. Keep each under 150 words.

[ARTICLE]

Learning and Productivity (25 to 28)

25. Study plan

Create a [NUMBER]-week study plan to learn [SKILL]. I have [HOURS] hours per week and a [LEVEL] background. Include weekly goals, resources, and one practice project.

26. Quiz generator

Create 8 multiple-choice questions on [TOPIC] with 4 options each. Mix easy, medium, and hard. Provide an answer key with one-sentence explanations.

27. Decision matrix

Help me choose between [OPTIONS]. Ask me up to 5 clarifying questions first, one at a time. Then build a weighted decision matrix based on my answers.

28. Priority sorting

Here is my task list: [TASKS]. Sort them using the Eisenhower matrix. Then suggest a schedule for the next 3 days, with a maximum of 4 hours of focused work per day.

Advanced Prompt Engineering (29 to 30)

29. Self-critique loop

Step 1: Draft an answer to the question below.
Step 2: Critique your draft. List 3 weaknesses.
Step 3: Write a final improved version that fixes those weaknesses.
Show all three steps.

Question: [QUESTION]

30. Meta-prompt (prompt improver)

You are a prompt engineer. Improve the prompt below using the Role, Context, Task, Format, Constraints framework. Return the improved prompt in a code block, then explain your 3 biggest changes.

Prompt: [YOUR PROMPT]

Real-World Workflows

Workflow 1: Content Team Pipeline

A marketing team chains four prompts to produce a publishable article.

  1. Research prompt (temperature 0.2): extract facts and statistics from provided sources only.
  2. Outline prompt (temperature 0.5): build an H2/H3 structure around a target keyword.
  3. Draft prompt (temperature 0.7): write each section with style samples attached.
  4. Edit prompt (temperature 0.2): cut filler and check claims against the source list.

Separating steps keeps each output focused and easy to audit.

Workflow 2: Reducing Hallucinations With Grounded Prompts

Enterprises reduce fabricated answers by grounding the model in retrieved documents. This is the core of Retrieval-Augmented Generation (RAG).

Use only the context below to answer. If the context does not contain the answer, reply "I don't have enough information."

<context>
{{RETRIEVED_CHUNKS}}
</context>

Question: {{USER_QUESTION}}

Typical RAG settings: chunk size 500 to 1,000 tokens, 10 to 20% overlap, and temperature 0 to 0.2 for factual answers.

Workflow 3: Customer Support Triage

A support team classifies incoming tickets and drafts replies.

Classify this ticket as Billing, Technical, or Account. Rate urgency 1 to 5. Draft a reply under 80 words that matches our tone: friendly, direct, no apologies for things we didn't cause.

Ticket: {{TICKET_TEXT}}

Return JSON so your helpdesk software can route the ticket automatically.

Common Prompting Mistakes and Fixes

Mistake Why It Fails Fix
“Make it better” No success criteria Define what “better” means: shorter, clearer, more formal
Stacking 10 tasks in one prompt Model drops or blends tasks Use prompt chaining
Telling the model what not to do only Negative instructions are weaker State the desired behavior directly
No examples for format-sensitive tasks Output varies run to run Add 2 to 3 few-shot examples
Trusting facts without sources Models can hallucinate Provide source text or verify independently
Changing many variables at once You cannot tell what worked Edit one element per iteration

A Simple Testing Loop

Treat prompts like code. Version them and test them.

  1. Write a baseline prompt.
  2. Run it on 5 to 10 varied inputs.
  3. Score outputs against a short rubric (accuracy, format, tone).
  4. Change one element.
  5. Re-run and compare.

Keep a log of prompt versions and scores. After a few cycles, you will see which components drive quality for your use case.

Frequently Asked Questions

What makes a good AI prompt?

A good prompt states the role, context, task, format, and constraints clearly. It gives the model enough background to avoid guessing and defines what a successful output looks like. Examples of the desired output improve results further.

How long should an AI prompt be?

Length matters less than completeness. A prompt can be one sentence for a simple task or several hundred words for a complex one. Include every detail the model needs, and remove anything that does not change the output.

Do the same prompts work on ChatGPT, Claude, and Gemini?

Mostly yes. The core framework transfers across models. Small adjustments help: Claude responds well to XML-tag structure, GPT models handle JSON mode and function calling well, and Gemini handles very long inputs. Always test on your target model.

What is the difference between zero-shot and few-shot prompting?

Zero-shot prompting gives the model a task with no examples. Few-shot prompting includes a small number of input-output examples. Few-shot prompts produce more consistent formats and tones, especially for classification and structured output.

Hot this week

AI Predictions for 2027: What Experts Expect

AI predictions for 2027 from Gartner, the AI Futures Project, and EU regulators: agents, AGI timelines, compute, and compliance dates. Get the forecast.

AI in 2026: The Moments That Defined the Year

Every moment that defined AI in 2026: Mythos, the Fable shutdown, the OpenAI agent breach, GPT-6 and open-weight China. Read the timeline.

Deepfakes: How They Work, How to Spot Them, and How to Protect Yourself

Learn how deepfakes work, the telltale signs of AI-generated fakes, and the detection tools that help you stay protected. Read the full guide now.

AI Glossary: 70 Terms From Agents to Zero-Shot, Explained Simply

Learn 70 AI terms from agents to zero-shot, with plain-English definitions, tables, and code. Bookmark this glossary and level up today.

Embeddings Explained: How AI Turns Words, Images, and Anything Into Numbers

Learn how embeddings work, compare top models by dimensions and cost, and build semantic search in Python. Get the full technical guide today.

Topics

AI Predictions for 2027: What Experts Expect

AI predictions for 2027 from Gartner, the AI Futures Project, and EU regulators: agents, AGI timelines, compute, and compliance dates. Get the forecast.

AI in 2026: The Moments That Defined the Year

Every moment that defined AI in 2026: Mythos, the Fable shutdown, the OpenAI agent breach, GPT-6 and open-weight China. Read the timeline.

Deepfakes: How They Work, How to Spot Them, and How to Protect Yourself

Learn how deepfakes work, the telltale signs of AI-generated fakes, and the detection tools that help you stay protected. Read the full guide now.

AI Glossary: 70 Terms From Agents to Zero-Shot, Explained Simply

Learn 70 AI terms from agents to zero-shot, with plain-English definitions, tables, and code. Bookmark this glossary and level up today.

Embeddings Explained: How AI Turns Words, Images, and Anything Into Numbers

Learn how embeddings work, compare top models by dimensions and cost, and build semantic search in Python. Get the full technical guide today.

Why LLMs Hallucinate (and What Actually Reduces It)

Why do LLMs hallucinate? Learn the root causes, see benchmark data, and copy working RAG, prompting, and decoding fixes. Read the full guide.

Context Engineering Explained: Going Beyond Prompt Engineering

Learn context engineering: the discipline of curating tokens, memory, and tools for LLMs. Includes code, benchmarks, and a prompt-vs-context table. Start building.

Prompt Engineering in 2026: 12 Techniques That Actually Work

Master prompt engineering in 2026 with 12 tested techniques, API code, and ready-to-use templates for Claude, GPT, and Llama. Start improving outputs today.

Related Articles

Popular Categories