How to Write Better Prompts for Claude and ChatGPT: 5 Rules That Actually Work (2026)
To write better prompts for Claude and ChatGPT, follow 5 rules: assign a role, give context before the task, add 1-3 examples, specify the exact output format, and add constraints for what to exclude. These five changes, applied consistently, improve AI output quality by 30–50% — verified across Anthropic's and OpenAI's own internal benchmarks.
Most people use AI the same way they use a search engine: type a question, hope for a good answer. That approach gets mediocre results. The founders and developers getting the best outputs treat prompts like instructions to a very literal, very capable new hire — someone who does exactly what you say, but only what you say.
Here's the complete playbook.
Why Your Prompts Are Getting Weak Results
Before the five rules, understand why prompts fail. The core problem is ambiguity. Claude and ChatGPT are extremely capable at following instructions, but they cannot read your mind. When a prompt is vague, the model fills the gaps with its own best guess — and that guess is often generic.
Consider the difference:
Weak prompt: "Write a LinkedIn post about AI."
Strong prompt: "You are a senior product manager at a B2B SaaS company. Write a LinkedIn post about how your team cut customer support ticket volume by 40% using an AI chatbot. Tone: first-person, honest, slightly vulnerable about the initial scepticism. Length: 150-180 words. Do not use hashtags. End with a question to drive comments."
The second prompt is 5x longer. It's also 10x more likely to produce something you'd actually post.
The prompt engineering market reached $1.13 billion in 2025 and is projected to hit $1.52 billion in 2026 — that commercial growth reflects exactly how much output quality differences matter to real businesses.
Rule 1: Assign a Role First (Role Prompting)
What it is: Tell the AI who it is before you tell it what to do.
Role assignment activates the right vocabulary, domain knowledge, and reasoning style. Claude and ChatGPT are both trained on vast corpora — a well-defined role narrows which part of that training gets foregrounded for your task.
Why it works: When you write "Act as a senior Flutter developer," you get Flutter-specific terminology, error-handling conventions, and performance considerations that a generic coding prompt won't surface. Role priming is one of the six techniques confirmed to work reliably in 2026 across both ChatGPT and Claude.
Role prompt templates
For technical tasks:
You are a senior backend engineer with 10 years of Node.js experience specialising in high-throughput REST APIs. You write clean, well-commented TypeScript and always consider security implications.
For content tasks:
You are a conversion copywriter who specialises in B2B SaaS landing pages. You write clear, benefit-first copy that avoids jargon. Your style is direct and confident — no fluff, no clichés.
For analysis tasks:
You are a financial analyst at a growth-stage startup. You present numbers plainly, call out risks directly, and never hide bad news in vague language.
Claude vs ChatGPT: role prompting differences
For Claude: put the role in a <role> tag at the very start of your prompt. Claude treats the first block of a prompt as the highest-priority instruction.
<role>
You are a senior product designer who specialises in mobile app UX for fintech applications. You think in user flows, not features.
</role>For ChatGPT: put the role in the system message if you're using the API, or in the first line of your prompt in ChatGPT.com. Plain English works well here — no special syntax needed.
Rule 2: Give Context Before the Task
What it is: Provide relevant background before stating what you want. AI models perform dramatically better when they understand the situation, not just the instruction.
Think of it like briefing a consultant. You wouldn't say "write a proposal" without explaining what the project is, who the client is, and what outcome you're trying to achieve. The same applies to AI.
What good context includes
- Who the audience is — their knowledge level, role, and what they care about
- What already exists — if you're improving or continuing something, paste it in
- What the final output is used for — a draft for human review vs a final deliverable require different levels of polish
- Constraints you're working within — brand guidelines, technical limitations, word counts, budget ranges
Example: weak vs strong context
Without context:
"Write onboarding email copy for our app."
With context:
"We're a fintech startup building a savings app for first-time investors in the UK, aged 25–40. We've just launched and are sending the welcome email to users who signed up yesterday. The tone is friendly and encouraging — our brand voice is like a knowledgeable friend, not a corporate bank. The email should explain the three things they can do in the app this week. They're likely slightly overwhelmed by their first investment product."
The context-rich version gives the model everything it needs to make judgment calls the same way a skilled human would.
Claude's context window advantage
Claude supports a 200K+ token context window — roughly 150,000 words. This means you can paste entire codebases, full research papers, multi-document histories, or 300-page reports directly into the prompt. Use this. The more relevant context you provide, the more accurate Claude's outputs become. ChatGPT's context window is smaller (128K tokens on GPT-4o), but the principle is the same: more context = less hallucination.
Rule 3: Add 1-3 Examples (Few-Shot Prompting)
What it is: Include examples of what "good" looks like inside your prompt. This is called few-shot prompting — and it is one of the highest-ROI prompt improvements you can make.
The data:
- Few-shot prompts outperform zero-shot (no examples) by 25–40% in accuracy across standard benchmarks
- One example alone improves output consistency by 20%
- Chain-of-thought few-shot examples (showing reasoning, not just answers) boost accuracy further — GSM8K math benchmark scores jump from 17.7% to 40.7% with CoT examples
Zero-shot vs few-shot: real comparison
Zero-shot (no example):
Write a subject line for a cold email to a startup CTO about our API monitoring tool.
Result: Generic. Something like "Improve Your API Performance" — could be from anyone.
Few-shot (with 2 examples):
Write a subject line for a cold email to a startup CTO about our API monitoring tool.
Here are 2 examples of subject lines that have worked for us:
- "We caught 3 API failures before your users did last Tuesday"
- "Your checkout API returned 503s 14 times this week"
These work because they're specific, reference real data, and create mild urgency without hype. Write 5 more in this style.
Result: Specific, data-driven, pattern-matched to what you know works.
How to structure few-shot examples for Claude
Use <examples> tags:
<examples>
<example>
<input>Product: AI writing tool. Audience: freelance copywriters. Tone: confident peer, not salesy.</input>
<output>Stop rewriting the same brief three times. One prompt, one draft, five minutes. Your client doesn't know the difference — but your calendar does.</output>
</example>
<example>
<input>Product: Project management app. Audience: agency owners. Tone: direct, ROI-focused.</input>
<output>Every hour your team spends updating status docs is an hour not billed. We fixed that.</output>
</example>
</examples>
Now write similar copy for: Product: AI expense tracking for startups. Audience: seed-stage founders. Tone: friendly, time-focused.When not to use few-shot examples
For reasoning models (Claude Opus 4.8, OpenAI o3) — models that do internal step-by-step thinking — heavy few-shot examples can reduce performance. These models reason before they answer. Adding multiple examples can constrain their reasoning path unnecessarily. For reasoning models, a single clear goal usually outperforms an examples-heavy prompt.
Rule 4: Specify the Exact Output Format
What it is: Tell the AI exactly how you want the answer structured. Don't leave format open to interpretation.
This is the rule most people skip — and it's the one that causes the most frustration. If you don't specify format, you get the model's default: usually a wall of prose or a generic bulleted list, regardless of whether that's useful for your use case.
Output format options to specify
| Format | When to use | Example instruction |
|---|---|---|
| Bullet list | Quick reference, checklists | "Return as a bulleted list with max 10 items" |
| Numbered steps | Processes, tutorials | "Format as numbered steps, one action per step" |
| Table | Comparisons, data | "Return a markdown table with columns: Feature / Claude / ChatGPT" |
| JSON | API integration, structured data | "Return valid JSON only. Schema: name (string), score (number), reason (string)" |
| Short paragraphs | Human-readable copy | "3 paragraphs max, 60-80 words each" |
| Code blocks | Technical outputs | "Return code only in a Python code block. No explanation unless I ask" |
| Headline + body | Marketing copy | "Format: [Headline]\n[2-3 sentence body]\n[CTA]" |
The <output_format> tag for Claude
Claude follows explicit format instructions with exceptional reliability. Use this structure:
<output_format>
Return a JSON array. Each object must have exactly these fields:
- "keyword": string (the keyword phrase)
- "intent": string (one of: "informational", "navigational", "commercial", "transactional")
- "difficulty": number (1-10)
- "monthly_volume_estimate": string (e.g. "2K-5K")
Return only the JSON array. No preamble, no explanation.
</output_format>ChatGPT output format tip
For ChatGPT, plain language format instructions work well. Add them at the end of your prompt:
"Format your response as: Problem | Root Cause | Fix | Prevention. Use that exact structure for each issue. No intro paragraph."
Rule 5: Add Constraints — Tell It What NOT to Do
What it is: Explicitly state what to avoid. Constraints are as important as instructions.
This is counterintuitive. Most people write prompts as a list of what they want. The best prompts also include a short list of what they don't want — because AI models fill every gap with their own defaults, and those defaults are often wrong for your specific situation.
Common constraints to add
- Tone constraints: "Do not use corporate jargon. Do not write in passive voice. Do not use the word 'leverage'."
- Length constraints: "Maximum 150 words. Do not pad with filler sentences."
- Format constraints: "Do not add an intro paragraph. Do not summarise at the end."
- Content constraints: "Do not include pricing speculation. Do not reference competitors by name."
- Accuracy constraints: "If you are not certain of a fact, say so rather than guessing."
The hallucination constraint
One of the most valuable constraints for factual tasks:
If you don't know something with confidence, write "I'm not certain about this — you should verify."
Do not invent statistics, citations, or named examples. Flag any claim that needs verification.
This single constraint dramatically reduces hallucinations in research and writing tasks. Claude, in particular, responds well to explicit permission to say "I don't know" — without it, models tend to fill knowledge gaps confidently and incorrectly.
Claude <constraints> tag example
<constraints>
- Do not use bullet points. Write in short, direct paragraphs only.
- Do not start any sentence with "I" or "We".
- Avoid the words: leverage, synergy, cutting-edge, game-changer, innovative.
- Maximum 200 words total.
- Do not end with a call to action or summary sentence.
</constraints>Full Prompt Template: Put All 5 Rules Together
Here is a production-ready prompt template that combines all five rules. Copy this, fill in the brackets, and use it as your baseline for any complex task.
For Claude (XML structure):
<role>
[Who Claude is — seniority, specialisation, perspective]
</role>
<context>
[Background: what the project is, who the audience is, what constraints exist, what already exists]
</context>
<task>
[Single, clear statement of exactly what you want Claude to do]
</task>
<examples>
<example>
<input>[Sample input]</input>
<output>[What a good output looks like]</output>
</example>
</examples>
<output_format>
[Exact structure: format type, fields, length, any schema]
</output_format>
<constraints>
- [Thing to avoid 1]
- [Thing to avoid 2]
- [Thing to avoid 3]
</constraints>For ChatGPT (plain text structure):
Role: [Who you are — e.g. "You are a senior UX researcher with 8 years in B2B SaaS"]
Context: [Background information — who the audience is, what already exists, relevant constraints]
Task: [What you want, stated once, clearly]
Example of good output:
Input: [sample]
Output: [what good looks like]
Format: [Exact output structure — e.g. "Return 3 options, each with: Headline | Body (50 words max) | CTA"]
Avoid: [List of things not to do]
Claude vs ChatGPT: Key Prompt Differences
Understanding how these two models differ saves hours of trial and error.
| Factor | Claude (Anthropic) | ChatGPT (OpenAI) |
|---|---|---|
| Best structure | XML tags (<task>, <context>) | Plain English or markdown |
| Instruction following | Very literal — says what you said, no more | More flexible — infers intent |
| Context window | 200K+ tokens (Claude Sonnet/Opus) | 128K tokens (GPT-4o) |
| Long prompt behaviour | Follows all constraints even in long prompts | May drop constraints after ~8K tokens |
| Reasoning models | Claude Opus 4.8 — omit CoT instructions | o3/o4 — keep prompts short |
| Few-shot examples | Use <examples> XML tags | Use labelled sections or newlines |
| Hallucination control | Add explicit "say I don't know" instruction | Add "do not speculate" instruction |
| Best for | Long-form analysis, complex documents, code review | Creative tasks, conversation, iterative brainstorming |
3 Prompt Engineering Mistakes to Stop Making in 2026
1. Writing "think step by step" for reasoning models
This was the best trick in 2023. It backfires on Claude Opus 4.8 and OpenAI o3/o4 — these models reason internally before responding. Adding explicit chain-of-thought instructions constrains their internal reasoning and degrades output quality. Use it only with standard chat models (GPT-4o, Claude Sonnet).
2. Longer is always better
OpenAI's current best practice guide explicitly recommends shorter, outcome-focused prompts. The goal is minimum necessary structure for maximum reliable output. Extra context that isn't directly relevant dilutes the signal. If you're adding 500 words of background and only 50 words of task instruction, something is wrong.
3. Using the same prompt for every model
Claude and ChatGPT are different products with different strengths. Claude is more literal and rewards XML structure. ChatGPT is more flexible and rewards clear system messages and conversational framing. A prompt that works brilliantly in Claude may produce mediocre results in ChatGPT and vice versa. Test both; optimise for each.
Quick Reference: The 5 Rules
| Rule | Claude syntax | ChatGPT syntax | Impact |
|---|---|---|---|
| Role assignment | <role>You are a...</role> | "You are a [role]..." | Vocabulary, tone, domain accuracy |
| Context | <context>Background...</context> | "Context: ..." | Reduces irrelevant answers |
| Few-shot examples | <examples><example>...</example></examples> | "Example:\nInput: ...\nOutput: ..." | +25–40% accuracy vs zero-shot |
| Output format | <output_format>Return JSON...</output_format> | "Format: ..." at end | Removes formatting guesswork |
| Constraints | <constraints>- Do not...</constraints> | "Avoid: ..." | Cuts hallucinations, eliminates defaults |
Putting It Into Practice
The gap between average AI output and exceptional AI output isn't the model — it's the prompt. GPT-4o and Claude Sonnet are capable of producing expert-level writing, code, analysis, and strategy. Most users never see it because they're querying these systems like a search engine.
These five rules — role, context, examples, format, constraints — are not advanced techniques. They're the baseline for professional AI use in 2026. Apply them to your next prompt and compare the result to what you were getting before.
If you're building a product, internal tool, or AI integration and need help engineering prompts at scale — or want to explore what a custom AI agent could do for your business — book a free discovery call with the CodeXcelerate team. We build AI workflows, agents, and integrations for startups in the US, UK, Australia, New Zealand, Ireland, Singapore, UAE and beyond.
