Copilot Best Practices (What Not To Do)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone so you know that co-pilot is a powerful AI assistant 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 co-pilot 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 co-pilot fly the plane co-pilot 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 co-pilot 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 co-pilot 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 a developer you are still responsible for checking everything co-pilot generates so it's far better to let co-pilot point you in the right direction and to help complete the code that you write as you write it let it be the co-pilot but you are the captain flying the plane the next point I'd like to make is don't misuse co-pilot 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 co-pilot you want to do it efficiently for example right after line 14 here it's technically possible that I can use comments to prompt co-pilot 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 add my prompt and as you can see it makes a suggestion on line 15 which I can accept the other way to prompt co-pilot is to use the side panel chat but this is more used 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 SU suggestions from co-pilot so for example when I just hit enter co-pilot smart enough to notice that oh you use 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 co-pilot to Fig fix the issue and when I hit enter it can find the problem and offer a suggestion and as you could see on line 16 it added an equal sign here but a quicker way to have addressed this issue was just to use the slash command so within co-pilot 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 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 that's on line 16 it added the equal right before the greater than sign so you want to keep this in mind for common commands that you might ask such as to fix a problem or to explain some code to write documentation or some test so I could select let's say the 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 EX Etc so definitely make some time to get familiar with some of these slash commands and they will be getting updated as co-pilot 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 co-pilot context is everything and the clearer the context is for co-pilot 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 co-pilot 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 ad event list I want to have that highlighted I could choose not to highlight it and ask co-pilot but it's just inefficient and it's just better to have it highlighted and then maybe I can come over here and ask it to explain it to me and there won't be any confusion co-pilot will know exactly what to explain to me in regards to the ad event listener the other point I'd like to mention and as you could 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 co-pilot takes that into consideration when answering questions so if you know some of your questions might be relevant to the stylesheet 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 co-pilot 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 co-pilot because it is constantly learning from your feedback so let's say for example there was a typo over here and when I ask co-pilot 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 Ellipsis right above you have the option to do that doing this will help co-pilot 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 co-pilot hope you found it useful and don't forget to check out our other co-pilot related videos thanks again for watching and I will see you in the next one
Info
Channel: Visual Studio Code
Views: 36,158
Rating: undefined out of 5
Keywords: vscode, visual studio code, vs code
Id: 2q0BoioYSxQ
Channel Id: undefined
Length: 8min 43sec (523 seconds)
Published: Thu Feb 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.