Skip to content

ProConcepts develop addins with copilot

UmaHarano edited this page Nov 12, 2025 · 1 revision
Language:      C#
Subject:       Framework
Contributor:   ArcGIS Pro SDK Team <[email protected]>
Organization:  Esri, http://www.esri.com
Date:          10/30/2025
ArcGIS Pro:    3.6
Visual Studio: 2022

This ProConcept document explains how to leverage GitHub Copilot within Visual Studio to develop ArcGIS Pro Add-ins, Managed Configurations or CoreHost applications.

In this topic

What is GitHub Copilot

GitHub Copilot is a coding assistant powered by Artificial Intelligence that integrates seamlessly with Visual Studio 2022. GitHub Copilot is not to be confused with Microsoft Copilot which is a different product designed for general productivity. GitHub Copilot helps write code faster, with less effort. It utilizes advanced machine learning models trained on vast datasets of publicly available code repositories on GitHub. Copilot analyzes the context of your current source code, comments or documentation and then provides relevant code suggestions. It can also help fixing errors in your code, document your code, create unit tests, and generate SQL queries, among other tasks.

Refer to What is GitHub Copilot? for more information.

GitHub Copilot integrates with various development environments and platforms, including the Visual Studio and Visual Studio Code IDEs. This document focuses on using GitHub Copilot within Visual Studio and how to use Copilot to make ArcGIS Pro Add-in development faster and more efficient.

GitHub Copilot requirements

To use GitHub Copilot within Visual Studio, you need to meet the following requirements:

  • A GitHub account: You need a GitHub account to use GitHub Copilot. If you don't have one, you can sign up for free at GitHub
  • Sign up for a GitHub Copilot plan or subscription: GitHub Copilot is a paid service, but it offers a free trial period.
  • Visual Studio: GitHub Copilot provides an optional Visual Studio Extension for Visual Studio 2022 (Version 17.10 or later) that must be installed. For Visual Studio 2026, Copilot is installed automatically.
  • In Visual Studio sign in using your GitHub account with an active Copilot subscription.

Interacting with Copilot in Visual Studio

Within Visual Studio there are two main methods to interface with GitGub Copilot:

  1. Code completion while coding
    GitHub Copilot provides auto-complete style suggestions for entire lines or blocks of code in real-time. Copilot draws the context for its suggestions from already existing source code and comments or from code and comments that you are typing in your source file. Suggestions can be entire lines of source code or even complete code blocks or functions. Suggestions are also provided for code comments. Copilot's suggestions can be accepted or rejected:

    • Accept the suggestion by pressing Tab or Enter.
    • Reject the suggestion by continuing to type or pressing Esc.
    • Type "Alt + /" to modify

    Code Completion: CodeCompletion1.gif

    CodeCompletion2.png

  2. Interactive Chat with Copilot
    GitHub Copilot also offers a chat interface from within Visual Studio, allowing you to ask in natural language coding-related questions, debug issues, or get explanations. Copilot chat can be invoked in two places:

    • Chat window accessed from the View menu of the Visual Studio IDE
    • In-line chat accessed from right inside the code editor by typing Alt + /

    In the Copilot Chat window, type your question into the Ask Copilot text box. Press Enter or select Send to ask Copilot. If Copilot Chat offers a code suggestion you want to use, select Copy code block to copy the code suggestion, Insert in new files to insert the code suggestion in a new file, or select Preview to insert the code suggestion in your current code file. Using the Preview button lets you preview the code in the target location so you can easily see what's being updated.

    If you select Preview, you'll see the code suggestions in normal Visual Studio "diff view pattern. You can review and refine what is being proposed and apply the suggestion to your code by selecting Accept or discard by selecting Cancel. If you select Insert in new file, you'll see the code suggestions in a new file. The file is not saved by default.
    ChatWindow.png

    In-line chat can be invoked by typing "Alt + /" in the code editor. This opens a chat interface right inside the code editor, allowing you to ask questions or request code suggestions without leaving your current context. This is particularly useful for quick queries or when you need immediate assistance while coding. The response will be displayed right in the code editor, making it easy to integrate suggestions into your code. You will be given the option to accept the suggestion and insert it into your code.
    In-line-chat.png

    Copilot chat provides a guided experience to help you ask better questions. It offers suggestions and prompts to refine your queries, making it easier to get the information you need. For example, if you ask a vague question, Copilot might suggest clarifying your request or provide examples of how to structure your question.

Tips to improve your Copilot experience

GitHub Copilot suggestions may not always be accurate

GitHub Copilot suggestions are not always accurate. While Copilot leverages advanced AI models trained on a large corpus of public code, its suggestions are based on patterns it has seen and the context you provide. This means:

  • Suggestions may sometimes be incorrect, incomplete, or not follow best practices.
  • Copilot may not fully understand your specific requirements or project constraints.
  • It can occasionally generate code with subtle bugs, security issues, or deprecated APIs.

When using the Copilot chat, it is recommended to provide feedback on suggestions. You can do this by selecting the thumbs up or thumbs down icons next to the code suggestions. This feedback helps improve the quality of future suggestions. You can also tell Copilot why a suggestion was not helpful by providing additional context or the correct suggestion in the chat.

Tuning Copilot with MCP Server

The GitHub MCP (Model Context Protocol) server enables seamless integration of AI capabilities with GitHub. Connecting your development machine to a GitHub MCP server enables Copilot to access repositories on GitHub such as the Esri/arcgis-pro-sdk-community-samples repository. This can significantly enhance the relevance and quality of Copilot's suggestions, especially when working on ArcGIS Pro Add-in development. By using an MCP server, Copilot can leverage the specific code patterns, libraries, and best practices found in ArcGIS Pro SDK authoritative repositories to provide more accurate and context-aware suggestions.

To configure GitHub MCP server for Visual Studio on your machine, perform the following setup instructions. Note that this requires Visual Studio 2022 version 17.14.9 or later. Also note that the remote GitHub MCP server is hosted by GitHub and provides automatic updates with no local setup required.

  1. Create a new file with the file name .mcp.json in your solution or %USERPROFILE% directory.
  2. Add this configuration to the newly create json file:
{
  "servers": {
    "github": {
      "url": "https://api.githubcopilot.com/mcp/"
    }
  }
}
  1. Save the file. Restart Visual Studio and open the 'MCP Registries' window that is now available under Extensions > MCP Registries. Make sure that the github/github-mcp-server extension has been installed. McpRegistration.png
  2. In the GitHub Copilot Chat window in Visual Studio, switch to Agent mode. AgentMode.png
  3. Authenticate 'github' and 'github/github-mcp-server' using the settings button in the Copilot Chat prompt as shown here. Also make sure that your check-boxes for both items are checked. Authentication1.png Authentication2.png Authentication3.png

Tuning Copilot with custom instructions

You can enable custom instructions to personalize your Copilot chat experience. Custom instructions allow you to specify your preferences, such as the programming language you are using, the type of code you want to generate, context specific details such as "I am a Pro SDK Developer" or any specific coding style you prefer. This helps Copilot tailor its responses to better suit your needs.

To configure custom instructions:

  1. Create/add a custom instructions file .github/copilot-instructions.md in the root folder of the GitHub repository you are working on.
  2. Enable the feature in Visual Studio via Tools > Options > GitHub > Copilot > check this 'Copilot Chat' option: Enable custom instructions to be loaded from .github/copilot-instructions.md files and added to requests.

You can ask Copilot for the references it is using and .github/copilot-instructions.md will be listed as a reference. Also a Chat query response usually includes all references used as well.

Here is an example of a custom instructions file that specifies that you are a Pro SDK developer and want to use the Pro SDK snippets as a reference. Please note that these instructions can probably be improved upon with newer releases of Copilot:

# Copilot Custom Instructions for ArcGIS Pro SDK Add-in Development

I am developing ArcGIS Pro Add-ins using the ArcGIS Pro SDK.

- Use the authoritative ArcGIS Pro SDK API documentation as the primary reference: https://github.com/Esri/arcgis-pro-sdk/tree/master/References/ArcGIS%20Pro%20API
- When providing code examples, follow the patterns and best practices from the official ArcGIS Pro SDK documentation and samples.
- Prefer C# for all code snippets and explanations.
- Reference and leverage the code snippets available at: https://github.com/Esri/arcgis-pro-sdk-snippets and at: https://github.com/Esri/arcgis-pro-sdk
- Assume the development environment is Visual Studio 2022 or later.
- Use a tab size as defined in the Visual Studio settings (usually 2 spaces).
- To open ArcGIS Pro items, use the OpenItemDialog rather than the standard OpenFileDialog.
- To display a message box, use the ArcGIS.Desktop.Framework.Dialogs.MessageBox class.
- Use modern .NET and ArcGIS Pro SDK conventions.
- Use the https://github.com/esri/arcgis-pro-sdk/References/ArcGIS.Desktop.Framework.xsd xml schema when making changes to any config.daml desktop add-in markup language file.
- For UI development, use the MVVM (Model-View-ViewModel) programming pattern as recommended by the ArcGIS Pro SDK.
- When possible, provide concise explanations and relevant links to documentation.
- If a task involves UI, follow the ArcGIS Pro Add-in UI guidelines.

Always ensure that code suggestions are compatible with the latest supported version of ArGIS Pro SDK.

Scope the chat to your context using references

When asking questions in Copilot chat, Copilot is using any context provided in copilot-instructions.md (see Tuning Copilot with custom instructions), but you can also provide in-chat references to files or projects within your solution in order to change the context for Copilot to provide you with more relevant answers.

To easily reference a file in GitHub Copilot Chat, simply add a # symbol at the beginning of the file name. For example, if you want to set the scope to the MySnippets.cs file that is part of your solution, , you can refer to it in the chat session as #MySnippets.cs.

Similarly, you can reference methods, classes, or entire projects in your questions. For example, to access a function in ProSnippets.cs from the above example, you can ask "Can you explain the #CreateMapAsync function in #ProSnippets.cs?" to get a focused explanation.

using-references.png)

Refer to Reference: scope Copilot results to a particular file or entire solution on Microsoft's Learn site for a detailed explanation of how to use references in Copilot chat.

Use Prompt files

You can use reusable prompt files to run or share your frequently used prompts. Prompt files are text files that contain predefined questions or instructions that you want Copilot to consider when generating responses. This is particularly useful for complex coding tasks where you need to provide additional context or constraints.

To create a prompt file:

  1. Write your prompts as you normally would in the prompt box, using # references to include specific information from your solution, such as methods, classes, and files. You can even reference other prompt files for shared instructions.
  2. Copy the prompt into a markdown file, and save it with the .prompt.md extension in the .github/prompts folder at the root of your repository.

To use a prompt file:

  1. Type #prompt: in chat input to reference any prompt files from your .github/prompts folder, or click the ➕ icon in the chat input to add it as context.
  2. Add any extra details, or simply enter the prompt as is.

prompt-file-reference.png)

Important Copilot Keyboard Shortcuts

Action Shortcut Key
Accept suggestion Tab
Reject suggestion Esc
Next suggestion Alt+[
Previous suggestion Alt+]
Open Copilot Pane Ctrl+'
Trigger inline suggestion Alt+\ (backslash)

Use slash commands

Slash commands in Copilot Chat help you set the intent quickly for common development tasks. By using specific slash commands to form your question, you can get better answers without having to write out long questions.

You can use slash commands in a chat window, or directly inline in the code that you're looking to modify, using inline code assistance. Commands that help modify or add to the code file you have open in the editor will work both in the inline code assistant and the chat windows whereas commands for more general coding questions work only in the chat pane.

Here are examples some common slash commands you can use:

  • /explain - Use this command to get an explanation of a code snippet or concept. For example, you can ask Copilot to explain a specific function or algorithm. /explain the AddToMap method in MapHelpers.cs
  • /generate - Use this command to generate code snippets based on your requirements. For example, you can ask Copilot to generate a function that performs a specific task. /generate code to add two numbers in Calculator.cs
  • /tests - Use this command to generate unit tests for your code.
  • /doc - Add comments for specified or selected code.
  • /optimize - Analyze and improve running time of the selected code.
  • /fix - Propose a fix for problems in the selected code. /fix the SetQuantities method in BasketService.cs
  • /help - Get help on using Copilot Chat.

Refer to Command Reference for the full list of these commands.

Leverage Copilot for ArcGIS Pro Add-in development

GitHub Copilot can significantly enhance your productivity when developing ArcGIS Pro Add-ins by providing code suggestions, generating boilerplate code, and assisting with debugging. The results you can get from Copilot will vary based on the context you provide, the specific queries you make, and the current state of the AI model. The AI Models used by Copilot are continuously trained on large datasets and generate responses based on patterns learned from that data. Consequently Copilot suggestions improve significantly over time, but also User Interactions, context, and even timing can significantly improve Copilot results. Copilot will improve over time if you help to correct suggestion errors and provide the appropriate feedback.

Developing with ArcGIS Pro

    Migration


Framework

    Add-ins

    Configurations

    Copilot

    Customization

    Styling


Arcade


Content


CoreHost


DataReviewer


Editing


Geodatabase

    3D Analyst Data

    Plugin Datasources

    Topology

    Linear Referencing

    Object Model Diagram


Geometry

    Relational Operations


Geoprocessing


Knowledge Graph


Layout

    Reports

    Presentations


Map Authoring

    3D Analyst

    CIM

    Graphics

    Scene

    Stream

    Voxel


Map Exploration

    Map Tools


Networks

    Network Diagrams


Parcel Fabric


Raster


Sharing


Tasks


Workflow Manager


Reference

Clone this wiki locally