controlling-command-visibility

Control Visual Studio command visibility with UIContext rules and BeforeQueryStatus logic.

14|2|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/madskristensen/vs-agent-plugins --skill controlling-command-visibility
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: controlling-command-visibility
Source: https://github.com/madskristensen/vs-agent-plugins/tree/main/skills/controlling-command-visibility
Command: npx skills add https://github.com/madskristensen/vs-agent-plugins --skill controlling-command-visibility

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guidance helps developers ensure Visual Studio commands are visible and enabled only in the appropriate UI contexts, reducing clutter and preventing unintended actions.

Core Features & Use Cases

  • Declarative visibility using VisibilityConstraints in .vsct or VisibleWhen in VisualStudio.Extensibility to show/hide commands before a package loads.
  • UIContext-based rule definition with ProvideUIContextRule or equivalent to activate contexts like file type, editor content, or solution state.
  • Runtime enablement and visibility adjustments after package initialization via BeforeQueryStatus and related APIs, with optional delegation back to UIContext using Command.Supported.
  • Cross-model coverage for Visual Studio extension development using out-of-process, in-process Toolkit, or legacy VSSDK approaches.

Quick Start

Define UIContext rules and runtime checks to conditionally display VS commands.

Frequently Asked Questions about controlling-command-visibility

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I show Visual Studio commands only when relevant?

To show Visual Studio commands only when relevant, apply declarative visibility constraints in .vsct files or use ProvideUIContextRule attributes to define contextual rules based on active file types, solution state, or UI contexts before and after package load.

What is BeforeQueryStatus used for in VS extension development?

BeforeQueryStatus is used to adjust command enablement and visibility at runtime after package initialization. It allows dynamic contextual checks during Visual Studio extension development, with optional delegation back to UIContext using Command.Supported for predictable UX.

How do I control command visibility before a VS package loads?

Control command visibility before a package loads by declaring VisibilityConstraints in .vsct files or using VisibleWhen in VisualStudio.Extensibility. This pre-loads declarative rules tied to UIContexts, ensuring commands remain hidden until the appropriate context activates.

Can I use ProvideUIContextRule to activate contexts based on editor content?

Yes, ProvideUIContextRule can activate UI contexts based on editor content, active file types, or solution state. This allows Visual Studio extensions to declaratively trigger command visibility rules without requiring the package to be fully loaded.

What is the best way to manage UI context for out-of-process VS extensions?

The best way to manage UI context across out-of-process, in-process Toolkit, or legacy VSSDK extensions is to combine declarative VisibleWhen constraints for pre-load visibility with BeforeQueryStatus logic for runtime adjustments, ensuring consistent command behavior.

Why are my Visual Studio extension commands always visible in menus?

Commands remain visible because they lack declarative VisibilityConstraints or ProvideUIContextRule definitions. Implement contextual visibility rules in .vsct files or use BeforeQueryStatus handlers to hide them when the UI context does not match the active file types or solution state.