Voltar ao índice
Design e UI Fonte oficial

Comandos para extensões do VS Code

Orienta nomes, títulos, categorias, ícones, visibilidade e posicionamento de comandos contribuídos por extensões do VS Code.

Ver código no GitHub Instala diretamente do repositório-fonte.

O que esta skill faz

Esta skill ajuda a adicionar ou atualizar comandos seguindo as convenções de extensões do VS Code. Ela diferencia comandos regulares dos exclusivos da Side Bar e orienta regras de enablement, when, group e Command Palette.

Quando usar

  • Registrar um comando regular no package.json
  • Criar uma ação exclusiva da Side Bar
  • Controlar visibilidade com condições when
  • Definir posição de comandos em títulos e menus de contexto

Como usar

  1. Revise o repositório e localize as contribuições de commands e menus
  2. Defina title para todo comando e category para comandos regulares
  3. Use o padrão _extensionId.comando#sideBar para ações da Side Bar
  4. Configure icon, enablement, when e group conforme o local de exibição
  5. Verifique se comandos exclusivos não aparecem na Command Palette

O que revisar antes de instalar

  • As regras fornecidas não cobrem toda a API de extensões do VS Code
  • Condições when e grupos dependem do contexto específico da extensão
  • A skill não implementa automaticamente o handler do comando

SKILL.md

---
name: vscode-ext-commands
description: 'Guidelines for contributing commands in VS Code extensions. Indicates naming convention, visibility, localization and other relevant attributes, following VS Code extension development guidelines, libraries and good practices'
---

# VS Code extension command contribution

This skill helps you to contribute commands in VS Code extensions

## When to use this skill

Use this skill when you need to:
- Add or update commands to your VS Code extension

# Instructions

VS Code commands must always define a `title`, independent of its category, visibility or location. We use a few patterns for each "kind" of command, with some characteristics, described below:

* Regular commands: By default, all commands should be accessible in the Command Palette, must define a `category`, and don't need an `icon`, unless the command will be used in the Side Bar.

* Side Bar commands: Its name follows a special pattern, starting with underscore (`_`) and suffixed with `#sideBar`, like `_extensionId.someCommand#sideBar` for instance. Must define an `icon`, and may or may not have some rule for `enablement`. Side Bar exclusive commands should not be visible in the Command Palette. Contributing it to the `view/title` or `view/item/context`, we must inform _order/position_ that it will be displayed, and we can use terms "relative to other command/button" in order to you identify the correct `group` to be used. Also, it's a good practice to define the condition (`when`) for the new command is visible.