{"id":16696292,"url":"https://github.com/atterdag/copilotdemo","last_synced_at":"2026-03-17T21:31:47.762Z","repository":{"id":224397750,"uuid":"763054688","full_name":"atterdag/copilotdemo","owner":"atterdag","description":"Walkthrough basic Copilot functionality that can be used to demo for new users.","archived":false,"fork":false,"pushed_at":"2024-03-03T21:03:01.000Z","size":1128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T01:06:30.175Z","etag":null,"topics":["copilot","copilot-chat","copilot-tutorial","demo"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atterdag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-25T12:48:24.000Z","updated_at":"2024-03-03T20:27:31.000Z","dependencies_parsed_at":"2024-11-19T18:10:37.056Z","dependency_job_id":"413b69b3-0af1-474a-b65b-760ade121ee5","html_url":"https://github.com/atterdag/copilotdemo","commit_stats":null,"previous_names":["atterdag/copilotdemo"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/atterdag/copilotdemo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atterdag%2Fcopilotdemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atterdag%2Fcopilotdemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atterdag%2Fcopilotdemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atterdag%2Fcopilotdemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atterdag","download_url":"https://codeload.github.com/atterdag/copilotdemo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atterdag%2Fcopilotdemo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30631891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copilot","copilot-chat","copilot-tutorial","demo"],"created_at":"2024-10-12T17:27:31.637Z","updated_at":"2026-03-17T21:31:47.738Z","avatar_url":"https://github.com/atterdag.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Copilot example\n\nThis is a _do-it-yourself_ exercise on how to use GitHub Copilot with some simple examples. The exercise require that you have Docker and Docker Compose installed, and - of course - a working GitHub Copilot subscription.\n\nFinally the exercise is expecting that you use Visual Studio Code, but it should be possible to use other editors as well.\n\n## Inline suggestion\n\nFirst lets start with a basic example on how to use the in-editor suggestions from GitHub Copilot. In my experience this is the most common way to use Copilot in my daily work, in that Copilot is just silently working in the background and suggesting next lines being Python code or Structurizr DSL statements or even documentation in Markdown. Copilot simply just frees up mental capacity to focus on the problem at hand. Of course there is a risk that Copilot will manipulate the thought process in a specific direction, but often I find that Copilot will make suggestions that I hadn't thought of myself, and as such expand my horizon rather than limit it. After all in the end I'm the one who decides what to accept and what to reject.\n\n### A [Fizz buzz](https://en.wikipedia.org/wiki/Fizz_buzz) example\n\nCreate a file named `fizzbuzz.py`, and copy the following code:\n\n```python\n# Create FizzBuzz function that receives a parameter with a number\n# If the number is divisible by 3, return \"Fizz\"\n# If the number is divisible by 5, return \"Buzz\"\n# If the number is divisible by 3 and 5, return \"FizzBuzz\"\n# Else, print the number\ndef fizzbuzz\n```\n\nThe [GitHub Copilot VSCode extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) will capture the open files in VSCode in a Context which is transmitted to the Copilot Service.\n\n\u003cimg src=\"images/CopilotFlowDiagram.png\" width=\"1000\"\u003e\n\nThe Copilot Service will then match the Context with a Code Reference Index created by the [OpenAI Cordex model](https://openai.com/blog/openai-codex), delete the Context, and send back a suggestion to the open file in VSCode. So wait a moment for the suggestion to appear and press `tab` to accept the suggestion.\n\nNow generate some code to run the function by bringing up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n\n```\nAdd code to run the function in a loop from 1 to 100\n```\n\nCopilot will suggest the following code a snippet to run the function in a loop. Press `tab` to accept the suggestion.\n\n\u003cimg src=\"images/FizzbuzzImperfectSuggestion.png\" width=\"1000\"\u003e\n\nMost likely the code will not be perfect, and you have to fix things like identation, missing colons, etc. But it is a good starting point, and cleaning up the code shouldn't take more than a few seconds.\n\n\u003cimg src=\"images/FizzbuzzComplete.png\" width=\"1000\"\u003e\n\nBut if you are really lazy you can just select all text, and bring up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\n/fix\n```\n\n## Generative example\n\nNow lets try Copilot Chat to generate the files to create a simple Python project that simulates a REST API and fetches the data from the API and outputs it to YAML.\n\nBut first ... where is the Chat? By default you find it as a panel on the left sidebar in VSCode, but you can always move to the right sidebar as I actually prefer thus at the same time leaving the left sidebar for the file explorer while have chat running on the right.\n\n\u003cimg src=\"images/WhereIsChat.png\" width=\"500\"\u003e\n\n### Setup python project with virtualenv\n\nLets start with just setting up Python Virtual Environment in the project by writing into the *Copilot Chat*:\n\n\n```\ncan you give me give the bash commands to setup an virtualenv that can read the output from a REST API and output it to YAML?\n```\n\nIn the Chat side panel find the code example with the shell commands, and click on the \"Insert into terminal\" button.\n\n![Where the button???](images/InsertToTerminal.png)\n\nYou can see that Chat inserts the commands into the VSCode terminal, so click `Enter` in the terminal to execute the commands.\n\n### Create the test environment\n\nCreate a Docker Compose file with nginx that mount the subdirectory `./html` in the container.\n\n```\ncan you create a docker compose file that runs nginx and maps the html directory to the nginx html using a bind volume\n```\n\nSave the following code to `compose.yml`:\n\n![](images/InsertToNewFile.png)\n\n\nLet's change compose file to listen to port 8888, but first, open the `compose.yml` file, select all, and bringing up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\ncan you change this compose file to listen to port 8888\n```\n\nAccept the change and save the file.\n\n![Acceptance is key](images/ChangeComposePort.png)\n\nNow create a JSON test file to simulate API response.\n\n```\ncan you create a json file named api without the .json extension with some test data in html/\n```\n\nIn case Copilot forgets to create the `html` directory first, then is fine, because Chat works like GPT and can understand the context of the conversation as well as the open file. So you can just ask:\n\n```\nyou forgot to create the html directory first\n```\n\nRun the suggested commands to create the `html` directory and the `api` file.\n\nRun in an other terminal the following command to start the nginx server:\n\n```bash\ndocker-compose up\n```\n\n### Create simple python that fetches data from nginx\n\nCreate a simple python script to retrieve data from the nginx server.\n\n```\ngenerate python script to retrieve data from http://localhost:8888/api\n```\n\nIn the chat, you will see the code example, and you can again click on the \"Insert into file\" button to insert the code into the `get_data.py` file.\n\nLets just document code by bringing up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\n/doc\n```\n\nLets refactor from a function to a class, so again bring up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\ncan you refactor the code to a class\n```\n\nAccept the suggestion, save the file, and run the script:\n\n```shell\n(myenv) ✔ ~/src/github/atterdag/copilotdemo [main|✚ 2…5]\n14:16 $ python get_data.py\n{'name': 'Test', 'description': 'This is some test data'}\n```\n\n### Create complex python example\n\nCreate a module that creates classes to fetch and process json data\n\nOpen `html/api` file in VSCode and write in Chat:\n\n```\nconsidering the json open, can you create a python package that interprets the json data from \u003chttp://localhost:8888/api\u003e with multiple classes in separate files and how to organize them in a python module named get_some_api_output. Also create a main.py file that uses the classes to fetch and process the json data and output it to stdout.\n```\n\nYou can now see how Copilot suggests the code call the URL, and base the output on the `html/api` content.\n\nBut lets be a little more helpless:\n\n```\ncan you include the commands to create the files and folder structure?\n```\n\nSo open the files created by the commands, and if Copilot Chat didn't already populate files with content using the command, you can copy the code into the files.\n\nSometimes the `main.py` ends up being created in the module folder, so just move it to the root of the project. But this just emphasizes the importance of actually knowing what you are doing, and not just blindly accepting the suggestions.\n\nNow refactor code to convert output to `YAML`, so open `main.py` and bring up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\ncan you refactor the code to convert the output to yaml\n```\n\nLet's create a unit test, by opening `main.py` and bring up the Copilot function in the editor by pressing `CTRL-i` and type:\n\n```\n/tests\n```\n\nCopilot will suggest to create a new file call `test_main.py` and insert the test code.\n\n![](images/CreateTests.png)\n\nAfter accepting that Copilot creates the test, then just run `pytest`:\n\n```shell\npip install pytest\npytest\n```\n\nYou will probably get an error from `pytest` because the output data is not the correct value as according to as the static file `html/api`. But you can just fix the test by changing the expected value in the test file.\n\n## Conclusion\n\nCopilot is not a replacement for a developer. It is more akind to a pair programming partner that can help you with the boring stuff, and sometimes even come up with suggestions that you hadn't thought of yourself. But it is important to remember that Copilot is not a human, and as such it can make mistakes, and it is important to understand what you are doing, and not just blindly accept the suggestions. But if you are willing to put in the effort to understand what you are doing, then Copilot can be a great help in your daily work. (yeah ... this whole paragraph was generated by Copilot ... but I still think it is true ...)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatterdag%2Fcopilotdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatterdag%2Fcopilotdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatterdag%2Fcopilotdemo/lists"}