Copilot Best Practices (What Not To Do)
Summary
TLDRThe video provides best practices for using Copilot efficiently. Key points include not letting Copilot entirely control coding without oversight, using inline prompts and chat features appropriately, leveraging existing slash commands before creating new prompts, clearly establishing context so Copilot suggestions are relevant, and providing feedback to help Copilot improve over time. The goal is for developers to maximize Copilot's capabilities as an assistant while retaining responsibility as the pilot directing the coding.
Takeaways
- 😀 Copilot is meant to assist, not fully replace the developer
- 👩💻 Review Copilot's code suggestions instead of blindly accepting them
- ✈️ You are the pilot, Copilot is the copilot - it should support you, not fly the plane
- ⚙️ Use the right Copilot features for the task, like inline chat for code prompts
- 🔀 Don't recreate existing prompts - use slash commands for fixes and explanations
- 🗺️ Keep relevant code selected and remove off track chat history to help Copilot's context
- 📄 Add project files to give Copilot workspace context
- 🔙 Use up arrow in chat to reuse previous prompts
- 👍 Use thumbs up/down and report issues to improve Copilot over time
- ✅ Check out more Copilot best practice videos to optimize usage
Q & A
What is the main purpose of Copilot?
-Copilot is meant to be an assistant that helps developers write code faster and better by providing relevant code suggestions.
What are some things you should not do with Copilot?
-You should not let Copilot write full programs on its own without reviewing the code it produces. You should also not misuse Copilot's prompting tools or forget about context when asking it questions.
Why is it important to review Copilot's code suggestions?
-Copilot does not always produce correct, optimal, or secure code so it's important for developers to review everything Copilot generates before using it.
What is the best way to prompt Copilot when you are within code?
-When within code, you should use inline chat to prompt Copilot rather than comments, as inline chat is more efficient.
How can you improve Copilot's context when conversing with it?
-You can delete previous off-track questions, highlight code you want to ask about, and add relevant files to your project.
How can you navigate previous questions you asked Copilot?
-When your cursor is at the bottom of the chat panel, you can hit the up arrow key to access your previous questions to Copilot.
What feedback features does Copilot have?
-Copilot has thumbs up/thumbs down buttons to rate suggestions and an option to report issues to help it improve over time.
What are some common slash commands in Copilot?
-Some common slash commands are 'fix' to fix problems in code, 'explain' to get explanations of code, and 'test' to generate tests.
Why should you avoid recreating prompts?
-You should first check if a prompt already exists using the slash commands before manually recreating a prompt to be more efficient.
What Copilot agent is aware of your workspace context?
-The '@workspace' agent knows details about your current project files and workspace to provide better solutions.
Outlines
😊 Don't let Copilot fly the plane
This paragraph explains that Copilot is meant to assist developers, not fully replace them. It advises against letting Copilot build entire apps by itself without review, as it does not always produce optimal, secure code. While Copilot can generate helpful suggestions, developers must still thoroughly review everything it produces.
😃 Use Copilot tools efficiently
This paragraph provides examples of efficient ways to prompt Copilot, such as using inline chat and the side panel chat. It advises against using comments to prompt Copilot. It also recommends using slash commands for common requests to avoid recreating existing prompts.
Mindmap
Keywords
💡copilot
💡misuse
💡slash commands
💡context
💡feedback
💡ghost text
💡inline chat
💡responsible
💡replace
💡optimal
Highlights
Copilot is meant to be an assistant, not a replacement for the developer
Don't let Copilot write code without reviewing it thoroughly
You are still responsible for checking everything Copilot generates
Let Copilot be the copilot, but you are the pilot
Use inline chat for code prompts rather than comments
Use the side panel chat for more conversational questions
Use ghost text to get code suggestions without specific prompts
Use slash commands for common requests like fixing code issues
Don't recreate prompts for requests that already have slash commands
Keep relevant code selected when prompting for context
Add project files for Copilot to consider when answering questions
Use up arrow to reuse previous prompts instead of scrolling
Use feedback features to help Copilot improve over time
Rate suggestions using thumbs up/down buttons
Report issues by clicking the flag icon above prompts
Transcripts
Hi everyone.
So you know that Copilot is a powerful AI system
that helps you write code faster and better.
But is there a right and wrong way to use
it?
If you want to use it optimally, the answer is
yes, and in this best practice video I will show
you what not to do with Copilot in order to
use it efficiently.
So let's go ahead and take a look.
The first thing that I want to mention is don't
let Copilot fly the plane.
Copilot, as the name suggests, is meant to be an
assistant on your flight, not a replacement for you, the
real pilot.
So don't ask a Copilot to build an enterprise app
on its own, assuming success.
It is not a substitute for your own full knowledge.
Also, it does not always produce correct optimal secure code.
So while it's tempting to let Copilot write a lot
of code for you, doing so without reviewing it may
hinder productivity.
It's a fantastic tool for generating code suggestions, but as
a developer you are still responsible for checking everything copilot
generates, so it's far better to let copilot point you
in the right direction and to help complete the code
that you write as you write it.
Let it be the copilot, but you are the captain
flying the plane.
The next point I'd like to make is don't misuse
copilot tools.
For example, in real life it may be possible to
eat spaghetti with a spoon, but it's not very efficient.
Likewise, when prompting Copilot, you want to do it efficiently.
For example, right after line 14.
Here, it's technically possible that I can use comments to
prompt copilot saying something like to add product rating to
this form in addition to the product name, price, and
description that's already there, and when I hit enter it
will make a suggestion.
But this is not the most efficient way to do
this whenever you're within code.
If you need to make a prompt you want to
use inline chat so I can hit command I here
add my prompt and as you can see it makes
a suggestion on line 15 which I can accept.
The other way to prompt copilot is to use the
side panel chat, but this is more use for conversational
questions rather than a simple prompt like this.
So something that would be more appropriate is if I
were to add that product rating like I just did.
I can come to chat and ask it where else
in this app must I update if I add product
rating to this form.
And as you could see, it could tell us all
the different areas in the app that we'll need to
make additional updates and the details of that update after
I add an input for product rating.
Now I just use product rating as an example here,
but we're not going to really add this.
If we're here on line 14 and we didn't know
that we wanted to add product rating, we can just
use Ghost Text to get suggestions from Copilot.
So for example, when I just hit enter, Copilot's smart
enough to notice that, oh, you used product name, price,
and description.
Maybe you might want a product image and I can
go ahead and select that.
If I move on to the next line it will
give me another option.
How about product category?
And so after using ghost text and getting some suggestions
there, if I then decide I wanted to add product
rating, I can go ahead and request that.
But the point is you want to do what's the
simplest first using ghost text inline chat and for something
more detailed conversation wise, the chat panel.
But definitely do not use comments for prompting.
Something else to keep in mind is that we don't
want to recreate existing prompts.
So somewhere in this code here between line 14 and
19 there's some type of issue.
So I can ask a copilot to fix the issue
and when I hit enter it can find the problem
and offer a suggestion.
And as you can see on line 16 at an
= here.
But a quicker way to have addressed this issue was
just to use the slash command.
So within Copilot I can just hit slash and as
you could see fix was already an option.
Propose a fix for the problems in the selected code
and just by selecting that and hit enter I get
prompted with a solution.
Now, sometimes when you're prompted with solutions, there could be
more than one solution, so make sure that you navigate
through each one to see which is best and select
them.
But in this case, there's just one that I could
accept, and it's on line 16.
It added the equal right before the>.
So you want to keep this in mind for common
commands that you might ask, such as to fix the
problem or to explain some code to write documentation or
some tests so I could select let's say at the
very part.
If I was still unfamiliar with like how interfaces in
this particular code here works, I could use the slash
command to explain the selected area and on the left
hand side it will explain to me how the TypeScript
interface declaration works.
Now, while we're in the chat panel here, I should
also mention that the slash command also works here, and
you have even more options than from the inline chat,
which includes API, search, workspace, etcetera.
So definitely make some time to get familiar with some
of these slash commands and they will be getting updated
as Copilot matures in order to be as efficient as
possible without having to recreate prompts that already exist.
Next up, don't forget about context when using Copilot.
Context is everything, and the clearer the context is for
Copilot, the more relevant its solutions will be.
So there's a few things that you want to do.
The first is that if you're having conversation with Copilot,
particularly in the panel, and you sense that the suggestions
that you're getting are a little bit off track, you
can always go back up and delete previous questions and
prompts that you've asked just by navigating up and down
the panel and hitting the X to remove the request
and its response.
The other thing to keep in mind in terms of
context is to always have the related parts of your
code selected when giving it a prompt.
So if I want to ask questions, let's say related
to the add event listener, I want to have that
highlighted.
I could choose not to highlight it and ask Copilot,
but it's just inefficient and it's just better to have
it highlighted and then maybe I can come over here
and asks it to explain it to me and there
won't be any confusion.
Copilot will know exactly what to explain to me in
regards to the addevent listener.
The other point that I'd like to mention, and as
you can see right in the prompt, is at Workspace.
The AT workspace agent knows about your workspace and can
answer questions related to it.
So solutions you get is relevant to your project, but
not just a general technical answer.
Another thing to point out is to add files to
your project so that copilot takes that into consideration when
answering questions.
So if you know some of your questions might be
relevant to the style sheet, make sure that that's open
and part of your project.
And last but not least, you can always reuse prompts
that you've asked, and you don't need to have to
scroll up and down to look at your previous prompts.
If you have your cursor right at the bottom of
the panel here, just by hitting the up arrow, you
can navigate through your previous prompts and that also saves
time.
So in short, when you manage your context by keeping
all these practices in mind, you'll definitely be maximizing the
relevance of the solutions Copilot ends up giving you.
And the last thing that I'd like to mention is
to not ignore the feedback features.
Use the feedback and rating features of copilot because it
is constantly learning from your feedback.
So let's say for example there was a typo over
here and when I asked copilot for a suggestion, you'll
notice on the right hand side of the prompt Here
you can use the thumbs up or thumbs down button
to rate the suggestions if you want to report any
issues by clicking on the...
Right above you have the option to do that.
Doing this will help Copilot improve over time and provide
you with better code suggestions in the future.
That's it for this best practice video on what not
to do with Copilot.
Hope you found it useful and don't forget to check
out our other Copilot related videos.
Thanks again for watching and I will see you in
the next one.
Посмотреть больше похожих видео
GitHub Copilot tips and tricks
DIESES KOSTENLOSE COPILOT FEATURE MUSST DU KENNEN - Mit dem Notizbuch bis zu 18000 Zeichen im Prompt
I Tried Every AI Coding Assistant
הבינה המלאכותית של מיקרוסופט (Copilot) - עכשיו דרך אתר אינטרנט יעודי
Intro to GitHub Copilot in Visual Studio
Como acessar o GPT-4 de GRAÇA (sem assinar ChatGPT PLUS)
5.0 / 5 (0 votes)