/vs-extensibility-skills:showing-message-boxesfrom vs-extensibility-skills
Shows how to display message boxes, prompts, info bars, and status bar notifications in Visual Studio extensions, covering both the new out-of-process VisualStudio.Extensibility model and legacy VSSDK.
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.
Visual Studio provides multiple notification mechanisms. Choose the right one based on how urgently you need the user's attention:
| Mechanism | When to use |
|---|---|
| Status bar | Non-critical — user doesn't need to act |
| Info bar | Important but not blocking — user can act when ready |
| Message box / User prompt | Blocking — user must acknowledge or choose before continuing |
| Output window | Informational logging — user can review at their leisure |
Using the VS-native APIs matters because they handle window parenting, theming, focus management, and threading automatically — raw WPF or WinForms dialogs do none of this and can appear behind the IDE or break input focus.
When to use this vs. alternatives:
ShowPromptAsyncUse ShellExtensibility.ShowPromptAsync() from the Microsoft.VisualStudio.Extensibility SDK. This is the recommended approach for new extensions.
NuGet package: Microsoft.VisualStudio.Extensibility
Key namespace: Microsoft.VisualStudio.Extensibility.Shell
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken cancellationToken)
{
await this.Extensibility.Shell().ShowPromptAsync(
"This is a user prompt.",
PromptOptions.OK,
cancellationToken);
}
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
{
if (!await this.Extensibility.Shell().ShowPromptAsync(
"Continue with executing the command?",
PromptOptions.OKCancel,
ct))
{
return;
}
// User confirmed — proceed
}
if (!await this.Extensibility.Shell().ShowPromptAsync(
"Continue with executing the command?",
PromptOptions.OKCancel.WithCancelAsDefault(),
ct))
{
return;
}
| Option | Buttons | Default returns |
|---|---|---|
PromptOptions.OK | OK | true / Close → false |
PromptOptions.OKCancel | OK, Cancel | OK → true, Cancel/Close → false |
PromptOptions.RetryCancel | Retry, Cancel | Retry → true, Cancel/Close → false |
| Option | Icon |
|---|---|
PromptOptions.ErrorConfirm | Error icon |
PromptOptions.WarningConfirm | Warning icon |
PromptOptions.AlertConfirm | Alert icon |
PromptOptions.InformationConfirm | Information icon |
PromptOptions.HelpConfirm | Help icon |
Define an enum for the return values:
public enum TokenThemeResult
{
None,
Solarized,
OneDark,
GruvBox,
}
Then build a custom PromptOptions<TResult>:
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
{
TokenThemeResult selected = await this.Extensibility.Shell().ShowPromptAsync(
"Select a token color theme:",
new PromptOptions<TokenThemeResult>
{
Choices =
{
{ "Solarized", TokenThemeResult.Solarized },
{ "One Dark", TokenThemeResult.OneDark },
{ "GruvBox", TokenThemeResult.GruvBox },
},
DismissedReturns = TokenThemeResult.None,
DefaultChoiceIndex = 0,
Title = "Theme Selector",
Icon = ImageMoniker.KnownValues.Settings,
},
ct);
}
string? projectName = await this.Extensibility.Shell().ShowPromptAsync(
"Enter the project name:",
new InputPromptOptions { DefaultText = "MyProject" },
ct);
If you're mixing the new extensibility model into an existing VSSDK package:
public class MyPackage : AsyncPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
VisualStudioExtensibility extensibility =
await this.GetServiceAsync<VisualStudioExtensibility, VisualStudioExtensibility>();
await extensibility.Shell().ShowPromptAsync(
"Hello from in-proc",
PromptOptions.OK,
cancellationToken);
}
}
The Community Toolkit wraps the VSSDK APIs with simpler, discoverable helpers.
NuGet package: Community.VisualStudio.Toolkit
Key namespace: Community.VisualStudio.Toolkit
// Simple synchronous message box
VS.MessageBox.Show("Title", "The message");
// Async with buttons and icon
await VS.MessageBox.ShowAsync(
"Title",
"The message",
OLEMSGICON.OLEMSGICON_INFO,
OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL);
var model = new InfoBarModel(
new[] { new InfoBarTextSpan("An update is available. "),
new InfoBarHyperlink("Install now") });
InfoBar infoBar = await VS.InfoBar.CreateAsync(ToolWindowGuids80.SolutionExplorer, model);
infoBar.ActionItemClicked += OnInfoBarAction;
await infoBar.TryShowInfoBarUIAsync();
await VS.StatusBar.ShowMessageAsync("Operation completed successfully.");
The low-level Visual Studio SDK APIs. Use these when you don't have the Community Toolkit or need full control.
NuGet package: Microsoft.VisualStudio.SDK
Key namespaces: Microsoft.VisualStudio.Shell, Microsoft.VisualStudio.Shell.Interop
VsShellUtilities.ShowMessageBox(
this.package, // IServiceProvider (your AsyncPackage)
"Hello World!", // message
"Command", // title
OLEMSGICON.OLEMSGICON_INFO, // icon
OLEMSGBUTTON.OLEMSGBUTTON_OK, // buttons
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); // default button
Returns an int matching VSConstants.MessageBoxResult values for branching on the user's choice.
Info bars require implementing IVsInfoBarUIEvents and using IVsInfoBarUIFactory:
var shell = (IVsShell)ServiceProvider.GetService(typeof(SVsShell));
shell.GetProperty((int)__VSSPROPID7.VSSPROPID_MainWindowInfoBarHost, out var host);
var infoBarHost = (IVsInfoBarHost)host;
var infoBarModel = new InfoBarModel(
new[] { new InfoBarTextSpan("An update is available. "),
new InfoBarHyperlink("Install now") },
KnownMonikers.StatusInformation,
isCloseButtonVisible: true);
var factory = (IVsInfoBarUIFactory)ServiceProvider.GetService(typeof(SVsInfoBarUIFactory));
IVsInfoBarUIElement uiElement = factory.CreateInfoBar(infoBarModel);
uiElement.Advise(this, out _);
infoBarHost.AddInfoBar(uiElement);
IVsStatusbar statusBar = (IVsStatusbar)ServiceProvider.GetService(typeof(SVsStatusbar));
statusBar.SetText("Operation completed successfully.");
Important: Do NOT use
System.Windows.MessageBoxorSystem.Windows.Forms.MessageBoxdirectly in any approach. They don't parent correctly against the Visual Studio main window.
VisualStudio.Extensibility + ShowPromptAsync. It runs out-of-process and won't crash VS.VS.MessageBox from the Community Toolkit, or VsShellUtilities.ShowMessageBox.MessageBox.Show() — it creates parenting issues with the VS window.CancellationToken and handle dismissal gracefully.await-ing ShowPromptAsync. Without await, the method returns immediately and the prompt may never display or may appear after the command has already finished.System.Windows.MessageBox or System.Windows.Forms.MessageBox instead of the VS APIs. Switch to VsShellUtilities.ShowMessageBox, VS.MessageBox.ShowAsync, or ShowPromptAsync.await JoinableTaskFactory.SwitchToMainThreadAsync() before the call, or use the async Toolkit overload VS.MessageBox.ShowAsync.None unexpectedly: The user dismissed the dialog (clicked X or pressed Escape). Always set DismissedReturns to a safe default and handle that value explicitly.IVsInfoBarHost — the main window host vs. a tool window host are different objects. For the Toolkit, ensure you pass a valid tool window GUID to VS.InfoBar.CreateAsync.Do NOT use
System.Windows.MessageBoxorSystem.Windows.Forms.MessageBox— not parented to VS, can appear behind IDE, not themed. UseVS.MessageBox.ShowAsync(Toolkit),VsShellUtilities.ShowMessageBox(VSSDK), orShowPromptAsync(Extensibility).
Do NOT show message boxes from a background thread without switching to UI thread first — use
VS.MessageBox.ShowAsync(Toolkit, handles thread switching) orSwitchToMainThreadAsync()beforeVsShellUtilities.ShowMessageBox(VSSDK).
Do NOT show message boxes during solution load, package init, or unattended operations — use an InfoBar instead for background-triggered notifications.
Do NOT display raw exception messages in user-facing message boxes — log the full exception; show a user-friendly summary.
Do NOT use more than 3 choices in a prompt — the Extensibility API enforces this limit. Use a custom dialog for more options.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
visual-studio, message-box, user-prompt, notifications, vssdk
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