The best way to get up and running with ChatGPT is by using a cheat sheet. Check out our ChatGPT Cheat Sheet.
In ChatGPT prompt engineering, various elements play a critical role in shaping the user's prompt and obtaining the desired output. These elements are role, result, intent, context, and constraint.
Let's define each of them and provide an example that illustrates their use.
Suppose you're seeking advice on improving coding practices, specifically focusing on C#. Here's how each part can be framed:
"Give me some C# coding tips"
❌ Figure: Bad example - prompt is vague and lacking context
"As a senior software engineer, I need your guidance to improve my C# coding practices. I am working on a large-scale data processing project where readability and efficiency are critical. Can you provide me with some specific, actionable tips to enhance my code's performance while ensuring it remains clean and easy for others to understand?"
✅ Figure: Good example - prompt contains context, goal, and constraint
Here’s how that breaks down:
By specifying the role, result, intent, context, and constraint in the prompt, you can guide ChatGPT to deliver a more relevant and targeted response, addressing your specific needs and expectations.
✅ Figure: Another good example
"Welcome! Let's create a fantastic Prompt together. We will be defining a [Role] for me, my [Goal], the [Context] in which I will operate, the [Result] I aim to achieve, and the [Constraints] within which I will work. We'll also decide on the writing [Style] that best suits your preferences."
Here are the steps:
Step 1: "First, let's start by defining my [Role]. What is my [Role]?"
(After User's Response)
Step 2: "Now that we have my [Role], let's define my [Goal] and the [Result] I aim to achieve within the context. What is the [Goal] of this [Role], and what [Result] are you trying to achieve?"
(After User's Response)
Step 3: "Perfect! Could you now provide the [Context] within which the [Role] operates to achieve the [Result]?"
(After User's Response)
Step 4: "Thank you for the details. Now, let's decide the [Constraints] under which this [Role] operates. For instance, are there any limits or restrictions, such as word count, to consider in our description?"
(After User's Response)
Step 5: "Now, which writing style would you prefer for this description? It could resemble the style of a notable author, or a general style, such as descriptive, expository, or technical. For example, if you choose the expository style, our output will be factual and informative, explaining the subject in a straightforward and logical manner."
(After User's Response)
Final Step: "Great, we've collected all the information! Now, let's review the requirements. Here is the finished Prompt." Replace the items in square brackets below with the user's previous Responses as follows:
Prompt: "Your role is [Role]. The result required is [Result]. The context is [Context]. The goal is [Goal]. With the following [Constraint] and written in the following [Style]".
"Are you ready to proceed?"
(After User's Response)
Instruction: Do not include any narrative introduction; only show the [Result]
Execute Prompt.
Figure: Paste this perfect prompt generator into ChatGPT to make sure you include all of the elements