Copilot aka , GitHub Copilot en Visual Studio 2022 (GIT Azure Devops)

6 views
Skip to first unread message

Kiquenet

unread,
7:20 AM (8 hours ago) 7:20 AM
to AltNet-Hispano
Utilizan  Visual Studio 2022 y   .github/instructions/*.instructions.md ?
y también ?
.editorconfig for coding standards
CONTRIBUTING.md for best practices, guidelines, architectural standards, etc.
and README.md for high level project information


Getting Copilot to respond the way you want can be a challenge. You may have different coding standards, best practices, or architectural patterns in different areas of your codebase. With instruction files, you can now target specific instructions to specific folders or files in your repository, making Copilot truly project-aware and consistent across sessions.

Enable the feature
Turn on the feature at Tools > Options > GitHub > Copilot > Copilot Chat > Enable custom instructions to be loaded from .github/instructions/*.instructions.md files and added to requests.

Write instruction files
1. Format your instructions with the applyTo header and specify a glob pattern for which files you want these instructions to be included for.
 
---

applyTo: "src/**/*.cs"

---
2. In the file body, you can use natural language to specify your content and reference other instruction files to compose instructions together.
3. Save the file with the .instructions.md file extension in the root of your repository in the .github/instructions folder.

Tip: You can even get Copilot's help refining your instructions to be more detailed.
How it works

When you prompt Copilot, it will automatically detect which instruction files apply to the files in your current context and attach them as references. You can see which instructions were attached by clicking on the references in the response card.



Copilot memories

For Copilot to work effectively for your unique team and repository, it needs to learn about your project and team best practices. Copilot memories enable Copilot to understand and apply your project's specific coding standards, making it project-aware and consistent across sessions.

How Copilot memories work
Memories use intelligent detection to understand your team's preferences as you prompt in the chat. That means, as you prompt how you normally would, Copilot is looking for instances where you correct its behavior, explicitly indicate a standard, or ask it to remember something. When detected, you'll see a confirmation nudge to save the preference. Copilot will then categorize the preference into one of three files:

.editorconfig for coding standards
CONTRIBUTING.md for best practices, guidelines, architectural standards, etc.
and README.md for high level project information


So, as you prompt, you're not only teaching Copilot how to respond better to you in the future, but you're also helping out your team by documenting your development best practices, and augmenting their future Copilot responses as well!



Kiquenet

unread,
8:48 AM (6 hours ago) 8:48 AM
to AltNet-Hispano

When a preference is detected, you can choose where to save it:

  • User-level preferences: Saved to %USERPROFILE%/copilot-instructions.md. These preferences apply to all your Copilot sessions across projects.
  • Repo-level preferences: Saved to /.github/copilot-instructions.md. These preferences are shared with your team via the repository.

This approach lets you personalize Copilot for your own workflow while also establishing shared coding standards for your team.



Use a .github/copilot-instructions.md file

To use a .github/copilot-instructions.md file:

  1. Create/add a custom instructions file .github/copilot-instructions.md in the root of your repository.
  1. Enable the feature in Visual Studio from the Tools > Options pane. Expand the All Settings > GitHub > Copilot > Copilot Chat section and select the Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests checkbox.

Custom instructions aren't visible in the Chat view or inline chat. However, when used by Copilot, the.github/copilot-instructions.md file is listed in the References list of a response.

Copilot memories can automatically detect your preferences during chat and add them to your instruction files, so you don't have to write them manually.

Use user-level preferences

In addition to repo-level custom instructions, you can define user-level preferences that apply to all your Copilot sessions across projects. User-level preferences are saved to %USERPROFILE%/copilot-instructions.md.

Use user-level preferences for personal coding standards, preferred patterns, or workflow conventions that you want Copilot to follow regardless of the repository you're working in. Repo-level instructions in .github/copilot-instructions.md still apply alongside your user-level preferences, so your team's shared standards are also respected.

You can add preferences to this file manually, or let Copilot memories detect and save them automatically as you chat.

Use .instructions.md files

Instead of using a single instructions file that applies to all chat requests, you can create multiple *.instructions.md files that apply to specific file types or tasks. For example, you can create instructions files for different programming languages, frameworks, or project types.

To use a .github/instructions/*.instructions.md file:

  1. Create the .github/instructions directory if it does not already exist.

  2. Add one or more .github/instructions/*.instructions.md files.

  3. Add the applyTo property in the frontmatter section of the instructions file. Use glob syntax to specify what files or folders the instructions apply to.

  4. Enable the feature in Visual Studio.

    In the Tools > Options pane, expand the All Settings > GitHub > Copilot > Copilot Chat section and select the Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests checkbox.

Instructions file format

Targeted instruction files use the .instructions.md extension and have this structure:

  • Header (optional): YAML frontmatter
    • description: Description shown on hover in Chat view
    • applyTo: Glob pattern that matches the files or folders you want the instructions to apply to
  • Body: Instructions in Markdown format
Example

Here's an example C# custom instruction:

markdown
## C# Instructions --- applyTo: `**/*.cs` --- - Write clear and concise comments for each function. - Use PascalCase for component names, method names, and public members. - Use camelCase for private fields and local variables. - Add a newline before the opening curly brace of any code block (such as after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.). - Ensure that the final `return` statement of a method is on its own line.

Copy these instructions into your .github/instructions/*.instructions.md file to use and automatically apply to Copilot behavior.

For more examples of custom instructions, see the list of instruction samples on GitHub.





Kiquenet

unread,
10:47 AM (4 hours ago) 10:47 AM
to AltNet-Hispano

🤖 [dotnet/skills para GitHub Copilot CLI]dotnet/skills para asistentes IA — Microsoft ha publicado los mismos skills que usa el propio equipo que desarrolla .NET. Gracias a ellos, optimizarás las respuestas de tus asistentes de IA con el conocimiento directo del equipo de .NET. Podrás resolver tareas complejas y errores de depuración de forma más fiable, reduciendo los intentos fallidos. Al integrar estas "habilidades" en tu entorno de trabajo, ganarás productividad aplicando patrones ya probados en escenarios reales de ingeniería. Muy, muy interesante.

Y si usas Azure, han publicado también los skills correspondientes.

Reply all
Reply to author
Forward
0 new messages