← Blog

Best Prompt Engineering Tips for Better LLM Output

2026-09-20 · 5 min read · SubToAPI Team

If you're searching for the best prompt engineering tips, you probably already know the basics — you're looking for the specific, actionable habits that separate mediocre outputs from consistently good ones. This isn't a list of vague advice like "be clear" or "give context." Below are concrete tips you can apply today, with examples, that address the actual failure modes people run into when working with LLMs in production.

The core idea to internalize first: a prompt is not a question, it's a specification. The more precisely you define the task, format, constraints, and edge cases, the less the model has to guess — and guessing is where quality degrades.

Structure Your Prompt Like a Spec, Not a Sentence

Instead of writing one long paragraph, break your prompt into labeled sections. Models handle structured input more reliably than dense prose.

Task: Summarize the following support ticket in 2 sentences.
Audience: Internal engineering team.
Constraints: No customer names, no speculation about root cause.
Format: Plain text, no markdown.

Ticket:
"""
{ticket_text}
"""

This separation of task/constraints/format/input reduces ambiguity and makes it trivial to swap inputs programmatically without rewriting the whole prompt.

Put Instructions Before the Data, Then Repeat Key Constraints After

Models weight the beginning and end of a prompt more heavily than the middle — a well-documented effect sometimes called "lost in the middle." For long inputs (documents, transcripts, logs), state the instruction first, then the data, then restate the critical constraint at the end.

Extract all dates mentioned in the document below. Return them as ISO 8601.

Document:
{long_document}

Reminder: return ONLY a JSON array of dates, nothing else.

This single change fixes a surprising number of "the model added extra commentary" complaints.

Use Few-Shot Examples for Anything Format-Sensitive

If output format matters — JSON schemas, specific tone, classification labels — show 2-3 examples rather than describing the format in words. Examples compress ambiguity faster than instructions.

Classify the sentiment as positive, negative, or neutral.

Text: "The app crashed twice today." → negative
Text: "Support fixed my issue in minutes." → positive
Text: "I updated my billing address." → neutral

Text: "{input_text}" →

Few-shot prompting costs more tokens, but it reliably outperforms zero-shot for structured or subjective tasks.

Separate System Instructions from User Input

Mixing your instructions and the user's data in one string is a common source of prompt injection and inconsistent behavior. Use the system role (or an equivalent structural separation) to hold your rules, and keep user-supplied content isolated and clearly delimited.

const response = await fetch("https://api.subtoapi.app/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    system: "You are a strict JSON extraction engine. Never include explanations.",
    messages: [
      { role: "user", content: `Extract the invoice total from: """${userInput}"""` }
    ]
  })
});

Keeping the system prompt stable and versioned separately from user input also makes it much easier to test changes without breaking the parts that already work. See /docs/messages for the full request format.

Tell the Model What Not to Do — But Sparingly

Negative constraints ("don't apologize," "don't include a preamble," "don't use markdown") work, but stacking too many dilutes their effect. Pick the 1-3 constraints that actually matter for your use case and state them explicitly rather than listing every possible thing to avoid.

Ask for Reasoning Only When You Need It

Chain-of-thought style prompting ("think step by step") improves accuracy on multi-step reasoning tasks, but it adds latency and cost, and for simple classification or extraction tasks it can actually introduce noise. Reserve it for genuinely hard problems — math, multi-step logic, debugging — and skip it for straightforward lookups or formatting tasks.

Constrain the Output Format Explicitly When You Need to Parse It

If your code parses the model's response, don't hope it returns clean JSON — force it:

Return your answer as valid JSON matching this exact schema, with no other text:
{"category": string, "confidence": number, "reason": string}

Pair this with a strict system prompt and, where the API supports it, validate the response before passing it downstream. If you need tool-style structured calls instead of raw JSON parsing, check /docs/tools.

Test Prompts Against Real Edge Cases, Not Just Happy Paths

The prompt that works on your three test inputs often breaks on the fourth. Before shipping, run it against:

If you're building this into a product, streaming responses back to the client while you validate is often better UX than waiting for the full completion — see /docs/streaming if you're wiring this into an API-based workflow.

Version and Diff Your Prompts

Treat prompts as code. Keep them in version control, log which prompt version produced which output, and A/B test changes before rolling them out broadly. Small wording changes can shift output quality meaningfully, and without versioning you lose the ability to debug regressions.

Iterate With the Model's Actual Failures, Not Assumptions

When output is wrong, don't guess why — feed the bad output back and ask the model to critique its own response against your original instructions. This often reveals which part of the prompt was ambiguous faster than manual inspection.

If you're building an application on top of Claude and want a straightforward way to turn these prompting patterns into a production API — with streaming, tool use, and per-key usage tracking — SubToAPI wraps your existing Claude access into a standard HTTPS API. Check /docs/quickstart to get a key running in a few minutes, or /pricing for plan details.

FAQ

What's the single highest-impact prompt engineering tip? Separate your instructions from your input data and be explicit about the output format. Most quality issues trace back to ambiguity in one of these two areas rather than the model's capability.

Do longer, more detailed prompts always produce better results? No. Past a certain point, extra detail adds noise and can bury the constraints that matter most. Prioritize clarity and structure over length — a well-organized short prompt often outperforms a rambling long one.

How do I know if a prompt change actually improved output? Run it against a fixed set of test inputs, including edge cases, before and after the change, and compare results side by side. Anecdotal "it feels better" testing misses regressions that show up on inputs you didn't happen to try.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →