/vs-extensibility-skills:adding-tool-windowsfrom vs-extensibility-skills
Creates and shows tool windows in Visual Studio extensions using VisualStudio.Extensibility, VSIX Community Toolkit, or legacy VSSDK approaches.
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 tool window is a dockable panel in Visual Studio (like Solution Explorer or Error List). It consists of an outer shell managed by VS and custom content provided by your extension.
Tool windows give extensions a persistent, dockable surface whose position, visibility, and dock state VS saves automatically across sessions. Without them, interactive extensions are limited to transient dialogs or output text.
When to use a tool window vs. alternatives:
ToolWindow or BaseToolWindow<> or ToolWindowPane).vsixmanifest (Toolkit/VSSDK only)Tool windows use Remote UI — your extension runs out-of-process and defines XAML DataTemplates that VS renders in-process. This keeps VS stable even if your extension crashes.
NuGet package: Microsoft.VisualStudio.Extensibility
Key namespaces: Microsoft.VisualStudio.Extensibility.ToolWindows, Microsoft.VisualStudio.Extensibility.UI
using Microsoft.VisualStudio.Extensibility;
using Microsoft.VisualStudio.Extensibility.ToolWindows;
using Microsoft.VisualStudio.RpcContracts.RemoteUI;
[VisualStudioContribution]
internal class MyToolWindow : ToolWindow
{
private readonly MyToolWindowContent content = new();
public MyToolWindow(VisualStudioExtensibility extensibility)
: base(extensibility)
{
Title = "My Tool Window";
}
public override ToolWindowConfiguration ToolWindowConfiguration => new()
{
Placement = ToolWindowPlacement.DocumentWell,
DockDirection = Dock.Right,
AllowAutoCreation = true,
};
public override async Task InitializeAsync(CancellationToken cancellationToken)
{
// Do any async work BEFORE the UI is created (e.g., load data, query services).
// This runs before GetContentAsync is called.
}
public override Task<IRemoteUserControl> GetContentAsync(CancellationToken cancellationToken)
=> Task.FromResult<IRemoteUserControl>(content);
protected override void Dispose(bool disposing)
{
if (disposing)
content.Dispose();
base.Dispose(disposing);
}
}
MyToolWindowContent.cs:
using Microsoft.VisualStudio.Extensibility.UI;
internal class MyToolWindowContent : RemoteUserControl
{
public MyToolWindowContent()
: base(dataContext: new MyToolWindowData())
{
}
public override async Task ControlLoadedAsync(CancellationToken cancellationToken)
{
await base.ControlLoadedAsync(cancellationToken);
// Called after the UI is rendered — safe to start background updates here.
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
}
using System.Runtime.Serialization;
using Microsoft.VisualStudio.Extensibility.UI;
[DataContract]
internal class MyToolWindowData : NotifyPropertyChangedObject
{
private string? _statusText = "Ready";
[DataMember]
public string? StatusText
{
get => _statusText;
set => SetProperty(ref _statusText, value);
}
[DataMember]
public IAsyncCommand RefreshCommand { get; }
public MyToolWindowData()
{
RefreshCommand = new AsyncCommand(async (parameter, ct) =>
{
StatusText = "Refreshing...";
// Do work
StatusText = "Done";
});
}
}
MyToolWindowContent.xaml:
<DataTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vs="http://schemas.microsoft.com/visualstudio/extensibility/2022/xaml">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="{Binding StatusText}" />
<Button Content="Refresh" Command="{Binding RefreshCommand}" Margin="0,8,0,0" />
</StackPanel>
</DataTemplate>
Add it as an embedded resource in your .csproj:
<ItemGroup>
<!-- Simple case: XAML file name matches the RemoteUserControl class name -->
<EmbeddedResource Include="MyToolWindowContent.xaml" />
<Page Remove="MyToolWindowContent.xaml" />
<!-- When the XAML file name differs from the RemoteUserControl class name -->
<EmbeddedResource Include="Views\MyToolWindowView.xaml">
<!-- LogicalName must match the fully qualified RemoteUserControl class name + ".xaml" -->
<LogicalName>MyCompany.MyExtension.RemoteUI.MyToolWindowContent.xaml</LogicalName>
</EmbeddedResource>
</ItemGroup>
[VisualStudioContribution]
public class ShowMyToolWindowCommand : Command
{
public ShowMyToolWindowCommand(VisualStudioExtensibility extensibility)
: base(extensibility) { }
public override CommandConfiguration CommandConfiguration => new("My Tool Window")
{
Placements = new[] { CommandPlacement.KnownPlacements.ViewOtherWindowsMenu },
Icon = new(ImageMoniker.KnownValues.ToolWindow, IconSettings.IconAndText),
};
public override async Task ExecuteCommandAsync(IClientContext context, CancellationToken ct)
{
await this.Extensibility.Shell().ShowToolWindowAsync<MyToolWindow>(activate: true, ct);
}
}
Tool windows can auto-show/hide based on activation constraints:
public override ToolWindowConfiguration ToolWindowConfiguration => new()
{
Placement = ToolWindowPlacement.DocumentWell,
// Show only when a .cs file is the active document
VisibleWhen = ActivationConstraint.ClientContext(
ClientContextKey.Shell.ActiveSelectionFileName, @"\.cs$"),
};
The Community Toolkit provides BaseToolWindow<T> which uses an async factory pattern — do your async work in CreateAsync before returning the WPF control. This prevents blocking the UI thread during initialization.
NuGet package: Community.VisualStudio.Toolkit
Key namespace: Community.VisualStudio.Toolkit
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Community.VisualStudio.Toolkit;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Shell;
public class MyToolWindow : BaseToolWindow<MyToolWindow>
{
public override string GetTitle(int toolWindowId) => "My Tool Window";
public override Type PaneType => typeof(Pane);
public override async Task<FrameworkElement> CreateAsync(int toolWindowId, CancellationToken cancellationToken)
{
// ✅ Do ALL async work here BEFORE creating the WPF control.
// This runs on a background thread — the UI is NOT blocked.
var data = await LoadDataFromServiceAsync(cancellationToken);
// Only return the control after async work is done.
return new MyToolWindowControl(data);
}
[Guid("d3b3ebd9-87d1-41cd-bf84-268d88953417")]
internal class Pane : ToolWindowPane
{
public Pane()
{
BitmapImageMoniker = KnownMonikers.StatusInformation;
}
}
private async Task<MyData> LoadDataFromServiceAsync(CancellationToken ct)
{
// Simulate loading data from a service or file
await Task.Delay(500, ct);
return new MyData { Message = "Loaded!" };
}
}
Key pattern:
CreateAsyncis the async factory. Do ALL slow work (file I/O, service calls, solution queries) insideCreateAsyncbefore instantiating theUserControl. This ensures the WPF content is ready when VS renders the tool window, with zero UI-thread blocking.
MyToolWindowControl.xaml:
<UserControl x:Class="MyExtension.MyToolWindowControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"
toolkit:Themes.UseVsTheme="True">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock x:Name="StatusLabel" Text="Ready" />
<Button Content="Refresh" Click="OnRefreshClick" Margin="0,8,0,0" />
</StackPanel>
</UserControl>
MyToolWindowControl.xaml.cs:
using System.Windows;
using System.Windows.Controls;
namespace MyExtension
{
public partial class MyToolWindowControl : UserControl
{
public MyToolWindowControl(MyData data)
{
InitializeComponent();
StatusLabel.Text = data.Message;
}
private void OnRefreshClick(object sender, RoutedEventArgs e)
{
StatusLabel.Text = "Refreshed!";
}
}
}
[ProvideToolWindow(typeof(MyToolWindow.Pane), Style = VsDockStyle.Tabbed, Window = WindowGuids.SolutionExplorer)]
public sealed class MyPackage : ToolkitPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
this.RegisterToolWindows();
}
}
The package must inherit from
ToolkitPackage, notAsyncPackage.
[Command(PackageIds.MyToolWindowCommand)]
internal sealed class ShowMyToolWindowCommand : BaseCommand<ShowMyToolWindowCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await MyToolWindow.ShowAsync();
}
}
The raw VSSDK uses ToolWindowPane and AsyncPackage.FindToolWindow. To follow async best practices, use AsyncPackage and perform initialization in InitializeAsync before the tool window UI loads.
NuGet package: Microsoft.VisualStudio.SDK
Key namespaces: Microsoft.VisualStudio.Shell, Microsoft.VisualStudio.Shell.Interop
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Shell;
[Guid("a1b2c3d4-e5f6-7890-abcd-ef1234567890")]
public class MyToolWindow : ToolWindowPane
{
public MyToolWindow() : base(null)
{
this.Caption = "My Tool Window";
// ⚠️ Do NOT do slow work here — this runs on the UI thread.
// The WPF content is set later after async init completes.
}
/// <summary>
/// Called by the package after async initialization is done.
/// Sets the WPF content with pre-loaded data.
/// </summary>
public void SetContent(MyToolWindowControl control)
{
this.Content = control;
}
}
MyToolWindowControl.xaml:
<UserControl x:Class="MyExtension.MyToolWindowControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock x:Name="StatusLabel" Text="Ready" />
<Button Content="Refresh" Click="OnRefreshClick" Margin="0,8,0,0" />
</StackPanel>
</UserControl>
MyToolWindowControl.xaml.cs:
using System.Windows;
using System.Windows.Controls;
namespace MyExtension
{
public partial class MyToolWindowControl : UserControl
{
public MyToolWindowControl(string initialMessage)
{
InitializeComponent();
StatusLabel.Text = initialMessage;
}
private void OnRefreshClick(object sender, RoutedEventArgs e)
{
StatusLabel.Text = "Refreshed!";
}
}
}
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
[ProvideToolWindow(typeof(MyToolWindow), Style = VsDockStyle.Tabbed, Window = ToolWindowGuids.SolutionExplorer)]
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid("your-package-guid-here")]
public sealed class MyPackage : AsyncPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
// ✅ Background-thread async work happens here.
var data = await LoadDataAsync(cancellationToken);
// Switch to UI thread to create WPF controls and register commands.
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
// Now find/create the tool window pane and set its UI.
var window = (MyToolWindow)FindToolWindow(typeof(MyToolWindow), 0, true);
if (window?.Frame == null)
throw new NotSupportedException("Cannot create tool window");
window.SetContent(new MyToolWindowControl(data.Message));
// Register the command to show the tool window.
OleMenuCommandService commandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
var cmdId = new CommandID(PackageGuids.MyCmdSet, PackageIds.ShowMyToolWindowCommand);
commandService?.AddCommand(new MenuCommand(ShowToolWindow, cmdId));
}
private void ShowToolWindow(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
var window = FindToolWindow(typeof(MyToolWindow), 0, true);
if (window?.Frame == null)
throw new NotSupportedException("Cannot create tool window");
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
}
private async Task<MyData> LoadDataAsync(CancellationToken ct)
{
await Task.Delay(500, ct);
return new MyData { Message = "Loaded!" };
}
}
Key pattern: Use
AsyncPackagewithAllowsBackgroundLoading = true. Perform all async work inInitializeAsyncon the background thread, then callJoinableTaskFactory.SwitchToMainThreadAsync()before touching WPF or VS services that require the UI thread. Never do slow work in theToolWindowPaneconstructor.
InitializeAsync on the ToolWindow for pre-load async work; UI is defined via Remote UI DataTemplates that render in-process.CreateAsync async factory to load data before returning the WPF FrameworkElement. Never do slow work in the Pane constructor.AsyncPackage.InitializeAsync to do background work, then SwitchToMainThreadAsync before creating WPF content. Never block the UI thread in the ToolWindowPane constructor.Dispose your tool window content to avoid leaks.[VisualStudioContribution] attribute is on both the ToolWindow class and the Command class. For Toolkit, ensure this.RegisterToolWindows() is called in InitializeAsync..xaml file is set as EmbeddedResource with <Page Remove="..."/> in the .csproj. If the XAML file name doesn't match the RemoteUserControl class name, set the <LogicalName> to the fully qualified class name + .xaml.Pane constructor instead of CreateAsync. Move all async initialization to the CreateAsync factory method.[ProvideToolWindow] attribute is missing from the package class, or the GUID on the ToolWindowPane doesn't match the one in the attribute.AllowAutoCreation is set appropriately in ToolWindowConfiguration. For VSSDK / Toolkit, verify the [ProvideToolWindow] Style and Window parameters are set.RemoteUserControl (Extensibility) or not unsubscribing from events in the WPF UserControl. Override Dispose and clean up.Do NOT do slow or async work in the
ToolWindowPaneconstructor (VSSDK) orPaneconstructor (Toolkit) — they run on the UI thread and freeze VS. UseInitializeAsync(VSSDK) orCreateAsync(Toolkit) instead.
Do NOT use synchronous
Package— useAsyncPackagewithAllowsBackgroundLoading = true(VSSDK) orToolkitPackage(Toolkit). Sync packages degrade IDE launch time.
Do NOT create WPF controls on a background thread — WPF requires the UI thread. Creating controls before
SwitchToMainThreadAsynccausesInvalidOperationException.
Do NOT set
ToolWindowPane.Contentto aFrameworkElementwith inline async calls in its constructor — the WPF constructor should be synchronous and fast.
Do NOT block the UI thread with
.Result/.Wait()/.GetAwaiter().GetResult()in tool window initialization — useasync/awaitwithJoinableTaskFactory.
Do NOT forget to
DisposeyourRemoteUserControl(Extensibility) or unsubscribe from events in WPFUserControl— undisposed content causes memory leaks.
Do NOT use
ToolWindowPanewith the older synchronousPackage.FindToolWindow— useAsyncPackageand async initialization. Old templates may show the sync pattern; do not follow them.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
visual-studio-extension, tool-window, vsix, vssdk, remote-ui
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