Skip to content

Commit

Permalink
Add section on getting the best out of Copilot Chat (#6848)
Browse files Browse the repository at this point in the history
* initial content

* add section on iterating

* tune the first image
  • Loading branch information
Greg Van Liew authored Nov 22, 2023
1 parent 6f1a204 commit cef9227
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
37 changes: 36 additions & 1 deletion docs/editor/github-copilot.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ A function name can only be so descriptive without being overly long so function
#### Prime Copilot with sample code
One trick to get Copilot on the right page is to copy and paste sample code that is close to what you are looking for. Providing a small example can help Copilot generate suggestions that match the language and tasks you want to achieve. Once Copilot begins providing you with the code you want and will actually use, you can delete the sample code from the file. This can be especially helpful to jump start Copilot to a newer library version when it defaults to the providing older code suggestions.
One trick to get Copilot on the right page is to copy and paste sample code into your open editor that is close to what you are looking for. Providing a small example can help Copilot generate suggestions that match the language and tasks you want to achieve. Once Copilot begins providing you with the code you want and will actually use, you can delete the sample code from the file. This can be especially helpful to jump start Copilot to a newer library version when it defaults to the providing older code suggestions.
### Be consistent and keep the quality bar high
Expand Down Expand Up @@ -336,6 +336,41 @@ The **Ask GitHub Copilot** command will open the Chat view and input your search
![Chat view with answer to "hide editor overview"](images/artificial-intelligence/copilot-answer-hide-editor-overview.png)
## Getting the most of of Copilot Chat
This section is similar to the earlier [Getting the most out of Copilot](#getting-the-most-out-of-copilot), which had recommendations for getting the best editor inline completions from Copilot. Here we'll cover tips to effectively use Copilot Chat (Chat view, inline chat, Quick Chat).
### Use agents and slash commands
[Agents](#agents-and-slash-commands) are designed to collect extra context either about a code base or a specific domain or technology. By using the appropriate agent, Copilot Chat can find and provide better information to send to the Copilot backend.
* Use `@workspace` if you want to ask questions about your open project.
* Use `@vscode` if you want to know about VS Code features and APIs.
Slash commands help Copilot Chat understand your **intent** when you ask a question. Are you learning about a code base (`/explain`) or do you want help fixing an issue (`/fix`) or creating test cases (`/test`)? By letting Copilot Chat know what you're trying to do, it can tune its reply to your task and provide helpful commands, settings, and code snippets.
You could write out your project scope or current task with a natural language query but using agents and slash commands is more concise and explicit.
### Iterate on your solution
When asking Copilot Chat for help, you aren't stuck with the first response. You can iterate and prompt Copilot to improve the solution. Copilot has both the context of the generated code and also your current conversation.
Here's an example using inline chat to create a function to calculate Fibonacci numbers:
![First response from Copilot for a function to calculate Fibonacci numbers](images/artificial-intelligence/fibonacci-first.png)
Maybe you're prefer a solution that doesn't use recursion:
![Ask Copilot to not use recursion and new result](images/artificial-intelligence/fibonacci-second.png)
You can even ask Copilot to follow coding conventions or improve variable names:
![Ask Copilot to use better variable names and new result](images/artificial-intelligence/fibonacci-third.png)
Even if you've already accepted a result, you can always ask Copilot to iterate on the code later:
![Ask inline chat to use better variable names on existing code](images/artificial-intelligence/fibonacci-better-var-names.png)
## Additional resources
Congratulations, you've now used artificial intelligence to enhance your coding!
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cef9227

Please sign in to comment.