WriteMyAIPromptFree, no sign-up

Prompt engineering guides

15 guides covering how prompting actually works: what to put in a prompt and in what order, the techniques worth knowing, how the major models differ, and the harder topics — structured output, prompt injection, evaluation, and working with long documents.

Fundamentals

  • What is prompt engineering?

    Prompt engineering is the practice of writing and refining instructions so a language model produces the output you want reliably, rather than occasionally. It is less about clever phrasing than about supplying what the model cannot infer: the task stated precisely, the background it lacks, the shape of the answer, and how the result will be judged.

  • How to write an AI prompt that works

    To write a good AI prompt, state the task specifically, supply the background the model cannot infer, define the output format, list explicit constraints, show one example, and say how the result will be judged. Then order it so context comes before instructions and the task is restated last.

  • The ten most common prompting mistakes

    The most common prompting mistakes are using uncheckable adjectives like "good" and "engaging", withholding context the model cannot infer, asking leading questions that bias the answer, burying the instruction in the middle of a long prompt, and never testing a prompt against more than one input.

Techniques

  • Few-shot prompting

    Few-shot prompting is giving a model several worked examples inside the prompt so it can infer the pattern and apply it to new input. Two to five examples is the usual range. It works because an example communicates format, length, register and depth simultaneously — all things that stay ambiguous when described in prose.

  • Chain-of-thought prompting

    Chain-of-thought prompting is instructing a model to work through its reasoning step by step before giving an answer. It measurably improves accuracy on arithmetic, logic and multi-step analysis, because generating intermediate steps gives the model more computation to reach a conclusion. It does not help short creative work, and often makes it worse.

  • How to write a system prompt

    A system prompt is a persistent instruction that sets a model’s role, rules and boundaries for an entire conversation, separate from individual user messages. It is the right place for anything that should always be true — persona, tone, refusal rules, output format — and the wrong place for anything specific to one request.

  • Role prompting

    Role prompting is telling a model to adopt a specific persona so its vocabulary, priorities and level of detail match that role. It works when the role implies a concrete standard the model can apply. It does nothing when the role is flattery — "world-class expert" names no standard and changes little.

Models and formats

  • Prompting Claude vs ChatGPT vs Gemini

    Claude follows XML-delimited structure most reliably, ChatGPT works best with markdown headings and a separate system message, and Gemini prefers the task stated before the material rather than after. The content of a good prompt is identical across all three — only the packaging changes.

  • How to write image prompts

    Image prompts work as comma-separated descriptor stacks rather than sentences, because diffusion models respond to weighted terms rather than grammar. Order the stack subject, action, environment, composition, lighting, medium and style, then quality modifiers and parameters — terms nearer the front carry more weight.

  • Prompting AI for code

    A coding prompt should state the language and version, supply the surrounding code the model must fit into, name the error cases to handle, and require complete runnable output with no placeholder comments. Add an instruction to say so when unsure an API exists — that is where fabricated method names come from.

Going further

  • Getting structured output from AI

    To get reliable structured output, put the schema in the prompt before the source material, instruct the model to return only the data with no prose or code fences, give an explicit rule for missing values so it returns null rather than guessing, and use schema enforcement or response prefill where the API offers it.

  • Prompt injection and prompt security

    Prompt injection is an attack where instructions hidden inside content a model processes cause it to ignore its original instructions. It works because a model sees one undifferentiated stream of text and cannot inherently distinguish your instructions from a sentence inside a document it was asked to summarise.

  • How to evaluate a prompt

    To evaluate a prompt, collect at least ten inputs covering the real range including awkward cases, write down what a correct output looks like for each, and re-run the whole set after every change. Without a fixed test set, a change that improves one example is indistinguishable from a change that improves nothing.

  • Building reusable prompt templates

    A prompt template is a reusable prompt with placeholders for the parts that change, so a tested structure can be applied to many inputs. Name variables for what they mean, validate that none are left unreplaced, and version the template — a change that improves one input can quietly degrade another.

  • Prompting with long documents and large context

    Models recall information at the start and end of a long context more reliably than in the middle, an effect known as lost in the middle. Selecting the relevant few hundred words usually beats supplying tens of thousands, and where you must supply a lot, structure and ordering determine what actually gets used.

Looking for a definition instead? The glossary covers the vocabulary. Or put any of this into practice in the prompt builder.