Prompt Engineering 101: Getting Better Results from LLMs

Prompt engineering sounds like it should be obsolete as models get smarter, but well-structured prompts still reliably outperform vague ones, even on the most capable frontier models. A handful of concrete techniques account for most of the improvement.

Be Specific About Format and Constraints

Vague:
"Write about database indexing"

Specific:
"Write a 200-word explanation of database indexing for a junior
developer who knows SQL basics but has never used an index.
Include one concrete example using a CREATE INDEX statement."

The model isn’t reading your mind — every constraint you leave implicit is a constraint it has to guess at, and it will guess wrong at least some of the time.

Few-Shot Examples Anchor the Output Format

Classify the sentiment of each review as positive, negative, or neutral.

Review: "This product exceeded my expectations!"
Sentiment: positive

Review: "It arrived broken and support never responded."
Sentiment: negative

Review: "It's fine, does what it says."
Sentiment: neutral

Review: "Absolutely love the build quality and the price."
Sentiment:

Showing 2-3 examples of the exact input/output pattern you want is often more reliable than describing the desired format in prose, especially for structured or classification-style tasks.

Ask the Model to Reason Before Answering

For anything involving multi-step logic, explicitly asking the model to work through its reasoning before giving a final answer measurably improves accuracy on harder problems — the model effectively gets to “think out loud” rather than jumping straight to a guess.

Before answering, list the relevant facts and work through the
problem step by step. Then give your final answer on a new line
starting with "Answer:".

Iterate Like You Would with Code

Treat your first prompt as a draft, not a final version. If the output isn’t what you wanted, the fastest fix is usually adding one more explicit constraint that was implicit in your head but never made it into the text — not rewriting the whole prompt from scratch.