GitHub Copilot - Patterns & Exercises
GitHub 🌟
en 🇬🇧
en 🇬🇧
  • Introduction
  • Contributing to the Project
  • General
    • Code completion
    • Comment to code
    • Code to comment
    • Quick Q&A
    • Regular expression
    • Language translation
    • Type hinting
    • Code to document
    • Object generation from structured data
    • Showing examples
  • Client Side Tips
    • Copilot snnipet handling
    • GitHub Copilot Shortcuts
    • Go to definition
    • Pin the files you need
  • Design Patterns
    • AI readable naming convention
    • Consistent coding style
    • High-level architecture first
    • Working on small chunks
    • Context-less Architecture
    • Eliminating a tiny OSS dependency
  • Collaboration
    • AI friendly documentation
    • Coaching on prompts
  • Test
    • Creating unit tests
    • Specify how to generate test code
    • Writing failure case first
    • Writing test cases in natural language first
    • Test only what is necessary
  • Refactoring
    • Writing test code before refactoring
    • Making the calculation part independent
    • Asking with open-ended questions
  • Archived
    • GitHub Copilot Patterns & Exercises Guide
    • Translations
      • German 🇩🇪
      • Spanish 🇪🇸
      • French 🇫🇷
      • Italy 🇮🇹
      • Japanese 🇯🇵
      • Portuguese 🇵🇹
      • Chinese 🇨🇳
Powered by GitBook
On this page
  • Description
  • Example
  • Exercise
  • Checklist for Further Learning
Edit on GitHub
  1. General

Quick Q&A

Getting the quick answer to your question.

Last updated 1 year ago

Description

In the collaborative coding environment, quick interactions and clarifications are often key to efficient development. While GitHub has the "GitHub Copilot Chat" product for more structured and extensive conversations, the "Quick Q&A" technique serves as a lightweight alternative. It enables developers to rapidly engage with Copilot in the code editor for brief one-liner answers and insights. It's not a distinct feature but a method that leverages commenting for quick interactions with Copilot, making it an agile and handy tool for on-the-spot guidance.

Example

Using the Quick Chat technique, you can pose questions directly in your code and get brief responses from Copilot:

# me: What's the best way to optimize this loop?
# copilot: 

Then GitHub Copilot will answer to the question

# me: What's the best way to optimize this loop?
# copilot: Consider using a vectorized approach or caching intermediate results. 

It can be just "q:" and "a:"

// q: How do I get the current time in milliseconds?
// a: 

For more context-based dialogue, roles can be defined:

# Roles: copilot
#   Expert in Python with 15+ years of experience
# Role: me
#   Mid-level engineer
#
# me: What's the best way to optimize this loop?
# copilot: Consider using a vectorized approach or caching intermediate results. 

Exercise

  • Exercise 1: Compare Quick Chat with "copilot chat" by engaging with both and noting the differences.

  • Exercise 2: Use Quick Chat to get one-liner answers to three different coding questions.

  • Exercise 3: Define roles within Quick Chat and observe how contextual information affects Copilot's responses.

Checklist for Further Learning

  • How does Quick Chat differ from the "copilot chat" product, and when might one be preferred over the other?

  • How can the Quick Chat technique be integrated into various stages of the development process?

  • What are the potential drawbacks or limitations of using Quick Chat, and how might they be mitigated?