Skip to main content

ChatGPT Prompt Engineering Guide

Learn proven techniques to write effective prompts for ChatGPT that get you better answers, more accurate code, and clearer explanations.

ChatGPT by OpenAI is one of the most versatile AI assistants available. From writing and coding to analysis and creative tasks, ChatGPT can help with almost anything—if you know how to ask.

This guide covers prompt engineering techniques that work across ChatGPT's capabilities, whether you're using GPT-4, GPT-4o, or other models.

Understanding ChatGPT's Strengths

ChatGPT excels at:

  • Conversational interactions - Natural back-and-forth dialogue
  • Following complex instructions - Multi-step tasks with conditions
  • Role-playing - Acting as experts, characters, or specific personas
  • Code generation - Writing, explaining, and debugging code
  • Creative writing - Stories, articles, marketing copy
  • Analysis - Summarizing, comparing, extracting insights

ChatGPT works best when you're clear about what you want and provide enough context for it to understand your needs.

ChatGPT Prompt Best Practices

1. Set a Clear Role

Tell ChatGPT who to be:

You are a senior software architect with 15 years of experience in distributed systems. Review this microservices architecture for potential issues.

2. Provide Context

Give background information:

I'm building a SaaS product for small businesses. We expect 1,000 users initially, growing to 50,000 in year one.

What database should I use for storing user analytics data?

3. Specify Output Format

Tell ChatGPT how to structure its response:

Compare React and Vue for a new project.

Format your response as:
- Overview (2 sentences)
- Pros of React (bullet points)
- Pros of Vue (bullet points)
- Recommendation with reasoning

4. Use Examples (Few-Shot)

Show what you want:

Convert these sentences to a formal tone:

Informal: "Hey, wanted to check if you're free tomorrow?"
Formal: "I am writing to inquire about your availability tomorrow."

Informal: "Can you send me that report ASAP?"
Formal:

5. Break Down Complex Tasks

Split complex requests into steps:

Help me write a business proposal:

Step 1: First, ask me 5 questions to understand my business and goals.
Step 2: Based on my answers, create an outline.
Step 3: After I approve the outline, write the full proposal.

Effective ChatGPT Prompt Examples

Coding Assistance

You are a TypeScript expert. Review this function for:
1. Type safety issues
2. Potential bugs
3. Performance improvements
4. Best practice violations

```typescript
function processUsers(users) {
  return users.map(u => ({
    ...u,
    fullName: u.firstName + ' ' + u.lastName
  }));
}
```

Provide specific fixes with code examples.

Writing Assistance

Write a product description for a wireless noise-canceling headphone.

Audience: Young professionals aged 25-35
Tone: Modern, confident, not overly technical
Length: 150-200 words
Must include: Battery life, comfort, and sound quality
Avoid: Clichés like "game-changer" or "revolutionary"

Analysis and Research

Analyze the pros and cons of remote work for software development teams.

Consider:
- Productivity and focus
- Collaboration and communication
- Work-life balance
- Team culture
- Hiring and talent

Present as a balanced analysis with a final recommendation.

Learning and Explanation

Explain Kubernetes to me in 3 levels:

1. Like I'm a complete beginner who doesn't know what containers are
2. Like I'm a developer who has used Docker but not orchestration
3. Like I'm preparing for a technical interview

For each level, include a real-world analogy.

Advanced ChatGPT Techniques

Chain of Thought

Ask ChatGPT to think step by step:

Solve this problem step by step, showing your reasoning at each stage:

A store offers a 20% discount on items over $50. If I buy 3 items priced at $30, $45, and $80, and there's a 10% sales tax applied after discounts, what's my total?

Self-Critique

Ask ChatGPT to review its own output:

Write a marketing email for our new product launch.

After writing, critique your own email:
- What could be misunderstood?
- What's missing?
- How could it be more compelling?

Then provide an improved version.

Perspective Taking

Get multiple viewpoints:

Analyze this startup idea from three perspectives:

1. A venture capitalist looking for investment opportunities
2. A potential customer who might use this product
3. A competitor in the market

Identify what each would find appealing and concerning.

Constraint-Based Generation

Set specific constraints:

Write a tweet about productivity.

Constraints:
- Exactly 280 characters
- Include one emoji
- Ask a question to encourage engagement
- Don't use the word "productivity"

Common ChatGPT Prompting Mistakes

Being Too Vague

Bad: "Help me with my code"

Good: "This React component re-renders unnecessarily. Identify why and suggest optimizations using useMemo or useCallback."

Not Providing Context

Bad: "Write me a cover letter"

Good: "Write a cover letter for a Senior Frontend Developer role at a fintech startup. I have 5 years of React experience and led a team of 3. Emphasize my leadership and fintech interest."

Asking Multiple Unrelated Questions

Bad: "What's the best programming language and also can you write me a poem?"

Good: Focus on one task at a time, or explicitly structure multi-part requests

Not Iterating

Bad: Accepting the first response without refinement

Good: "Good start, but make the tone more casual and add a specific example in paragraph 2"

ChatGPT Prompt Engineering Guide | One Shotr FAQ

Ready to optimize your prompts?

Get better results from ChatGPT Prompt Engineering | One Shotr with One Shotr.

Try One Shotr Free

3 free prompts - No credit card required