Prompting Guide Intermediate
The quality of ChatGPT's output depends directly on the quality of your input. This lesson covers proven techniques for crafting effective prompts, from basic principles to advanced strategies like chain of thought and structured output.
Fundamental Prompting Principles
Follow these core principles for better results with any ChatGPT prompt:
-
Be specific and clear
Vague prompts produce vague answers. State exactly what you want, the format you need, and any constraints.
-
Provide context
Tell ChatGPT who you are, what the task is for, and any relevant background information.
-
Specify the output format
Want a table? Bullet points? JSON? Code? Tell ChatGPT explicitly how to format the response.
-
Set constraints
Define limits like word count, reading level, tone, or what to include and exclude.
-
Iterate and refine
If the first response is not perfect, provide feedback and ask ChatGPT to adjust.
System Prompts
A system prompt is a special instruction that sets the behavior and personality of ChatGPT for an entire conversation. In the API, it uses the system role. In the ChatGPT UI, you can set this through Custom Instructions or Custom GPTs.
System: You are a senior Python developer with 15 years of experience. You write clean, well-documented code following PEP 8 conventions. When asked to write code: - Always include type hints - Add docstrings to all functions - Include error handling - Provide usage examples - Explain your design decisions briefly User: Write a function to retry an HTTP request with exponential backoff.
Custom Instructions
Custom Instructions let you set persistent preferences that apply to every conversation. You configure two sections:
| Section | Purpose | Example |
|---|---|---|
| "What would you like ChatGPT to know about you?" | Provide context about yourself | "I'm a full-stack developer working with React and Node.js. I prefer TypeScript." |
| "How would you like ChatGPT to respond?" | Define response style and format | "Be concise. Use code blocks with syntax highlighting. Skip basic explanations." |
Few-Shot Prompting
Provide examples of the desired input-output pattern before your actual request. This is one of the most reliable techniques for getting consistent results.
Convert these product descriptions into taglines: Product: A noise-canceling headphone with 30-hour battery Tagline: Silence the world. Listen for days. Product: A waterproof backpack with solar charging panel Tagline: Adventure-proof. Sun-powered. Product: A smart thermostat that learns your schedule Tagline:
Chain of Thought Prompting
Ask ChatGPT to think step by step before giving a final answer. This dramatically improves accuracy on complex reasoning, math, and logic problems.
User: A store sells apples for $1.50 each. If you buy 5 or more, you get a 20% discount. Tax is 8%. How much do 7 apples cost? Think through this step by step before giving the final answer.
Structured Output
Request specific output formats to get machine-parseable or consistently structured results:
User: Analyze this customer review and return a JSON object with these fields: - sentiment: "positive", "negative", or "neutral" - topics: array of discussed topics - rating_estimate: 1-5 score - summary: one-sentence summary Review: "The laptop is incredibly fast and the screen is gorgeous. Battery life could be better though - I only get about 4 hours. Great value for the price." Return only valid JSON, no other text.
Using Markdown in Prompts
ChatGPT understands and generates markdown. Use it to structure complex prompts:
# Task Write a technical blog post about React Server Components. ## Requirements - **Length:** 800-1000 words - **Audience:** Intermediate React developers - **Tone:** Technical but approachable ## Structure 1. Introduction (what and why) 2. How they work (with code examples) 3. Benefits vs traditional SSR 4. When to use them 5. Conclusion ## Constraints - Use React 19 syntax - Include at least 3 code examples - Add a comparison table
Image Prompts
When uploading images to ChatGPT, write clear prompts about what you want done with the image:
# Analyzing a screenshot of code: "This screenshot shows an error in my Python code. Identify the bug and suggest a fix." # Analyzing a chart: "Describe the trends shown in this bar chart. What are the top 3 insights?" # Extracting data from an image: "Extract all the text from this receipt and organize it into a table with columns: Item, Quantity, Price"
Code Interpreter Prompts
When using Code Interpreter (Advanced Data Analysis), be explicit about what you want:
User: I've uploaded a CSV file with sales data. Please: 1. Load the data and show the first 5 rows 2. Create a bar chart of monthly revenue 3. Calculate the top 5 products by total sales 4. Generate a summary report as a downloadable PDF Use matplotlib for charts with a clean, professional style. Use blue (#2563eb) as the primary color.
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX