Skip to main content

Command Palette Extensions

Command Palette (CmdPal) is the next-generation launcher for PowerToys, designed with extensibility as a core principle. Unlike PowerToys Run plugins, Command Palette extensions are WinRT-based and language-agnostic, allowing developers to create rich, interactive experiences.
Command Palette is currently in preview. The API may introduce breaking changes before reaching v1.0.0.

Extension Architecture

Command Palette extensions are built on Windows Runtime (WinRT) components, making them accessible from any language that supports WinRT interfaces including C#, C++/WinRT, Rust, and more.

Core Components

  • IExtension - Entry point for extensions
  • ICommandProvider - Provides commands and pages
  • IListPage - Display searchable lists of items
  • IContentPage - Display rich content (forms, markdown, trees)
  • ICommand - Individual commands and actions
  • IExtensionHost - Host APIs for status, logging, and notifications

Creating Your First Extension

Quick Start: Using the Command Palette

The fastest way to create an extension:
  1. Open Command Palette (Win+Alt+Space)
  2. Type “Create extension”
  3. Enter your project name and display name
  4. Choose a location for your project
  5. Open the generated .sln file in Visual Studio

Manual Project Setup

If you prefer to create the project manually:
  1. Create a Windows Runtime Component project in Visual Studio
  2. Target Windows 10.0.22621.0 or higher
  3. Add references:
    • Microsoft.CommandPalette.Extensions
    • Microsoft.CommandPalette.Extensions.Toolkit (C# helper library)

Extension SDK Reference

IExtension Interface

The main entry point for your extension:

ICommandProvider Interface

Provides commands and pages to the Command Palette:
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.idl

IListPage Interface

Display searchable lists of items:
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.idl

ICommand Result Types

Commands return results that control navigation:
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.idl

Building a Simple Extension

Here’s a complete example of a basic Command Palette extension:

Extension Entry Point

Command Provider

List Page

Real-World Example: Calculator Extension

Here’s a simplified version of the Calculator extension:
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/CalculatorCommandProvider.cs
Key features:
  • Top-level command for main calculator page
  • Fallback command for evaluating math expressions typed anywhere
  • Settings page accessible via context menu
  • Icon configuration for light/dark themes

Advanced Features

Form Pages

Create interactive forms using Adaptive Cards JSON:

Markdown Content

Display formatted markdown:

Dynamic Filtering

Implement IDynamicListPage for server-side filtering:

Extension Host APIs

Use host APIs for status updates and logging:

Toolkit Helpers (C#)

The Microsoft.CommandPalette.Extensions.Toolkit provides useful C# helper classes:

CommandProvider Base Class

AnonymousCommand

Quick command creation:

CommandResult Helpers

Testing Extensions

Local Testing

  1. Build your extension in Visual Studio
  2. Deploy to Command Palette:
    • Build sets up the extension automatically
    • Or manually copy to extensions folder
  3. Restart Command Palette:
    • Close Command Palette if open
    • Reopen with Win+Alt+Space

Debug Extensions

  1. Set breakpoints in your extension code
  2. In Visual Studio: Debug > Attach to Process
  3. Select Microsoft.CmdPal.UI.exe
  4. Open Command Palette and trigger your extension

Extension Packaging

Extensions can be packaged and distributed:
  1. Build in Release mode
  2. Package files:
    • Extension DLL
    • Dependencies
    • Assets (icons, etc.)
  3. Create installer or distribution package
  4. Provide installation instructions
Extensions run with full user privileges. Only install extensions from trusted sources.

API Evolution

Command Palette uses versioned APIs:
src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions/Microsoft.CommandPalette.Extensions.idl
You can implement newer interfaces for additional features while maintaining backward compatibility.

Best Practices

  1. Performance
    • Keep GetItems() fast (< 100ms)
    • Use IDynamicListPage for expensive searches
    • Implement LoadMore() for large datasets
  2. User Experience
    • Provide clear titles and subtitles
    • Use appropriate icons
    • Show loading states for long operations
    • Handle errors gracefully
  3. Resource Management
    • Implement proper disposal in IExtension.Dispose()
    • Unsubscribe from events
    • Clean up background tasks
  4. Accessibility
    • Provide keyboard shortcuts where appropriate
    • Use semantic command names
    • Support high contrast themes

Resources

Next Steps

Explore Example Extensions

Check out the built-in extensions in the PowerToys source code for real-world examples

Join the Community

Share your extensions and get help from other developers