Skip to main content
All CollectionsTroubleshooting
How to write effective prompts for optimal output
How to write effective prompts for optimal output
Updated over 2 months ago

Writing an effective prompt is key to getting accurate, relevant, and useful responses from AI models. A well-crafted prompt sets clear expectations, provides necessary details, and helps the AI understand the specific context of your request. This guide outlines some best practices for writing prompts that will improve the quality of the AI's output.

1. Be Clear and Specific

Ambiguity is one of the main reasons for unsatisfactory AI responses. To avoid this:

  • Provide necessary details: Include all relevant information the AI needs to generate a good response. For example, if you want to know about a specific type of software, include the software's name and version, if applicable.

  • Avoid vague language: Use precise words instead of general terms. For instance, instead of asking, "Tell me about the weather," you can ask, "What is the current temperature in Paris?"

Example of a vague prompt:

  • “Write me a test script."”

Improved prompt:

  • “Write me a Cypress test in JavaScript to test a simple login page.”

2. Set the Desired Format

If you expect the response in a certain format, specify it. The AI can provide information in the form of lists, tables, summaries, comparisons, and more.

3. Define the Scope

Clearly define the scope of your question or request. This helps the AI understand how broad or narrow its response should be.

Example of an unclear scope:

  • “Create a test script.”

Improved prompt:

  • “Create a Selenium test script in Python to validate the checkout process, including steps for adding an item to the cart, applying a discount code, and completing the payment.”

4. Incorporate Context When Necessary

Context helps guide the AI’s response. Provide background information if your query is part of a larger task or problem. For example, if you're asking for a code review, mention what aspect should be analyzed: performance, security, or coding standards.

  • Bad Prompt: "Review this code."

  • Good Prompt: "Review the following Python code for potential security vulnerabilities and suggest improvements."

5. Use Examples to Clarify

When you're looking for a specific type of output, giving an example can significantly improve the quality of the response.

6. Break Complex Queries Into Parts

If you have a multi-faceted question, breaking it into smaller, sequential steps can result in a more organized and comprehensive response.

Good example:

First, you ask for test cases for a login feature:

  • "Can you suggest some test cases for the login function of a web application?"

Then, you refine one specific test case:

  • "Can you further elaborate on the test case for invalid password checks?"

Bad example:

  • "Can you provide all the test cases for a web application, including security, performance, and validation?"

7. Use Follow-up Prompts for Clarification

Sometimes, the initial response may not be perfect, and that’s okay! You can refine the AI’s output by asking follow-up questions or adding more context.

Good example:

First, you ask for a strategy:

  • "What is a good strategy for testing an application?"

Then, you ask for clarification on a specific part:

  • "Can you explain more about how load testing works in this context?"

8. Specify Tone or Style

If you need the AI to respond in a particular tone (e.g., formal, conversational, humorous), clearly mention that in your prompt.


Good example:

Specify a formal tone:

  • "Can you explain what a unit test is in a formal tone?"

Specify an informal tone:

  • "Can you tell me what a unit test is in a casual and friendly way?"

Bad example:

  • "What is a unit test?"

9. State the Length of the Response

Specifying the desired length ensures that the response fits your needs, whether you want a brief answer or an in-depth explanation.

Good example:

Request a short response:

  • "Can you give me a brief summary of the benefits of automated testing?"

Request a detailed response:

  • "Can you give me a detailed explanation of how to set up a test strategy for a mobile application?"

Bad example:

  • "Can you explain how to set up a test strategy?"

10. Iterate and Experiment

Don’t be afraid to experiment with different prompts to find what works best. Sometimes, a slight rephrasing can lead to a more satisfying output.

Good example:

First, you ask:

  • "Can you write a simple example of an API test?"

If the answer is too complex, you rephrase the question:

  • "Can you write a simplified example of an API test for beginners?"

Bad example:

  • Repeating the same prompt: "Can you write an API test?"

Quick Checklist for Writing Prompts:

  • Is my question clear and specific?

  • Have I provided enough context?

  • Did I state the format, tone, or length I want?

  • Am I asking for too much in one prompt? Can I break it down?

  • Have I given an example if needed?

Did this answer your question?