Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
36 changes: 18 additions & 18 deletions content/copilot/concepts/ai-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -98,25 +98,25 @@ 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

The deployment phase involves preparing your code for production and ensuring a smooth release.

**{% 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

Expand All @@ -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

Expand Down
46 changes: 25 additions & 21 deletions content/copilot/concepts/prompt-engineering.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,38 @@ 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

Use examples to help {% data variables.product.prodname_copilot_short %} understand what you want. You can provide example input data, example outputs, and example implementations.

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.

Expand Down
6 changes: 3 additions & 3 deletions content/copilot/get-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions content/copilot/how-tos/use-chat/get-started-with-chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions content/copilot/how-tos/use-chat/use-chat-in-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 %}**.

Expand Down
Loading
Loading