Skip to content
FUNDAMENTALS·2026·GUIDE

Prompt Engineering Examples 2026: 12 Copy-Paste Templates for Real Developer Use Cases

Featured image

Most prompt engineering examples on the internet demonstrate technique on toy problems — “summarise this article,” “write a poem in the style of X,” “explain photosynthesis to a five-year-old.” Those examples teach structure but do not help you ship.

The 12 prompt engineering examples below are organised by what you are actually building: code review automation, incident reporting, user story conversion, data extraction, system prompts for Lovable, and AI agent scaffolding. Every example follows the same four-part structure — role, task, constraints, output format — because that structure is what separates a prompt that works once from a prompt that works reliably.

These are the best prompt engineering templates for 2026 for working engineers. Copy the one closest to your use case, swap in your context, and test it on real inputs before treating it as production-ready. For the techniques behind these examples, see the Prompt Engineering Guide. For how to document and version the prompts you adopt, see the Prompt Documentation Template.


Each example uses the same four-field structure. Understanding what each field does prevents the most common adaptation mistake — changing the task and forgetting to update the constraints.

Role sets the model’s behaviour, vocabulary, and level of technical depth. “You are a senior backend engineer” produces different output than “You are a helpful assistant” even for identical tasks. Make the role as specific as your actual use case allows.

Task is stated in one to three bullet points. Bullet points here are intentional — they force you to separate distinct actions rather than running them together in a paragraph, which reduces the model’s likelihood of skipping one.

Constraints are the boundaries. These are the most important field and the most commonly omitted. A constraint like “do not suggest refactors outside the scope of the reviewed function” is worth more than any amount of positive instruction — it prevents the model from doing something plausible but wrong.

Output format pins the return shape. Specify JSON, Markdown, plain prose, or a structured list explicitly. Without this field, the model’s output structure varies between runs in ways that break downstream parsing.

These four fields together form a complete prompt contract. Effective prompting at production scale means treating this contract as the stable interface, not the suggestion.


Use this when you want structured, actionable code review feedback rather than free-form commentary. The constraints prevent the model from rewriting the entire function when you only asked it to review it.

You are a senior software engineer conducting a code review.
Task:
- Review the function provided for correctness, readability, and edge case handling.
- Identify any bugs, security issues, or performance concerns.
- Suggest specific improvements with code snippets where relevant.
Constraints:
- Limit feedback to the function provided — do not suggest refactors to calling code.
- Flag security issues separately from style issues.
- Do not rewrite the entire function unless a rewrite is strictly necessary.
- Maximum 5 feedback items. Prioritise by severity.
Output format:
Return a Markdown list with this structure for each item:
**[Severity: Critical | High | Medium | Low]** — [Issue description]
Suggested fix: [code snippet or prose]
Function to review:
{{paste function here}}

Use this after an outage or production incident. The structured output means the report is ready to paste into your incident management system without reformatting.

You are an SRE writing a post-incident report for an engineering team.
Task:
- Write a concise post-incident report based on the incident details provided.
- Cover timeline, root cause, impact, and follow-up actions.
- Keep the tone factual and blameless.
Constraints:
- Do not speculate about root cause beyond what the data supports — mark unknowns as "under investigation."
- Timeline entries must include timestamps.
- Follow-up actions must be assigned to a role, not a named individual.
- Maximum 400 words for the full report body.
Output format:
Return valid Markdown with these headings:
## Summary
## Timeline
## Root cause
## Impact
## Follow-up actions
Incident details:
{{paste your incident notes, logs, or Slack thread summary here}}

Use this to generate consistent, conventional commit messages from a diff or a description of changes. Consistent commit messages make changelogs and git bisect significantly more useful.

You are a software engineer writing commit messages following the Conventional Commits specification.
Task:
- Generate a commit message for the change described or shown below.
- Choose the correct type: feat, fix, docs, style, refactor, test, chore.
- Write a subject line and, if the change is non-trivial, a body paragraph.
Constraints:
- Subject line must be 72 characters or fewer.
- Subject line must be in imperative mood ("add feature" not "added feature").
- Do not include "this commit" in the message.
- If the change has a breaking change, add BREAKING CHANGE in the footer.
Output format:
Return only the commit message text, no preamble or explanation.
Change description or diff:
{{paste diff or describe the change here}}

Use this when onboarding new engineers to a codebase, or when a complex query needs documentation for a non-technical stakeholder.

You are a senior data engineer explaining SQL queries to a mid-level software engineer.
Task:
- Explain what the SQL query below does in plain English.
- Identify any performance concerns or anti-patterns.
- Suggest one improvement if a clear one exists.
Constraints:
- Assume the reader understands basic SQL but not advanced window functions or CTEs.
- Do not rewrite the query unless asked.
- Keep the explanation under 200 words.
Output format:
Return three sections: What it does, Potential issues, Suggested improvement (or "None identified").
Query:
{{paste SQL query here}}

Use this to convert raw product requirements into well-formed user stories. The few-shot structure in the constraints means you get consistent formatting without having to specify every detail.

You are a product engineer converting raw requirements into user stories.
Task:
- Convert the requirement below into one or more user stories.
- Follow the "As a [user], I want [goal] so that [reason]" format.
- Add acceptance criteria as a bulleted list under each story.
Constraints:
- One user story per distinct user goal — do not bundle multiple goals into one story.
- Acceptance criteria must be testable — no vague terms like "works correctly" or "is fast."
- Maximum 3 acceptance criteria per story.
- Do not add technical implementation detail to the story itself.
Output format:
Return Markdown. Each story as a heading, acceptance criteria as a bulleted list beneath it.
Requirement:
{{paste raw requirement here}}

Use this to generate a concise executive summary of a PRD section for a stakeholder who will not read the full document. The constraint on fabrication is critical — the model must not invent details not present in the source.

You are a technical writer summarising product requirements for a non-technical executive audience.
Task:
- Summarise the PRD section provided into a concise executive summary.
- Highlight the business problem, the proposed solution, and the success metric.
- Flag any assumptions or open questions that require a decision.
Constraints:
- Do not introduce information not present in the source document.
- Do not use technical jargon — write for a reader who does not know what an API is.
- Maximum 150 words for the summary body.
- List open questions separately, not embedded in the summary.
Output format:
Return Markdown with sections: Summary (150w max), Open questions (bulleted list).
PRD section:
{{paste PRD section here}}

Use this to extract structured fields from unstructured text — support tickets, emails, form submissions, or any free-form input that needs to be parsed into a database.

You are a data engineer extracting structured information from unstructured text.
Task:
- Extract the specified fields from the text provided.
- If a field is not present in the text, return null for that field.
- Do not infer or guess values not explicitly stated in the source text.
Constraints:
- Return only valid JSON — no comments, no markdown fences, no preamble.
- If the text is ambiguous for a field, return null rather than guessing.
- Dates must be in ISO 8601 format (YYYY-MM-DD).
Output format:
Return ONLY valid JSON with this schema:
{
"name": string | null,
"email": string | null,
"issue_type": string | null,
"priority": "low" | "medium" | "high" | null,
"reported_date": string | null,
"description": string | null
}
Source text:
{{paste unstructured text here}}

Use this to classify incoming user messages, support tickets, or queries into a fixed set of categories. The explicit “unknown” category is essential — without it, the model will force every input into one of the defined categories even when it does not fit.

You are a classification model categorising customer support tickets.
Task:
- Classify the support ticket below into exactly one of the defined categories.
- Return your confidence level.
- If the ticket does not fit any category, classify it as "unknown."
Constraints:
- Return only the classification — no explanation unless confidence is below 0.7.
- If confidence is below 0.7, add a one-sentence explanation of the ambiguity.
- Never force a ticket into a category it does not clearly match.
Categories:
- billing: questions about charges, invoices, or payment methods
- technical: bugs, errors, or product not working as expected
- account: login issues, password resets, account settings
- feature_request: suggestions for new functionality
- unknown: does not clearly fit any of the above
Output format:
Return JSON: { "category": string, "confidence": float, "note": string | null }
Ticket:
{{paste support ticket here}}

System prompts are the stable contract that governs an AI assistant’s behaviour across all conversations. They are the highest-leverage prompt in any application — a well-written system prompt eliminates entire categories of failure.

Lovable is a full-stack AI app builder. Its system prompt context is different from a general LLM chat — you are defining the behaviour of an AI assistant embedded in a specific product workflow, with access to code generation and component editing tools.

You are an expert full-stack developer embedded in Lovable, helping users build React applications with Supabase backends.
Your role:
- Help users describe, design, and build features in plain English.
- Generate clean, production-grade React and TypeScript code.
- Integrate Supabase auth, database, and storage correctly.
- Explain what you are building before you build it.
Constraints:
- Always use TypeScript, not JavaScript.
- Use Tailwind CSS for all styling — no inline styles.
- Use Supabase client v2 patterns — not v1.
- Never generate placeholder data for authenticated routes — use real Supabase queries.
- If a request is ambiguous, ask one clarifying question before proceeding.
- Do not generate code that exposes the Supabase service role key client-side.
Behaviour:
- Start every response by restating what you understood the user to want in one sentence.
- If a request would require breaking an existing component, say so before doing it.
- Prefer editing existing components over creating new ones unless a new component is clearly the right approach.

Use this as the system prompt for an AI agent that has access to tools or APIs. The explicit forbidden section is the most important part — it prevents the agent from taking irreversible actions without confirmation.

You are an AI assistant embedded in an internal engineering tool with access to the following tools: [list your tools here].
Your role:
- Help engineers complete tasks using the tools available to you.
- Prefer accuracy and correctness over speed.
- Ask for clarification when a request is ambiguous before taking any action.
Process for every request:
1. Restate what you understood the user to want in one sentence.
2. List the tools you plan to use and the order you will use them.
3. Confirm with the user before taking any irreversible action.
4. Execute the plan and report the result.
5. Ask if the result meets the user's need before closing the task.
Constraints:
- Never take an action that cannot be undone without explicit user confirmation.
- Never access data outside the scope of the current task.
- If a tool returns an error, report it immediately — do not retry silently.
- Do not fabricate tool output if a tool call fails.
Forbidden actions (require explicit confirmation every time):
- Deleting any resource
- Sending any message or notification to an external system
- Modifying production data
- Creating or revoking API keys or credentials

Every example above will fail on some inputs. Knowing the common failure modes before you hit them in production saves significant debugging time.

The instruction-following floor. Smaller models — particularly quantised Llama variants under 13B — follow multi-constraint prompts less reliably than GPT-4 or Claude. If you are running these examples on a smaller model and seeing constraint violations, the fix is not to add more constraints. It is to reduce the number of constraints per prompt and split complex tasks into two sequential prompts.

Few-shot drift. The examples in the code review and user story prompts work because the output format is pinned. If you add examples of your own and those examples vary in structure, the model will average across them rather than following the most recent one. Keep your few-shot examples structurally identical — same fields, same order, same format every time.

The null problem in extraction. The JSON data extractor above instructs the model to return null for missing fields. In practice, some models will omit the field entirely rather than returning null, which is structurally different and will break a parser that expects the key to be present. Add a validation step that checks for key presence, not just value presence.

Context length and the system prompt. The AI agent system prompt above is long. In long conversations, models deprioritise the system prompt as the context window fills up. If you are using the agent pattern in a multi-turn application, repeat the critical constraints — especially the forbidden actions list — in a compressed form in the user prompt every few turns.


A prompt engineering pattern is a reusable structure that solves a specific category of problem. The examples above use these four patterns consistently — recognising them means you can adapt any example to a new use case without starting from scratch.

The extraction pattern — role + schema + “return only JSON, no preamble.” Use when you need structured data from unstructured input. The JSON data extractor and intent classifier above both use this pattern.

The classification pattern — role + categories list + “never force a match.” Use when you need to sort inputs into a fixed set of buckets. Always include an “unknown” or “other” category. The intent classifier above is the reference implementation.

The transformation pattern — role + input format + output format + constraints. Use when you are converting one form of content into another — requirements to user stories, raw notes to incident reports, diffs to commit messages. The user story converter and commit message generator use this pattern.

The review pattern — role + scope constraint + severity ranking + format. Use when you want structured feedback rather than free-form commentary. The scope constraint (“limit feedback to the function provided”) is the most important element — without it, the model reviews things you did not ask it to review.

These four patterns cover the majority of developer use cases. For a deeper treatment of the techniques behind them, see the Prompt Engineering Guide.


What are the best prompt engineering examples for developers in 2026?

Section titled “What are the best prompt engineering examples for developers in 2026?”

The most useful prompt engineering examples for developers are task-specific and include all four structural elements: role, task, constraints, and output format. The highest-value categories are code review (structured feedback with severity ranking), data extraction (JSON schema with null handling), intent classification (fixed categories with an “unknown” fallback), user story conversion (requirement to acceptance criteria), and system prompts for AI-assisted tools. Every example in this guide includes constraints — the most commonly omitted element — because constraints are what prevent a prompt from producing plausible but wrong output.

What is the difference between a prompt template and a prompt example?

Section titled “What is the difference between a prompt template and a prompt example?”

A prompt template is a reusable structure with placeholders — {{paste your code here}}, {{describe the change}}. A prompt example is a template with those placeholders filled in with real content, showing what a complete prompt looks like in practice. This guide provides templates with placeholders because the placeholders are where your context goes. Copy the template, replace the placeholders with your actual input, and test the result on five to ten real inputs before treating it as reliable.

What prompt design techniques produce the most consistent output?

Section titled “What prompt design techniques produce the most consistent output?”

The four prompt design techniques that most reliably improve consistency are: pinning the output format explicitly (JSON schema, Markdown heading structure, or plain text with length constraints), adding a scope constraint that defines what the model should not do, using role + task + constraints as the base structure rather than free-form instructions, and including an explicit handling rule for edge cases (“if the field is not present, return null”). Consistency problems that persist after applying these techniques are usually model-specific and are solved by testing on the target model rather than adjusting the prompt structure.

How do I adapt these examples for GPT-4, Claude, and Llama?

Section titled “How do I adapt these examples for GPT-4, Claude, and Llama?”

The structure works across all three, but each model has specific behaviours to account for. GPT-4 follows long constraint lists reliably and handles JSON output well with minimal prompting. Claude follows system prompts with high fidelity and is the most reliable for multi-constraint tasks in long conversations. Llama models under 13B parameters frequently omit fields in structured output and are prone to prepending explanatory text before JSON — add “Return only the JSON. No explanation before or after.” explicitly for Llama targets. For ai prompt engineering techniques 2026 that are model-specific, the Anthropic and OpenAI official documentation remains the most accurate source for each model’s specific behaviours.

A Lovable system prompt is the system-level instruction set that governs an AI assistant built within the Lovable platform — a full-stack app builder that generates React and Supabase code. Unlike a general-purpose system prompt, a Lovable system prompt needs to specify the exact technology stack (TypeScript, Tailwind, Supabase v2), the behaviour contract for ambiguous requests, and constraints around code that would expose sensitive credentials client-side. The example in this guide is a starting point — adapt the technology constraints to match your specific Lovable project stack.

How many examples should I include in a few-shot prompt?

Section titled “How many examples should I include in a few-shot prompt?”

Two to three examples is the practical optimum for most tasks. One example is often insufficient — the model may treat it as the only valid pattern rather than a general template. More than three examples adds token overhead without meaningfully improving consistency, and in some tasks it causes the model to average across the examples rather than follow the most relevant one. The exception is classification tasks, where five to seven examples (one to two per category) improves accuracy on edge cases. All examples must come from real production inputs — synthetic examples consistently fail to capture the variance of real data.