Master the core principles of prompt engineering with GitHub Copilot
Summary
TLDRThe video script introduces the '3 S Principle' of prompt engineering for effective AI collaboration, emphasizing simplicity, specificity, and brevity. It illustrates how breaking down complex tasks into simple steps with clear prompts can reduce errors and accelerate development. The script also highlights the importance of providing specific context to AI tools like GitHub Copilot to enhance accuracy and efficiency, and demonstrates the use of inline chat for iterative problem-solving.
Takeaways
- π **Simple**: Prompts should focus on solving simple problems to reduce the chance of errors and hallucinations by AI like GitHub Copilot.
- π **Break Down**: Complex solutions should be divided into simple steps to improve accuracy and speed.
- π **Verbosity Reduction**: Using words like 'simple' in prompts can help reduce verbosity and get straight to the point with AI.
- π **Contextual Awareness**: Having related files open as tabs helps AI tools like Copilot understand the context and provide better assistance.
- π€ **AI Anticipation**: With sufficient context, AI can anticipate the next steps without needing explicit prompts.
- π **Specificity**: When asking for complex solutions, provide specific context to reduce the AI's need to guess and improve the quality of responses.
- π **Project Context**: Use the @workspace agent in Copilot to make use of the project context for more accurate responses.
- π **Direct References**: Pointing Copilot directly at files or using variables like #file can increase the specificity of the AI's assistance.
- π« **Grammar Flexibility**: When interacting with AI, you don't need to worry about perfect grammar or spelling; focus on being clear and concise.
- π **Iterative Process**: Use the '3 S's' (Simple, Specific, Short) iteratively to refine and achieve the desired outcome with AI assistance.
- π οΈ **Productivity Focus**: The goal of prompt engineering is to enhance developer productivity by learning effective ways to communicate with AI tools.
Q & A
What is the '3 S Principle' of prompt engineering mentioned in the video?
-The '3 S Principle' of prompt engineering stands for Simple, Specific, and Short. It is a guideline to effectively collaborate with AI like GitHub Copilot to achieve the best results.
Why is it important to keep prompts simple according to the video?
-Keeping prompts simple reduces the amount of code that needs to be checked for accuracy, which in turn reduces the chance for errors and hallucinations, making the coding process faster and more efficient.
What are 'hallucinations' in the context of AI coding assistance?
-'Hallucinations' refer to instances when AI, like GitHub Copilot, makes up information or uses files and libraries that don't exist because it doesn't know the correct answer.
How can breaking down a solution into simple steps help with prompt engineering?
-By breaking down a solution into simple steps, you allow for easier management and accuracy checking of the code. This method also helps in avoiding the complexity that can lead to errors.
What role does the 'specific' aspect of the 3 S Principle play in prompt engineering?
-Being specific helps in providing the AI with the exact context it needs to generate accurate and relevant responses, reducing the need for guesswork and improving the quality of the AI's assistance.
Why is it recommended to use the @workspace agent in GitHub Copilot?
-The @workspace agent in GitHub Copilot serves as an expert on your project, allowing the AI to understand the project's context better and provide more accurate and relevant suggestions.
What does the 'short' aspect of the 3 S Principle entail?
-The 'short' aspect encourages brevity in prompts, suggesting that you don't need to use proper grammar or complete sentences. Typos are also less critical, allowing for faster and more efficient communication with the AI.
How can having related files open as tabs in the editor improve the AI's responses?
-Having related files open as tabs provides the AI with additional context, which helps it to understand the project better and offer more accurate and relevant suggestions.
What is the significance of using specific variables like #file in GitHub Copilot?
-Using specific variables like #file allows you to point the AI directly at specific files or parts of the code, ensuring that the AI's suggestions are tailored to the exact context of your project.
How can the 3 S Principle be applied to create a CSS layout with a fixed header and footer?
-You can apply the 3 S Principle by first asking for a fixed header, then a fixed footer, and finally for a body that scrolls in between. This approach breaks down the task into simple, specific, and short prompts, making the process more efficient.
What is the ultimate goal of using the 3 S Principle in prompt engineering?
-The ultimate goal of using the 3 S Principle is to enhance developer productivity by creating prompts that yield the best results with the least amount of effort and in the shortest amount of time.
Outlines
π€ The '3 S Principle' of Prompt Engineering
This paragraph introduces the concept of prompt engineering, emphasizing the '3 S Principle' which stands for Simple, Specific, and Short. It explains the importance of starting with simple problems to minimize errors and 'hallucinations' from AI like GitHub Copilot. The speaker illustrates how breaking down complex tasks into simpler steps can lead to more accurate and faster results. The paragraph also touches on the use of specific language in prompts to reduce AI verbosity and the importance of having related files open for context, allowing Copilot to provide more accurate completions.
π Applying the '3 S Principle' for Effective Prompting
The second paragraph delves deeper into applying the '3 S Principle' for prompt engineering. It discusses the counterproductive nature of lengthy prompts and how to avoid them by using simple, specific, and short prompts incrementally. The speaker provides an example of creating a CSS layout with a fixed header and footer, suggesting that breaking the task into smaller, focused prompts can enhance developer productivity. The paragraph concludes by reiterating the importance of the '3 S's' and encourages viewers to practice prompt engineering to improve their results and productivity.
Mindmap
Keywords
π‘Prompt Engineering
π‘GitHub Copilot
π‘3 S Principle
π‘Simple
π‘Specific
π‘Short
π‘Hallucinations
π‘Swagger
π‘Workspace Agent
π‘Inline Chat
π‘SMART Coding
Highlights
The '3 S Principle' of prompt engineering stands for Simple, Specific, and Short, offering an effective way to collaborate with AI like GitHub Copilot.
Simple prompts help solve straightforward problems, reducing the chance for errors and hallucinations in AI-generated code.
Breaking solutions into simple steps allows for faster, more accurate code development with AI assistance.
Using the word 'simple' in prompts can help AI provide more concise and relevant responses.
Having related files open as tabs helps GitHub Copilot understand context and provide better answers.
GitHub Copilot can automatically perform actions when the context is clear, reducing the need for explicit prompts.
For complex tasks, being specific in prompts is crucial to guide AI and avoid ambiguous responses.
Using the @workspace agent in Copilot helps it understand the project context for more accurate assistance.
Pointing Copilot directly at files with the #file variable increases the specificity and relevance of AI responses.
Providing specific context, such as selected code, reduces the AI's need to guess and improves the quality of responses.
Short prompts are more efficient, allowing AI to quickly provide relevant answers without needing complete sentences or correct spelling.
The '3 S's' can be combined to achieve the best results, as demonstrated by iteratively building a CSS layout with fixed header, footer, and scrollable body content.
Iterative prompting with simple, specific, and short questions leads to more productive outcomes in AI collaboration.
As developers write more prompts, they will learn to identify which prompts yield the best results and enhance productivity.
The video encourages viewers to explore other content on GitHub Copilot for further insights into effective AI collaboration.
The concept of 'SMART coding' is introduced as a way to achieve efficient and effective coding practices with AI assistance.
Transcripts
Prompt engineering or prompt crafting, or just prompting whatever word
you use to describe it;
it's all about how to effectively collaborate with an AI
to get the best results, like GitHub Copilot.
In this video, I'm going to show you something called
the "3 S Principle" of prompt engineering.
The Three S principle stands for Simple, specific, and Short.
Easy to remember, right?
The first S, simple means that you should try to
solve as simple a problem as possible with your prompts.
For instance, let's say that we want to create an
API that returns some weather data and uses Swagger.
When you use Copilot, it's tempting to ask for all
of this and have it implement a solution in a
single shot.
While Copilot will happily try and do this for you,
the more code that Copilot writes, the greater the chance
for errors and what we call hallucinations, which are things
that Copilot just makes up when it doesn't know an
answer.
In this example, Copilot uses files that don't exist, libraries
that we don't have installed, and on and on.
It's tough to deal with code like this because now
you're in the business of fixing errors, not writing code.
Instead, break your solution up into simple steps and let's
perform them one at a time.
When you work in simple steps, there's less code that
you have to check for accuracy and you can just
move that much faster.
Once we have a simple server, we can then add
a route file for the weather.
You'll notice that I'm using simple not just as a
concept, but as an actual word in the prompt.
You don't have to do this, but I do find
that it helps cut down on the verbosity from the
AI and gets me just what I need more of
the time.
OK, now we can use this route.
It's important to know that when you're using GitHub Copilot
completions like I am here, also called "Ghost Text", that
you have related files open as tabs.
Otherwise Copilot can't see those files and it may give
you bad answers.
But now that Copilot has all this context here, we
don't even have to ask Copilot anymore to do anything
like use the route.
It already knows what we're going to do next and
just does it because the best prompt is the one
that you don't have to write.
Now there are times when you're going to need more
complex answers and there's just no way around that.
This is especially true if you're not 100% sure how
to do something and you need some guidance from Copilot.
For instance, if we want to integrate Swagger, which is
an API documentation tool, there isn't really a way for
us to be simple here because I don't know how
to get started at all.
I need to ask a more open-ended question, and the
more you ask for, the more specific you need to
be, and that's our second S - Specific.
If I ask an open-ended question about how to integrate
Swagger here, I get an open-ended answer.
In fact, Copilot might not even know what language I
want to work in.
Why doesn't Copilot know about my project?
Copilot tries to intelligently pull in context
for you this often means the editor area, which is
the code you can see in the editor, but not
all the code in the file.
It also knows about the code that you have selected,
which is a great habit to get into,
So that Copilot knows exactly what code you want to
talk about.
To reduce the amount of guessing that Copilot has to
do, your best bet is to provide the specific context.
In this case, we can use the @workspace agent in
Copilot to have it look at our project and use
that as the basis for this answer.
Agents in Copilot are like experts on certain subjects.
In this case, the workspace agent is an expert on
your project.
You can add further specificity by pointing Copilot directly at
files.
So if we want to create an interface here that
matches the shape of the JSON in the data, we
can do that with the #file variable.
There are other variables too, such as #editor which includes
all of the visible code in the editor, space, selection
which includes the selected code, and rerminal lastCommand and
selection, which include information from the terminal specific always use
specific prompts and always provide specific context to copilot.
Now, if you've been paying close attention so far, you
may have noticed that I've been using our last S
all along, and that's short.
When you talk to Copilot, you don't need to phrase
questions as if you were talking to a human, You
don't need proper grammar, You don't even need complete sentences.
You don't have to spell things correctly.
You can safely omit almost all of that and get
the same answer faster.
Type less because typos don't matter.
Now, while we've gone over these principles separately, you'll use
them together to get the best results.
For instance, if I wanted a CSS layout that had
a fixed header, fixed footer, and body content that scrolled
in the middle, I could write a pretty lengthy prompt
to try and pull this off.
But if you think about it, this is a bit
of a step backwards for developer productivity, right?
We want to learn keyboard shortcuts and be quick, not
type everything that's in your brain.
So how can we use the principle of simple, specific,
and short to pull this off?
First we'll ask for a fixed header, then we ask
for a fixed footer, and then we'll ask for a
body that scrolls in between Simple, specific, and short.
And we use the inline chat here to iterate our
way to the answer that we wanted instead of trying
to do it all in one shot.
And that's it.
All you have to remember are the "3 S's"
simple, specific, and short, and you've nailed the core principles
of prompt engineering.
And as you write more prompts, you'll just start to
figure out what prompts get you the best results and
make you the most productive.
Make sure you check out all of our other videos
on GitHub, Copilot, and as always happy SMART coding.
Browse More Related Video
![](https://i.ytimg.com/vi/dJUwdFQVWLI/hq720.jpg)
5 guide GRATUITE per ChatGPT, Claude, Copilot, e altre AI
![](https://i.ytimg.com/vi/1UXyhj5iPBU/hq720.jpg)
Prompt Engineering - Corso professionale Parte 1/2
![](https://i.ytimg.com/vi/69bH4IHZivs/hq720.jpg)
"Next Level Prompts?" - 10 mins into advanced prompting
![](https://i.ytimg.com/vi/UFc-RPbq8kg/hq720.jpg)
Problem-Solving for Developers - A Beginner's Guide
![](https://i.ytimg.com/vi/H9Hz6mmn5vY/hq720.jpg)
Basi e Principi utili del Prompt Engineering, l'arte di saper parlare con le AI Generative
![](https://i.ytimg.com/vi/pZha15NEBh0/hq720.jpg)
Unleash ChatGPT Potential with the SCRIBE Method
5.0 / 5 (0 votes)