1
0
mirror of synced 2025-12-20 18:36:31 -05:00
Files
docs/content/copilot/tutorials/customization-library/prompt-files/your-first-prompt-file.md
Siara 164e19962b Discovery landing page (#58174)
Co-authored-by: Claire W <78226508+crwaters16@users.noreply.github.com>
Co-authored-by: Anne-Marie <102995847+am-stead@users.noreply.github.com>
Co-authored-by: Jules <19994093+jules-p@users.noreply.github.com>
Co-authored-by: Jules Porter <jules-p@users.noreply.github.com>
Co-authored-by: hubwriter <hubwriter@github.com>
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
2025-10-29 18:30:03 +00:00

2.4 KiB

title, intro, versions, category, complexity, octicon, topics, contentType
title intro versions category complexity octicon topics contentType
Your first prompt file Create your first {% data variables.product.prodname_copilot_short %} prompt file with this simple code explanation example that works for any programming language.
feature
copilot
Prompt files
Getting started
Configure Copilot
Simple
copilot
Copilot
tutorials

{% data reusables.copilot.prompt-files-preview-note %}

About customizations

You can customize {% data variables.product.prodname_copilot %}'s responses using two types of files:

  • Custom instructions provide ongoing guidance for how {% data variables.product.prodname_copilot %} should behave across all your interactions. For an introductory example, see AUTOTITLE.
  • Prompt files (public preview) define reusable prompts for specific tasks that you can invoke when needed. {% data reusables.copilot.prompt-files-available-in-editors %}

Your first prompt file

Start with this simple prompt file that helps you write clear, well-documented code explanations.

Code explanation prompt

---
mode: 'agent'
description: 'Generate a clear code explanation with examples'
---

Explain the following code in a clear, beginner-friendly way:

Code to explain: ${input:code:Paste your code here}
Target audience: ${input:audience:Who is this explanation for? (e.g., beginners, intermediate developers, etc.)}

Please provide:

* A brief overview of what the code does
* A step-by-step breakdown of the main parts
* Explanation of any key concepts or terminology
* A simple example showing how it works
* Common use cases or when you might use this approach

Use clear, simple language and avoid unnecessary jargon.

Test it out

  1. Save the prompt file above as explain-code.prompt.md in your .github/prompts folder.

  2. In {% data variables.product.prodname_vscode %}, display the {% data variables.copilot.copilot_chat_short %} view and enter /explain-code.

    {% data variables.product.prodname_copilot_short %} will switch to agent mode, if this is not already selected, and will prompt you to enter some code and an audience type.

  3. Enter:

    The code is `function fibonacci(n) { return n <= 1 ? n : fibonacci(n-1) + fibonacci(n-2); }`. The audience is beginners.
    

{% data reusables.copilot.prompt-files-further-reading %}