WriteMyAIPromptFree, no sign-up

AI prompt for writing error messages

This is a ready-made AI prompt for writing error messages, written for Claude and free to copy. Error messages get written last, by whoever implemented the error path, in the voice of the system rather than the user. The result states what failed internally and not what the person should now do. The prompt below handles that: it is compiled as a coding task, so it carries the structure and the constraints that kind of work needs.

The prompt

Written for Claude. Compiled as a coding task — writing, reviewing, debugging, or refactoring software.

<role>
You are a senior software engineer who writes production-ready, tested code.
</role>

<context>
The error states: {{error_states}}. What the user was trying to do: {{user_goal}}. What they can actually do about each: {{remedies}}.
</context>

<task>
Write error messages for {{feature}}.
</task>

<constraints>
- Say what happened, then what to do about it. Never only the first.
- No error codes without an accompanying plain-English explanation.
- Never blame the user.
- If nothing can be done, say so and say who can help.
- Return complete, runnable code. No placeholder comments, no "// rest of implementation here", no omitted sections.
- Handle the error cases you can foresee, and state explicitly which ones you deliberately did not handle.
- If you are unsure whether an API, library version, or language feature exists, say so rather than guessing at a plausible-looking name.
</constraints>

<output_format>
Respond with a single fenced code block containing the complete implementation, then a short note covering anything the reader needs to know before running it.
</output_format>

<approach>
Work through the problem step by step before giving your answer. Show the reasoning that actually drives your conclusion rather than a tidy summary written after the fact.
</approach>

<success_criteria>
Before you finish, check the output against every item below and fix anything that fails.

- Every message tells the user their next action.
</success_criteria>

<before_you_start>
If anything above is unclear, or you are missing information you need, ask up to three specific clarifying questions before producing any output. Do not invent facts, names, numbers, sources, or quotations to fill a gap — if you do not know something, say so plainly.
</before_you_start>

Now, write error messages for {{feature}}.

Optional: start the reply with ``` to force the output straight into shape.

Open this in the prompt builder to add your own context and see what would improve it most.

What makes writing error messages hard to prompt for

Error messages get written last, by whoever implemented the error path, in the voice of the system rather than the user. The result states what failed internally and not what the person should now do.

Why this prompt works

Background comes before the instruction
The model reads the situation before it learns what to do with it, which stops the instruction being diluted by everything that follows. The task is then restated as the final line, where models weight it most heavily.
Rules a coding task assumes but nobody writes down
Return complete, runnable code. No placeholder comments, no "// rest of implementation here", no omitted sections. Handle the error cases you can foresee, and state explicitly which ones you deliberately did not handle. These are added automatically because leaving them implicit is the most common reason this kind of output disappoints.
Success criteria the model checks itself against
Stating how the output will be judged gives the model something concrete to verify before it finishes. Prompts without criteria produce work that is plausible but incomplete, because nothing defined when it was done.
Permission to ask instead of guess
This brief leaves room for interpretation, so the prompt tells the model to ask before inventing details. That converts a confidently wrong answer into a question you can actually answer.
A prefill that removes the preamble
Starting the reply with ````` forces the output straight into the required shape and removes the "Sure, here is..." opener entirely.

What to replace

PlaceholderWhat to put there
{{error_states}}Your error states.
{{user_goal}}Your user goal.
{{remedies}}Your remedies.
{{feature}}Your feature.

Check the output before you use it

  • For each message, name the user's next action. If there is none, the message is incomplete.
  • Remove anything that implies the user did something stupid.
  • Check no message shows a raw code or stack trace without explanation.

The same prompt for other models

Identical content, packaged the way each model reads most reliably.

ChatGPT

## Role

You are a senior software engineer who writes production-ready, tested code.

## Context

The error states: {{error_states}}. What the user was trying to do: {{user_goal}}. What they can actually do about each: {{remedies}}.

## Task

Write error messages for {{feature}}.

## Constraints

- Say what happened, then what to do about it. Never only the first.
- No error codes without an accompanying plain-English explanation.
- Never blame the user.
- If nothing can be done, say so and say who can help.
- Return complete, runnable code. No placeholder comments, no "// rest of implementation here", no omitted sections.
- Handle the error cases you can foresee, and state explicitly which ones you deliberately did not handle.
- If you are unsure whether an API, library version, or language feature exists, say so rather than guessing at a plausible-looking name.

## Output format

Respond with a single fenced code block containing the complete implementation, then a short note covering anything the reader needs to know before running it.

## Approach

Work through the problem step by step before giving your answer. Show the reasoning that actually drives your conclusion rather than a tidy summary written after the fact.

## Success criteria

Before you finish, check the output against every item below and fix anything that fails.

- Every message tells the user their next action.

## Before you start

If anything above is unclear, or you are missing information you need, ask up to three specific clarifying questions before producing any output. Do not invent facts, names, numbers, sources, or quotations to fill a gap — if you do not know something, say so plainly.

Now, write error messages for {{feature}}.

Gemini

**Task**

Write error messages for {{feature}}.

**Role**

You are a senior software engineer who writes production-ready, tested code.

**Context**

The error states: {{error_states}}. What the user was trying to do: {{user_goal}}. What they can actually do about each: {{remedies}}.

**Constraints**

- Say what happened, then what to do about it. Never only the first.
- No error codes without an accompanying plain-English explanation.
- Never blame the user.
- If nothing can be done, say so and say who can help.
- Return complete, runnable code. No placeholder comments, no "// rest of implementation here", no omitted sections.
- Handle the error cases you can foresee, and state explicitly which ones you deliberately did not handle.
- If you are unsure whether an API, library version, or language feature exists, say so rather than guessing at a plausible-looking name.

**Output format**

Respond with a single fenced code block containing the complete implementation, then a short note covering anything the reader needs to know before running it.

**Approach**

Work through the problem step by step before giving your answer. Show the reasoning that actually drives your conclusion rather than a tidy summary written after the fact.

**Success criteria**

Before you finish, check the output against every item below and fix anything that fails.

- Every message tells the user their next action.

**Before you start**

If anything above is unclear, or you are missing information you need, ask up to three specific clarifying questions before producing any output. Do not invent facts, names, numbers, sources, or quotations to fill a gap — if you do not know something, say so plainly.

Now, write error messages for {{feature}}.

Common questions

What makes a good error message?
It says what happened in plain language and what to do next. A message that only reports failure leaves the person exactly where they were, except more frustrated.
Should error messages include error codes?
Include them alongside a plain explanation, never instead of one. Codes help support staff and mean nothing to the person reading them, so they belong at the end rather than as the message itself.
Which AI model is best for writing error messages?
All of them handle this; what changes is the packaging. This page shows the same prompt written for Claude, ChatGPT, Gemini. Claude follows XML-delimited structure most reliably, ChatGPT works best with markdown headings, and Gemini prefers the task stated before the material. The content of the prompt is identical in each.
Can I change this prompt for my own situation?
Yes, and you should. Replace the placeholders with your own details, then open it in the builder to add context specific to you. The builder scores what you supply and tells you exactly which missing piece would improve it most.
Why does this prompt include rules I did not ask for?
Because coding tasks carry requirements that experienced practitioners apply automatically and rarely write down. The compiler adds them so the output does not fail on something obvious. Every added rule is listed on the how it works page.

Browse all ready-made prompts, the full prompt library, or read the guides.