Skip to content

How to Write a Good Prompt

Guidelines for Crafting Effective Prompts

  1. Be Clear and Specific:
  2. Clearly define the task or objective.
  3. Avoid ambiguous language.

Example: - Bad: "Write a function." - Good: "Write a Python function to calculate the factorial of a number using recursion."

  1. Provide Context:
  2. Include relevant details to help the user or system understand the task.

Example: - Bad: "Generate test cases." - Good: "Generate test cases for a login feature that includes username and password validation."

  1. Use Examples:
  2. Provide input-output examples to clarify expectations.

Example: - Input: "5" - Output: "120"

  1. Be Concise:
  2. Avoid unnecessary details while ensuring completeness.

Example: - Bad: "Write a function that does something with numbers." - Good: "Write a function to find the sum of an array of integers."

  1. Iterate and Refine:
  2. Test the prompt and refine it based on the results.

Template for Writing Prompts

Intent: [Clearly state the purpose of the prompt.]

Context: [Provide relevant details and background information.]

Task: [Describe the task to be performed.]

Example:
Input: [Provide an example input.]
Output: [Provide the expected output.]