Mindket

How to improve a prompt with AI: OpenAI's optimizer and Anthropic's improver

A black banner titled "Prompt optimization" over the line "Generate, improve and test prompts with AI".

To improve a prompt with AI, give an existing prompt to a tool that rewrites it by the vendor's best practices, then compare the rewrite with the original on your own cases. OpenAI's prompt optimizer fixes contradictions, vague format rules and examples that disagree with the instructions. Anthropic's prompt improver refines a prompt with techniques like chain-of-thought reasoning. OpenAI warns that the result can do worse on some inputs.

In this lesson

  • Collect three or more inputs where your prompt fails, with the reply you wanted, before you ask any tool to rewrite it.
  • Read the rewrite line by line. A good change removes a contradiction or states a rule, and you should be able to name which.
  • Tell the tool the change you want in your own words, then run it again on the new version.
  • Keep the original until the rewrite beats it on the same inputs.
All courses
On this page
  1. Before you start
  2. Run OpenAI's prompt optimizer
  3. Give the optimizer graded examples
  4. A prompt with mixed signals
  5. What the optimized prompt looks like
  6. What improved, by OpenAI's own numbers
  7. What Anthropic says its prompt improver does
  8. Improve a prompt yourself with OpenAI's edit meta-prompt
  9. Common mistakes
  10. Try it yourself
  11. Next: test prompt versions side by side
  12. Check yourself
  13. Frequently asked questions
  14. Sources

Before you start

An optimizer takes a prompt you already have and returns a rewritten one. You need a prompt that fails in a way you can name, and three or four inputs to try it on, ideally with the replies you wanted. If you have no prompt yet, lesson 1 writes a first draft.

Part of OpenAI's tooling is on a clock, so look at the dates first. The deprecations page schedules existing evals to become read-only on 31 October 2026. That date had already passed when this lesson was checked on 6 November 2026. The page also schedules the Evals dashboard and API to shut down on 30 November 2026. The optimizer guide says OpenAI is deprecating the dataset-backed prompt optimizer as part of that platform. It does not say what happens to the plain Optimize button, so treat both OpenAI routes as possibly gone by December. What outlives them is the habit of reading the changes and then testing.

OpenAI's schedule for Evals and reusable prompts
  1. Deprecation announced

    For the Evals platform and for reusable prompt objects.

  2. Existing evals become read-only

  3. Evals dashboard and API shut down

    The v1/prompts API and reusable prompt objects are scheduled to shut down the same day.

Source: OpenAI Docs: Deprecations (read November 6, 2026)

Run OpenAI's prompt optimizer

OpenAI's prompt optimizer guide describes a chat interface in the dashboard. You enter a prompt, and OpenAI optimizes it according to current best practices before returning it. The GPT-5 cookbook notebook shows the plain route, which needs no dataset.

  1. Open the Optimize Playground and paste your prompt into the Developer Message section.
  2. Press Optimize. That opens the optimization panel.
  3. Type the specific edits you want, or press Optimize again to have the prompt refined for the target model and task.
  4. Read the result. The notebook says the tool shows snippets of what it changed and why, which you can open as comments or in inline reviewer mode.
  5. Ask for one more change if something is missing. The notebook adds "enforcing the single-pass streaming" this way, on top of the optimized version.
  6. Test the new prompt on your inputs before you use it anywhere.

Give the optimizer graded examples

The guide says the optimizer can learn from your own data: annotations (Good or Bad, plus custom columns), written critiques in an output_feedback field, and grader results. It asks for a Good or Bad rating and a detailed, specific critique, and for graders that capture the properties you want.

The guide also says the optimizer is only as good as those graders. OpenAI recommends narrow graders, one for each property where your prompt fails. The guide still words these steps as if the platform were open, and the read-only date has passed, so check your dashboard before you plan around them.

  • Make a dataset that holds the prompt and an evaluation dataset, with at least three rows that have responses.
  • Give each row at least one grader result or human annotation.
  • Click Optimize at the bottom of the prompt pane. A new tab opens and the work runs in the background.
  • View and test the result, then repeat: generate outputs, annotate them, run graders and optimize again.

A prompt with mixed signals

The notebook starts from a short, friendly prompt for a Python task and says it hides contradictions and underspecified instructions. The optimizer is described as removing three kinds of failure: contradictions, missing or unclear format rules, and inconsistencies between the prompt and its few-shot examples. This is the baseline prompt as the notebook prints it.

Write Python to solve the task on a MacBook Pro (M4 Max). Keep it fast and lightweight.

- Prefer the standard library; use external packages if they make things simpler.
- Stream input in one pass to keep memory low; reread or cache if that makes the solution clearer.
- Aim for exact results; approximate methods are fine when they don't change the outcome in practice.
- Avoid global state; expose a convenient global like top_k so it's easy to check.
- Keep comments minimal; add brief explanations where helpful.
- Sort results in a natural, human-friendly way; follow strict tie rules when applicable.

Output only a single self-contained Python script inside one Python code block, with all imports, ready to run.
Baseline lines from the notebook's prompt, the notebook's reading of each, and the matching lines of its optimized prompt. From OpenAI's GPT-5 optimizer notebook, read on 6 November 2026.
Baseline lineThe fork it opensThe optimized prompt says instead
Prefer the standard library, but external packages are fine if they make things simplerHeavier imports that change speed and whether the script runs everywhereUse only Python stdlib. No approximate algorithms.
Stream input in one pass, but reread or cache if that is clearerMulti-pass designs and caches that defeat the streaming limitDo NOT materialize the entire token stream or any large intermediate list.
Aim for exact results, but approximate methods are fine when they do not change the outcomeA judgment the model cannot check, so counts near the cutoff can driftExact Top-K semantics, sorted by count descending, then token ascending.
Sort in a natural, human-friendly way, and follow strict tie rulesA convenient built-in order that breaks ties differently from the evaluatorNo reliance on Counter.most_common tie behavior.

What the optimized prompt looks like

After one Optimize press and the extra request to enforce single-pass streaming, the notebook's prompt is built from labelled sections: Objective, Hard requirements, Performance and memory constraints, Guidance, Output format and Examples. Every soft permission in the baseline became a hard rule. The sections before the examples are below. The Examples section that follows holds a complete script.

# Objective
Generate a single, self-contained Python script that exactly solves the specified task on a MacBook Pro (M4 Max).

# Hard requirements
- Use only Python stdlib. No approximate algorithms.
- Tokenization: ASCII [a-z0-9]+ on the original text; match case-insensitively and lowercase tokens individually. Do NOT call text.lower() on the full string.
- Exact Top‑K semantics: sort by count desc, then token asc. No reliance on Counter.most_common tie behavior.
- Define `top_k` as a list of (token, count) tuples with length = min(k, number of unique tokens).
- When globals `text` (str) and `k` (int) exist, do not reassign them; set `top_k` from those globals. If you include a `__main__` demo, guard it to run only when globals are absent.
- No file I/O, stdin, or network access, except optionally printing `top_k` as the last line.

# Performance & memory constraints
- Do NOT materialize the entire token stream or any large intermediate list.
- Do NOT sort all unique (token, count) items unless k >= 0.3 * number_of_unique_tokens.
- When k < number_of_unique_tokens, compute Top‑K using a bounded min‑heap of size k over counts.items(), maintaining the correct tie-break (count desc, then token asc).
- Target peak additional memory beyond the counts dict to O(k). Avoid creating `items = sorted(counts.items(), ...)` for large unique sets.

# Guidance
- Build counts via a generator over re.finditer with re.ASCII | re.IGNORECASE; lowercase each matched token before counting.
- Prefer heapq.nsmallest(k, cnt.items(), key=lambda kv: (-kv[1], kv[0])) for exact selection without full sort; avoid heapq.nlargest.
- Do NOT wrap tokens in custom comparator classes (e.g., reverse-lex __lt__) or rely on tuple tricks for heap ordering.
- Keep comments minimal; include a brief complexity note (time and space).

# Output format
- Output only one Python code block; no text outside the block.

What improved, by OpenAI's own numbers

The notebook generated 30 scripts with each prompt, using GPT-5, and measured them on a MacBook Pro with an M4 Max chip. Exactness stayed at 100% for both prompts. The gains came in peak memory and average time, and in two scores from 1 to 5 that one LLM judge prompt gave for how closely the code followed the task and for code quality. The notebook prints no run date. OpenAI's cookbook registry lists it as added on 7 August 2025.

A second example runs FailSafeQA, a finance benchmark that deliberately perturbs both the question and the context and reports robustness, context grounding and compliance. The notebook's note on this run mentions GPT-5-mini and says the baseline prompt already scores 4 or more almost every time. It points to the share of perfect 6 out of 6 judge scores instead, and does not print that share. The figures below are what its summary table prints, as averages across datapoints with a compliance threshold of 6, and the notebook does not say what scale they are on. These are OpenAI's numbers on two tasks, and the notebook itself says prompting is not a one-size-fits-all experience.

Top-K frequent words task, 30 runs per prompt. From the published outputs of OpenAI's GPT-5 optimizer notebook, read on 6 November 2026.
MeasureBaseline promptOptimized prompt
Average time (seconds)7.9066.977
Peak memory (KB)3626.3577.5
Exact results (%)100100
Task adherence by an LLM judge (1 to 5)4.404.90
Code quality by an LLM judge (1 to 5)4.734.90
FailSafeQA summary figures, baseline and optimized promptAs printed in the notebook's summary table. The notebook does not say what scale they are on, so the bars are drawn against 1 only to fit the page. The gold bars are the optimized prompt.
  • Robustness, baseline0.32
  • Robustness, optimized0.54
  • Context grounding, baseline0.80
  • Context grounding, optimized0.95

Source: OpenAI Cookbook: GPT-5 prompt migration and improvement with the optimizer (read November 6, 2026)

What Anthropic says its prompt improver does

Anthropic added a prompt improver to its Console in November 2024. Its account on X said you can take an existing prompt and Claude will refine it automatically with techniques like chain-of-thought reasoning. A minute later, Alex Albert posted a similar announcement: you can take any prompt, run it through the improver and get an optimized prompt back.

Neither post lists what the improver changes, so read the Console's own notes before you rely on a detail. Chain-of-thought is the one named technique. The chain-of-thought lesson shows what a reasoning section looks like inside a prompt.

Take any prompt, run it through the improver, and get an optimized prompt in return.

Alex Albert (@alexalbert__), Anthropic · X (read November 6, 2026)
Anthropic (@AnthropicAI) on X, 14 November 2024: we've added a new prompt improver to the Anthropic Console. Take an existing prompt and Claude will automatically refine it with prompt engineering techniques like chain-of-thought reasoning.
Anthropic on X, 14 November 2024
Alex Albert (@alexalbert__) on X, 14 November 2024: we've added a Claude-powered prompt improver to the Anthropic Console. Take any prompt, run it through the improver, and get an optimized prompt in return. Here's how it works.
Alex Albert on X, 14 November 2024

Screenshots of X's own embeds of the posts, taken on 6 November 2026, with the time in UTC. The second post opens a thread, and its later posts are not in the screenshot. Select a screenshot to open the post on X.

Improve a prompt yourself with OpenAI's edit meta-prompt

You can run a rewrite without any dashboard. OpenAI's prompt generation guide prints a meta-prompt for edits. It asks the model to open with a reasoning section that judges the current prompt, name the one to three most important fixes, and only then write out the full corrected prompt. The text below is its opening, up to the Guidelines list, which is the one from lesson 1.

In the guide's code the meta-prompt is the system message, and one user message that starts "Task, Goal, or Current Prompt:" carries the rest. Its edit example passes only a change request, "Make this product launch announcement clearer and more concise." Pasting the meta-prompt into a chat window, ahead of your current prompt and your change, is this lesson's suggestion.

Given a current prompt and a change description, produce a detailed system prompt to guide a language model in completing the task effectively.

Your final output will be the full corrected prompt verbatim. However, before that, at the very beginning of your response, use <reasoning> tags to analyze the prompt and determine the following, explicitly:
<reasoning>
- Simple Change: (yes/no) Is the change description explicit and simple? (If so, skip the rest of these questions.)
- Reasoning: (yes/no) Does the current prompt use reasoning, analysis, or chain of thought?
    - Identify: (max 10 words) if so, which section(s) utilize reasoning?
    - Conclusion: (yes/no) is the chain of thought used to determine a conclusion?
    - Ordering: (before/after) is the chain of though located before or after
- Structure: (yes/no) does the input prompt have a well defined structure
- Examples: (yes/no) does the input prompt have few-shot examples
    - Representative: (1-5) if present, how representative are the examples?
- Complexity: (1-5) how complex is the input prompt?
    - Task: (1-5) how complex is the implied task?
    - Necessity: ()
- Specificity: (1-5) how detailed and specific is the prompt? (not to be confused with length)
- Prioritization: (list) what 1-3 categories are the MOST important to address.
- Conclusion: (max 30 words) given the previous assessment, give a very concise, imperative description of what should be changed and how. this does not have to adhere strictly to only the categories listed
</reasoning>
  1. Paste the meta-prompt, then your current prompt and the change you want in one sentence.
  2. Read the reasoning section first. It shows what the model thinks is wrong, and you can disagree where you know your task better.
  3. Copy the corrected prompt out and compare it with your original, line by line.

Common mistakes

  • Judging a rewrite by how it reads. OpenAI's guide says an optimized prompt can perform worse than your original on specific inputs.
  • Leaving a contradiction for the tool to settle. If your prompt allows two behaviors, decide which one you want before you press Optimize.
  • Skipping the change list. The notebook says the optimizer shows what it changed and why.
  • Keeping the result only as an OpenAI prompt object. OpenAI is retiring those and says to move their content into your application code.
  • Expecting OpenAI's numbers on your task. They come from one coding task and one finance benchmark.

Try it yourself

  • Take a prompt with two soft permissions, like the baseline above, and write which way you want each one to go.
  • Run it through one optimizer, or through the edit meta-prompt.
  • List every line that changed and sort them: a contradiction removed, a rule added, a format stated, or something else.
  • Keep the sorted list. It shows which kind of fix your prompts need most.

Next: test prompt versions side by side

A rewrite is a claim until you test it. Lesson 3 sets up a small test set and compares two versions of a prompt on it.

Check yourself

  1. In OpenAI's cookbook example, what stayed the same after the prompt was optimized?

    Show answer

    B. Exactness of the results, 100% for both Both prompts produced exact results every time, so the gain came in memory, speed and how closely the code followed the task.

  2. What does OpenAI's optimizer guide say about an optimized prompt?

    Show answer

    D. It can perform worse than your original on specific inputs The guide says to evaluate and manually review optimized prompts before production, since one can do worse on specific inputs.

  3. What does the dataset route of OpenAI's optimizer need at a minimum?

    Show answer

    A. At least three rows with responses, each with a grader result or annotation The guide asks for at least three rows of data with responses and at least one grader result or human annotation for each row.

  4. Which of these did OpenAI schedule to shut down on 30 November 2026?

    Show answer

    C. The Evals dashboard and API, and reusable prompt objects The deprecations page lists the Evals dashboard and API and the v1/prompts API with reusable prompt objects for that date.

Frequently asked questions

What is a prompt optimizer?

A tool that takes a prompt you wrote and returns a rewrite based on prompting best practices. OpenAI's lives in its dashboard, and Anthropic's is called the prompt improver.

Does OpenAI's prompt optimizer still work?

Only the dataset-backed version is named in the guide's deprecation notice, and it goes with the Evals platform. Nothing there covers the plain Optimize button, so read the deprecations page before you build a workflow on either.

Is Anthropic's prompt improver the same as its prompt generator?

Anthropic's posts describe two features. The generator writes a prompt from a description of what you want, as lesson 1 shows. The improver starts from a prompt you already have.

Can the optimizer work without graders or test data?

Yes. You can paste a prompt and press Optimize with nothing else, which is how the cookbook example starts. A dataset adds feedback the optimizer can use: at least three rows with responses, each with a grader result or an annotation.

How do I improve a prompt without a vendor tool?

Ask a chat model to assess the prompt first, the way OpenAI's edit meta-prompt does, then apply only the changes you agree with. Test the new version against the old one before you switch.

Sources

  1. OpenAI Docs: Prompt optimizer (read November 6, 2026)https://developers.openai.com/api/docs/guides/prompt-optimizer
  2. OpenAI Docs: Deprecations (read November 6, 2026)https://developers.openai.com/api/docs/deprecations
  3. OpenAI Cookbook: GPT-5 prompt migration and improvement with the optimizer (read November 6, 2026)https://developers.openai.com/cookbook/examples/gpt-5/prompt-optimization-cookbook
  4. OpenAI Docs: Prompt generation (read November 6, 2026)https://developers.openai.com/api/docs/guides/prompt-generation
  5. GitHub: openai/openai-cookbook registry.yaml, the notebook's entry (read November 6, 2026)https://github.com/openai/openai-cookbook/blob/main/registry.yaml
  6. X: Anthropic (@AnthropicAI) on the new prompt improver in the Anthropic Console (read November 6, 2026)https://x.com/AnthropicAI/status/1857108263042502701
  7. X: Alex Albert (@alexalbert__) on the Claude-powered prompt improver (read November 6, 2026)https://x.com/alexalbert__/status/1857108576797639166

Share this lesson

Read prompts that were tuned by others

Mindket lists agent skills, and each one is a folder of instructions, examples and files that you can open and read before you install it.

Browse skills

This lesson as Markdown · Prompt optimization: let AI write, improve and test your prompts · All courses