Prompt Writing Best Practices Public Preview

DigitalOcean GenAI Platform lets you build GPU-powered AI agents with fully-managed deployment. Agents can use pre-built or custom foundation models, incorporate function and agent routes, and implement RAG pipelines with knowledge bases.


Effective prompts guide your agent to accurate, relevant responses by ensuring specificity, context, and intent, similar to asking well-structured questions to a support team.

When testing your agent, well-designed prompts identify training gaps, refine responses, and improve accuracy and consistency, enhancing the user experience.

Maintain a Neutral Tone

When writing prompts for your agent, maintain a neutral tone and avoid sarcasm or figurative language. Sarcasm or figurative language may confuse the agent, leading to literal but unhelpful responses. A neutral tone ensures concise, balanced, and unbiased answers.

Maintain neutrality by:

  • Using direct, straightforward language.
  • Replacing figurative expressions (for example, metaphors, idioms, sarcasm) with literal statements.
  • Avoiding emotional language or biased terms.
Prefer Avoid
Summarize the key points of the generative AI article accurately.
Can you summarize the main points of this article about generative AI?

Ask Intentional Questions

When asking your agent questions, make them explicit, concise, and tailored to your needs. Avoid vague or broad phrasing to ensure accurate and actionable responses.

Ask intentional questions by:

  • Providing clear context for the agent to focus.
  • Including desired outcomes or format, like a code snippet, step-by-step instructions, list, or paragraph.
  • Indicating the level of detail needed, such as a brief overview or detailed explanation.
  • Adding relevant background information for context.
Prefer Avoid
Explain how I can improve the accuracy of my model, specifically through hyperparameter tuning?
Can you explain how I can improve the accuracy of my model?

Limit Prompts to One Question

When writing prompts, ask one question at a time and avoid combining multiple questions in a single prompt.

Compound questions can confuse the agent, leading to incomplete or skipped answers. Simple, focused prompts ensure direct and relevant responses.

Prefer Avoid
What is RAG?" After receiving the answer, follow up with, “How is RAG useful?
Can you explain what RAG is, and also tell me how it is useful?

Separate Complex Prompts

If your prompt is complex, divide it into smaller questions to guide your agent effectively toward the desired answer.

Separating complex prompts ensures specific, accurate, and complete responses while avoiding vague or partial answers. It also helps address each part of your query systematically.

Separate complex prompts by:

  1. Identifying the components of the prompt and creating smaller, focused questions for each.
  2. Starting with foundational questions to gather background information before addressing the main topic.
  3. Using a step-by-step approach to cover different aspects of the query and combining the answers for a complete response.
Prefer Avoid
  1. How do I create a model for text generation?
  2. How do I train a model for text generation?
  3. How do I evaluate the performance of a model for text generation?
How do I create, train, and evaluate a model for text generation?

Add Examples or Screenshots

When writing prompts, add examples or screenshots if the question alone might confuse the agent.

Examples or screenshots provide context, clarify your query, and help the agent understand the situation or desired outcome.

Use examples or screenshots to improve prompts by:

  • Showing the response you want with an example or screenshot.
  • Highlighting incorrect outcomes to help the agent avoid them.
  • Including step-by-step examples or screenshots to illustrate issues, such as an error in a script.
  • Demonstrating how specific inputs should produce specific outputs.
Prefer Avoid
I tried running a Python script (see the attached screenshot), but I keep getting a ‘TypeError: unsupported operand type(s)’. Could you help identify the cause of this error?
I tried running a Python script, but I keep getting a type error.
In this article...