The Complete OpenAI Prompt Engineering Guide
Everything from OpenAI's official prompt engineering docs. Six core strategies with tactics, examples, and real before/after comparisons.
Official OpenAI docs →The six strategies
OpenAI's guide is built around six core strategies, each with specific tactics you can apply immediately: 1) Write clear instructions, 2) Provide reference text, 3) Split complex tasks into subtasks, 4) Give models time to think, 5) Use external tools, 6) Test changes systematically. Master these in order and you'll get dramatically better results from any GPT model.
Write clear instructions
The number one mistake is being vague. GPT can't read your mind. Include details about the desired context, outcome, length, format, and style. Ask the model to adopt a persona for domain expertise. Use delimiters (triple quotes, XML tags, markdown headers) to separate instructions from content. Specify exact steps for multi-part tasks. Provide examples of desired output. Instead of 'summarize this', say 'summarize in 3 bullet points, each under 20 words, focusing on business impact.'
Provide reference text
When you need factual accuracy, give the model source material and instruct it to answer using only that text. This is the simplest form of RAG (Retrieval-Augmented Generation) and dramatically reduces hallucination. You can instruct the model to answer with citations from the provided text, or to say 'I don't know' if the answer isn't in the source material.
Split complex tasks into subtasks
Complex tasks have higher error rates than simple ones. Instead of one massive prompt, break the work into a pipeline of focused steps. Use intent classification first to route to the right instructions. For long conversations, summarize previous dialogue to maintain context without hitting token limits. Think of it like software engineering: decompose the problem.
Give models time to think
Chain-of-thought prompting is one of the most powerful techniques available. Ask the model to work through its reasoning before giving a final answer. This is especially effective for math, logic, code analysis, and multi-step problems. You can use 'inner monologue' to hide the reasoning from end users, or use a sequence of queries where the model's thinking is kept separate from the final output.
Use external tools
Don't force the model to do everything. Compensate for weaknesses by feeding outputs of other tools into the model. Use text retrieval (RAG) to inject relevant documents dynamically. Use code execution for accurate math and data processing. Give the model access to APIs through function calling. Embeddings-based search can efficiently find relevant knowledge at runtime.
Test changes systematically
If a prompt modification improves one example, that doesn't mean it's better overall. It might actually hurt other cases. Define a comprehensive test suite ('eval') that covers the full range of expected inputs. Evaluate outputs against gold-standard answers, either automatically or with a separate model evaluation step. Without systematic testing, you're flying blind.