- Sabrina Ramonov š
- Posts
- 2-Minute Hack to High-Quality Prompts
2-Minute Hack to High-Quality Prompts
Simplest Guide to 'Prompt Engineering'
If you're new to ChatGPT, creating high-quality prompts might seem scary.
But, it doesn't have to be!
The trick is to use ChatGPT as your personal prompt engineer.
For technical or advanced users, there are additional tools and workflows to refine your prompts, but Iāll start with the basics.
The inspiration for this guide came from a TikTok video I posted last night, asking people what ChatGPT prompts they want.
I received dozens of requests overnight, including:
Prompts for academic writing
Prompts to write a detail business plan
Prompts to create a standard operating procedure
Prompts for project management focused on civil or construction
And, many more!
But, one thing stood out:
Many people already know what they wantā¦ they just need a little guidance on how to create effective ChatGPT prompts to get going.
So, Iām going to show you how to make high-quality prompts using ChatGPT.
You wonāt have to pay for $10k prompt engineering courses ā ripoff!
You wonāt have to pay $200 for a bundle of premade prompts ā ripoff!
Instead, make your own personalized optimized prompts for freeš
Hereās the Youtube version of this post:
What type of content do you like best?Your vote helps me prioritize what content I should make next! |
Let's dive into a real example.
I chose one of the prompt requests I received:
TikTok @sabrina_ramonov
Our objective is to make an effective ChatGPT prompt that takes a software specification (aka āspecā) and creates software test cases from the spec.
Step 1: Let ChatGPT Think About the Problem and Tasks
First, I give ChatGPT a relevant identity:
āYou are a senior software engineer.ā
Next, I tell ChatGPT what I want it to do:
āYouāve been tasked with understanding a software spec, writing test cases based on the spec, and writing code for each test case.ā
Then, I ask ChatGPT to explain in detail how it would approach these tasks.
āList out step-by-step how you would approach this problem.ā
At the end of the prompt, I add a technique called Chain-of-Thought, which helps ChatGPT produce better answers:
āTake a deep breath and think through it step-by-stepā.
Hereās the full ChatGPT prompt:
You are a senior software engineer. You've been tasked with understanding a software spec, writing test cases based on the spec, and writing code for each test case. List out step-by-step how you would approach this problem. Take a deep breath and think through it step-by-step.
All Iām doing is giving ChatGPT a little context, explaining what tasks I want ChatGPT to do, and asking ChatGPT how it would approach the tasks.
Step 2: Review ChatGPTās Answer
ChatGPT will provide a detailed explanation of the steps involved in writing test cases, including preconditions, actual results, and different types of testing like unit tests and integration tests.
The initial output may include steps we donāt need, or it may be missing steps that are important.
But, that's okay!
You can always trim, edit, add.
Thatās the fun part - experimenting with prompts to get better answers.
Here is ChatGPTās detailed breakdown of how itād approach the problem of writing test cases from a given software spec:
Sabrina Ramonov @ sabrina.dev
Sabrina Ramonov @ sabrina.dev
Great answer, thanks ChatGPT!
The screenshots above show the most useful parts of ChatGPTās answer.
I truncated the rest. You can view the full answer in my Youtube video.
Next, weāre going to take ChatGPTās answer, and weāre going to ask ChatGPT to generate a high-quality effective prompt for us.
Step 3: Use Custom GPT to Make Prompts
First, letās install a custom GPT for prompt engineering:
go to ChatGPTās GPT store
type āpromptā
select one of the options
I like the first option, Prompt Engineer, because itās free and has many users.
Start a new chat with the Prompt Engineer GPT.
Iām going to ask the GPT to write a prompt that takes a software spec and writes test cases.
And, Iām going to paste the output from the previous step.
This ensures the final prompt incorporates ChatGPTās step-by-step plan to approach the problem of writing tests cases from a spec.
Hereās the prompt we feed into Prompt Engineer GPT:
Build a new prompt from scratch that takes a software spec, a programming language, and writes test cases. The prompt should cover all these steps and best practices for writing test cases given a spec:
{{PASTE OUTPUT FROM PREVIOUS STEP}}
Important: remember to paste the output from the previous step!
And, hereās the prompt generated by Prompt Engineer GPT:
You are provided with a software specification document and a programming language to use. Follow these steps to create detailed test cases and implement them in the given programming language:
1. Understand the Software Specification:
- Read the spec thoroughly.
- Identify main features, functionalities, and requirements.
- Highlight input/output requirements, constraints, edge cases, and expected behaviors.
- Create a glossary of technical terms.
- Identify and clarify any ambiguities.
- Break down the requirements into manageable components.
2. Write Test Cases:
- Identify test scenarios, including normal and edge cases.
- Create a test plan covering all scenarios.
- Write detailed test cases including ID, description, pre-conditions, steps, expected results, and priority.
- Use test case management tools to document the test cases.
- Review and refine the test cases with peers.
3. Write Code for Each Test Case:
- Set up the development environment with necessary tools and version control.
- Follow coding standards.
- Start with simple test cases and implement basic functionality.
- Implement and test incrementally, using a TDD approach.
- Write unit tests using appropriate frameworks.
- Perform integration testing.
- Refactor and optimize the code.
- Document the code thoroughly.
- Conduct peer reviews and additional testing to ensure quality.
Step 4: Test and Iterate
Before testing the prompt, I tweak it.
I remove steps ChatGPT cannot accomplish, such as:
Review and refine the test cases with peers
Use test case management tools to document the test cases.
Conduct peer reviews and additional testing to ensure quality.
Set up the development environment with necessary tools and version control.
Now, take the prompt generated by the Prompt Engineer GPT and test it with a sample software spec.
Hereās a sample software spec I found online.
Feed the sample software spec into ChatGPT along with our updated prompt.
INPUT
And now, letās see what ChatGPT generates! šļø
Yay, nice work, ChatGPT! š„³
ChatGPT successfully analyzed a software spec and produced test cases, including the description, pre-conditions, steps, expected results, and priority for each test case. It also made a āskeleton code outlineā for the test suite.
Certainly, the test suite needs more work, but keep in mind ChatGPT did not have access to any code. It created the test cases purely from the given software spec and input programming language (e.g. python).
Closing the loop, we have:
used ChatGPT to create a detailed plan to solve a specific task
used Prompt Engineer GPT to create a high-quality prompt, incorporating the detailed plan from the previous step
tested our ChatGPT-generated prompt on a realistic software spec
confirmed our prompt works well!
Now, the fun continues ā how would you improve this prompt further?
What would you add, remove, or edit?
[ADVANCED] Anthropic & Fabric
For technical or advanced users, hereās my personal prompt creation workflow.
Itās simple.
I use Anthropic's Prompt Generator and describe the following:
prompt inputs
prompt outputs
task details (include as much info as possible)
Anthropic's Prompt Generator automatically breaks down the task into detailed steps and formats the input variables clearly via XML tags, making it easier for ChatGPT to understand and execute the task.
Then, I feed in the Anthropic-generated prompt into Fabricās improve_prompt pattern, which applies numerous ātacticsā (i.e. prompt engineering techniques) to further enhance the prompt.
Last Thoughts
Creating awesome prompts with ChatGPT is straightforward once you get the hang of it.
Start by letting ChatGPT think through your desired task, refine its output, then feed it into a custom prompt engineering GPT to write your prompt. Test the prompt with real examples and iterate until youāre happy!
For non-technical users, sticking to ChatGPT is sufficient. As you gain experience, you'll get better at writing prompts to get better answers.
For advanced users, tools like Anthropic's Prompt Generator and open-source frameworks like Fabric will take your prompting to the next level.
Most importantly ā
Enjoy the process!
In my humble opinion, the right attitude is to āPlay with AIā.
Did I miss anything?
Have ideas or suggestions?
Message me on LinkedInš
Sabrina Ramonov
P.S. If youāre enjoying my free newsletter, itād mean the world to me if you share it with others. My newsletter just launched, every single referral helps. Thank you!
share by copying and pasting the link: https://www.sabrina.dev