Convert Few-Shot Prompts to Claude Assistant Prefill Format

Transforms raw user-assistant examples into Claude API prefill messages that steer token generation and stop hallucinations.

Text prompt for Claude and ChatGPT

You get: Target Format Schema, converted Payload and hallucination Prevention Check

Prompt

Prompt
Act as an AI systems engineer specializing in model migration between OpenAI, Gemini, and Anthropic APIs.

Your job is to convert raw few-shot examples into Claude assistant prefill payloads that force immediate schema compliance.

Rules:
1. Separate input context from target output, moving the opening token of the output into a prefilled assistant message.
2. Strip conversational filler (such as 'Sure, here is your answer') so generation starts inside the target syntax.
3. Show both the full messages array structure and the exact prefilled prefix string.
4. Highlight where hallucinations typically happen in vanilla prompts and how this prefill prevents them.

Output format:
- Target Format Schema: Message roles and prefill location
- Converted Payload: Ready-to-copy API payload structure
- Hallucination Prevention Check: 2-3 specific failure modes eliminated
- Edge Cases: One scenario where prefill could break parsing

Paste your raw examples below, or ask me 2 short questions to specify your use case.

Example output

Example for: Extracting purchase order line items from messy procurement emails without conversational preamble.

Target Format Schema
system: You extract purchase line items. Output valid JSON array only.
messages:
  - role: user
    content: Email text
  - role: assistant
    content: "["
Converted Payload
messages = [
    {
        "role": "user",
        "content": """Invoice request from Acme Corp:
        Item 1: 50x ergonomic desks at $240 each (SKU: DSK-41).
        Item 2: 100x monitor arms at $45 each (SKU: ARM-12).
        Shipping address: Warehouse 4.""",
    },
    {
        "role": "assistant",
        "content": "[\n  {\n    \"sku\": \"",
    },
]
Hallucination Prevention Check
  • Eliminates conversational preamble: Prefilling [\n {\n "sku": " removes introductory phrases like "Here is the extracted data:", which frequently cause downstream JSON parser failures.
  • Prevents invented metadata: Forcing the token sequence directly into the first key stops the model from hallucinating summary fields or unrequested wrapper objects like {"items": [...]}.
  • Constrains structural drift: Claude must complete the specific key-value pair immediately, reducing the probability of invented SKU formats.
Edge Cases

If the incoming email contains zero items or is a spam message, the model cannot return an empty list or error string because the opening bracket and first key are already prefilled into its response buffer.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Prefilling the assistant turn eliminates markdown chatter and forces immediate compliance with the target schema.
  • Explicitly separates OpenAI-style role histories into Anthropic's prefill structure without losing example context.
  • Identifies structural edge cases where prefilling empty states or error conditions requires fallback logic.

Use this prompt in ChatGPT, Gemini, or Claude when porting OpenAI chat completions to Anthropic Claude prefill structures to guarantee strict formatting.

Common edits

  • Switch the prefill token from JSON syntax to XML tags like `<analysis>` for chain-of-thought workflows.
  • Request output formatting in LangChain, TypeScript, or raw REST curl calls instead of standard Python dictionaries.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Major AI Models

Convert Complex System Prompts into Few-Shot Training Pairs

Transforms dense system instructions into five high-quality input-output pairs that clarify model expectations and edge-case handling.

Major AI Models

Migrate OpenAI System Prompts to Claude XML Format

Convert your existing OpenAI instructions into optimized XML-tagged blocks for Claude that improve instruction adherence and context parsing.

Major AI Models

Calculate Context Window Budgets for Long-Document Prompts

Generates a token allocation plan across input docs, scratchpads, and outputs for ChatGPT, Claude, and Gemini to prevent context overflow.

Major AI ModelsClaude

Compress Production Prompts to Reduce Token Usage and Latency

Compress high-volume system instructions into concise directives, showing exact deletions and estimated token savings.

Major AI ModelsClaude

Harden JSON Extraction with Strict Null and Fallback Rules

Get a hardened extraction prompt, strict schema specification, and edge-case test table that enforce null-over-guessing, enum fallbacks, and error handling.

Major AI Models

Audit AI Prompts for Universal Compatibility and Portability

Identify vendor-specific jargon and rewrite your prompts into universal instructions that work consistently across ChatGPT, Claude, and Gemini.