Specifying Output Format

Tell the model exactly what the reply should contain, a full file, a diff, a snippet, or JSON, so it drops straight into your workflow.

TL;DR

  1. State the exact output you want: full file, unified diff, snippet, or structured JSON.
  2. The right format depends on how you will consume the result, by eye, by patch, or by program.
  3. Naming the format and saying 'nothing else' removes the cleanup step.

Pick By Consumer

    For Your Eyes

    A snippet or full file is fine when you will read and paste it yourself.

    "Return the function in one code block."
    For A Patch

    A diff applies cleanly and shows exactly what changed.

    "Return a unified diff against the
    current file."
    For A Program

    Strict JSON (or another machine format) when output is parsed downstream.

    "Return only JSON matching this schema."

Code Formats

    Full File

    Best for new or small files; the model returns the whole thing.

    "Output the complete file, ready to save."
    Changed Function Only

    For edits, ask for just the function that changed to save context.

    "Return only the updated handler,
    not the whole module."
    Unified Diff

    Shows additions and removals for quick, safe review.

    "Give a git-style diff with 3 lines
    of context."

Structured Output

    Describe The Schema

    Spell out keys, types, and whether fields are optional.

    { "name": string,
      "deps": string[],
      "risky": boolean }
    Give One Example

    A single example object removes ambiguity about shape.

    { "name": "auth", "deps": ["jwt"],
      "risky": true }
    Forbid Extras

    Say no prose and no markdown fences so a parser does not choke.

    "Return only the JSON. No markdown,
    no commentary."

Trim The Noise

    Say 'Only'

    The word 'only' is the fastest way to cut explanation you do not want.

    "Return only the code."
    Separate Sections

    If you want notes too, ask for them labeled and after the code.

    "Code first, then a 1-line rationale."
    Set Length

    Cap explanations so the reply stays scannable.

    "Explain in at most two sentences."

Tips

  1. For edits to existing code, ask for a diff or just the changed function so you can see what moved.
  2. When output feeds a script, demand strict JSON with a named schema and 'no prose, no markdown'.

Warnings

  1. Without a format you get prose wrapped around code that you must trim before using.
  2. Asking for a 'full file' of a large module wastes context and risks the model dropping parts.

In Practice

FAQ