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:

  1. Be specific and clear

    Vague prompts produce vague answers. State exactly what you want, the format you need, and any constraints.

  2. Provide context

    Tell ChatGPT who you are, what the task is for, and any relevant background information.

  3. Specify the output format

    Want a table? Bullet points? JSON? Code? Tell ChatGPT explicitly how to format the response.

  4. Set constraints

    Define limits like word count, reading level, tone, or what to include and exclude.

  5. 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 Prompt Example
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.

Few-Shot Example
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:
Tip: 2-3 examples usually suffice. Make your examples diverse enough to show the pattern but consistent enough to establish the style.

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.

Chain of Thought Example
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.
💡
Note: The o1 and o3 models use chain of thought internally and automatically. You do not need to explicitly ask them to "think step by step" - they already do this. This technique is most useful with GPT-4o and GPT-4o mini.

Structured Output

Request specific output formats to get machine-parseable or consistently structured results:

JSON Output Example
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:

Markdown-Structured Prompt
# 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:

Image Analysis Prompts
# 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:

Code Interpreter Prompt
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.
Common mistake: Do not assume ChatGPT remembers previous conversations. Each new conversation starts fresh (unless Memory is enabled). Always include all necessary context in your prompt.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.