Skip to main content

ChatGPT Prompt Engineering for Developers

Principle 1: Write clear and specific instructions

Tactic 1: Use Delimiters

  • Triple quotes: '''''
  • Triple backticks: ```
  • Triple dashes: ---
  • Angle brackets: <>
  • XML tags: <tag> </tag>

Tactic 2: Ask for structured output (e.g., HTML/JSON)

Tactic 3: Ask the model to check whether the conditions are satisfied

Tactic 4: Few-shot prompting

  • Give successful examples of completing tasks before asking the model to perform the task.

Principle 2: Give the model time to think

  • Instruct the model to think longer about the problem.

Tactic 1: Specify the steps required to complete the task

  • (Step 1, Step 2, … Step N)

Tactic 2: Instruct the model to work out its own solution before rushing to a conclusion