// Fundamentals

How to Write Prompts That Actually Work

A practical framework — not theory

Most bad AI output isn't a model problem. It's a prompt problem. The same model that gives you a generic, hedge-everything answer to a vague prompt can give you something sharp and specific if you structure the request differently. Here's the framework we use inside PromptLab's auto-engineer feature, broken down so you can apply it manually too.

Why most prompts fail

A language model doesn't know what you meant. It only knows what you wrote, and it predicts the most likely useful response to that text. When the prompt is vague, the most likely response is an average one: safe, generic, a little long, and aimed at nobody in particular. That's why "write me a blog post about love" gives you the same polished-but-empty article everyone else gets.

The fix isn't a magic phrase. It's removing the guesswork. Every detail you leave out is a decision the model makes for you, and it makes the safest one.

The four parts of a working prompt

Every prompt that reliably produces good output has some version of these four elements, even if they're not labeled:

1. Role

Tell the model what perspective to answer from. Not "you are a helpful assistant" — that's the default anyway. Be specific: "you are a senior backend engineer reviewing this code for production readiness" changes the vocabulary, the assumptions, and the level of detail you get back. A good role answers two questions: who is speaking, and what do they care about?

2. Context

Models can't read your mind or your codebase. If the task depends on constraints — a tech stack, an audience, a tone, a prior decision you've already made — state it. Omitted context is the single biggest cause of generic output. A useful test: if you handed this prompt to a smart freelancer who knew nothing about your project, would they have what they need?

3. Task

Say exactly what you want done, as a verb: "summarize," "rewrite," "critique," "generate three variations," "find the bug." Vague tasks like "help me with this" force the model to guess your intent, and it will guess conservatively. One prompt should carry one main task.

4. Format

Specify how you want the answer structured — bullet points, a table, JSON, under 200 words, no preamble. Without this, models default to a safe middle ground: some prose, some structure, usually longer than you wanted. Format instructions also make output easier to reuse, because you know what shape it will arrive in.

A before-and-after example

Weak prompt:

Help me write a product description for my app.

Strong prompt:

You are a conversion-focused copywriter for developer tools. Write a 3-sentence product description for a Chrome extension that auto-fills API keys during local testing. Audience: backend developers who hate repetitive setup. Tone: direct, no marketing fluff. No emoji.

The second version doesn't just get you a better answer — it gets you a predictable answer, which is what actually matters when you're iterating.

A second example: code review

Weak prompt:

Review this function.

Strong prompt:

You are a senior engineer doing a pre-merge review of a Node.js API handler. Check for: unhandled errors, missing input validation, and anything that could block the event loop. List each issue with the line it affects and a one-line fix. If the code is fine, say so in one sentence. Do not rewrite the whole function.

Notice what changed. The role sets the standard, the checklist narrows the search, the output format makes the review scannable, and the last line stops the model from doing more than you asked.

Use examples when format matters

Sometimes describing the output is harder than showing it. Include one or two short examples of what a good answer looks like, and the model will match the pattern. This is often called few-shot prompting, and it's especially useful for tone, naming conventions, classification labels and anything with a strict structure:

Classify each support message as BUG, BILLING, or FEATURE. Reply with the label only. Message: "I was charged twice this month" → BILLING Message: "The export button does nothing on Safari" → BUG Message: "Can you add dark mode?" →

Set constraints, including what to exclude

Constraints stop the model from drifting. Useful ones include length ("under 120 words"), audience ("for a non-technical founder"), style ("no jargon, no buzzwords") and scope ("only use the information below"). Telling the model what not to do is often faster than describing everything you do want.

Iterate with one change at a time

Prompting is a loop, not a single shot. When the output is off, resist rewriting everything. Instead:

  1. Run it and read the output critically.
  2. Diagnose the gap. Is it the wrong tone, missing context, wrong length or wrong structure?
  3. Change one thing that addresses that gap.
  4. Run it again and compare to the last version.

Changing one variable at a time is how you learn what actually moves the output. If you change five things and the result improves, you won't know which one mattered.

Common mistakes

A reusable template

When you're unsure where to start, fill in this skeleton and delete what you don't need:

You are [specific role]. Context: [who it's for, what it's for, anything the model must know]. Task: [one clear verb and object]. Constraints: [length, tone, things to avoid]. Format: [bullets, table, JSON, number of items].

Quick checklist before you hit send

Frequently asked questions

How long should a prompt be?

As long as it needs to be to remove guesswork, and no longer. A precise four-sentence prompt beats a rambling page of background. Add length only when it adds information the model needs.

Do I always need to start with "You are..."?

No. A role helps most when the task depends on expertise or perspective, like review, critique or copywriting. For simple lookups or rewrites, clear context and task are enough.

Will the same prompt work on Claude, ChatGPT and Gemini?

Usually the structure carries over, but each model has its own habits in tone, length and formatting. The reliable way to find out is to run the same prompt side by side and compare, which is what PromptLab's Compare tab is for.

Why do I get different answers from the same prompt?

Models sample their output, and the temperature setting controls how much randomness that involves. Lower values give steadier, more repeatable answers. Higher values give more varied, creative ones. For factual or structured tasks, go lower. For brainstorming and writing, go higher.

Where this fits into PromptLab

PromptLab's auto-engineer feature applies this framework automatically — you give it a rough idea, and it fills in role, context, format, and task structure before sending it to the model. The template library takes this further with pre-built structures for common jobs like code review, marketing copy, and security analysis, so you're not rebuilding the same scaffolding every time.

TRY THE PROMPT ENGINEER →