Skip to content

Prompt Engineering Best Practices

Master the art of prompt engineering with these proven best practices and guidelines.

Bad:

Write something about marketing.

Good:

Write a 500-word blog post about email marketing best practices for small businesses, focusing on subject lines, personalization, and automation.

Bad:

Explain this error.

Good:

I'm getting a "TypeError: Cannot read property 'map' of undefined" error in my React component when trying to render a list of users. Here's my code: [CODE]. The users array should come from an API call. What's causing this error and how do I fix it?

Bad:

Format this data nicely.

Good:

Format this sales data as a table. Here's an example of the desired output:
| Product | Q1 Sales | Q2 Sales | Growth |
|---------|----------|----------|--------|
| Widget A | $10,000 | $12,000 | +20% |
Now format this data: [YOUR DATA]

Use this structure for consistent results:

  • Context: Set the scene
  • Role: Define the AI’s persona
  • Instructions: Clear, specific directions
  • Samples: Provide examples
  • Parameters: Set constraints and format
Context: I'm launching a new SaaS product for project management.
Role: You are a senior marketing copywriter with expertise in SaaS products.
Instructions: Write compelling product descriptions that highlight key benefits and address common pain points.
Samples: Here's an example for a similar product:
"Streamline your workflow with intuitive task management that keeps your team aligned and productive."
Parameters:
- Length: 2-3 sentences
- Tone: Professional yet approachable
- Include one key benefit
- End with a call-to-action
  • Write a summary
  • Analyze the data
  • Compare options
  • Generate ideas
  • Explain the concept

Instead of “make a list,” specify:

  • Numbered list
  • Bullet points
  • Table format
  • JSON structure
  • Paragraph form
Write a product review that:
✓ Is between 150-200 words
✓ Includes 3 pros and 2 cons
✓ Uses a balanced, objective tone
✓ Ends with a 1-5 star rating
✗ Does not mention competitor brands
✗ Avoids technical jargon
You are a [ROLE] helping [AUDIENCE] with [TASK].
Goal: [SPECIFIC_OBJECTIVE]
Context: [BACKGROUND_INFO]
Requirements:
- [REQUIREMENT_1]
- [REQUIREMENT_2]
- [REQUIREMENT_3]
Format: [OUTPUT_FORMAT]
Input: [USER_INPUT]
  1. Use descriptive brackets: [TARGET_AUDIENCE] not [X]
  2. Provide defaults: [TONE: professional]
  3. Group related variables: [PRODUCT_NAME], [PRODUCT_FEATURES]
  4. Include validation: [WORD_COUNT: 100-300 words]
  1. Run Multiple Tests: Try different inputs
  2. Check Edge Cases: Test with unusual scenarios
  3. Validate Output: Ensure results meet requirements
  4. Compare Versions: A/B test prompt variations
  1. Start Simple: Begin with basic prompt
  2. Add Specificity: Include more details
  3. Test Results: Evaluate output quality
  4. Refine Language: Adjust wording
  5. Optimize Performance: Fine-tune for consistency
  • Works well with conversational tone
  • Responds to “Let’s think step by step”
  • Good at maintaining context across messages
  • Excels at analytical tasks
  • Prefers structured instructions
  • Strong at following complex formatting rules
  • Good at creative tasks
  • Responds well to examples
  • Effective with multimodal inputs
  1. Vague Instructions

    • “Make it better”
    • “Fix this”
    • “Write something”
  2. Overloading with Information

    • Too many requirements in one prompt
    • Conflicting instructions
    • Information overload
  3. Assuming Context

    • Not explaining background
    • Using undefined terms
    • Skipping important details
  4. Ignoring Output Format

    • No format specifications
    • Unclear structure requirements
    • Missing examples
  1. Specific Instructions

    • “Rewrite this paragraph to be more concise while maintaining the key points”
    • “Debug this code by identifying the syntax error”
    • “Write a 300-word product description”
  2. Focused Requests

    • Break complex tasks into steps
    • One main objective per prompt
    • Clear priority order
  3. Providing Context

    • Explain the situation
    • Define technical terms
    • Share relevant background
  4. Clear Formatting

    • Specify desired structure
    • Provide output examples
    • Set length requirements
  • Relevance: Does the output address your needs?
  • Accuracy: Is the information correct?
  • Consistency: Do you get similar results each time?
  • Efficiency: How many iterations does it take?
  1. Keep a Prompt Library: Save your best prompts
  2. Track Performance: Note what works well
  3. Document Variations: Record different versions
  4. Share with Team: Collaborate on improvements

Ready to apply these best practices?