Skip to content

eficode/copilot-prompt-engineering

Repository files navigation

Copilot Prompt Engineering

Copilot Prompt This repository includes Copilot training exercises intended to give you practical experience using Copilot + Copilot Prompt

🎯 Goal

Learn of how to use prompt engineering techniques to get accurate responses from Copilot + Copilot Prompt


Prompting Best Practices

  • Provide references
    • Improve relevance of the response by providing an example and context
  • Write clear instruction
    • Refine your prompt, provide context, write clearly, and give Copilot ample input for better results
  • Split up big tasks
    • Breaking down complex tasks minimizes errors and utilizes previous outcomes for efficiency
  • Allow GitHub Copilot time to think
    • Requesting Copilot’s thought process will enhance Copilot accuracy, but it may prolong wait times.
  • Test changes systematically
    • Measure performance, watch for prompt changes' side effects, and use test suites for implementation

Cornerstornes of Prompting

  • Context :: Provide Examples
    • Information to help GitHub Copilot understand the task better
  • Intent :: Give Directions
    • The specific goal or purpose you have in mind when creating a prompt
  • Clarity :: Easy to Understand
    • Being clear, transparent, and easily understood
  • Specificity :: Precision in Detail
    • Providing precise and detailed information, leaving little room for ambiguity or interpretation

Techniques

  • Zero-shot
  • One-Shot
  • Few-shot

✍️ Programming Languages

Javascript


💻 IDE

  • Visual Studio Code VS Code
  • Visual Studio Visual Studio
  • Jetbrains IDE Jetbrains IDE

🗒️ Guide

Prerequisites

  • Copilot
  • Copilot Chat

Optional

Note: DEMO 4 is an advanced demo that requires the use of the VS-Code Leetcode extension


DEMO 1

Zero-shot

Write me unit tests for all the operations in my calculator.js file

One-Shot

Write me unit tests for all the operations in my calculator.js file
Use the following example: test(‘adds 1 + 2 to equal 3’, () => ( expect(calculate(1, 2 ‘+’)).toBe(3); });

DEMO 2

Zero-shot

Can you create an HTML calculator for me?

One-Shot

Can you create an HTML calculator for me? Use the following example:  
<!DOCTYPE html>
<html>
  <head>
    <title>Calculator</title>
    <link rel="stylesheet" href="style.css">
  </head>
<body>
</html> 

DEMO 3

Zero-shot

Can you write me the code for a snake game?

One-Shot

Can you write me the code for a snake game? 
Example: Ensure that there is a leaderboard mechanic

DEMO 4

This exercise creates an MVC App that functions as an RSS Feeds client to report GitHub Health information

Get GitHub Status with Copilot Guide


DEMO 5 - LeetCode (Advanced Demo)

This demo uses a very detailed prompt with examples to guide Copilot in generating effective suggestions.

Setup and detailed walkthrough with the LeetCode extension

1. Install the LeetCode extension in VS-Code

2. Log into the LeetCode website

2.1    At the time of writing this document, the LeetCode extension may experience difficulties with logging in to leetcode.com. For guidance on connecting to the website, please refer to the instructions provided in this blog.

3. When you are connected to leetcode.com, start with some exercise

1. Open the `leetcode` extension

2. Select a problem to solve.

3. Start the coding exercise.

NOTE: before leetcode opens a solution file, it will ask for some info:

We recommend to use the following options:

  • Select an implementation language (your choice)

  • Just open the problem file (opens a new tab)

4. Now use the problem descption from leetcode with Copilot Chat (copy & paste), ask it to create the code

5. When you accepted the suggestion from copilot chat (copy into file)

Use the right click pop-up menu in the solutions file to test and submit your solution to leetcode


The final step is to evaluate the Copilot suggestion for its 'pass' or 'fail' status and to determin its corresponding 'score'

Good Luck

🤝 Contributing

Contributions are warmly welcomed! ✨

To contribute to a public exercise, please refer to our contribution guidelines here.

To create a net new exercise, please use this repository template.

About

An exercise Repo for Copilot Prompt-Crafting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published