Skip to content

mpchenette/copilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

copilot

Note

As with any GenAI, Copilot is non-deterministic. As such, results you get from Copilot may differ from what I demonstrate.

Install (for VS Code)

  1. Go to Extensions (on Activity Bar)
  2. Search for Copilot
  3. Install

    You will get both the Copilot and Copilot Chat extensions installed

  4. Using either the pop-up after install or the "Accounts" icon on the Activity Bar, sign into GitHub

Easy as that!

Familiarize (for VS Code)

After install, Copilot is 100% ready to go. Start coding to use Code completions or click the "Chat" icon on the Activity Bar to use Copilot Chat.

That's all!

Use

Code completion

Note

Although I don't always explicitly list it, there is an implied acceptance of Copilot's suggestions at the end of each step below.

point.py

  1. Navigate to point.py

    file name is part of the context Copilot uses!

class point
  1. Start a new comment "# create a class..."

    If the suggestions are wrong or I don't like them, just keep typing!

  2. Add "# should include getters, setters and a toString method" to your comment

    The clearer and more descriptive I am, the more helpful Copilot can be!

  3. Type "class Point:" and hit enter

    Copilot draws on all information in our file to build its context, so it can infer what we want based on what we have already commented and coded. Remember, file name is part of context!

  4. Accept all getters, setters and toString

    Copilot expedites "boring" coding (repetitive, boilerplate tasks). This gives us more time for the tasks and coding we enjoy.

  5. Start a new comment "# calculate the..." (we're going to create a distance function)

    Copilot is, once again, inferring what we might want here based on the context it has.

class line
  1. Start a new comment "# create a class..."
  2. Type "class..."

    Copilot will use the current context (in this case, the file name, and all comments and code in our current file), to determine how to structure and stylize suggested code. notice how Copilot automatically added getters, setters and a toString method (following the pattern it recognized from above) and it even automatically utilizes the distance method we defined previously.

Copilot Chat

Generate

Copilot works on more than just traditional code. Even with operational tasks and files, Copilot can help.

Infra as Code
  1. Navigate to iac.tf
  2. Ask Copilot chat to "write a terraform file that creates a webapp and sql DB in Azure for me"

    In Copilot Chat, we have various options for how to accepts suggested code.

Explain

  1. Open server.rs
  2. Ask Copilot Chat what this file is doing

Improve

  1. Ask Copilot Chat it if there are any ways we can improve the code
  2. Ask chat how to implement thread pools and accept changes

Translate

  1. Ask Copilot Chat to turn our rust code into python

Brainstorm

  1. Ask Copilot Chat: if I'm looking to create a webserver in python, how should I go about it? should I be creating it from scratch like I'm doing here?
  2. Ask it about the differences between the different frameworks it suggests.
  3. Ask it which to use if I'm looking to run a simple blog server and I don't have much coding experience.

Secure

Copilot can help identify and mitigate security vulnerabilities

  1. Navigate to sql.py
  2. Ask Copilot Chat to identify any security vulnerabilities it sees

@, # and /

#

We can use # to reference files or selections. Essentially, determine what context to use to answer the question we are asking. Note: #web for web search.

  1. Try this in chat:
    • what is the latest version of Node.js?
  2. then try this
    • #web what is the latest version of Node.js?
@

Called "participants". Use if you're looking to ask about a specific topic or domain. Example @docker. Copilot extensions can also provide more chat participants. Personally I don't use it much but it's there!

/

Short hand for common tasks in Copilot. So that I don't have to type out a full paragraph.

  • /tests - writes tests
  • /explain - explain code
  • /fix - fix errors

FAQ

  1. How does GitHub Copilot Chat differ from ChatGPT?
    • GitHub Copilot Chat takes into consideration the context of your codebase and workspace, giving you more tailored solutions grounded in the code that you've already written. ChatGPT does not do this.

Best Practices

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published