Reverse prompt engineering: from an output you like to a prompt you can reuse
TL;DR: Reverse prompt engineering means starting from a piece of text you like and working back to a prompt that produces text like it. You ask a model to describe the text's structure, tone and length, turn that into a prompt, test it, and save it as a template. You get similar output, not the original prompt.
What reverse prompt engineering is
Normal prompting goes forward: you write a prompt and get an output. Reverse prompt engineering goes backward. You start with an output you already like, such as an email that got replies, a product page that converts or a report your boss praised, and work out a prompt that would produce more text like it.
The goal is to recreate the style and structure, so you can produce the next one on demand. The opening move, the length, the order of the parts, the tone, the kind of detail used. Once those are written down as a prompt, anyone on your team can use it.
This guide is about recreating the style and structure of text you are allowed to use. It is not about extracting the hidden system prompt behind someone else's chatbot or product, which is a different activity, may break the provider's terms, and is not something we cover.
Why it's useful
- You know what good looks like but can't describe it. Most people can point to a great email faster than they can write the rules for one. The model can help put those rules into words.
- You want a repeatable template. One great output is luck. A prompt that produces it every week is a process.
- You want to learn why something works. Breaking a strong piece of writing into its parts teaches you more than copying it.
- You inherited outputs without the prompts. A colleague left and their AI-assisted reports were good. The prompts are gone, but the reports aren't.
The method in five steps
- Collect one to three samples. More than one helps the model separate the pattern from the accidents of a single piece. They should be the same kind of text for the same kind of reader.
- Ask the model to describe the samples. Structure, length, tone, sentence style, what each part does. Don't ask for a prompt yet: a description first gives you something to check.
- Ask for a prompt built from the description. It should produce new text with the same features about a different topic, with brackets for the parts that change.
- Test it on a new topic and compare. Run the prompt, then put the result next to your sample. Note what is different.
- Fix the prompt, then save it as a template. Two or three rounds is usually enough. Keep the final version where your team can find it.
Prompts for each step
Below is a [type of text, for example: product update email] that worked well with [audience]. Describe it so precisely that someone could write a new one on a different topic in the same style. Cover:
1. Structure: each part in order, what it does and roughly how long it is.
2. Tone and voice, with two short quotes that show it.
3. Sentence style: typical length, use of questions, use of numbers.
4. What it leaves out that most texts of this kind include.
5. Anything that looks deliberate rather than accidental.
Don't rewrite it or praise it.
<sample>
[paste the text you like]
</sample>Why it works: point 4 is the one people forget. What a good piece leaves out (no warm-up paragraph, no feature list, no exclamation marks) is often what makes it good.
Using your description, write a reusable prompt that would make an AI model produce a new [type of text] with the same structure, tone and length, about a different topic. Put the parts that change in [brackets], and add one line under each bracket saying what goes there. Tell the model to use only the facts it is given. Don't copy any sentences or details from the sample into the prompt.Here is my original sample and a new text made with the prompt below. List every way the new text differs from the sample in structure, tone, length or style, most important first. Then give me a revised prompt that closes those gaps.
<sample>
[paste the original]
</sample>
<new_text>
[paste the output from the prompt]
</new_text>
<prompt>
[paste the prompt you tested]
</prompt>Run the comparison in a fresh chat if you can. A new chat sees only what you paste, so it judges the texts without the reasoning from the earlier steps.
A worked example: a product update email
Say your team sent this email, and it got more replies than any update you have sent:
Subject: Exports now take seconds, not minutes
Hi Sam,
Quick one. Exports used to take up to five minutes on big accounts. As of today they finish in seconds, whatever the size.
You don't need to do anything. Next time you click Export, it's just faster.
One question: what do you export most? Hit reply and tell me. I read every answer.
Priya
Product team, NorthwindA good description from the step 2 prompt picks out the features that matter: a subject line that states the benefit as a before and after; "Quick one" as a signal it will be short; concrete numbers; a paragraph that tells the reader what to do, which here is nothing; one specific question to invite replies; a personal sign-off from a named person. It also notes what's missing: no "we're excited to announce", no feature list, no exclamation marks, under 70 words.
From that description, step 3 gives a template like this one, which you can test and adjust:
Write a product update email to a customer about this change: [what changed, with the before and after].
Follow this structure:
- Subject line: the benefit as a before and after, under 8 words.
- Greeting with first name, then "Quick one."
- Paragraph 1: what it was like before, then what it is like now, in two short sentences with concrete numbers.
- Paragraph 2: what the customer needs to do (often nothing), in under 20 words.
- Paragraph 3: one question about how they use the feature, and an invitation to reply.
- Sign off with a first name and team.
Style: plain words, sentences under 15 words, no exclamation marks, no "we're excited to announce". Under 90 words in total. Use only the facts I give; if a number is missing, write [number].Test it on a different change, for example a new calendar integration, and compare. Suppose the test email ends with a generic "Let us know what you think!" instead of a specific question about use. The fix is one line in the template: "The question must be about a specific way they use the feature, answerable in one sentence."
Template or example: which to keep?
Once you have a sample you like, you have two options: keep the reverse-engineered template, or paste the sample itself into future prompts as an example, which is few-shot prompting. Each has a place.
Measured with OpenAI's o200k_base tokenizer (used by GPT-5, GPT-4.1 and GPT-4o), the sample email above is 87 tokens. The template is 179. For a short text, pasting the sample is the cheaper option. The template is worth its length for other reasons.
| Template | Pasted example | |
|---|---|---|
| Length in this case (o200k_base tokens) | 179 | 87 |
| Copies the sample's wording or details | Rarely, if you told it not to | Sometimes: topics and phrases leak in |
| Easy to edit one rule | Yes, change a line | No, you need a different sample |
| Captures what's hard to describe | Only what the description caught | Yes, the model sees the real thing |
| Easy for a colleague to understand | Yes, the rules are written down | Less: they must guess what matters |
Often the best prompt uses both: the template's rules plus one sample, with a line saying "match the style of the sample, not its topic or wording". You can check the size of either version in our free token counter before you save it.
More places to use it
- Sales emails that got replies. Reverse-engineer the three best from your outbox, then compare the template's output against a weak email to see what was missing.
- Reports and summaries. Give it a past report your manager liked and ask for the structure as a prompt. Weekly reporting becomes filling in brackets.
- Social posts in your own voice. Use five of your best posts as samples. The description step can name habits you didn't know you had.
- Images. The same idea works for image generators: describe a reference image's subject, composition, lighting and style, then use the description as a prompt. Expect a similar image, never the same one.
For ready-made prompts to start from instead of a sample, see our prompt examples.
The limits
The main limit is in the definition: you get a prompt that produces similar output, not the prompt that produced the original. Many different prompts could produce the same text, and a model has no way of seeing which one was used. If the original was written by a person, there was no prompt at all.
Recovering an exact prompt from its output is an open research problem, and it is much harder than recreating a style. In 2023, John Morris and colleagues recovered 27% of prompts exactly on Llama-2 7B, but their method needs the model's next-token probabilities, which chat apps don't show you. A 2024 follow-up by Collin Zhang, Morris and Vitaly Shmatikov, called output2prompt, works from ordinary outputs, but it trains a dedicated model for the job. Asking a chatbot "what prompt made this?" is not that.
Other limits to keep in mind:
- Facts don't carry over. The template captures form. Every fact in a new piece has to come from you, which is why the template says to use only the facts given.
- One sample can mislead. With a single sample, the model may treat an accident (a topic, a length) as a rule. Two or three samples make the pattern clearer.
- Some qualities resist description. Humor, timing and a writer's ear are hard to put into rules. If the template keeps missing them, add the sample as an example.
- Use text you have the right to use. Learning structure from a competitor's landing page is normal practice. Reproducing their wording is not. Your own past work is the best source.
To write prompts from scratch rather than from a sample, start with how to write a prompt.
Let the right experts write your prompt
Prompt Expert is an AI prompt generator that brings the right experts to every job. They ask a few questions, read your website and files, and write the prompt for ChatGPT, Claude or Gemini with your real facts, working together when a job needs more than one.
See how it worksQuestions
What is reverse prompt engineering?
Reverse prompt engineering is working back from an output you like to a prompt that produces similar output. You ask a model to describe the text's structure and style, turn the description into a prompt, and test it.
Can AI tell me the exact prompt used to create a text?
No. A model can suggest a prompt that produces similar text, but many prompts could produce the same output and it can't know which was used. Research methods that recover exact prompts need special access or trained tools.
What prompt should I use to reverse engineer a text?
Ask the model to describe the text's structure, tone, sentence style and what it leaves out, without rewriting it. Then ask it to turn that description into a reusable prompt with brackets for the parts that change.
Is reverse prompt engineering the same as prompt injection?
No. Reverse prompt engineering recreates the style of a text you are allowed to use. Prompt injection tries to make a model ignore its instructions or reveal hidden ones, which is a security issue, not a writing technique.
Does reverse prompt engineering work for images?
Yes, in the same limited way. Ask a model to describe an image's subject, composition, lighting and style, then use that as a prompt. You'll get a similar image, not a copy.
Sources
- Morris et al. (2023): Language Model Inversion
- Zhang, Morris and Shmatikov (2024): Extracting Prompts by Inverting LLM Outputs
- Anthropic: Prompting best practices (use examples effectively)
- OpenAI: Prompt engineering guide