Chapter 2: The XML Sandwich | Legal Consulting Academy
Chapter 3 • Frameworks

The XML Sandwich: The Framework for Perfect Prompts

The Inexperienced Intern Analogy

To master the XML Sandwich, you must first change how you view Large Language Models. Do not treat the AI as a search engine or an all-knowing oracle.

"View the AI as an incredibly bright, fast, and diligent summer associate who has zero context about your firm, your client, or the specific legal standards of your jurisdiction."

If you gave that intern a messy stack of papers and said "fix this," the result would be unusable. The XML Sandwich provides the structural walls that prevent the AI's logic from "bleeding" and ensure it stays focused on the task at hand.

A high-end legal office with dark wood desks

Curator's Note

Structure isn't just about clarity; it's about control over the probabilistic nature of the model.

Anatomy of the Sandwich

The logical layering of a high-performance legal prompt.

<context> The Top Bread (Role & Background)
<instructions> The Core Task
arrow_forward
<format> The Structural Output
arrow_forward
<example> The Reference Standard
arrow_forward
<operating instructions> The Bottom Bread (Constraints)

Real-World Execution

Case Study: Litigation Timeline Prompt

Contextual Anchoring

We don't just say "make a timeline." We define the jurisdiction (Delaware Chancery) and the user's role (Lead Counsel).

Multi-Shot Formatting

By providing an <example> tag, we show the AI exactly how to parse dates—ensuring 100% consistency with firm standards.

Guardrail Enforcement

The <operating instructions> act as the final check, preventing the AI from "summarizing" or "explaining" its work.

Prompt Terminal

<context>

You are a litigation analyst. Analyze the following complaint filed in Delaware Chancery Court.

<instructions>

Extract every date and associated action into a chronological timeline.

<format>

Use a markdown table with columns: Date | Party | Action | Document Reference.

<operating instructions>

Do not include introductory text. If a date is approximate, denote with [EST].

account_balance Context

Defines the perspective the AI should take. Without this, the model defaults to a generic assistant, losing the nuance of legal privilege, professional skepticism, or judicial procedure.

assignment_turned_in Instructions

The imperative command. Be explicit about the verb: "Extract," "Draft," "Redact," or "Critique." Avoid ambiguous language like "Help me with..."

grid_view Format

Dictates the UI of the output. JSON for data ingestion, Markdown for reports, or Bulleted Lists for memos. This reduces the manual "cleanup" time post-generation.

history_edu Example

One-shot or few-shot prompting. By providing one perfect example of what you want, you reduce "hallucination" by 40% in complex legal tasks.

gavel Operating Instructions

The negative constraints. "Do not mention you are an AI," "Do not provide legal advice disclaimers," "Use only the provided document." These ensure the output is ready for immediate professional use.

Ready to Certify?

Test your mastery of the XML Sandwich Framework.

Completion of this quiz is required for CLE credit eligibility for Module 4. Ensure you have reviewed the litigation timeline example above.

Start Chapter 3 Quiz arrow_outward