How to Write Effective Prompts for ChatGPT and Claude

If you've ever felt like an AI model is giving you generic, unhelpful responses, the problem is almost always in how you're framing the request — not in the model itself. Prompt engineering isn't magic. It's a practical skill that improves with technique and concrete examples.

This guide covers the techniques that work in real workflows, with side-by-side comparisons of what produces good results and what doesn't.

What a Prompt Is and Why Structure Matters

A prompt is the instruction you give the model. LLMs like ChatGPT (GPT-4o) and Claude process your input and generate a response based on patterns from their training. The quality of that output depends directly on how much useful information you pack into the input.

Think of it this way: asking a model to "write me an email" is like asking a designer to "make something nice." The result could be anything. The more context you provide, the more predictable and useful the output becomes.

The Base Structure of a Good Prompt

Every effective prompt has at least three components:

  • Role or context: who the model is in this task
  • Concrete task: exactly what it needs to do
  • Output format: how you want the response structured

Without structure:

Write me an email about the project delay.

With structure:

Act as a project manager experienced in client communication.
Write a professional email informing a client that the project
is delayed by 2 weeks due to unforeseen external dependencies.
Tone: direct but reassuring. Length: 150 words max. No bullet points.

The difference in output quality is immediate and consistent.

Technique 1: Role Prompting

Assigning a role to the model orients its perspective when generating a response. It doesn't make the model become a different person — it activates more relevant patterns for that context.

Examples that work well:

  • You are a senior Python developer with 10 years of experience. Review this code and identify performance bottlenecks.
  • Act as a B2B SaaS copywriter. Write a value proposition for a workflow automation tool.
  • You are a financial analyst. Explain this accounting concept as if speaking to someone with no finance background.

The role is more effective when it's specific. "You are an expert" is vague. "You are a backend developer specializing in REST APIs with experience in high-availability systems" is useful.

Technique 2: Few-Shot Prompting

Instead of describing what you want, you show examples of the expected output. Models learn the pattern from your examples and replicate it.

Suppose you want the model to generate titles in a specific style:

Generate 5 blog post titles about AI automation.
Follow the style of these examples:

- "How I Automated My Inbox: Processing 200 Emails a Day with n8n"
- "The Workflow That Saves Me 3 Hours a Week (And How to Copy It)"
- "Why I Stopped Copying Data Manually and What I Use Instead"

Topic for new titles: extracting data from PDFs with AI.

This works better than describing the style in abstract terms because the model directly infers tone, length, and structure from the examples.

Technique 3: Chain of Thought

For complex problems, asking the model to reason step by step significantly improves accuracy. This is especially useful for analysis, debugging, and math.

Without chain of thought:

What is the time complexity of this algorithm?
[code]

With chain of thought:

Analyze the time complexity of this algorithm.
First, identify the loops and their stopping conditions.
Then determine how each one scales with input size.
Finally, give the resulting complexity in Big O notation.
[code]

The second prompt produces more accurate analysis because it forces the model to structure its reasoning before reaching a conclusion.

Technique 4: Using Delimiters

When a prompt mixes instructions with content to process, models can sometimes confuse which part is the task and which is the input. Delimiters prevent this.

Common ways to delimit:

Summarize the following text delimited by triple dashes:
---
[text to summarize]
---

Or using XML tags, which works especially well with Claude:

Review the following code and identify any bugs:

<code>
def calculate_average(items):
    return sum(items) / len(items)
</code>

Respond in this format: Issue found / Suggested fix.

Technique 5: Specifying Output Format

If you don't say how you want the result, the model decides. Sometimes it chooses well, sometimes it doesn't. Specifying the format saves you revision cycles.

Useful formats by use case:

  • Numbered lists: for steps or rankings
  • JSON: for processing output with code
  • Markdown with headers: for documentation
  • Table: for comparisons
  • Plain paragraphs, no bullets: for content you'll publish directly

Example for getting JSON output:

Extract the data from the following text and return it as JSON
with this structure: {"name": "", "company": "", "role": "", "email": ""}
Return only the JSON, no additional text.

[text]

Common Mistakes That Reduce Quality

Being too vague: "Write something about Python" could produce anything from a short story to technical documentation.

Asking for too much in one prompt: models like GPT-4o and Claude handle complex tasks well, but breaking a large task into steps produces better results than asking for everything at once.

Not saying what you don't want: specifying exclusions is just as useful as inclusions. "No introduction, no conclusion, no bullet points" prevents the model from padding responses with filler.

Assuming the model remembers: in each new conversation, the model has no memory of previous context. Include everything it needs to know directly in the prompt.

Differences Between ChatGPT and Claude for Prompting

Both models respond well to the techniques above, but with some nuances:

ChatGPT (GPT-4o) tends to be more concise by default and responds well to direct instructions. If you want longer responses, you need to ask explicitly. It handles multimodal inputs natively — you can include images directly in the prompt.

Claude (Anthropic) tends to generate more detailed responses and is particularly good at following complex formatting instructions. It responds very well to XML delimiters in prompts. You can find Claude's own prompt engineering documentation with techniques specific to its architecture.

Neither is universally better — it depends on the task. For code generation and short responses, GPT-4o is often more efficient. For long-form writing or tasks requiring precise format output, Claude tends to produce more consistent results.

A Reusable Prompt Template

This structure works for most professional tasks:

[ROLE]: Act as [role description].
[CONTEXT]: [Relevant background information for the task].
[TASK]: [Concrete description of what the model should do].
[CONSTRAINTS]: [What it should not do or limits to respect].
[FORMAT]: [How it should structure the response].

Not every field is always necessary, but keeping this template as a reference prevents the most common mistakes.

Next Steps

The techniques covered here — role prompting, few-shot examples, chain of thought, delimiters, and explicit format — cover 80% of everyday use cases. The best way to internalize them is to apply them to tasks you're already doing with AI and compare results.

If you work with code, the next level is exploring how to use these techniques directly in API calls, where you have full control over the prompt and results are more reproducible. OpenAI's prompt engineering guide and Anthropic's documentation are both worth reading as complementary references.