Skip to content

Commit 62f233e

Browse files
authored
[Release]: Add prompt files to JetBrains docs in custom instructions article (#57342)
1 parent 56aa699 commit 62f233e

File tree

7 files changed

+104
-8
lines changed

7 files changed

+104
-8
lines changed

content/copilot/concepts/prompting/response-customization.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contentType: concepts
3434

3535
{% jetbrains %}
3636

37-
> [!NOTE] This version of this article is about custom instructions in JetBrains IDEs. Click the tabs above for other environments. <!-- markdownlint-disable-line MD027 -->
37+
> [!NOTE] This version of this article is about custom instructions and prompt files in JetBrains IDEs. Click the tabs above for other environments. <!-- markdownlint-disable-line MD027 -->
3838
{% endjetbrains %}
3939

4040
{% xcode %}
@@ -74,7 +74,7 @@ You can create two types of repository custom instructions for {% data variables
7474
There are two types of files you can use to provide context and instructions to {% data variables.copilot.copilot_chat %} in {% data variables.product.prodname_vscode_shortname %}:
7575

7676
* **Repository custom instructions** allow you to specify instructions and preferences that {% data variables.product.prodname_copilot_short %} will consider when working in the context of the repository.
77-
* **Prompt files** (public preview) allow you to save common prompt instructions and relevant context in Markdown files (`*.prompt.md`) that you can then reuse in your chat prompts. Prompt files are only available in {% data variables.product.prodname_vscode_shortname %}.
77+
* **Prompt files** (public preview) allow you to save common prompt instructions and relevant context in Markdown files (`*.prompt.md`) that you can then reuse in your chat prompts. {% data reusables.copilot.prompt-files-available-in-editors %}
7878

7979
While custom instructions help to add codebase-wide context to each AI workflow, prompt files let you add instructions to a specific chat interaction.
8080

@@ -88,7 +88,14 @@ While custom instructions help to add codebase-wide context to each AI workflow,
8888

8989
{% jetbrains %}
9090

91-
{% data variables.product.prodname_copilot %} can provide chat responses that are tailored to the way your team works, the tools you use, or the specifics of your project, if you provide it with enough context to do so. Instead of repeatedly adding this contextual detail to your chat questions, you can create a custom instructions file in your repository that automatically adds this information for you. The additional information is not displayed in the chat, but is available to {% data variables.product.prodname_copilot_short %} to allow it to generate higher quality responses.
91+
{% data variables.product.prodname_copilot %} can provide chat responses that are tailored to the way your team works, the tools you use, or the specifics of your project, if you provide it with enough context to do so. Instead of repeatedly adding this contextual detail to your chat questions, you can create a custom instructions file in your repository that automatically adds this information for you.
92+
93+
There are two types of files you can use to provide context and instructions to {% data variables.copilot.copilot_chat %} in JetBrains IDEs:
94+
95+
* **Repository custom instructions** allow you to specify instructions and preferences that {% data variables.product.prodname_copilot_short %} will consider when working in the context of the repository.
96+
* **Prompt files** (public preview) allow you to save common prompt instructions and relevant context in Markdown files (`*.prompt.md`) that you can then reuse in your chat prompts. {% data reusables.copilot.prompt-files-available-in-editors %}
97+
98+
While custom instructions help to add codebase-wide context to each AI workflow, prompt files let you add instructions to a specific chat interaction.
9299

93100
{% endjetbrains %}
94101

@@ -229,6 +236,55 @@ Common use cases include:
229236

230237
{% data reusables.copilot.repository-custom-instructions-example %}
231238

239+
## About prompt files
240+
241+
> [!NOTE] Prompt files are {% data variables.release-phases.public_preview %} and subject to change.
242+
243+
Prompt files let you build and share reusable prompt instructions with additional context. A prompt file is a Markdown file, stored in your workspace, that mimics the existing format of writing prompts in {% data variables.copilot.copilot_chat_short %} (for example, `Rewrite #file:x.ts`). This allows blending natural language instructions and additional context.
244+
245+
Common use cases include:
246+
247+
* **Code generation**. Create reusable prompts for components, tests, or migrations (for example, React forms, or API mocks).
248+
* **Domain expertise**. Share specialized knowledge through prompts, such as security practices, or compliance checks.
249+
* **Team collaboration**. Document patterns and guidelines with references to specs and documentation.
250+
* **Onboarding**. Create step-by-step guides for complex processes or project-specific patterns.
251+
252+
You can have multiple prompt files in your workspace, each of which defines a prompt for a different purpose.
253+
254+
### Examples
255+
256+
The following examples demonstrate how to use prompt files.
257+
258+
* `New React form.prompt.md` - contains instructions for a reusable task to generate a form using React.
259+
260+
```markdown
261+
Your goal is to generate a new React form component.
262+
263+
Ask for the form name and fields if not provided.
264+
265+
Requirements for the form:
266+
- Use form design system components: [design-system/Form.md](../docs/design-system/Form.md)
267+
- Use `react-hook-form` for form state management:
268+
- Always define TypeScript types for your form data
269+
- Prefer *uncontrolled* components using register
270+
- Use `defaultValues` to prevent unnecessary rerenders
271+
- Use `yup` for validation:
272+
- Create reusable validation schemas in separate files
273+
- Use TypeScript types to ensure type safety
274+
- Customize UX-friendly validation rules
275+
```
276+
277+
* `API security review.prompt.md` - contains reusable information about security practices for REST APIs, which can be used to do security reviews of REST APIs.
278+
279+
```markdown
280+
Secure REST API review:
281+
- Ensure all endpoints are protected by authentication and authorization
282+
- Validate all user inputs and sanitize data
283+
- Implement rate limiting and throttling
284+
- Implement logging and monitoring for security events
285+
286+
```
287+
232288
{% endjetbrains %}
233289

234290
{% xcode %}

content/copilot/how-tos/configure-custom-instructions/add-repository-instructions.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,43 @@ To enable prompt files, configure the workspace settings.
631631
For more information about prompt files, see [Custom instructions for {% data variables.product.prodname_copilot %} in VS Code](https://code.visualstudio.com/docs/copilot/copilot-customization#_reusable-prompt-files-experimental) in the {% data variables.product.prodname_vscode %} documentation.
632632

633633
{% endvscode %}
634+
635+
{% jetbrains %}
636+
637+
## Using prompt files
638+
639+
{% data reusables.copilot.prompt-files-preview-note %}
640+
641+
Prompt files let you build and share reusable prompt instructions with additional context. A prompt file is a Markdown file, stored in your workspace, that mimics the existing format of writing prompts in {% data variables.copilot.copilot_chat_short %} (for example, `Rewrite #file:x.ts`). You can have multiple prompt files in your workspace, each of which defines a prompt for a different purpose.
642+
643+
When writing prompt instructions, you can reference other files in the workspace by using Markdown links—for example, `[index](../../web/index.ts)`—or by using the `#file:../../web/index.ts` syntax. Paths are relative to the prompt file. Referencing other files allows you to provide additional context, such as API specifications or product documentation.
644+
645+
Once prompt files are saved, their instructions will apply to the current workspace in JetBrains IDEs that you open with {% data variables.product.prodname_copilot_short %} enabled.
646+
647+
### Creating prompt files using the command line
648+
649+
1. Create the `.github/prompts` directory if it doesn't already exist in your workspace. This directory will be the location for your prompt files.
650+
1. Create a prompt file in the `.github/prompts` directory. The prompt file name can contain alphanumeric characters and spaces and should describe the purpose of the prompt information the file will contain. The file name must end with the `.prompt.md` file name extension, for example `TESTPROMPT.prompt.md`.
651+
1. Write the prompt instructions using Markdown formatting, and save the file.
652+
653+
### Creating prompt files using the settings page
654+
655+
{% data reusables.copilot.jetbrains-settings %}
656+
1. Under **Tools**, under **{% data variables.product.prodname_copilot %}**, click **Edit Settings**.
657+
1. Under "Settings Categories", click **Customizations**.
658+
1. Under "Prompt Files", click **Workspace**, to create a prompt file in your workspace.
659+
1. Enter a name for the prompt file, excluding the `.prompt.md` file name extension. The prompt file name can contain alphanumeric characters and spaces and should describe the purpose of the prompt information the file will contain.
660+
1. Click **Ok** to save the prompt file name.
661+
1. Write the prompt instructions using Markdown formatting, and save the file.
662+
663+
### Using prompt files
664+
665+
1. In the chat input box, type `/` followed by the name of the prompt file. For example, `/TESTPROMPT`.
666+
1. Optionally, attach additional files, to provide more context.
667+
1. Optionally, type additional information in the chat prompt box.
668+
669+
Whether you need to do this or not depends on the contents of the prompt you are using.
670+
671+
1. Submit the chat prompt.
672+
673+
{% endjetbrains %}

content/copilot/tutorials/customization-library/custom-instructions/your-first-custom-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ topics:
2020
You can customize {% data variables.product.prodname_copilot %}'s responses using two types of files:
2121

2222
* **Custom instructions** provide ongoing guidance for how {% data variables.product.prodname_copilot %} should behave across all your interactions.
23-
* **Prompt files (public preview)** define reusable prompts for specific tasks that you can invoke when needed. Prompt files are only available in {% data variables.product.prodname_vscode_shortname %}. For an introductory example, see [AUTOTITLE](/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file).
23+
* **Prompt files (public preview)** define reusable prompts for specific tasks that you can invoke when needed. {% data reusables.copilot.prompt-files-available-in-editors %} For an introductory example, see [AUTOTITLE](/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file).
2424

2525
While custom instructions help to add context to each AI workflow, prompt files let you add instructions to a specific chat interaction.
2626

content/copilot/tutorials/customization-library/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Customization library
3-
intro: 'Discover a curated collection of customizations, including custom instructions and prompt files (VS Code only), to enhance your {% data variables.product.prodname_copilot %} experience.'
3+
intro: 'Discover a curated collection of customizations, including custom instructions and prompt files ({% data variables.product.prodname_vscode_shortname %} and JetBrains IDEs only), to enhance your {% data variables.product.prodname_copilot %} experience.'
44
allowTitleToDifferFromFilename: true
55
versions:
66
feature: copilot
@@ -20,4 +20,3 @@ children:
2020
- /prompt-files
2121
contentType: tutorials
2222
---
23-

content/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ contentType: tutorials
2121
You can customize {% data variables.product.prodname_copilot %}'s responses using two types of files:
2222

2323
* **Custom instructions** provide ongoing guidance for how {% data variables.product.prodname_copilot %} should behave across all your interactions. For an introductory example, see [AUTOTITLE](/copilot/tutorials/customization-library/custom-instructions/your-first-custom-instructions).
24-
* **Prompt files (public preview)** define reusable prompts for specific tasks that you can invoke when needed. Prompt files are only available in {% data variables.product.prodname_vscode_shortname %}.
24+
* **Prompt files (public preview)** define reusable prompts for specific tasks that you can invoke when needed. {% data reusables.copilot.prompt-files-available-in-editors %}
2525

2626
## Your first prompt file
2727

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prompt files are only available in {% data variables.product.prodname_vscode_shortname %} and JetBrains IDEs.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
> [!NOTE]
2-
> * {% data variables.product.prodname_copilot_short %} prompt files are in {% data variables.release-phases.public_preview %} and subject to change. Prompt files are only available in {% data variables.product.prodname_vscode_shortname %}. See [AUTOTITLE](/copilot/concepts/prompting/response-customization?tool=vscode#about-prompt-files).
2+
> * {% data variables.product.prodname_copilot_short %} prompt files are in {% data variables.release-phases.public_preview %} and subject to change. {% data reusables.copilot.prompt-files-available-in-editors %} See [AUTOTITLE](/copilot/concepts/prompting/response-customization?tool=vscode#about-prompt-files).
33
> * For community-contributed examples of prompt files for specific languages and scenarios, see the [Awesome GitHub Copilot Customizations](https://github.com/github/awesome-copilot/blob/main/README.prompts.md) repository.

0 commit comments

Comments
 (0)