/vs-extensibility-skills:handling-protocol-urisfrom vs-extensibility-skills
Registers and handles custom URI protocol deep links (e.g. myext://open/file) in Visual Studio extensions using VSSDK or VSIX Community Toolkit.
Ships in vs-extensibility-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A protocol handler lets you register a custom URI scheme (e.g. myext://action/param) with Windows so that clicking such a link in a browser, email, or another app launches Visual Studio and passes the URI to your extension for processing.
Protocol handlers enable deep linking into your extension from external sources. This is useful for CI/CD dashboards that link to specific code locations, issue trackers that open VS with context, or onboarding flows that configure the IDE with one click. Without a protocol handler, users must manually open VS, navigate to the right file, and apply settings themselves.
When to use this vs. alternatives:
ProvideAppCommandLine (covered in this skill)devenv.exe with a command-line switch and appends the full URI.AsyncPackage loads via ProvideAppCommandLine, reads the URI from SVsAppCommandLine, and acts on it.Not supported. The new extensibility model does not provide a protocol handler API. Protocol registration requires a per-machine VSIX with AllUsers="true" and direct access to SVsAppCommandLine — both of which are only available in-process. Use the VSSDK / Toolkit approach below.
The Toolkit and VSSDK approaches are identical for protocol handlers — the Toolkit's AsyncPackage base class inherits directly from the VSSDK AsyncPackage. The steps below work with both.
NuGet packages:
Community.VisualStudio.Toolkit.17 (or .16 / .15)Microsoft.VisualStudio.SDK (≥ 17.0)Key types: AsyncPackage, ProvideAppCommandLineAttribute, SVsAppCommandLine, IVsAppCommandLine
MyExtension/
├── Protocol/
│ └── protocol.json ← protocol registration manifest
├── MyExtensionPackage.cs ← AsyncPackage with ProvideAppCommandLine
├── source.extension.vsixmanifest
└── MyExtension.csproj
Add a JSON file to your project that declares the URI scheme. This file tells the VSIX installer to register the protocol with Windows.
Protocol/protocol.json:
{
"$schema": "http://json.schemastore.org/vsix-manifestinjection",
"urlAssociations": [
{
"protocol": "myext",
"displayName": "My Extension Protocol Handler",
"progId": "VisualStudio.myext.[InstanceId]",
"defaultProgramRegistrationPath": "Software\\Microsoft\\VisualStudio_[InstanceId]\\Capabilities"
}
],
"progIds": [
{
"id": "VisualStudio.myext.[InstanceId]",
"displayName": "My Extension Protocol Handler",
"path": "[InstallDir]\\Common7\\IDE\\devenv.exe",
"arguments": "/MyExtHandler",
"defaultIconPath": "[InstallDir]\\Common7\\IDE\\devenv.exe"
}
]
}
Replace myext with your own protocol name and /MyExtHandler with your own command-line switch.
Set the file's properties in the .csproj:
<ItemGroup>
<Content Include="Protocol\protocol.json">
<IncludeInVSIX>true</IncludeInVSIX>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- This Build Action is what makes VS process it during install -->
<BuildAction>ContentManifest</BuildAction>
</Content>
</ItemGroup>
Important: In the Visual Studio Properties window, set Build Action to
ContentManifest. This is what triggers VSIX installer to process the protocol registration.
Protocol handlers require the extension to be installed for all users (per-machine). In source.extension.vsixmanifest:
<Installation AllUsers="true">
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,)" />
</Installation>
Add ProvideAppCommandLine to your package so it auto-loads when devenv is launched with your switch:
MyExtensionPackage.cs:
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Community.VisualStudio.Toolkit;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
namespace MyExtension;
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid(PackageGuids.MyExtensionPackageString)]
[ProvideAppCommandLine("MyExtHandler", typeof(MyExtensionPackage), Arguments = "1", DemandLoad = 1)]
public sealed class MyExtensionPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await base.InitializeAsync(cancellationToken, progress);
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
if (await GetServiceAsync(typeof(SVsAppCommandLine)) is IVsAppCommandLine cmdLine)
{
ErrorHandler.ThrowOnFailure(
cmdLine.GetOption("MyExtHandler", out int isPresent, out string optionValue));
if (isPresent == 1 && !string.IsNullOrEmpty(optionValue))
{
// optionValue contains the full URI, e.g. "myext://open/some-resource?id=42"
await HandleProtocolUriAsync(optionValue);
}
}
}
private async Task HandleProtocolUriAsync(string rawUri)
{
if (!Uri.TryCreate(rawUri, UriKind.Absolute, out Uri uri))
{
await VS.MessageBox.ShowErrorAsync("Invalid URI", $"Could not parse: {rawUri}");
return;
}
// Route based on host/path
switch (uri.Host.ToLowerInvariant())
{
case "open":
string filePath = uri.AbsolutePath.TrimStart('/');
await VS.Documents.OpenAsync(filePath);
break;
case "settings":
await VS.Commands.ExecuteAsync(KnownCommands.Tools_Options);
break;
default:
await VS.StatusBar.ShowMessageAsync($"Unknown protocol action: {uri.Host}");
break;
}
}
}
Use standard System.Uri to extract path segments, query parameters, and fragments:
private void ProcessUri(Uri uri)
{
// myext://navigate/file?path=C%3A%5Ccode%5Capp.cs&line=42
string action = uri.Host; // "navigate"
string resource = uri.AbsolutePath.Trim('/'); // "file"
var query = System.Web.HttpUtility.ParseQueryString(uri.Query);
string path = query["path"]; // "C:/code/app.cs"
string line = query["line"]; // "42"
}
| Parameter | Type | Description |
|---|---|---|
switchName | string | The command-line switch name (without / prefix) |
packageType | Type | The AsyncPackage type to auto-load |
Arguments | string | "0" = no value expected; "1" = a value follows the switch |
DemandLoad | int | 1 = force-load the package when the switch is present |
During development, protocol URIs won't work with F5 debugging because the experimental hive doesn't register protocols with Windows. To test:
myext://open/test).Alternatively, test from a command prompt:
devenv.exe /MyExtHandler "myext://open/some-resource"
Uri.TryCreate with UriKind.Absolute to reject malformed input.[ProvideAppCommandLine] switch name matches the switch in your protocol.json manifest. Ensure DemandLoad = 1 is set so VS force-loads your package.Uri.TryCreate with UriKind.Absolute and HttpUtility.ParseQueryString for query parameters. Don't try to parse URIs manually with string splitting.protocol.json is included in the VSIX as content (Build Action = Content, Include in VSIX = true).Do NOT use URI parameters directly in file paths, process arguments, or SQL queries — protocol URIs come from untrusted sources. Validate against an allowlist and sanitize paths.
Do NOT test protocol handlers using F5 debugging — the experimental hive doesn't register protocols with Windows. Install the VSIX in a regular VS instance.
Do NOT register generic protocol schemes (e.g.
vs://) — use a unique scheme that includes your extension name.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
protocol-handler, visual-studio-extension, deep-linking, uri-scheme, vssdk, vsix
Generated from the plugin's indexed repository (madskristensen/vs-agent-plugins) — no native marketplace selected
npx claudepluginhub p/madskristensen-vs-extensibility-skills41 skills in this plugin
/adding-codelens-indicatorsAdd custom CodeLens indicators that display inline information above code elements in the Visual Studio editor. Use when the user asks how to add a CodeLens indicator, show inline data above methods or classes, create a custom CodeLens provider, implement IAsyncCodeLensDataPointProvider, display git history or test status in CodeLens, or add a details popup to CodeLens entries. Covers VSSDK / VSIX Community Toolkit (in-process + out-of-process CodeLens service). VisualStudio.Extensibility (out-of-process) does not have a dedicated CodeLens API./adding-commandsAdd commands (menu items, toolbar buttons) to Visual Studio extensions. Use when the user asks how to create a command, add a menu item, add a toolbar button, register a command handler, wire up a .vsct file, use KnownMonikers icons on buttons, or place commands in menus/toolbars in a Visual Studio IDE extension. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches./adding-context-menusAdd native-looking context menus to custom WPF UI in Visual Studio extensions (tool windows, custom tree views, list views). Use when the user wants to show a right-click context menu from their own UI that looks native to VS. Covers defining VSCT context menus (type="Context"), grouping commands with separators, and programmatically showing them via IVsUIShell.ShowContextMenu. Do NOT use regular WPF ContextMenu — it won't match VS theming or support command routing. Covers VSSDK and VSIX Community Toolkit (in-process). VisualStudio.Extensibility (out-of-process) does not support VSCT-based context menus on custom UI./adding-editor-adornmentsAdd visual adornments (decorations, overlays, highlights) to the Visual Studio text editor. Use when the user asks how to draw on the editor, add inline decorations, highlight text visually, add background colors to lines, show icons in the editor, create viewport-relative overlays, or render custom WPF visuals on top of editor text. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches./adding-editor-classifiersAdd custom syntax highlighting and text classification to the Visual Studio editor. Use when the user asks how to colorize text, add syntax highlighting, create a classifier, highlight keywords, change text colors in the editor, create a custom language colorizer, or implement classification types. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches./adding-editor-marginsAdd custom margins to the Visual Studio text editor (gutter icons, side panels, bottom bars). Use when the user asks how to add a gutter, editor margin, side panel, bottom bar, line number gutter, custom glyph margin, or editor chrome. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches.Other plugins' skills for the same job