The Research Report
Reverse Prompting + Prompt Format Selection
By Hermann del Campo, Apr 2026
Published on Medium
Why the prompt matters more than the model
You’re building agents at 2 am. The model you pick is rarely the bottleneck. The prompt is. If the prompt is fuzzy, the agent fails. If the prompt is crisp, the model shines.
Reverse prompting – three patterns
1. Output‑to‑prompt derivation
Show the model a perfect piece of output. Ask it to write the system prompt that would generate that output. The model knows its own quirks, so the prompt it produces is often tighter than anything you could write manually.
2. Iterative self‑critique
Start with an initial prompt. Generate output. Ask the model to compare the output with a gold standard and suggest prompt changes. Run a few rounds. Three cycles usually give you 80 % of the final quality. After that the gains drop off.
3. Role‑based extraction
Describe the role, constraints, and desired output schema. Ask the model to synthesize a full system prompt as if it were a prompt engineer. This works well for multi‑agent pipelines where you need several consistent prompts.
All three patterns treat the model as a prompt debugger. They let you discover the right instructions instead of guessing.
Prompt format – XML, JSON, Markdown, or plain text?
The choice isn’t cosmetic. It changes how reliably the model follows rules, parses sections, and stays on budget.
| Format | When it shines | Where it falls |
|---|---|---|
| XML | Deep hierarchies, explicit type metadata, Anthropic Claude models | Token heavy, hard to read, breaks after >20 nesting levels |
| JSON | Defining output schemas, programmatic generation, cross‑model portability | No comments, strict syntax, verbose for natural‑language rules |
| Markdown | Human‑readable docs, mixed prose + structure, quick edits | Ambiguous markers, less precise for strict validation |
| Plain text | Tiny agents, conversational tone, token‑budget tight | No anchors, hard to enforce constraints, degrades on long prompts |
The hybrid that works in production
- XML outer shell – gives the model clear sections and attribute tags.
- Markdown inside – adds readable explanations, headings, and examples.
- JSON snippet for the output schema – guarantees the model returns well‑formed JSON.
<system_prompt>
<role>
You are a risk‑analysis agent for commercial‑real‑estate memos.
</role>
<input_schema>
{"property_id":"string","financials":{...}}
</input_schema>
<reasoning>
1. Validate cap‑rate against comparable sales.
2. Flag vacancy > market +2 %.
3. Cite the exact numbers you use.
</reasoning>
<output_schema>
{"propertyid":"string","risks":[{...}],"overallscore":0.0}
</output_schema>
<constraints>
<constraint>Never invent data.</constraint>
<constraint>If confidence < 0.7, route to human review.</constraint>
</constraints>
</system_prompt>
The XML tags keep the model from bleeding context between sections. The Markdown headings make the prompt easy to audit. The JSON block forces a valid return structure.
Measuring the impact
Running the three reverse‑prompting patterns on a set of 200 agents gave these results:
- Output‑to‑prompt reduced manual prompt‑writing time by 45 %.
- Iterative self‑critique improved downstream task accuracy from 78 % to 92 % after three cycles.
- Role‑based extraction let a five‑agent LangGraph pipeline ship in half the usual sprint.
Format tests on a customer‑support triage agent showed:
- XML achieved 99 % strict rule adherence but used 12 % more tokens.
- JSON hit 97 % valid‑JSON return rate with the lowest token cost.
- Markdown scored 94 % on rule adherence and was the easiest to edit.
- Plain text fell to 83 % on complex rule sets.
Token budgeting tip
If you run on Claude Opus 4.7, set a task budget (e.g., 200 K tokens) and effort = xhigh. The model will self‑pace, preferring thinking over tool calls. Combine that with the hybrid format and you get predictable token usage.
Take‑away checklist
- Pick a reverse‑prompting pattern that matches your workflow.
- Start with XML for structural clarity, embed Markdown for readability, and finish with JSON for output guarantees.
- Run a quick token audit using the model’s
task_budgetfeature. - Iterate three times at most; after that manual tweaking wins.
Citations
- Hermann del Campo, Reverse prompting and prompt format selection — the two levers nobody talks about when building agents that don’t suck, Medium, Apr 1 2026. https://medium.com/@hermanndelcampo/reverse-prompting-and-prompt-format-selection-the-two-levers-nobody-talks-about-when-building-c0b15740e291
- Rephrase‑it.com, How to structure prompts with XML and Markdown tags (so they don’t rot in prod), https://rephrase-it.com/blog/how-to-structure-prompts-with-xml-and-markdown-tags-so-they-
- Anthropic documentation, Claude and XML‑prompt performance, https://docs.anthropic.com/claude/docs/xml-prompting
Word count: 795