agentleFS
MicrosoftKnown publishermicrosoft/PowerToys/src/modules/cmdpal/ExtensionTemplate/TemplateCmdPalExtension/.github/skills/add-fallback-commands/SKILL.md

add-fallback-commands

Skill142k starsChanged 39 days agoMITView on GitHub

Add fallback commands to your Command Palette extension for catch-all search behavior. Use when asked to add search functionality, query matching, direct input handling, calculator-style evaluation, URL opening, command execution, or results that appear when no other extension matches. Used by 14 of 20 built-in extensions.

Trending

More talk lately.about the whole repository

Dec 2025: 1 mentionJan 2026: 5 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 4 mentionsMay 2026: 0 mentionsJun 2026: 2 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 1 mentionNov 2026: 1 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/PowerToys repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/PowerToys

The biggest 5 of 111 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 111

Talked about on GitHub, Bluesky and Hacker News (111 times).

On GitHub · 42

37 more on GitHub

On Bluesky · 41

36 more on Bluesky

On Hacker News · 28

23 more on Hacker News

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If no top-level commands match, CmdPal asks extensions for fallback results

    line 25
  2. Very specific:

    Use FallbackCommandItem wrapper (not CommandItem)

    line 155
  3. Distinctive:

    Keep fallback responses fast — users expect instant results

    line 158
  4. Very specific:

    Use PlaceholderText on your page to guide users

    line 159

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add Fallback Commands

Fallback commands are shown in Command Palette when no other results match the user's query. They enable your extension to act as a catch-all handler — perfect for calculators, web search, command execution, file path opening, and more.

When to Use This Skill

  • Adding search functionality that responds to any user input
  • Creating a calculator that evaluates expressions as the user types
  • Building a web search that triggers on unmatched queries
  • Opening files or URLs typed directly into the palette
  • Executing shell commands from the search bar

How Fallback Commands Work

  1. User types a query in Command Palette
  2. If no top-level commands match, CmdPal asks extensions for fallback results
  3. Your extension's FallbackCommands() provides items that respond to the query
  4. The fallback items can be static (always shown) or dynamic (filtered by query)

Quick Start: Static Fallback

Override FallbackCommands() in your CommandProvider:

public partial class MyCommandsProvider : CommandProvider
{
    private readonly ICommandItem[] _commands;
    private readonly FallbackCommandItem[] _fallbacks;

    public MyCommandsProvider()
    {
        DisplayName = "Web Search";
        Icon = new IconInfo("\uE721"); // Search icon

        var searchPage = new WebSearchPage();
        _commands = [new CommandItem(searchPage) { Title = DisplayName }];
        _fallbacks = [new FallbackCommandItem(searchPage) { Title = "Search the web" }];
    }

    public override ICommandItem[] TopLevelCommands() => _commands;
    public override IFallbackCommandItem[] FallbackCommands() => _fallbacks;
}

Dynamic Fallback with DynamicListPage

For fallbacks that filter results based on the query, use DynamicListPage:

internal sealed partial class WebSearchPage : DynamicListPage
{
    private string _query = string.Empty;

    public WebSearchPage()
    {
        Icon = new IconInfo("\uE721");
        Title = "Web Search";
        Name = "Search";
        PlaceholderText = "Type to search...";
    }

    public override void UpdateSearchText(string oldSearch, string newSearch)
    {
        _query = newSearch;
        RaiseItemsChanged();
    }

    public override IListItem[] GetItems()
    {
        if (string.IsNullOrWhiteSpace(_query))
            return [];

        return [
            new ListItem(new OpenUrlCommand($"https://www.google.com/search?q={Uri.EscapeDataString(_query)}"))
            {
                Title = $"Search Google for \"{_query}\"",
                Icon = new IconInfo("\uE721"),
            },
            new ListItem(new OpenUrlCommand($"https://www.bing.com/search?q={Uri.EscapeDataString(_query)}"))
            {
                Title = $"Search Bing for \"{_query}\"",
                Icon = new IconInfo("\uE721"),
            },
        ];
    }
}

Responsive Fallback with Cancellation

For expensive operations (API calls, file searches), use cancellation to stay responsive:

internal sealed partial class SmartSearchPage : DynamicListPage
{
    private CancellationTokenSource? _cts;
    private IListItem[] _results = [];

    public override void UpdateSearchText(string oldSearch, string newSearch)
    {
        // Cancel any in-flight search
        _cts?.Cancel();
        _cts = new CancellationTokenSource();
        var token = _cts.Token;

        _ = Task.Run(async () =>
        {
            // Debounce: wait for user to stop typing
            await Task.Delay(300, token);
            if (token.IsCancellationRequested) return;

            // Perform search
            _results = await SearchAsync(newSearch, token);
            RaiseItemsChanged();
        }, token);
    }

    public override IListItem[] GetItems() => _results;

    private async Task<IListItem[]> SearchAsync(string query, CancellationToken token)
    {
        // Your search logic here
        // Check token.IsCancellationRequested periodically
        return [];
    }
}

Real-World Examples (from built-in extensions)

ExtensionFallback Behavior
AppsSearch installed applications by name
CalcEvaluate mathematical expressions directly
ShellExecute command-line commands
WebSearchSearch the web with configured engine
IndexerOpen files by path
TimeDateParse time/date queries
WindowsSettingsJump to Windows Settings pages
WinGetSearch WinGet packages
WindowWalkerFind and switch to open windows

Key Points

  • FallbackCommands() returns IFallbackCommandItem[] (not ICommandItem[])
  • Use FallbackCommandItem wrapper (not CommandItem)
  • Wrap a DynamicListPage for query-reactive results
  • Cancel previous searches when new input arrives
  • Keep fallback responses fast — users expect instant results
  • Use PlaceholderText on your page to guide users

Documentation

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.