{"id":36444,"date":"2026-04-22T18:05:13","date_gmt":"2026-04-22T18:05:13","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=36444"},"modified":"2026-04-22T18:05:13","modified_gmt":"2026-04-22T18:05:13","slug":"c-code-intelligence-for-github-copilot-cli-preview","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/c-code-intelligence-for-github-copilot-cli-preview\/","title":{"rendered":"C++ Code Intelligence for GitHub Copilot CLI (Preview)"},"content":{"rendered":"<p>We recently brought C++ code understanding tools to GitHub Copilot in <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-code-editing-tools-for-github-copilot-now-in-public-preview\/\">Visual Studio<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/c-symbol-context-and-cmake-build-configuration-awareness-for-github-copilot-in-vs-code\/\">VS Code<\/a>. These tools provide precise, semantic understanding of your C++ code to GitHub Copilot using the same IntelliSense engine that powers code navigation in the IDE. Until now, these capabilities have been tied to GitHub Copilot in Visual Studio and VS Code. Today, we\u2019re bringing this same intelligence to the CLI with the release of the <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\/\">Microsoft C++ Language Server for GitHub Copilot CLI<\/a>, now available in Preview.<\/p>\n<h2>Why this matters<\/h2>\n<p>C++ is difficult for tools to reason about: complex include hierarchies, macros, templates, overloads, and build-system-dependent configurations mean that text search alone can give incomplete or misleading results. The Microsoft C++ Language Server provides the <a href=\"https:\/\/docs.github.com\/en\/copilot\/how-tos\/copilot-cli\/cli-getting-started\">GitHub Copilot CLI<\/a> with precise semantic data &#8211; including symbol definitions, references, call hierarchies, and type information &#8211; to complement grep-style search. Let\u2019s look at an example using <a href=\"https:\/\/github.com\/fmtlib\/fmt\">{fmt}<\/a>, an open-source formatting library.<\/p>\n<h3>Example scenario<\/h3>\n<p>I want to create a custom fmt formatter for the following internal type:<\/p>\n<pre class=\"prettyprint language-cpp\"><code class=\"language-cpp\">enum class LogLevel {info, warning, error};<\/code><\/pre>\n<p>One way to define a custom formatter is to inherit from an existing formatter. I want Copilot to provide a summary of all base formatters that are available to inherit from and a recommendation for which one I should use.<\/p>\n<p>With the Microsoft C++ Language Server enabled, Copilot:<\/p>\n<p>1. Uses workspace symbol search to find existing formatters in the fmt library<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-workspace-symbol.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-36448 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-workspace-symbol.webp\" alt=\"A screenshot of the Copilot CLI using the Microsoft C++ Language Server to search the workspace for a symbol.\" width=\"936\" height=\"499\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-workspace-symbol.webp 936w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-workspace-symbol-300x160.webp 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-workspace-symbol-768x409.webp 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<p>2. Uses go to definition on key base classes<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-gtd-no-alias.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-36447 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-gtd-no-alias.webp\" alt=\"A screenshot of the Copilot CLI using the Microsoft C++ Language Server to go to definition.\" width=\"936\" height=\"331\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-gtd-no-alias.webp 936w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-gtd-no-alias-300x106.webp 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/lsp-gtd-no-alias-768x272.webp 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<p>3. Summarizes all existing formatters, their purpose, and a recommendation<\/p>\n<p>In contrast, without the Microsoft C++ Language Server enabled, Copilot uses iterative grep searches to build its understanding of potentially relevant code.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-1.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-36445 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-1.webp\" alt=\"A screenshot of the Copilot CLI calling grep twice in a row.\" width=\"936\" height=\"232\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-1.webp 936w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-1-300x74.webp 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-1-768x190.webp 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<p>Then, instead of jumping to the definition of key base classes, it uses grep on the class name, which returns all instances of those types across the codebase to filter through.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-2.webp\"><img decoding=\"async\" class=\"aligncenter wp-image-36446 size-full\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-2.webp\" alt=\"A screenshot of the Copilot CLI calling grep on basic_ostream_formatter.\" width=\"936\" height=\"110\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-2.webp 936w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-2-300x35.webp 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2026\/04\/grep-2-768x90.webp 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<p>In this example, the precision of LSP protects against the retrieval of irrelevant results.<\/p>\n<h2>Getting started with the Microsoft C++ Language Server<\/h2>\n<p>The Microsoft C++ Language Server is available in Preview as a <a href=\"https:\/\/www.npmjs.com\/package\/@microsoft\/cpp-language-server\">npm package<\/a>. It runs on Windows, Linux, and macOS. Check out the <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\/#-quick-start\">quick start guide<\/a> in the README of our corresponding <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\">issue-only GitHub repository<\/a> to get started. An active GitHub Copilot subscription is required.<\/p>\n<p>The Microsoft C++ Language Server requires:<\/p>\n<ul>\n<li>Authenticating with the GitHub Copilot CLI<\/li>\n<li>Creating a <a href=\"https:\/\/clang.llvm.org\/docs\/JSONCompilationDatabase.html\">compile_commands.json file<\/a> for your project<\/li>\n<li>Configuring your project for use with the GitHub Copilot CLI<\/li>\n<\/ul>\n<p>Our issue-only GitHub repository contains a <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\/blob\/main\/skills\/setup-cpp-language-server\/SKILL.md\">skill<\/a> to automate steps #2-3 for CMake projects and <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\/#creating-compile_commandsjson-for-cmake-based-projects\">instructions to walk through the process yourself<\/a>. For MSBuild (vcxproj) users, we\u2019ve created a <a href=\"https:\/\/github.com\/microsoft\/msbuild-extractor-sample\">sample application<\/a> to help extract compile_commands.json from C++ MSBuild projects. Integrated support for C++ MSBuild projects is planned for a future release.<\/p>\n<p>Different models are more or less likely to call the C++ LSP. For best results, we recommend appending something like \u201cUse the C++ LSP\u201d to the end of your queries or creating a <a href=\"https:\/\/docs.github.com\/en\/copilot\/how-tos\/copilot-cli\/customize-copilot\/add-custom-instructions\">custom instructions file<\/a> to prefer the C++ LSP.<\/p>\n<h3>Share your feedback<\/h3>\n<p>The Microsoft C++ Language Server is available in Preview for early feedback. To report a problem or suggest an improvement, follow <a href=\"https:\/\/github.com\/microsoft\/cpp-language-server\/#-reporting-feedback\">these instructions<\/a> to open an issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently brought C++ code understanding tools to GitHub Copilot in Visual Studio and VS Code. These tools provide precise, semantic understanding of your C++ code to GitHub Copilot using the same IntelliSense engine that powers code navigation in the IDE. Until now, these capabilities have been tied to GitHub Copilot in Visual Studio and [&hellip;]<\/p>\n","protected":false},"author":2953,"featured_media":36453,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,3949],"tags":[],"class_list":["post-36444","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","category-copilot-2"],"acf":[],"blog_post_summary":"<p>We recently brought C++ code understanding tools to GitHub Copilot in Visual Studio and VS Code. These tools provide precise, semantic understanding of your C++ code to GitHub Copilot using the same IntelliSense engine that powers code navigation in the IDE. Until now, these capabilities have been tied to GitHub Copilot in Visual Studio and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/2953"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=36444"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36444\/revisions"}],"predecessor-version":[{"id":36454,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/36444\/revisions\/36454"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/36453"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=36444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=36444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=36444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}