ChatGPT Prompt Engineering Cheat Sheet

Master ChatGPT prompting — role assignment, chain-of-thought, few-shot, system messages, and temperature tuning for optimal outputs from GPT-4 and GPT-4o.

Last Updated: May 1, 2025

Core Techniques

TechniqueHow It WorksBest For
Role Assignment'You are an expert Python developer' — sets expertiseConsistent expertise, tone control
Chain-of-Thought'Let's think step by step' — forces reasoningMath, logic, multi-step problems
Few-Shot2-5 examples of input→output pairsFormat control, style matching
Zero-ShotDirect instruction, no examplesSimple, well-defined tasks
Structured Output'Return JSON with keys: name, age'API responses, parsing
Self-ConsistencyAsk 3-5 times → majority answerImproving accuracy

System Message Patterns

'You are a senior software engineer. Be concise. Prefer code.'
Role + style + preference
'NEVER make up information. If unsure, say so.'
Honesty guardrail
'Respond in JSON only: {"analysis":..., "confidence":0-100}'
Structured output

Parameters Guide

ItemDescription
Temperature (0-2)0=deterministic, 0.7=balanced, 1.5+=creative. Lower for facts, higher for brainstorming.
Top-P (0-1)Nucleus sampling — 0.1=only most likely tokens. Controls diversity differently from temperature.
Max TokensLimits response length — 256 for short, 2048+ for essays/code.
Frequency PenaltyReduces word repetition. Higher = less repetition.
Presence PenaltyEncourages new topics. Higher = less repetition of mentioned concepts.

Advanced Patterns

ItemDescription
Tree of ThoughtsExplore multiple reasoning paths → evaluate → commit. For complex planning.
ReAct PatternThought → Action → Observation loop. For tool-use and multi-step reasoning.
Constitutional AI'Check your answer against these principles: 1. Accuracy 2. Helpfulness'
Prompt ChainingBreak complex task: extract entities → classify → summarize → format
Iterative RefinementStart broad → refine based on output → add constraints → repeat
Pro Tip: The system message sets persistent context — use it to define role, tone, and constraints. The user message delivers the task.