Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.

Best practices · AI

Prompt Engineering Best Practices

Opens with credits

Vendor-neutral prompt engineering best practices, checked against the official prompting guides from Anthropic, OpenAI and Google. It covers clear instructions, prompt structure and long context, few-shot examples, reasoning and prompt chaining, output and parameter control, and how to test, iterate on and maintain prompts as models change.

Written by Tauseef Fayyaz6 chapters, 24 practicesAbout 18 min23 quiz questionsReviewed 13 October 2026

What you will learn

6 chapters · about 18 min

  1. 1Clear instructions and contextMost bad outputs come from prompts that leave the model to guess. These practices close the gaps a reader with no background would fall into.4 practices · 3 min
  2. 2Prompt structure and long contextA prompt that mixes instructions, documents and examples needs clear boundaries. These practices make each part easy for the model to find and hard to confuse.4 practices · 3 min
  3. Examples and few-shot promptingExamples are one of the most reliable ways to steer format, tone and structure. These practices make them teach the pattern without being copied word for word.4 practices · 3 minOpens with credits
  4. Reasoning, decomposition and prompt chainingNewer models reason internally, which changes how much step-by-step prompting you need. These practices cover when to split work and how to match prompts to the kind of model.4 practices · 3 minOpens with credits
  5. Output format and model settingsThe shape of the answer and the sampling settings matter as much as the instructions. These practices keep output predictable and avoid settings that newer models no longer need.4 practices · 3 minOpens with credits
  6. Testing, iteration and upkeepA prompt is only better if you can show it. These practices turn prompt writing from guesswork into a loop you can measure and maintain.4 practices · 3 minOpens with credits

About this guide

Prompt engineering is the part of building with language models that looks easy and is not. Anyone can write a prompt that works on the three inputs they tried. Writing one that behaves the same way on thousands of real inputs, survives a model upgrade and can be changed safely by a teammate takes a set of habits. These prompt engineering best practices are those habits.

The advice here is vendor-neutral. It is drawn from the prompting guides that Anthropic, OpenAI and Google publish for their own models, and where those guides agree, the practice is presented as general advice. Where they differ, for example on where long context belongs or which sampling settings to touch, the guide says so and tells you to settle it with your own tests rather than with folklore.

Two ideas run through every chapter. First, a model is like a capable new colleague with no background on your task: whatever you leave unsaid, it has to guess. Second, a prompt change is only an improvement if you can measure it. All three vendors put success criteria and a test set before any prompt tuning, and so does this guide.

Read the chapters in order if you are new to writing prompts. If you already ship LLM features, jump to the chapter on reasoning and prompt chaining or the one on output control, where newer models have changed what works.

Common questions

What is prompt engineering?

Prompt engineering is the practice of writing and testing the instructions, context and examples you send to a language model so that it produces the output you need, reliably. It includes structuring the prompt, choosing examples, controlling the output format and measuring changes against a test set.

How many examples should a few-shot prompt have?

Anthropic recommends 3 to 5 relevant, diverse examples for best results, and Google recommends including few-shot examples in general while warning that too many can cause overfitting. Start with three varied examples, then test whether adding or removing one changes your scores.

Should I still tell models to think step by step?

On reasoning models, usually not. Google says Gemini 3 thinks internally so explicit step-by-step reasoning is usually unnecessary, and OpenAI suggests giving reasoning models a goal rather than detailed steps. On fast non-reasoning models, explicit steps can still help. Test both on your own data.

Where should long documents go in a prompt?

Anthropic and Google both recommend putting long documents first and the question or instructions at the end. Anthropic reports that a query at the end can improve quality by up to 30 percent in its tests. Wrap each document in tags with its source so the model can cite it.

Should I lower the temperature for more accurate answers?

Not by default. Google recommends keeping Gemini 3 sampling settings at their defaults and warns that a temperature below 1.0 can cause looping on complex reasoning. Use clear instructions, examples and structured output for consistency, and change sampling settings only if your evals show a gain.

Sources (5)

Checked against these, last on 13 October 2026.

  1. Prompting best practices, Anthropic docsplatform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
  2. Prompt engineering overview, Anthropic docsplatform.claude.com/docs/en/build-with-claude/prompt-engineering/overview
  3. Prompt engineering, OpenAI docsdevelopers.openai.com/api/docs/guides/prompt-engineering
  4. Prompt design strategies, Google AI for Developersai.google.dev/gemini-api/docs/prompting-strategies
  5. Effective context engineering for AI agents, Anthropic Engineeringwww.anthropic.com/engineering/effective-context-engineering-for-ai-agents

Picked from the other libraries by shared topics.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.

  • 1:1 Mentorship
  • Fresh Graduate Mentorship
  • Career Guidance

Brand deals, promos and partnerships: tauseeffayyaz@gmail.com