diff --git a/content/contributing/writing-for-github-docs/using-markdown-and-liquid-in-github-docs.md b/content/contributing/writing-for-github-docs/using-markdown-and-liquid-in-github-docs.md index dfe53824f02d..e7e12262f762 100644 --- a/content/contributing/writing-for-github-docs/using-markdown-and-liquid-in-github-docs.md +++ b/content/contributing/writing-for-github-docs/using-markdown-and-liquid-in-github-docs.md @@ -144,6 +144,76 @@ Code annotations only work in articles with the `layout: inline` frontmatter pro For an example of an article that uses code annotations on {% data variables.product.prodname_docs %}, see [AUTOTITLE](/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions). +## {% data variables.product.prodname_copilot_short %} prompts + +Prompts for {% data variables.product.prodname_copilot_short %} can either be displayed in blocks or included inline within text. + +### Prompt blocks + +These are very similar to code blocks, but use the `copilot` keyword rather than the name of a programming language. + +Prompt blocks should always have a copy button, added using the `copy` option, and may also have a {% data variables.product.prodname_copilot_short %} button, added using the `prompt` option. The {% data variables.product.prodname_copilot_short %} button gives the reader a quick way to run the prompt in {% data variables.copilot.copilot_chat_short %} on {% data variables.product.prodname_dotcom_the_website %}. The `copy` and `prompt` options can be used in any order. + +#### Example prompt block with {% data variables.product.prodname_copilot_short %} and copy buttons + +````markdown +```copilot prompt copy +What is git? +``` +```` + +This is rendered as: + +```copilot prompt copy +What is git? +``` + +You should only add a {% data variables.product.prodname_copilot_short %} button to a prompt block if: +* The prompt can be run without any further context (as shown in the example above). +* There is a code block in the same article that provides the required context for the prompt. + +#### Including context with a prompt + +If you use a {% data variables.product.prodname_copilot_short %} button, you can add context to the prompt that is sent to {% data variables.copilot.copilot_chat_short %} by referencing a code block in the same article. You do this by adding `id=STRING-OF-YOUR-CHOICE` to the code block and `ref=STRING-OF-YOUR-CHOICE` to the prompt block. + +#### Example code block used as context within a prompt block + +````markdown +Add an id to the code block whose code you want to add to the prompt as context: + +```javascript id=js-age +function logPersonsAge(a, b, c) { + if (c) { + console.log(a + " is " + b + " years old."); + } else { + console.log(a + " does not want to reveal their age."); + } +} +``` + +Then, elsewhere in the same article, reference the id in the prompt block: + +```copilot copy prompt ref=js-age +Improve the variable names in this function +``` +```` + +There are many examples of prompt blocks with context in the {% data variables.product.prodname_copilot_short %} Cookbook. For example, see [AUTOTITLE](/free-pro-team@latest/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability). + +### Inline prompts + +For most inline prompts, mark these by using backticks, just like inline code. + +If the prompt does not require any context, you can add a clickable {% data variables.product.prodname_copilot_short %} icon after the prompt. This allows the reader to run the prompt in {% data variables.copilot.copilot_chat_short %} on {% data variables.product.prodname_dotcom_the_website %}. To add the clickable icon, surround the prompt with Liquid syntax tags: + +```markdown +{% raw %}... you can click {% prompt %}what is git{% endprompt %} to run this ...{% endraw %} +``` + +This is rendered as: + +... you can click {% prompt %}what is git{% endprompt %} to run this ... + ## Octicons Octicons are icons used across {% data variables.product.prodname_dotcom %}’s interface. We reference Octicons when documenting the user interface and to indicate binary values in tables. Find the name of specific Octicons on the [Octicons site](https://primer.style/octicons). diff --git a/content/copilot/concepts/ai-tools.md b/content/copilot/concepts/ai-tools.md index d14b4502ccbd..b1929d8ab3c4 100644 --- a/content/copilot/concepts/ai-tools.md +++ b/content/copilot/concepts/ai-tools.md @@ -45,7 +45,7 @@ On {% data variables.product.github %}, use **{% data variables.product.prodname Once you've chosen an issue to address, **{% data variables.copilot.copilot_chat_short %}** can help you brainstorm ideas for your project and learn about the various tools, libraries, and resources you might need. You can ask {% data variables.copilot.copilot_chat_short %} generalized questions about the project you're envisioning to get suggestions on a path forward. For example: -> I'd like to build an web app that helps users track their daily habits and provides personalized recommendations. Can you suggest features and technologies I could use? +`I'd like to build an web app that helps users track their daily habits and provides personalized recommendations. Can you suggest features and technologies I could use?` ## Creation @@ -59,27 +59,27 @@ With **{% data variables.copilot.next_edit_suggestions %}** ({% data variables.r Use {% data variables.copilot.copilot_chat_short %} in **ask mode** as your pair programmer to get help with coding tasks, understand tricky concepts, and improve your code. You can ask it questions, get explanations, or request suggestions in real time. -> Can you explain what this JavaScript function does? I'm not sure why it uses a `forEach` loop instead of a `for` loop. +* `Can you explain what this JavaScript function does? I'm not sure why it uses a forEach loop instead of a for loop.` -> What’s the difference between `let`, `const`, and `var` in JavaScript? When should I use each one? +* `What’s the difference between let, const, and var in JavaScript? When should I use each one?` ### Using {% data variables.copilot.copilot_chat_short %} in edit mode Use {% data variables.copilot.copilot_chat_short %} in **edit mode** when you want more granular control over the edits that {% data variables.product.prodname_copilot_short %} proposes. In edit mode, you choose which files {% data variables.product.prodname_copilot_short %} can make changes to, provide context to {% data variables.product.prodname_copilot_short %} with each iteration, and decide whether or not to accept the suggested edits. -> Refactor the `calculateTotal` function to improve readability and efficiency. +* `Refactor the calculateTotal function to improve readability and efficiency.` -> The login function is not working as expected. Can you debug it? +* `The login function is not working as expected. Can you debug it?` -> Format this code to follow Python’s PEP 8 style guide. +* `Format this code to follow Python’s PEP 8 style guide.` ### Using {% data variables.copilot.copilot_chat_short %} in agent mode In **agent mode**, {% data variables.copilot.copilot_chat_short %} can assist with automating repetitive tasks and managing your workflow directly within your project. Use it to create pull requests after you make code changes. You can also use it to run tests and linters in the background while you're working on your project. - > Create a pull request for the recent changes in the `user-auth` module and include a summary of the updates. +* `Create a pull request for the recent changes in the user-auth module and include a summary of the updates.` - > Run all tests and linters for the `payment-processing` module and provide a summary of any issues or errors found. +* `Run all tests and linters for the payment-processing module and provide a summary of any issues or errors found.` ## Reviews @@ -98,13 +98,13 @@ The testing phase validates that your application works as intended. This phase **{% data variables.copilot.copilot_chat_short %}** can assist by generating unit and integration tests, debugging failures, and suggesting additional test cases to ensure comprehensive coverage. Here are some example prompts: -> Write unit tests for this function to calculate the factorial of a number. Include edge cases like 0 and negative numbers. +* `Write unit tests for this function to calculate the factorial of a number. Include edge cases like 0 and negative numbers.` -> How do I run these tests using Python's unittest framework? +* `How do I run these tests using Python's unittest framework?` -> Write integration tests for the `deposit` function in the BankAccount class. Use mocks to simulate the NotificationSystem. +* `Write integration tests for the deposit function in the BankAccount class. Use mocks to simulate the NotificationSystem.` -> What additional tests should I include to ensure full coverage for this module? +* `What additional tests should I include to ensure full coverage for this module?` ## Deployment @@ -112,11 +112,11 @@ The deployment phase involves preparing your code for production and ensuring a **{% data variables.copilot.copilot_chat_short %}** can help you configure deployment scripts, set up CI/CD pipelines, and troubleshoot issues. Here are some example prompts: -> Write a deployment script for a Node.js application using GitHub Actions to deploy to an AWS EC2 instance. +* `Write a deployment script for a Node.js application using GitHub Actions to deploy to an AWS EC2 instance.` -> Set up a GitHub Actions workflow to build, test, and deploy a Python application to Heroku. +* `Set up a GitHub Actions workflow to build, test, and deploy a Python application to Heroku.` -> Analyze this deployment log and suggest why the deployment failed. +* `Analyze this deployment log and suggest why the deployment failed.` ## Operation @@ -126,11 +126,11 @@ You can use the **{% data variables.copilot.copilot_coding_agent %}** ({% data v For issues you're tackling yourself, use **{% data variables.copilot.copilot_chat_short %}** for help analyzing logs, debugging issues, and suggesting optimizations. For example: -> Analyze this error log and suggest possible causes for the issue. +* `Analyze this error log and suggest possible causes for the issue.` -> Write a script to monitor the memory usage of this application and alert when it exceeds a threshold. +* `Write a script to monitor the memory usage of this application and alert when it exceeds a threshold.` -> How can I optimize the database queries in this code to improve performance? +* `How can I optimize the database queries in this code to improve performance?` ## Next steps diff --git a/content/copilot/concepts/prompt-engineering.md b/content/copilot/concepts/prompt-engineering.md index 9033bd7f00ff..a547d34cc041 100644 --- a/content/copilot/concepts/prompt-engineering.md +++ b/content/copilot/concepts/prompt-engineering.md @@ -23,11 +23,13 @@ When writing a prompt for {% data variables.product.prodname_copilot_short %}, f For example: -> Write a function that tells me if a number is prime -> -> The function should take an integer and return true if the integer is prime -> -> The function should error if the input is not a positive integer +```copilot copy prompt +Write a JavaScript function that tells me if a number is prime + +The function should take an integer and return true if the integer is prime + +The function should error if the input is not a positive integer +``` ## Give examples @@ -35,22 +37,24 @@ Use examples to help {% data variables.product.prodname_copilot_short %} underst For example: -> Write a function that finds all dates in a string and returns them in an array. Dates can be formatted like: -> -> * 05/02/24 -> * 05/02/2024 -> * 5/2/24 -> * 5/2/2024 -> * 05-02-24 -> * 05-02-2024 -> * 5-2-24 -> * 5-2-2024 -> -> Example: -> -> findDates("I have a dentist appointment on 11/14/2023 and book club on 12-1-23") -> -> Returns: ["11/14/2023", "12-1-23"] +```copilot copy prompt +Write a Go function that finds all dates in a string and returns them in an array. Dates can be formatted like: + +* 05/02/24 +* 05/02/2024 +* 5/2/24 +* 5/2/2024 +* 05-02-24 +* 05-02-2024 +* 5-2-24 +* 5-2-2024 + +Example: + +findDates("I have a dentist appointment on 11/14/2023 and book club on 12-1-23") + +Returns: ["11/14/2023", "12-1-23"] +``` Unit tests can also serve as examples. Before writing your function, you can use {% data variables.product.prodname_copilot_short %} to write unit tests for the function. Then, you can ask {% data variables.product.prodname_copilot_short %} to write a function described by those unit tests. diff --git a/content/copilot/get-started/quickstart.md b/content/copilot/get-started/quickstart.md index a44c632fc99a..1f961f421382 100644 --- a/content/copilot/get-started/quickstart.md +++ b/content/copilot/get-started/quickstart.md @@ -52,9 +52,9 @@ To use {% data variables.product.prodname_copilot_short %} on the {% data variab For example, you could enter: - * Explain this file. - * How could I improve this code? - * How can I test this code? + * `Explain this file.` + * `How could I improve this code?` + * `How can I test this code?` {% data variables.product.prodname_copilot_short %} responds to your request in the panel. diff --git a/content/copilot/how-tos/provide-context/use-mcp/use-the-github-mcp-server.md b/content/copilot/how-tos/provide-context/use-mcp/use-the-github-mcp-server.md index d599f2420d94..e4cff5ef3b80 100644 --- a/content/copilot/how-tos/provide-context/use-mcp/use-the-github-mcp-server.md +++ b/content/copilot/how-tos/provide-context/use-mcp/use-the-github-mcp-server.md @@ -434,7 +434,7 @@ To configure the remote {% data variables.product.github %} MCP server with a PA } } ``` - + ## Using the {% data variables.product.github %} MCP server in Xcode The {% data variables.product.github %} MCP server enables you to perform a wide range of actions on {% data variables.product.github %}, via {% data variables.copilot.copilot_chat_short %} in Xcode. @@ -546,8 +546,12 @@ The {% data variables.product.github %} MCP server is automatically configured i 1. In the prompt box, type a request related to the skill you want {% data variables.copilot.copilot_chat_short %} to perform, and press **Enter**. Some examples of requests you can make are: - * `Create a new branch called [BRANCH-NAME] in the repository [USERNAME/REPO-NAME].` - * `Merge the pull request [PULL-REQUEST-NUMBER] in the repository [USERNAME/REPO-NAME].` + + {% prompt %}Create a new branch called [BRANCH-NAME] in the repository [OWNER/REPO-NAME].{% endprompt %} + + {% prompt %}Search for users with the name [USER-NAME]{% endprompt %} + + {% prompt %}Merge the pull request [PR-NUMBER] in the repository [OWNER/REPO-NAME].{% endprompt %} 1. {% data variables.copilot.copilot_chat_short %} will ask you to confirm that you want to proceed with the action. Click **Allow** to confirm. 1. {% data variables.copilot.copilot_chat_short %} will use the relevant skill from the {% data variables.product.github %} MCP server to perform the action you requested. {% data variables.copilot.copilot_chat_short %} will show you the result of the action in the chat interface. diff --git a/content/copilot/how-tos/use-chat/get-started-with-chat.md b/content/copilot/how-tos/use-chat/get-started-with-chat.md index 0b8f66c8b3d4..63652004b837 100644 --- a/content/copilot/how-tos/use-chat/get-started-with-chat.md +++ b/content/copilot/how-tos/use-chat/get-started-with-chat.md @@ -251,9 +251,9 @@ Some of the example prompts require you to be in a specific context on the {% da You can ask {% data variables.copilot.copilot_chat_short %} general software questions. For example: -* `tell me about nodejs web server frameworks` -* `how can I create an Express app` -* `what is the best way to update an npm package` +* {% prompt %}tell me about nodejs web server frameworks{% endprompt %} +* {% prompt %}how can I create an Express app{% endprompt %} +* {% prompt %}what is the best way to update an npm package{% endprompt %} ## Ask questions about a repository diff --git a/content/copilot/how-tos/use-chat/use-chat-in-github.md b/content/copilot/how-tos/use-chat/use-chat-in-github.md index 0288ca0f065f..c7b5841f8532 100644 --- a/content/copilot/how-tos/use-chat/use-chat-in-github.md +++ b/content/copilot/how-tos/use-chat/use-chat-in-github.md @@ -35,11 +35,11 @@ Depending on the question you ask, and your enterprise and organization settings Some examples of general questions you could ask are: - * `What are the advantages of the Go programming language?` - * `What is Agile software development?` - * `What is the most popular JavaScript framework?` - * `Give me some examples of regular expressions.` - * `Write a bash script to output today's date.` + * {% prompt %}What are the advantages of the Go programming language?{% endprompt %} + * {% prompt %}What is Agile software development?{% endprompt %} + * {% prompt %}What is the most popular JavaScript framework?{% endprompt %} + * {% prompt %}Give me some examples of regular expressions.{% endprompt %} + * {% prompt %}Write a bash script to output today's date.{% endprompt %} {% data reusables.copilot.stop-response-generation %} 1. If {% data variables.product.prodname_copilot_short %} uses a Bing search to answer your question, you can click the **_n_ references** link at the top of the response to see the search results that {% data variables.product.prodname_copilot_short %} used to answer your question. @@ -59,7 +59,7 @@ Depending on the question you ask, and your enterprise and organization settings When you ask a question, {% data variables.product.prodname_copilot_short %} may generate one or more files as part of its response. In the {% data variables.copilot.copilot_chat_short %} panel, the files are displayed inline, within the chat response. In immersive view (that is, at [https://github.com/copilot](https://github.com/copilot)), the generated files are displayed in a side panel. You can view and edit the files in the panel, or download them to your computer. -For example, asking `Generate a simple calculator using HTML, CSS, and JavaScript` may generate multiple files, such as `index.html`, `styles.css`, and `script.js`. +For example, asking {% prompt %}Generate a simple calculator using HTML, CSS, and JavaScript{% endprompt %} may generate multiple files, such as `index.html`, `styles.css`, and `script.js`. In immersive view, you can also preview how some file formats, such as Markdown, render by toggling to the "Preview" tab in the side panel. @@ -118,9 +118,9 @@ To navigate between subthreads: {% data variables.product.prodname_copilot_short %} has access to a collection of skills to fetch data from {% data variables.product.github %}, which are dynamically selected based on the question you ask. -You can explicitly ask {% data variables.copilot.copilot_chat_dotcom %} to use a particular skill - for example, `Use the Bing skill to find the latest GPT4 model from OpenAI`. +You can explicitly ask {% data variables.copilot.copilot_chat_dotcom %} to use a particular skill - for example, {% prompt %}Use the Bing skill to find the latest GPT4 model from OpenAI.{% endprompt %} -Generate a list of currently available skills by asking {% data variables.product.prodname_copilot_short %}: `What skills are available?` +Generate a list of currently available skills by asking {% data variables.product.prodname_copilot_short %}: {% prompt %}What skills are available?{% endprompt %} ## Asking {% data variables.copilot.copilot_chat_short %} questions in different contexts @@ -171,9 +171,9 @@ You can ask {% data variables.product.prodname_copilot_short %} a question about For example, you could enter: - * What does this repo do? - * Where is authentication implemented in this codebase? - * How does license file detection work in this repo? + * `What does this repo do?` + * `Where is authentication implemented in this codebase?` + * `How does license file detection work in this repo?` 1. Click **Ask {% data variables.product.prodname_copilot_short %}**. diff --git a/content/copilot/how-tos/use-chat/use-chat-in-mobile.md b/content/copilot/how-tos/use-chat/use-chat-in-mobile.md index 941a5fb0030e..8e5ca5f3890e 100644 --- a/content/copilot/how-tos/use-chat/use-chat-in-mobile.md +++ b/content/copilot/how-tos/use-chat/use-chat-in-mobile.md @@ -63,11 +63,11 @@ You can ask a general question about software development{% ifversion ghec %} th 1. At the bottom of the page, in the "Ask {% data variables.product.prodname_copilot_short %}" box, type a question and send the message. Some examples of general questions you could ask are: - * What are the advantages of the Go programming language? - * What is Agile software development? - * What is the most popular JavaScript framework? - * Give me some examples of regular expressions. - * Write a bash script to output today's date. + * `What are the advantages of the Go programming language?` + * `What is Agile software development?` + * `What is the most popular JavaScript framework?` + * `Give me some examples of regular expressions.` + * `Write a bash script to output today's date.` 1. Within a conversation thread, you can ask follow-up questions. {% data variables.product.prodname_copilot_short %} will answer within the context of the conversation. For example, you could type "tell me more" to get {% data variables.product.prodname_copilot_short %} to expand on its last comment. @@ -84,11 +84,11 @@ You can ask questions about a specific repository, to get help with understandin For example, if you chose the repository you are working in as the context, you could ask: - * What is the main purpose of this repo? What problem does it solve or what functionality does it provide? - * What web frameworks are used in this project? - * Where is rate limiting implemented in our API? - * How is the code organized? Explain the project architecture. - * Are there any specific environment requirements for working on this project? + * `What is the main purpose of this repo? What problem does it solve or what functionality does it provide?` + * `What web frameworks are used in this project?` + * `Where is rate limiting implemented in our API?` + * `How is the code organized? Explain the project architecture.` + * `Are there any specific environment requirements for working on this project?` > [!IMPORTANT] > {% data variables.product.prodname_copilot_short %}'s ability to answer natural language questions like these in a repository context is improved when the repository has been indexed for semantic code search. Without indexing, {% data variables.copilot.copilot_mobile_short %} may not be able to provide the most relevant answers to your questions. @@ -110,15 +110,15 @@ You can chat with {% data variables.product.prodname_copilot_short %} about a fi For example, if you are asking about the entire file, you could enter: - * Explain this file. - * How could I improve this code? - * How can I test this script? + * `Explain this file.` + * `How could I improve this code?` + * `How can I test this script?` If you are asking about specific lines, you could enter: - * How could I improve this class? - * Add error handling to this code. - * Write a unit test for this method. + * `How could I improve this class?` + * `Add error handling to this code.` + * `Write a unit test for this method.` {% data variables.product.prodname_copilot_short %} responds to your request in the panel. @@ -135,10 +135,10 @@ You can ask questions about a specific pull request in a repository. For example, you could ask: - * What is the purpose of this pull request? - * What changes are being made in this pull request? - * Are there any potential issues with this pull request? - * What is the status of this pull request? + * `What is the purpose of this pull request?` + * `What changes are being made in this pull request?` + * `Are there any potential issues with this pull request?` + * `What is the status of this pull request?` {% data variables.product.prodname_copilot_short %} responds to your request in the panel. @@ -153,10 +153,10 @@ You can ask questions about a specific issue in a repository. For example, you could ask: - * What is the purpose of this issue? - * What is the status of this issue? - * What are the steps to reproduce this issue? - * Are there any potential solutions to this issue? + * `What is the purpose of this issue?` + * `What is the status of this issue?` + * `What are the steps to reproduce this issue?` + * `Are there any potential solutions to this issue?` {% data variables.product.prodname_copilot_short %} responds to your request in the panel. @@ -171,10 +171,10 @@ You can ask questions about a specific discussion in a repository. For example, you could ask: - * What is the purpose of this discussion? - * What are the main points of this discussion? - * What are the next steps for this discussion? - * Are there any potential issues with this discussion? + * `What is the purpose of this discussion?` + * `What are the main points of this discussion?` + * `What are the next steps for this discussion?` + * `Are there any potential issues with this discussion?` {% data variables.product.prodname_copilot_short %} responds to your request in the panel. diff --git a/content/copilot/how-tos/use-copilot-for-common-tasks/use-copilot-to-create-issues.md b/content/copilot/how-tos/use-copilot-for-common-tasks/use-copilot-to-create-issues.md index d62e0260b617..cffb47c3d942 100644 --- a/content/copilot/how-tos/use-copilot-for-common-tasks/use-copilot-to-create-issues.md +++ b/content/copilot/how-tos/use-copilot-for-common-tasks/use-copilot-to-create-issues.md @@ -30,13 +30,13 @@ You can create issues from {% data variables.copilot.copilot_chat_short %}'s imm 1. Go to the immersive view of {% data variables.copilot.copilot_chat_short %} ([https://github.com/copilot](https://github.com/copilot)). 1. In the prompt box, describe the issue you want to create. - If you contribute issues to multiple repositories, use the `organization/repository` format to specify the target repository for this issue. If you don't specify a repository, {% data variables.product.prodname_copilot_short %} will infer the repository based on the repository you last created an issue in. + If you contribute issues to multiple repositories, use the `repo-owner/repo-name` format to specify the target repository for this issue. If you don't specify a repository, {% data variables.product.prodname_copilot_short %} will infer the repository based on the repository you last created an issue in. For example: - * `In octo-org/octo-repo, create a feature request to add fuzzy matching to search.` - * `Log a bug for a 500 error. This happens consistently when I try to log into the site.` - * `Create a task to change the application logo background to red and add the label "needs design review".` + * {% prompt %}In OWNER/REPOSITORY, create a feature request to add fuzzy matching to search.{% endprompt %} + * {% prompt %}Log a bug for a 500 error. This happens consistently when I try to log into the site.{% endprompt %} + * {% prompt %}Create a task to change the application logo background to red and add the label "needs design review".{% endprompt %} > [!NOTE] You can only use {% data variables.product.prodname_copilot_short %} to create issues in repositories where you already have permission to create issues. This feature doesn't change your access or bypass repository permissions. @@ -71,9 +71,7 @@ You can create issues from {% data variables.copilot.copilot_chat_short %}'s imm If your prompt includes multiple tasks or bugs, {% data variables.product.prodname_copilot_short %} can draft more than one issue at a time. -For example: - -`In octo-org/octo-repo, create 3 issues: 1) DETAILS OF ONE TASK, 2) DETAILS OF ANOTHER TASK, 3) DETAILS OF A THIRD TASK` +For example: {% prompt %}In OWNER/REPOSITORY, create 3 issues: 1) DETAILS OF ONE TASK, 2) DETAILS OF ANOTHER TASK, 3) DETAILS OF A THIRD TASK{% endprompt %} Each draft appears separately, and you can review and edit them individually. To publish the issues, click **Create** on each one you want to submit. @@ -121,7 +119,7 @@ To assign an issue to {% data variables.product.prodname_copilot_short %}, you n You can assign the issue during creation in one of two ways: -* **Natural language:** Prompt {% data variables.product.prodname_copilot_short %} with something like “Assign this issue to {% data variables.product.prodname_copilot_short %}." +* **Natural language:** Prompt {% data variables.product.prodname_copilot_short %} with something like `Assign this issue to {% data variables.product.prodname_copilot_short %}.` * **Manually:** Select "{% data variables.product.prodname_copilot_short %}" from the assignee list. Once the issue is assigned and created, {% data variables.product.prodname_copilot_short %} will start working on it automatically. You’ll see a 👀 emoji reaction on the issue to indicate that {% data variables.product.prodname_copilot_short %} is working on it. diff --git a/content/copilot/tutorials/build-apps-with-spark.md b/content/copilot/tutorials/build-apps-with-spark.md index 9cf736a9a995..0faa6bdab59c 100644 --- a/content/copilot/tutorials/build-apps-with-spark.md +++ b/content/copilot/tutorials/build-apps-with-spark.md @@ -38,7 +38,7 @@ For this tutorial, we'll create a simple marketing tool app, where: 1. Navigate to https://github.com/spark. 1. In the input field, enter a description of your app. For example: - ```text copy + ```copilot copy Build an app called "AI-Powered Marketing Assistant." The app should allow users to input a brief description of a product or service. When the user submits their brief, send this information to a generative AI model with a prompt that asks the AI to return the following: @@ -99,7 +99,7 @@ For our marketing app, let's add data storage so that users can save their favor 1. Use the following instruction in the "Iterate" tab to guide {% data variables.product.prodname_spark_short %}: - ```text copy + ```copilot copy Add a "Favorites" page where users can save and view their favorite marketing copy results. ``` diff --git a/content/copilot/tutorials/compare-ai-models.md b/content/copilot/tutorials/compare-ai-models.md index 8e28c096abb1..04adc10a165f 100644 --- a/content/copilot/tutorials/compare-ai-models.md +++ b/content/copilot/tutorials/compare-ai-models.md @@ -31,7 +31,7 @@ Consider a scenario where you are writing helper functions for access control in Below is the helper function that grants editor access to a document: -```python +```python id=grant-editor-access def grant_editor_access(user_id, doc_id): access = AccessManager() access.assign_role( @@ -44,7 +44,9 @@ def grant_editor_access(user_id, doc_id): ### Example prompt -`Add a docstring to the function that explains what it does.` +```copilot prompt copy ref=grant-editor-access +Add a docstring to the function that explains what it does. +``` ### Example response @@ -87,7 +89,7 @@ Suppose you are building a utility script and need to filter a list of user reco Here’s a sample list of users: -```python +```python id=user-list users = [ {"name": "Alice", "active": True, "signup_date": "2023-12-10"}, {"name": "Bob", "active": False, "signup_date": "2023-11-05"}, @@ -97,7 +99,9 @@ users = [ ### Example prompt -`Filter the list of users to only include active users, and sort them by signup_date.` +```copilot prompt copy ref=user-list +Filter the list of users to only include active users, and sort them by signup_date. +``` ### Example response @@ -131,7 +135,9 @@ You’re designing a shopping cart system and have a UML class diagram that outl ### Example prompt -`Use this UML diagram to generate the classes for a shopping cart system.` +```copilot copy +Use this UML diagram to generate the classes for a shopping cart system. +``` ### Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md b/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md index 6f9eb4b7c815..8a3eb29bdab5 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md @@ -35,7 +35,9 @@ This example assumes that you use labels to track issues related to user feedbac Navigate to the **Issues** tab in your repository, then type: -`Find the issues with the feedback label that have the most reactions, and categorize them based on sentiment.` +```copilot copy +Find the issues with the feedback label that have the most reactions, and categorize them based on sentiment. +``` >[!TIP] To try out this prompt, you can go to the [`microsoft/vscode`](https://github.com/microsoft/vscode/issues) repository, which uses labels to track feature requests, and type: `Find the issues with the feature-request label that have the most reactions, and categorize them based on sentiment.` @@ -76,7 +78,9 @@ In this scenario, you've chosen a piece of user feedback to address. Someone req This example assumes you are asking about an issue in the same repository where you are using {% data variables.copilot.copilot_chat_short %}. -`Write a feature specification for Issue #426.` +```copilot copy +Write a feature specification for Issue #426. +``` ### Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md b/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md index b8761e9dd766..f539cecc9b3d 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md @@ -25,7 +25,7 @@ When tasked with implementing new features or enhancing existing ones, developer You're assigned the task of creating a new feature that displays the most recently viewed items on a user dashboard. Below is an example issue for implementing this functionality: -```text +```text id=recent-items-feature [Feature Request] Add "Recent Items" section to user dashboard #753 ## Issue Description @@ -49,7 +49,9 @@ You want to evaluate different approaches to this implementation to see whether Navigate to the issue, then type: -`Given the criteria in Issue #753, list options for implementation and tradeoffs for each option.` +```copilot copy prompt ref=recent-items-feature +Given the criteria in Issue #753, list options for implementation and tradeoffs for each option. +``` >[!TIP] When you are using {% data variables.product.prodname_copilot_short %} to help identify implementation options, it's good practice to start with a general prompt to spark ideas, like in this example. Then you can follow up with more specific questions to dive more deeply into the options it suggests. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md index a0838c0b3dcb..dc208296aa28 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md @@ -27,7 +27,7 @@ While they may be considered "common knowledge" by many developers, the vast maj The JavaScript code below has a potential XSS vulnerability that could be exploited if the `name` parameter is not properly sanitized before being displayed on the page. -```javascript +```javascript id=potential-xss function displayName(name) { const nameElement = document.getElementById('name-display'); nameElement.innerHTML = `Showing results for "${name}"` @@ -38,7 +38,9 @@ function displayName(name) { You can ask {% data variables.copilot.copilot_chat_short %} to analyze code for common security vulnerabilities and provide explanations and fixes for the issues it finds. -`Analyze this code for potential security vulnerabilities and suggest fixes.` +```copilot copy prompt ref=potential-xss +Analyze this code for potential security vulnerabilities and suggest fixes. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md index 298e44626ab9..ee399dac1a28 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md @@ -33,11 +33,13 @@ Before you begin, ensure that {% data variables.product.prodname_dependabot %} i Make sure your repository is attached to the prompt for context. -`Analyze the codebase and project structure of this repository. Detect all package managers and package ecosystems in use, including their respective locations (e.g., npm, yarn, pip, maven, gradle, composer, github-actions, etc.).` +```copilot copy +Analyze the codebase and project structure of this repository. Detect all package managers and package ecosystems in use, including their respective locations (e.g., npm, yarn, pip, maven, gradle, composer, github-actions, etc.). -`For each detected ecosystem, create a configuration entry in a single, top-level .github/dependabot.yml file that enables security and version updates on a reasonable schedule. Use the recommended best practices for each ecosystem. Clearly specify the directory for each ecosystem detected. If multiple ecosystems or multiple directories are present, include them all in the configuration.` +For each detected ecosystem, create a configuration entry in a single, top-level .github/dependabot.yml file that enables security and version updates on a reasonable schedule. Use the recommended best practices for each ecosystem. Clearly specify the directory for each ecosystem detected. If multiple ecosystems or multiple directories are present, include them all in the configuration. -`In the output, include any notes on the configuration or best practices, as well as next steps that include how to commit the dependabot.yml file to the repository via the GitHub web browser and how to check that Dependabot version updates and Dependabot security updates are enabled.` +In the output, include any notes on the configuration or best practices, as well as next steps that include how to commit the dependabot.yml file to the repository via the GitHub web browser and how to check that Dependabot version updates and Dependabot security updates are enabled. +``` ### Example output @@ -102,17 +104,16 @@ You want to customize your {% data variables.product.prodname_dependabot %} conf ### Example prompt -`I want to customize my pull requests for Dependabot security and version updates, so that:` - -`* Pull requests are automatically assigned to the team "octocat-reviewers."` - -`* The label "security-management" is automatically added to every pull request.` +```copilot copy +I want to customize my pull requests for Dependabot security and version updates, so that: -`* The number of open Dependabot PRs is limited.` +* Pull requests are automatically assigned to the team "octocat-reviewers." +* The label "security-management" is automatically added to every pull request. +* The number of open Dependabot PRs is limited. +* Development dependencies are ignored. -`* Development dependencies are ignored.` - -`Draft an update to the dependabot.yml file in my repository that specifies these customization options.` +Draft an update to the dependabot.yml file in my repository that specifies these customization options. +``` > [!TIP] > * There are many customization options to explore. For more information, see [AUTOTITLE](/code-security/dependabot/dependabot-security-updates/customizing-dependabot-security-prs) and [AUTOTITLE](/code-security/dependabot/dependabot-version-updates/customizing-dependabot-prs). @@ -144,4 +145,4 @@ updates: prefix: "pip" ignore: - dependency-name: "pip" -``` +``` diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md index e54f38834663..8072715f678d 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md @@ -27,19 +27,17 @@ Let's say you recently created a repository for a new web application, you want ### Example prompt -`Provide step-by-step instructions on how to enable the following essential security features in my GitHub repository:` +```copilot copy prompt +Provide step-by-step instructions on how to enable the following essential security features in my GitHub repository: -`* Secret scanning` +* Secret scanning +* Push protection +* Dependabot alerts +* Dependabot security updates +* Branch protection rules, including enforced code reviews before merging -`* Push protection` - -`* Dependabot alerts` - -`* Dependabot security updates` - -`* Branch protection rules, including enforced code reviews before merging` - -`Explain why each feature is important and how it helps secure my repository.` +Explain why each feature is important and how it helps secure my repository. +``` ### Example response @@ -74,17 +72,16 @@ Let's say you want to share your project publicly, and want to set out a clear s ### Example prompt -`Write a GitHub security policy (SECURITY.md) for my repository. The policy should include:` +```copilot copy prompt +Write a GitHub security policy (SECURITY.md) for my repository. The policy should include: -`* A clear description of how users can report security vulnerabilities.` +* A clear description of how users can report security vulnerabilities. +* A response timeline for security issues. +* Guidelines for responsible disclosure. +* Supported versions of the software. -`* A response timeline for security issues.` - -`* Guidelines for responsible disclosure.` - -`* Supported versions of the software.` - -`Format it as a well-structured Markdown document.` +Format it as a well-structured Markdown document. +``` ### Example output @@ -97,7 +94,7 @@ Thank you for helping to keep this project and its users secure! This document o ## Reporting a Vulnerability -If you discover a security vulnerability, please report it by emailing **security@yourdomain.com** or by using the GitHub [security advisories](https://github.com/octocat/octocat-repo/security/advisories) feature. +If you discover a security vulnerability, please report it by emailing **security@yourdomain.com** or by using the GitHub [security advisories](https://github.com/octocat/octocat-repo/security/advisories) feature. **Do not** report security vulnerabilities via public GitHub issues or pull requests. When reporting a vulnerability, please include as much information as possible to help us understand and reproduce the issue: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md index dd1611407a55..4e7840506e90 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md @@ -22,7 +22,9 @@ You want to create a Gantt chart to visualize the timeline of a project. You can ## Example prompt -`Create a mermaid gantt diagram that covers the period August 1st 2025 until January 31st, 2025. Include 5 phases, each taking 6 weeks, and overlapping equally.` +```copilot copy prompt +Create a mermaid gantt diagram that covers the period August 1st 2025 until January 31st, 2025. Include 5 phases, each taking 6 weeks, and overlapping equally. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md index 616cd3d83830..2fc31440f378 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md @@ -22,7 +22,9 @@ You are reviewing a long discussion thread about a feature request. You want to ## Example prompt -`Can you summarize the key points and action items from this discussion?` +```copilot copy +Can you summarize the key points and action items from this discussion? +``` ## Example response @@ -44,7 +46,9 @@ You have a number of open issues assigned to you, and you want to extract the de ## Example prompt -`Can you list the open issues assigned to me, along with their deadlines and priorities?` +```copilot copy prompt +Can you list the open issues assigned to me, along with their deadlines and priorities? +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md b/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md index 996d8e4079cb..833c4bfcf29a 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md @@ -34,7 +34,7 @@ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined' Below is the JSON data that caused the error: -```json +```json id=json-error { "location": "San Francisco", "current_weather": { @@ -53,7 +53,9 @@ Below is the JSON data that caused the error: ## Example prompt -`Why is my JSON object invalid and how can I fix it?` +```copilot copy prompt ref=json-error +Why is my JSON object invalid and how can I fix it? +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md b/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md index 7a4fe971aac2..63cf6f16bb4b 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md @@ -25,7 +25,7 @@ When making requests to APIs, it's common to encounter rate limits that restrict The following Python code fetches weather data from an external API. If the API has rate limits, requests may fail when limits are exceeded, and your app may need a way to handle these responses gracefully by implementing retry logic. -```python +```python id=rate-limit-example from flask import Flask, request import requests @@ -45,7 +45,9 @@ def get_weather(): ## Example prompt -`How can I handle API rate limits within get_weather().` +```copilot copy prompt ref=rate-limit-example +How can I handle API rate limits within get_weather(). +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md b/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md index 4a728ad79fe0..0e6024ddd0b8 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md @@ -24,7 +24,7 @@ Working with legacy code can be challenging for developers, especially when the The block of COBOL below connects to a database and inserts a record. The code lacks documentation, which makes it difficult to understand what it does and how it works. -```text +```text id=cobol-insert-record IDENTIFICATION DIVISION. PROGRAM-ID. INSERT-RECORD. @@ -75,9 +75,11 @@ INSERT-AND-VALIDATE. ## Example prompt -We can use a simple prompt to ask {% data variables.copilot.copilot_chat_short %} to document the code. +We can use a simple prompt to ask {% data variables.copilot.copilot_chat_short %} to add documentation to the code. -`Document this code` +```copilot copy prompt ref=cobol-insert-record +Comment this code thoroughly +``` > [!NOTE] If you want the documentation generated in another format like Markdown, you can specify the desired output format in the prompt. For example: `Document this code in Markdown`. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md b/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md index a00e9c45e129..a4a4a3394c64 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md @@ -25,7 +25,7 @@ There may be times where you need to explain complex algorithms or logic in your In the C# code below, we have a method which fetches data, retries if there's an error, and updates a status label. You might want to explain, in comments in the code, how the method works and how it handles retries and cancellations. -```csharp +```csharp id=fetch-data-with-retry private static readonly HttpClient _client = new HttpClient(); public async Task FetchDataFromApiWithRetryAsync(string apiUrl, CancellationToken cancellationToken, int maxRetries, int cancellationDelay, Label statusLabel) @@ -82,7 +82,9 @@ private void UpdateStatusLabel(string message, Label statusLabel) We can ask {% data variables.copilot.copilot_chat_short %} to make this code easier to understand using comments. -`Add comments to this code to make it more understandable` +```copilot copy prompt ref=fetch-data-with-retry +Add comments to this code to make it more understandable +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md b/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md index 628349baaa5f..8b2d922ae104 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md @@ -25,7 +25,7 @@ One of the biggest challenges with legacy code is helping developers understand Consider the following COBOL code. If you're a Python developer (as an example), you might not be familiar with COBOL, so you could ask {% data variables.copilot.copilot_chat_short %} to explain the code to you. -```text +```text id=cobol-insert-record IDENTIFICATION DIVISION. PROGRAM-ID. INSERT-RECORD. @@ -78,7 +78,9 @@ INSERT-AND-VALIDATE. You can ask for an explanation of the COBOL code from the point of view of a Python developer. -`I'm a Python developer. Help me better understand this code. Please provide analogies.` +```copilot copy prompt ref=cobol-insert-record +I'm a Python developer. Help me better understand this code. Please provide analogies. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md b/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md index 4064f392767a..0839bd0639c4 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md @@ -25,7 +25,7 @@ It can be difficult to keep documentation up to date with changes to code. Howev Imagine a scenario where you have a TypeScript function that retrieves products by category name, but the documentation is out of date. -```typescript +```typescript id=fetch-products-by-category /** * Retrieves all products belonging to a specific category. * @@ -58,7 +58,9 @@ async getByCategoryName(categoryId: number, page = 1, pageSize = 10): Promise { @@ -54,7 +54,9 @@ export default Counter; ## Example prompt -`Use Redux to separate the UI code from the Counter component in this code.` +```copilot copy prompt ref=counter-component +Use Redux to separate the UI code from the Counter component in this code. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md index 7b976ad2a840..6788033b5cb0 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md @@ -33,7 +33,7 @@ When two or more transactions attempt to update the same rows in a database tabl The following SQL snippet updates one row of a table, then performs an operation that takes several seconds, then updates another row in the same table. This is problematic because the transaction locks the `id = 1` row for several seconds before the transaction completes, releasing the lock. If another transaction starts during this time that performs a similar operation, but locks the `id = 2` row first, so that it can update the row, and then attempts to lock the `id = 1` row, then both transactions will be left waiting for the other to complete, resulting in deadlock. -```sql +```sql id=deadlock-example BEGIN TRANSACTION; UPDATE my_table SET value = 'Some value' WHERE id = 301; -- Simulate a process taking 5 seconds: @@ -48,7 +48,9 @@ You can check whether there are any problems with this transaction. In the editor, select the transaction code, then ask {% data variables.copilot.copilot_chat_short %}: -`Is this transaction good?` +```copilot copy prompt ref=deadlock-example +Is this transaction good? +``` ### Example response 1 @@ -60,7 +62,9 @@ In this case, you decide not to add error handling. Right now you want to addres Enter this follow-up prompt: -`How can I rewrite this code to reduce the chance of deadlock to a minimum while not adversely affecting performance. Tell me anything else I can do to avoid a deadlock. Note: I don't want to add error handling at this time.` +```copilot copy prompt ref=deadlock-example +How can I rewrite this code to reduce the chance of deadlock to a minimum while not adversely affecting performance. Tell me anything else I can do to avoid a deadlock. Note: I don't want to add error handling at this time. +``` ### Example response 2 @@ -90,7 +94,7 @@ Searching table columns that have not been indexed will typically result in a fu The following SQL will result in a full table scan if `some_column` is not indexed: -```sql +```sql id=full-table-scan BEGIN TRANSACTION; SELECT * FROM my_table WHERE some_column = 'some_value'; -- More actions here, then: @@ -101,7 +105,9 @@ COMMIT TRANSACTION; Asking {% data variables.product.prodname_copilot_short %} the following question will usually reveal the potential problem. -`How can I optimize this transaction?` +```copilot copy prompt ref=full-table-scan +How can I optimize this transaction? +``` ### Example response @@ -127,7 +133,7 @@ It's important to avoid long-running queries and transactions, where possible, a The following SQL creates new rows in `target_table`, containing data from selected fields of rows in `source_table` where various conditions are met. If `source_table` is extremely large this may result in a long-running transaction. -```sql +```sql id=long-running-transaction BEGIN TRANSACTION; INSERT INTO target_table (first_name, last_name, email, dept, role, hire_date) @@ -143,7 +149,9 @@ COMMIT; You can ask {% data variables.product.prodname_copilot_short %} whether it's possible to avoid long-running transactions. -`source_table is an extremely large table. Without altering the table, how can I ensure this SQL doesn't become a long-running query, that blocks other operations?` +```copilot copy prompt ref=long-running-transaction +source_table is an extremely large table. Without altering the table, how can I ensure this SQL doesn't become a long-running query, that blocks other operations? +``` ### Example response @@ -192,7 +200,7 @@ It's important that the information in your databases remains accurate, consiste The following SQL transaction deletes an employee record and creates a deletion log. However, it's possible for the `DELETE` operation to succeed and the `INSERT` operation to fail, in which case there is no log record for the deletion. -```sql +```sql id=delete-employee BEGIN TRANSACTION; DELETE FROM employees @@ -206,7 +214,11 @@ COMMIT TRANSACTION; ### Example prompt -`How can I ensure that the DELETE and INSERT operations are only performed if both succeed?` +```copilot copy prompt ref=delete-employee +How can I ensure that the DELETE and INSERT operations are only performed if both succeed? +``` + +### Example response {% data variables.product.prodname_copilot_short %} tells you that you achieve this by using a transaction with error handling. It gives the following example using SQL Server's `TRY...CATCH` construct: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md index 7bdc2a8d0232..4dc14ceff406 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md @@ -29,19 +29,27 @@ You have run a linter on your code and it has identified some issues that need t * Select all of the code in the editor, then type: - `Fix the lint errors` + ```copilot copy + Fix the lint errors + ``` * You can specify a particular set of coding guidelines for a language, such as PEP8 for Python: - `Use PEP8 to fix the lint errors` + ```copilot copy + Use PEP8 to fix the lint errors + ``` * If you have a local file that defines your coding conventions and rules, you can drag the file into the chat window to add it as an attachment, then type: - `Use the attached style guide to fix the lint errors` + ```copilot copy + Use the attached style guide to fix the lint errors + ``` * Alternatively, you can ask {% data variables.copilot.copilot_chat_short %} to fix only a specific type of lint error: - `Make sure all functions use snake_case naming style` + ```copilot copy + Make sure all functions use snake_case naming style + ``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md index b99bf02a8516..7e5408d1101c 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md @@ -95,7 +95,9 @@ class OrderService: Open the project workspace in {% data variables.product.prodname_vscode_shortname %} or {% data variables.product.prodname_vs %} and enter the following prompt in the {% data variables.copilot.copilot_chat_short %} view. -`@workspace Refactor this project by using AOP to avoid logging that has cross-cutting concerns` +```copilot copy +@workspace Refactor this project by using AOP to avoid logging that has cross-cutting concerns +``` > [!NOTE] > The `@workspace` chat participant in {% data variables.product.prodname_vscode_shortname %} and {% data variables.product.prodname_vs %} provides {% data variables.product.prodname_copilot_short %} with context about all of the code in your workspace. You can use `@workspace` when you want {% data variables.product.prodname_copilot_short %} to consider the structure of your project and how different parts of your code interact. If you're using a JetBrains IDE, use `@project` rather than `@workspace`. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md index 2be91f5dcab4..6b2521095433 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md @@ -38,7 +38,7 @@ Descriptive variable names and parameter names make it easier to understand thei This JavaScript code logs a message about a person's age to the console. The abstract parameter names make it difficult to understand the purpose of the code. -```javascript +```javascript id=log-persons-age function logPersonsAge(a, b, c) { if (c) { console.log(a + " is " + b + " years old."); @@ -52,7 +52,9 @@ function logPersonsAge(a, b, c) { In the editor, select the function you want to change, then ask {% data variables.copilot.copilot_chat_short %}: -`Improve the variable names in this function` +```copilot copy prompt ref=log-persons-age +Improve the variable names in this function +``` ### Example response @@ -76,7 +78,7 @@ function logPersonAge(name, age, revealAge) { This Python code prints the sound that various animals make, if defined, or "Unknown animal" if the animal type is not recognized. However, the chain of `if...else` statements makes the code inefficient and cumbersome. -```python +```python id=animal-sound class Animal: def speak(self): pass @@ -111,7 +113,9 @@ print(animal_sound("fish")) ### Example prompt -`Simplify this code. Avoid using if/else chains but retain all function return values.` +```copilot copy prompt ref=animal-sound +Simplify this code. Avoid using if/else chains but retain all function return values. +``` ### Example response @@ -157,7 +161,7 @@ Deeply nested structures can make the code hard to follow, making it difficult t This Ruby code prints information about a user account based on three parameters. The use of nested `if...else` statements makes the code unnecessarily complex. -```ruby +```ruby id=determine-access def determine_access(user_role, has_permission, is_active) if user_role == "admin" if has_permission @@ -182,7 +186,9 @@ puts determine_access("user", true, true) ### Example prompt -`Rewrite this code to avoid the nested if/else statements` +```copilot copy prompt ref=determine-access +Rewrite this code to avoid the nested if/else statements +``` ### Example response @@ -211,7 +217,7 @@ It can be difficult to grasp exactly what a method or function does if it is too This Java method processes a customer order and prints a message. It performs multiple tasks in a single method. -```java +```java id=process-order public void processOrder(Order order) { if (order == null || order.getItems().isEmpty()) { throw new IllegalArgumentException("Order is invalid."); @@ -235,7 +241,9 @@ public void processOrder(Order order) { ### Example prompt -`How could the processOrder method be refactored to be more useful and easier to maintain` +```copilot copy prompt ref=process-order +How could the processOrder method be refactored to be more useful and easier to maintain +``` ### Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md index b8355cbfd035..f9feda3f9300 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md @@ -29,7 +29,7 @@ Hardcoded SQL queries and tightly coupled data access code can make it difficult This Python code connects to a SQLite database, retrieves a user record, and returns the user data. However, it fails to abstract the database connection logic and uses a hardcoded query that's vulnerable to SQL injection. -```python +```python id=database-connection import sqlite3 def get_user_by_id(user_id): @@ -45,7 +45,9 @@ def get_user_by_id(user_id): You can start by asking {% data variables.product.prodname_copilot_short %} a general question about how to improve the code. -`How can I improve this code to make it safe and easier to update and expand? List possible improvements but don't show revised code.` +```copilot copy prompt ref=database-connection +How can I improve this code to make it safe and easier to update and expand? List possible improvements but don't show revised code. +``` ## Example response 1 @@ -60,7 +62,9 @@ You can start by asking {% data variables.product.prodname_copilot_short %} a ge You can use the response to your first prompt to write a more specific prompt. -`Rewrite this code to make it more scalable and easier to maintain. Use a context manager. Avoid hardcoded SQL queries and tightly coupled data access code. Instead, use a repository pattern to abstract database interactions and make the code more modular and reusable. Where possible optimize the code to improve performance. Include error trapping, and make sure the code is not vulnerable to SQL injection.` +```copilot copy prompt ref=database-connection +Rewrite this code to make it more scalable and easier to maintain. Use a context manager. Avoid hardcoded SQL queries and tightly coupled data access code. Instead, use a repository pattern to abstract database interactions and make the code more modular and reusable. Where possible optimize the code to improve performance. Include error trapping, and make sure the code is not vulnerable to SQL injection. +``` ## Example response 2 diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md index d55b1bac4bf9..83652ea91928 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md @@ -29,7 +29,7 @@ Code that doesn’t follow established design patterns (like Singleton, Factory, This JavaScript code creates three `Person` objects, each with `name` and `age` properties. It then uses the name of a person to retrieve and print their age. -```javascript +```javascript id=person-module class Person { constructor(name, age) { this.name = name; @@ -60,7 +60,9 @@ getAge("Mario"); ## Example prompt 1 -`What design patterns could improve this code? Don't show me code examples.` +```copilot copy prompt ref=person-module +What design patterns could improve this code? Don't show me code examples. +``` ## Example response 1 @@ -74,7 +76,9 @@ getAge("Mario"); You can now ask {% data variables.product.prodname_copilot_short %} to implement the pattern that you feel is most appropriate. -`Refactor this code using the module pattern` +```copilot copy prompt ref=person-module +Refactor this code using the module pattern +``` ## Example response 2 diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md index c325d336b683..d1c51b70a087 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md @@ -27,7 +27,7 @@ Existing code may function correctly but be inefficient, leading to performance The following Python code prints every 1000th prime number up to the 10,000th prime. It includes a timer, and prints how long the code takes to run as the last line of the output. The program takes several seconds to complete. -```python +```python id=slow-prime import time def is_prime(n): @@ -59,7 +59,9 @@ if __name__ == "__main__": ## Example prompt -`Optimize this code for performance` +```copilot copy prompt ref=slow-prime +Optimize this code for performance +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md index 576eb18864a8..1c65ff218eae 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md @@ -29,7 +29,7 @@ The following C# code has a deep inheritance hierarchy where each class builds o A multi-level inheritance hierarchy like this can be difficult to understand, modify, and extend. -```csharp +```csharp id=employee-class public class Employee { public string Name { get; set; } @@ -66,7 +66,9 @@ public class President : VicePresident In this situation you might decide to use a parent `Employee` class whose properties other classes should inherit, but to avoid any other inheritance by defining all other properties separately for each class. -`Refactor this code so that classes only inherit the properties of the Employee class. All of the other properties that each class currently inherits should instead be declared independently in each class definition.` +```copilot copy prompt ref=employee-class +Refactor this code so that classes only inherit the properties of the Employee class. All of the other properties that each class currently inherits should instead be declared independently in each class definition. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md index 7daa3b91cd27..c944c832aa23 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md @@ -30,7 +30,7 @@ Translating a project containing multiple files is a more complex process, and i The following Perl script prompts the user to enter the path to a text file. It checks what the user enters and if a text file is found at that path, it outputs a word count and character count for the contents of the file. -```perl copy +```perl copy id=perl-script #!/usr/bin/perl use strict; use warnings; @@ -74,7 +74,9 @@ print "The file '$file_path' contains $word_count words and $char_count characte ## Example prompt -`Tell me how I can convert this Perl script to Typescript. The functionality and output of the new script should be exactly the same as the existing one. Also tell me how to run the new file using Node.` +```copilot copy prompt ref=perl-script +Tell me how I can convert this Perl script to Typescript. The functionality and output of the new script should be exactly the same as the existing one. Also tell me how to run the new file using Node. +``` ## Example response diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md index a3cbada3afbd..d56b75b35e1d 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md @@ -25,7 +25,7 @@ Creating end-to-end tests for a webpage can be time-consuming and complex as the Imagine a React application that displays product details on a webpage. You need to create end-to-end tests to ensure the product details are displayed correctly. You can ask {% data variables.copilot.copilot_chat_short %} to generate these tests for you. -```javascript +```javascript id=product-details import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; @@ -81,7 +81,9 @@ export default ProductDetails; > [!NOTE] This example uses Playwright for end-to-end testing, but you can use other frameworks like Selenium or Cypress. -`Using Playwright, generate an e2e test to ensure the product displays correctly.` +```copilot copy prompt ref=product-details +Using Playwright, generate an e2e test to ensure the product displays correctly. +``` If you have an existing test you wish {% data variables.product.prodname_copilot_short %} to use as a model, you can use `#file: path/to/test-file.js` to provide the path to the file, and include this information in the prompt. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md index 05712ca4300e..77fb96b56c51 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md @@ -25,7 +25,7 @@ When creating unit tests, it's important to ensure they're isolated and not depe Imagine a website built with TypeScript which displays a list of runners. You have a service which fetches the runners from a database, and the server-side code which uses this service. You want to test the server-side code, but you don't want to make a call to the database. You can ask {% data variables.copilot.copilot_chat_short %} to generate a mock object for the service. -```typescript +```typescript id=mock-service // SvelteKit example at +page.server.ts import service from './service'; @@ -42,7 +42,9 @@ export async function load({ params }) { This example assumes you are using [vitest](https://vitest.dev/) for your tests, but will work with other test runners. -`/tests Create a unit test to ensure the service is called correctly. Mock the service object.` +```copilot copy prompt ref=mock-service +/tests Create a unit test to ensure the service is called correctly. Mock the service object. +``` If you have an existing test you wish {% data variables.product.prodname_copilot_short %} to use as a model, you can use `#file: path/to/test-file.js` to provide the path to the file, and include this information in the prompt. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md index 3256fc897749..5fb34e99fae8 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md +++ b/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md @@ -23,7 +23,7 @@ A good suite of unit tests is critical to the success of any project. However, w Imagine you have a Python function which validates data before updating the database. You need to create unit tests to ensure the validation performs the way you expect. You can ask {% data variables.copilot.copilot_chat_short %} to generate these tests for you. -```python +```python id=validate-price def validate_price(price: float): if price <= 0: raise ValueError("Price must be greater than 0") @@ -33,7 +33,9 @@ def validate_price(price: float): ## Example prompt -`/tests Generate unit tests for this function. Validate both success and failure, and include edge cases.` +```copilot copy prompt ref=validate-price +/tests Generate unit tests for this function. Validate both success and failure, and include edge cases. +``` ## Example response diff --git a/content/copilot/tutorials/easy-apps-with-spark.md b/content/copilot/tutorials/easy-apps-with-spark.md index 401f999026e8..4af64274fb70 100644 --- a/content/copilot/tutorials/easy-apps-with-spark.md +++ b/content/copilot/tutorials/easy-apps-with-spark.md @@ -23,7 +23,7 @@ Let's start by generating an initial, basic version of our app that we can build 1. Navigate to https://github.com/spark. 1. Send the following prompt to generate the first iteration of your app: - ```text copy + ```copilot copy Please create a word search game. The game should take in a set of words from the user, then create a word search puzzle containing those words, as well as a word bank listing the words. Words in the puzzle can be horizontal, vertical, diagonal, forwards, and backwards, and are "found" when the user clicks and drags their mouse across them. Once all words are found, give the user the option to create a new puzzle. ``` @@ -36,7 +36,7 @@ Just like that, we have a working app! However, it still needs some tweaks. Let' 1. At the left side of the page, in the **Iterate** tab, send the following prompt: - ```text copy + ```copilot copy Please add a leaderboard and a timer to the game. The timer should start when the user generates a new puzzle, then stop when all words are found. The user should then be able to enter their name, and their name, time, and the number of words in their puzzle should be displayed on the leaderboard. The leaderboard should be sortable in ascending and descending order by each of the three categories. ``` @@ -51,7 +51,7 @@ While you're building your app, you may encounter some errors. Often, {% data va If you find an error that {% data variables.product.prodname_spark_short %} itself didn't flag, write a prompt to fix it. For best results, provide a detailed description of the error, as well as the ideal fixed state. For example, if you notice that adding words over a certain number of characters causes the puzzle to render incorrectly, send the following prompt: -```text copy +```copilot copy Please prevent users from entering words longer than the number of rows or columns in the puzzle. Additionally, add an option to change the size of a puzzle. If the user tries to enter a word that's longer than the current size of the puzzle, display an error message telling them that provided words must be less than or equal to the size of the puzzle. ``` diff --git a/content/copilot/tutorials/enhance-agent-mode-with-mcp.md b/content/copilot/tutorials/enhance-agent-mode-with-mcp.md index c16506fbd24b..3ba5993c11ba 100644 --- a/content/copilot/tutorials/enhance-agent-mode-with-mcp.md +++ b/content/copilot/tutorials/enhance-agent-mode-with-mcp.md @@ -100,9 +100,13 @@ Prompt {% data variables.product.prodname_copilot_short %} to analyze both acces In your prompt, include a link to the Figma file. In order for Copilot to successfully read and analyze the design specifications, select a specific node or layer in the file, so that the node ID is included in the URL. -**Example prompt**: `I need to make our customer portal WCAG 2.1 AA compliant. Use the Figma MCP to analyze our design specifications at https://figma.com/design/DESIGN-FILE-FOR-ACCESSIBILITY-SPECS?node-id=NODE_ID for accessibility requirements. Also use the GitHub MCP to find open GitHub issues with the labels accessibility or WCAG in the customer-portal repository. Then sort them into categories and list each issue that falls under the category with the issue title and number.` +#### Example prompt 1 -**Example response from {% data variables.product.prodname_copilot_short %}:** +```copilot copy +I need to make our customer portal WCAG 2.1 AA compliant. Use the Figma MCP to analyze our design specifications at https://figma.com/design/DESIGN-FILE-FOR-ACCESSIBILITY-SPECS?node-id=NODE_ID for accessibility requirements. Also use the GitHub MCP to find open GitHub issues with the labels accessibility or WCAG in the customer-portal repository. Then sort them into categories and list each issue that falls under the category with the issue title and number. +``` + +#### Example response 1 {% data variables.product.prodname_copilot_short %} should respond first by requesting to run tools from the Figma and GitHub MCP servers. Once you allow it, {% data variables.product.prodname_copilot_short %} will analyze the Figma design specifications and search for and organize GitHub issues into categories. @@ -118,9 +122,13 @@ This gives you a comprehensive overview of accessibility requirements that you c Next, ask {% data variables.product.prodname_copilot_short %} to create a detailed implementation plan. -**Example prompt**: `Based on your accessibility analysis of our Figma designs and GitHub issues, create a focused implementation plan for an immediate pull request addressing the highest priority accessibility issues. Don't make any changes yet. Also suggest follow-up issues we should create for the remaining Figma specifications.` +#### Example prompt 2 + +```copilot copy +Based on your accessibility analysis of our Figma designs and GitHub issues, create a focused implementation plan for an immediate pull request addressing the highest priority accessibility issues. Don't make any changes yet. Also suggest follow-up issues we should create for the remaining Figma specifications. +``` -**Example response from {% data variables.product.prodname_copilot_short %}:** +#### Example response 2 {% data variables.product.prodname_copilot_short %} will respond by creating a prioritized implementation plan focused on high-impact accessibility issues for an immediate pull request while suggesting follow-up issues for remaining work. @@ -137,9 +145,13 @@ You can ask {% data variables.product.prodname_copilot_short %} to adjust the pl After reviewing the plan, prompt {% data variables.product.prodname_copilot_short %} to begin implementing accessibility fixes. -**Example prompt**: `Create a new branch and implement the critical accessibility fixes according to your proposed implementation plan. Focus on the top three categories that you identified as highest priority. Create a pull request with proper references to the issues being fixed.` +#### Example prompt 3 + +```copilot copy +Create a new branch and implement the critical accessibility fixes according to your proposed implementation plan. Focus on the top three categories that you identified as highest priority. Create a pull request with proper references to the issues being fixed. +``` -**Example response from {% data variables.product.prodname_copilot_short %}:** +#### Example response 3 {% data variables.product.prodname_copilot_short %} will respond by executing the implementation plan, making targeted code changes to address the identified accessibility issues and creating a pull request. @@ -155,9 +167,13 @@ For example, {% data variables.product.prodname_copilot_short %} may create a ne You can prompt {% data variables.product.prodname_copilot_short %} to create and run accessibility tests using the Playwright MCP. -**Example prompt**: `Create focused accessibility tests for the components we've updated in the pull request. Use the Playwright MCP.` +#### Example prompt 4 -**Example response from {% data variables.product.prodname_copilot_short %}:** +```copilot copy +Create focused accessibility tests for the components we've updated in the pull request. Use the Playwright MCP. +``` + +#### Example response 4 {% data variables.product.prodname_copilot_short %} will respond by developing accessibility tests and, if necessary, creating a Playwright configuration file. @@ -174,9 +190,13 @@ Once the tests are created, {% data variables.product.prodname_copilot_short %} Finally, prompt {% data variables.product.prodname_copilot_short %} to update the {% data variables.product.github %} issues that have been addressed in the pull request, and create follow-up issues. -**Example prompt**: `Update the GitHub issues we've fixed in the pull request with comments summarizing the changes. Create the follow-up issues you suggested for the remaining accessibility work.` +#### Example prompt 5 + +```copilot copy +Update the GitHub issues we've fixed in the pull request with comments summarizing the changes. Create the follow-up issues you suggested for the remaining accessibility work. +``` -**Example response from {% data variables.product.prodname_copilot_short %}:** +#### Example response 5 {% data variables.product.prodname_copilot_short %} will respond by asking for permission to use the necessary tools from the {% data variables.product.github %} MCP server. It will then update the {% data variables.product.github %} issues with detailed comments and create structured follow-up issues for remaining work. diff --git a/content/copilot/tutorials/learn-a-new-language.md b/content/copilot/tutorials/learn-a-new-language.md index e9d8fd2e875d..2a59a33f67d4 100644 --- a/content/copilot/tutorials/learn-a-new-language.md +++ b/content/copilot/tutorials/learn-a-new-language.md @@ -25,27 +25,27 @@ Use {% data variables.copilot.copilot_chat_short %} to research the basics of th ### Example prompts: language basics -These are some prompts that you can use in {% data variables.copilot.copilot_chat_short %} to help you learn the basics of a new programming language: +These are some prompts that you can use in {% data variables.copilot.copilot_chat_short %} to help you learn the basics of a new programming language. Change `NEW-LANGUAGE` to the name of the language you want to find out about. -* `What is NEW-LANGUAGE best suited for? I am an experienced Python programmer, but I don't know anything about NEW-LANGUAGE.` +* {% prompt %}What is NEW-LANGUAGE best suited for? I am an experienced Python programmer, but I don't know anything about NEW-LANGUAGE.{% endprompt %} -* `What are the main ways in which NEW-LANGUAGE differs from other languages? Explain the most essential things I need to know as an experienced programmer who wants to learn to code in NEW-LANGUAGE.` +* {% prompt %}What are the main ways in which NEW-LANGUAGE differs from other languages? Explain the most essential things I need to know as an experienced programmer who wants to learn to code in NEW-LANGUAGE.{% endprompt %} -* `How can I install NEW-LANGUAGE?` +* {% prompt %}How can I install NEW-LANGUAGE?{% endprompt %} -* `How does error handling work in NEW-LANGUAGE?` +* {% prompt %}How does error handling work in NEW-LANGUAGE?{% endprompt %} -* `How do you manage dependencies and packages in NEW-LANGUAGE?` +* {% prompt %}How do you manage dependencies and packages in NEW-LANGUAGE?{% endprompt %} -* `What are the most essential libraries or frameworks I should know about for NEW-LANGUAGE?` +* {% prompt %}What are the most essential libraries or frameworks I should know about for NEW-LANGUAGE?{% endprompt %} -* `What testing frameworks does the NEW-LANGUAGE community typically use?` +* {% prompt %}What testing frameworks does the NEW-LANGUAGE community typically use?{% endprompt %} -* `What are the biggest mistakes newcomers to NEW-LANGUAGE typically make with this language?` +* {% prompt %}What are the biggest mistakes newcomers to NEW-LANGUAGE typically make with this language?{% endprompt %} -* `As an experienced programmer learning NEW-LANGUAGE, what are the things I should focus on first?` +* {% prompt %}As an experienced programmer learning NEW-LANGUAGE, what are the things I should focus on first?{% endprompt %} ## Use {% data variables.product.prodname_copilot_short %} as your personal trainer @@ -55,11 +55,13 @@ When you ask {% data variables.product.prodname_copilot_short %} how to code som ### Example prompts: asking for an explanation +Change `NEW-LANGUAGE` to the name of the language you want to find out about. + * `Explain your previous suggestion in more detail. I am new to NEW-LANGUAGE and I don't understand the code you suggested.` -* ``Show me how to write the following Ruby code in NEW-LANGUAGE: `people_over_50 = people.select { |person| person.age > 50 }`. Explain each part of the NEW-LANGUAGE code that you suggest.`` +* {% prompt %}Show me how to write the following Ruby code in NEW-LANGUAGE: `people_over_50 = people.select { |person| person.age > 50 }`. Explain each part of the NEW-LANGUAGE code that you suggest.{% endprompt %} * `Add comprehensive comments to this NEW-LANGUAGE file to explain what each part of the code does.` @@ -71,11 +73,11 @@ To get started, write a simple program that you would be able to write easily in -* `Show me the Rust code for a simple, useful command line tool that asks for user input and returns some useful information based on what was entered.` +* {% prompt %}Show me the Rust code for a simple, useful command line tool that asks for user input and returns some useful information based on what was entered.{% endprompt %} * `Comment the suggested code more thoroughly. I want to understand what every part of this code does.` -* `Give me the code for a very small Android app written in Kotlin.` +* {% prompt %}Give me the code for a very small Android app written in Kotlin.{% endprompt %} * `Suggests ways I could enhance this app.` @@ -122,19 +124,21 @@ While you are learning a new language, you should work on small units of code th ### Example prompts: specific questions +Change `NEW-LANGUAGE` to the name of the language you want to find out about. + -* `Explain all of the various ways that conditionals can be coded in NEW-LANGUAGE.` +* {% prompt %}Explain all of the various ways that conditionals can be coded in NEW-LANGUAGE.{% endprompt %} -* ``In JavaScript I'd write: `The ${numCats === 1 ? 'cat is' : 'cats are'} hungry.`. How do I write this in NEW-LANGUAGE?`` +* {% prompt %}In JavaScript I'd write: `The ${numCats === 1 ? 'cat is' : 'cats are'} hungry.`. How do I write this in NEW-LANGUAGE?{% endprompt %} -* `In NEW-LANGUAGE, how do I convert a string to all lowercase?` +* {% prompt %}In NEW-LANGUAGE, how do I convert a string to all lowercase?{% endprompt %} -* `What is the equivalent of num++ in NEW-LANGUAGE?` +* {% prompt %}What is the equivalent of num++ in NEW-LANGUAGE?{% endprompt %} -* `How do I run a program written in the NEW-LANGUAGE programming language?` +* {% prompt %}How do I run a program written in the NEW-LANGUAGE programming language?{% endprompt %} -* `How can I compile a single executable file for my NEW-LANGUAGE project, that I can distribute as a release?` +* {% prompt %}How can I compile a single executable file for my NEW-LANGUAGE project, that I can distribute as a release?{% endprompt %} ## Convert existing code to the new language diff --git a/content/copilot/tutorials/migrate-a-project.md b/content/copilot/tutorials/migrate-a-project.md index 4242b9b32213..d7fd0713761b 100644 --- a/content/copilot/tutorials/migrate-a-project.md +++ b/content/copilot/tutorials/migrate-a-project.md @@ -58,7 +58,9 @@ Assuming you've already familiarized yourself with the existing project, a good For example, for a migration from PHP to Python, you could ask: - `@workspace I want to migrate this project from PHP to Python. Give me a high level overview of the steps I need to take. Don't go into detail at this stage.` + ```copilot copy + @workspace I want to migrate this project from PHP to Python. Give me a high-level overview of the steps I need to take. Don't go into detail at this stage. + ``` > [!NOTE] > The `@workspace` chat participant sets the files in the current workspace as the context for the question you ask. @@ -136,11 +138,15 @@ After completing this example migration you can then use the same methodology on 1. Open the {% data variables.copilot.copilot_chat_short %} view. 1. Enter a prompt such as: - `@workspace Describe this project in detail, explaining what the various components do and how they interact.` + ```copilot copy + @workspace Describe this project in detail, explaining what the various components do and how they interact. + ``` 1. Ask {% data variables.product.prodname_copilot_short %} for a high-level overview of the migration process: - `@workspace I want to migrate this project from PHP to Python. Give me a high level overview of the steps I need to take. Don't go into detail at this stage.` + ```copilot copy + @workspace I want to migrate this project from PHP to Python. Give me a high-level overview of the steps I need to take. Don't go into detail at this stage. + ``` {% data variables.product.prodname_copilot_short %} will reply with instructions such as: @@ -183,7 +189,9 @@ After completing this example migration you can then use the same methodology on 1. If you haven't already decided which Python framework you want to use, you can ask {% data variables.product.prodname_copilot_short %} for advice: - `@workspace What Python frameworks can I use for this project once it is migrated to Python? Give me a selection of options, with a brief summary of the pros and cons of each in relation to this website project. Which framework would you recommend?` + ```copilot copy + @workspace What Python frameworks can I use for this project once it is migrated to Python? Give me a selection of options, with a brief summary of the pros and cons of each in relation to this website project. Which framework would you recommend? + ``` {% data variables.product.prodname_copilot_short %} replies with information about various frameworks, and concludes: @@ -195,7 +203,9 @@ After completing this example migration you can then use the same methodology on 1. Returning to {% data variables.product.prodname_copilot_short %}'s high-level overview, the first step is to set up a Python environment and install the necessary packages. To find out how to do this, in {% data variables.copilot.copilot_chat_short %}, enter: - `@workspace I want to use Flask. Tell me how to set up a virtual environment and install the necessary packages.` + ```copilot copy + @workspace I want to use Flask. Tell me how to set up a virtual environment and install the necessary packages. + ``` {% data variables.product.prodname_copilot_short %} will reply with instructions such as: @@ -225,7 +235,9 @@ After completing this example migration you can then use the same methodology on 1. Follow {% data variables.product.prodname_copilot_short %}'s instructions and use `pip list` to verify that Flask is installed. 1. Returning to {% data variables.product.prodname_copilot_short %}'s overview for the migration process, the next step is to convert the configuration. Ask {% data variables.product.prodname_copilot_short %} for help with this. For example: - `@workspace As the first step in migrating this project from PHP to Python, create a Python configuration file by converting the functions in functions.php to Python functions. Tell me where to locate the Python config file in the project.` + ```copilot copy + @workspace As the first step in migrating this project from PHP to Python, create a Python configuration file by converting the functions in functions.php to Python functions. Tell me where to locate the Python config file in the project. + ``` {% data variables.product.prodname_copilot_short %} suggests that you create a file called `config.py` in the `includes` directory, containing the following code. @@ -293,7 +305,9 @@ After completing this example migration you can then use the same methodology on 1. Create the `includes/config.py` file and delete the existing `includes/config.php` file. 1. Returning to the overview again, ask {% data variables.product.prodname_copilot_short %} to help you rewrite the PHP functions. - `@workspace Continuing the migration of this project from PHP to Python, create Python functions to replace the existing PHP functions. Tell me where to locate the Python functions in the project.` + ```copilot copy + @workspace Continuing the migration of this project from PHP to Python, create Python functions to replace the existing PHP functions. Tell me where to locate the Python functions in the project. + ``` {% data variables.product.prodname_copilot_short %} suggests you create a file called `functions.py` in the `includes` directory, containing the following code. @@ -347,7 +361,9 @@ After completing this example migration you can then use the same methodology on 1. Create the `includes/functions.py` file and delete the existing `includes/functions.php` file. 1. Continuing with the overview, the next step is to create a Flask application. Ask {% data variables.product.prodname_copilot_short %} to help you with this: - `@workspace Set up a Flask application to handle routing and views, and map the routes to corresponding views. Tell me the location of any files that need to be created or changed.` + ```copilot copy + @workspace Set up a Flask application to handle routing and views, and map the routes to corresponding views. Tell me the location of any files that need to be created or changed. + ``` {% data variables.product.prodname_copilot_short %} suggests you create a file called `app.py` in the root of the project, containing the following code. @@ -455,7 +471,9 @@ After completing this example migration you can then use the same methodology on 1. Copy the initial `TemplateNotFound` error message to the {% data variables.copilot.copilot_chat_short %} view and ask how you can fix this. For example: - ``@workspace When I run `python3 app.py`, I get the following error in the browser: `jinja2.exceptions.TemplateNotFound: template.html`. How can I fix this?`` + ```copilot copy + @workspace When I run `python3 app.py`, I get the following error in the browser: `jinja2.exceptions.TemplateNotFound: template.html`. How can I fix this? + ``` {% data variables.product.prodname_copilot_short %} replies that the error indicates that Flask is unable to locate the `template.html` file. @@ -469,7 +487,9 @@ After completing this example migration you can then use the same methodology on Copy this error message to the {% data variables.copilot.copilot_chat_short %} view and ask for help. - ``@workspace When I run `python3 app.py`, I get the following error in the browser: `jinja2.exceptions.UndefinedError: 'get_config' is undefined.` How can I fix this?`` + ```copilot copy + @workspace When I run `python3 app.py`, I get the following error in the browser: `jinja2.exceptions.UndefinedError: 'get_config' is undefined.` How can I fix this? + ``` {% data variables.product.prodname_copilot_short %} replies that the error occurs because `get_config` is not available in the Jinja2 template context. It advises you to add the following code to the `app.py` file, directly before the line `@app.route('/')`: @@ -485,7 +505,9 @@ After completing this example migration you can then use the same methodology on 1. Ask {% data variables.product.prodname_copilot_short %}: - `@workspace The deployed website does not use the CSS styles. How can I fix this?` + ```copilot copy + @workspace The deployed website does not use the CSS styles. How can I fix this? + ``` {% data variables.product.prodname_copilot_short %} tells you that Flask expects your CSS file to be in a directory called `static`. It suggests moving the existing `style.css` file from the `template` directory into a new `static` directory, and then updating the path to the `style.css` file within the `head` portion of the `template.html` file. Change this to: diff --git a/content/copilot/tutorials/modernize-legacy-code.md b/content/copilot/tutorials/modernize-legacy-code.md index a1eb317e8273..5335a006cfba 100644 --- a/content/copilot/tutorials/modernize-legacy-code.md +++ b/content/copilot/tutorials/modernize-legacy-code.md @@ -84,7 +84,9 @@ Open the repository in your IDE then, in the {% data variables.copilot.copilot_c ### Example prompt 1 -`/explain #file:main.cob #file:operations.cob #file:data.cob Can you please create a high level overview of the app. It will be great if you can explain each file in detail and how they are linked.` +```copilot copy +/explain #file:main.cob #file:operations.cob #file:data.cob. Create a high level overview of the app. Explain each file in detail and how they are linked. +``` ### Example response 1 @@ -105,7 +107,9 @@ The next step is to understand how the files are linked together. You can use `@ ### Example prompt 2 -`@workspace can you create a sequence diagram of the app showing the data flow of the app. Please create this in mermaid format so that I can render this in a markdown file.` +```copilot copy +@workspace Create a sequence diagram of the app showing the data flow of the app. Create this in mermaid format so that I can render this in a markdown file. +``` {% data variables.product.prodname_copilot_short %} outputs the Mermaid markup for a full sequence diagram that shows how the application works. You can copy and paste this markup into a Mermaid application to generate the diagram. @@ -115,10 +119,10 @@ Create a test plan to ensure that the application works as expected after you ma ### Example prompt 3 -```shell -@workspace The current Cobol app has no tests. Can you please create a test plan of current business logic that I can use to validate with business stakeholders about the current implementation. +```copilot copy +@workspace The current COBOL app has no tests. Create a test plan of current business logic that I can use to validate with business stakeholders about the current implementation. -Later I would like to use this test plan to create unit and integration tests in a node.js app. I am in the middle of transforming the current Cobol app to a node.js app. +Later I would like to use this test plan to create unit and integration tests in a node.js app. I am in the middle of transforming the current COBOL app to a node.js app. The test plan should include the following: @@ -131,7 +135,7 @@ The test plan should include the following: 7. Status (Pass/Fail) 8. Comments -Please create the test plan in a markdown table format. The test plan should cover all the business logic in the current Cobol app. +Create the test plan in a markdown table format. The test plan should cover all the business logic in the current COBOL app. Convert this to markdown syntax to insert as a new file ``` @@ -156,7 +160,9 @@ Then, iteratively convert the COBOL files to Node.js. ### Example prompt 4 -`Can you convert code in #file:main.cob to node.js?` +```copilot copy +Convert the code in #file:main.cob to node.js +``` ### Example response 4 @@ -332,7 +338,9 @@ To refine the application, you will need to: * **Work iteratively with {% data variables.product.prodname_copilot_short %}** to adjust the logic until the Node.js program behaves as expected. * **Use targeted prompts** to debug and improve specific parts of the code, such as: - `@workspace - analyze main.js and ensure account balance updates correctly when crediting an account.` + ```copilot copy + @workspace - analyze main.js and ensure the account balance updates correctly when crediting an account. + ``` Refactoring legacy code isn’t always a one-step process—{% data variables.product.prodname_copilot_short %} can assist in debugging and improving functionality as you refine your new Node.js implementation. @@ -342,7 +350,9 @@ The next step is to generate unit and integration tests to ensure that the appli ### Example prompt 5 -`@workspace I would like to create unit and integration tests cases from the test plan mentioned in #file:TESTPLAN.md file The node.js code is in node-accounting-app folder and I am looking to generate tests for #file:operations.js file. Use a popular testing framework and also provide all the dependencies required to run the tests.` +```copilot copy +@workspace I would like to create unit and integration tests cases from the test plan mentioned in #file:TESTPLAN.md file. The node.js code is in the node-accounting-app folder and I am looking to generate tests for #file:operations.js file. Use a popular testing framework and also provide all the dependencies required to run the tests. +``` ### Example response 5 @@ -360,7 +370,9 @@ If a test fails, use {% data variables.product.prodname_copilot_short %} to help ### Example prompt 6 -`@workspace - analyze test failures in operations.test.js and suggest fixes to match the expected behavior.` +```copilot copy +@workspace - analyze test failures in operations.test.js and suggest fixes to match the expected behavior. +``` Even if all tests pass, the program may still have issues. Automated tests don’t always catch missing functionality or logic errors, so manual testing is required to ensure the application behaves as expected. diff --git a/src/secret-scanning/data/public-docs.yml b/src/secret-scanning/data/public-docs.yml index 252a5d612e11..c01480ecbedd 100644 --- a/src/secret-scanning/data/public-docs.yml +++ b/src/secret-scanning/data/public-docs.yml @@ -1490,7 +1490,7 @@ ghec: '*' isPublic: true isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -1550,7 +1550,7 @@ ghec: '*' isPublic: true isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -2917,7 +2917,7 @@ ghec: '*' isPublic: false isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -3316,7 +3316,7 @@ ghes: '>=3.17' isPublic: false isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -4113,7 +4113,7 @@ ghes: '>=3.18' isPublic: false isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -4798,7 +4798,7 @@ ghes: '*' isPublic: false isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false @@ -4902,7 +4902,7 @@ ghes: '>3.4' isPublic: true isPrivateWithGhas: true - hasPushProtection: false + hasPushProtection: true hasValidityCheck: false base64Supported: false isduplicate: false diff --git a/src/secret-scanning/lib/config.json b/src/secret-scanning/lib/config.json index 77aab81edb7e..ea0204bae18a 100644 --- a/src/secret-scanning/lib/config.json +++ b/src/secret-scanning/lib/config.json @@ -1,5 +1,5 @@ { - "sha": "2fd995a6f5c493aac019d1cf38312f2075a085fe", - "blob-sha": "dfaec435d708f9e3aeec2350b1326b010e266ace", + "sha": "7d3e136cc0b0bc945f61287764dca2db9fb99494", + "blob-sha": "4aeb765d8bcffdaf9063e38b779b126b276c9f75", "targetFilename": "code-security/secret-scanning/introduction/supported-secret-scanning-patterns" } \ No newline at end of file