AgentSkillsCN

vscode-integration

VS Code IDE 运行时意识。在内置工具的选择、验证、映射与使用方面,全面覆盖所有子工具(askQuestions、runCommand、扩展、openSimpleBrowser、vscodeAPI、installExtension、newWorkspace、getProjectSetupInfo),并明确参数模式、响应格式、约束条件与使用习惯。

SKILL.md
--- frontmatter
name: vscode-integration
description: VS Code IDE Runtime awareness. for built-in tools selection, validation, mapping and usage, Covers all sub-tools (askQuestions, runCommand, extensions, openSimpleBrowser, vscodeAPI, installExtension, newWorkspace, getProjectSetupInfo) with parameter schemas, response formats, constraints, and usage patterns.

VS Code Integration Skill

The vscode tool is the core IDE integration layer for all agents and subagents. It exposes VS Code's native capabilities through structured sub-tools. This skill documents each sub-tool's contract, constraints, and usage patterns.

Rule: Every agent/subagent MUST include 'vscode' in its tools: list.


Sub-Tool Reference

1. askQuestions — Interactive User Input

Renders native VS Code quick-pick widgets and returns structured JSON responses. Primary mechanism for gathering user preferences, clarifications, and decisions.

Schema

code
ask_questions({
  questions: [                      // 1–4 questions per call
    {
      header: "string",             // ≤12 chars — UI label AND response key (REQUIRED)
      question: "string",           // Full question text (REQUIRED)
      multiSelect: boolean,         // true = checkboxes, false = single-select (default: false)
      allowFreeformInput: boolean,  // true = user can type custom text (default: false)
      options: [                    // 0–6 options; omit/empty = free text input only
        {
          label: "string",          // Option text (REQUIRED)
          description: "string",    // Secondary text shown below label (optional)
          recommended: boolean      // Pre-selects option, shows recommended badge (optional)
        }
      ]
    }
  ]
})

Response

json
{
  "answers": {
    "<header>": {
      "selected": ["Label A", "Label B"],
      "freeText": "user typed text or null",
      "skipped": false
    }
  }
}

Hard Constraints

ParameterLimitFailure Mode
header≤12 charactersValidation error — tool call fails
questions1–4 per callValidation error — tool call fails
options0–6 per questionValidation error — tool call fails
recommendedMax 1 per questionUX confusion — multiple pre-selected
recommendedNEVER on quiz/poll optionsReveals answer — pre-selects it

Patterns

Single-select decision:

code
ask_questions({ questions: [{
  header: "Approach",
  question: "Which implementation approach?",
  options: [
    { label: "Option A", description: "Fast, less flexible", recommended: true },
    { label: "Option B", description: "Slower, extensible" },
    { label: "Skip", description: "Keep current" }
  ]
}]})

Multi-select priorities:

code
ask_questions({ questions: [{
  header: "Focus",
  question: "Which areas to prioritize?",
  multiSelect: true,
  options: [
    { label: "Performance", recommended: true },
    { label: "Security" },
    { label: "UX" }
  ]
}]})

Free text with suggestions:

code
ask_questions({ questions: [{
  header: "Name",
  question: "Module name?",
  allowFreeformInput: true,
  options: [
    { label: "analytics", description: "Based on described functionality" },
    { label: "reporting", description: "Matches naming convention" }
  ]
}]})

Pure free text (no presets):

code
ask_questions({ questions: [{
  header: "Details",
  question: "Describe the expected behavior."
}]})

Batched wizard (max 4):

code
ask_questions({ questions: [
  { header: "Scope", question: "...", options: [...] },
  { header: "Priority", question: "...", multiSelect: true, options: [...] },
  { header: "Timeline", question: "...", options: [...] }
]})

2. runCommand — VS Code Command Execution

Executes any VS Code command by its command ID. Maps to vscode.commands.executeCommand().

Schema

code
run_vscode_command({
  commandId: "string",   // VS Code command ID (REQUIRED)
  name: "string",        // Human-readable description (REQUIRED)
  args: ["string"]       // Arguments array (optional)
})

Useful Command IDs

File Operations:

Command IDPurpose
workbench.action.files.saveSave active file
workbench.action.files.saveAllSave all files
workbench.action.files.newUntitledFileCreate new untitled file
workbench.action.closeActiveEditorClose active editor
workbench.action.closeAllEditorsClose all editors
workbench.action.revertFileRevert file to saved

Editor:

Command IDPurpose
editor.action.formatDocumentFormat active document
editor.action.organizeImportsOrganize imports
editor.action.commentLineToggle line comment
editor.action.triggerSuggestTrigger autocomplete
editor.action.renameRename symbol
editor.action.revealDefinitionGo to definition

Terminal:

Command IDPurpose
workbench.action.terminal.newCreate new terminal
workbench.action.terminal.killKill active terminal
workbench.action.terminal.clearClear terminal
workbench.action.terminal.focusFocus terminal panel

Workspace & Layout:

Command IDPurpose
workbench.action.toggleSidebarVisibilityToggle sidebar
workbench.action.togglePanelToggle bottom panel
workbench.action.toggleZenModeToggle Zen mode
workbench.action.maximizeEditorMaximize editor
workbench.action.newWindowOpen new VS Code window

Tasks & Testing:

Command IDPurpose
workbench.action.tasks.runTaskRun specific task
workbench.action.tasks.buildRun build task
testing.runAllRun all tests
testing.reRunLastRunRe-run last test run

Git:

Command IDPurpose
git.stageStage file
git.stageAllStage all changes
git.commitCommit staged changes
git.pushPush to remote
workbench.view.scmOpen source control view

Search:

Command IDPurpose
workbench.action.findInFilesOpen workspace search
editor.action.startFindReplaceActionFind and replace in file
workbench.action.quickOpenQuick open file (Ctrl+P)
workbench.action.showAllSymbolsGo to symbol in workspace

3. extensions — Marketplace Search

Search the VS Code extension marketplace for extensions.

Schema

code
vscode_searchExtensions_internal({
  category: "string",   // Extension category (optional, enum below)
  keywords: ["string"], // Search keywords (optional)
  ids: ["string"]       // Specific extension IDs to look up (optional)
})

Category enum: AI, Azure, Chat, Data Science, Debuggers, Extension Packs, Education, Formatters, Keymaps, Language Packs, Linters, Machine Learning, Notebooks, Programming Languages, SCM Providers, Snippets, Testing, Themes, Visualization, Other

When to Use

  • User asks "what extension for X?"
  • Need to verify an extension exists before recommending
  • Comparing extensions for a specific purpose

4. openSimpleBrowser — In-Editor URL Preview

Opens a URL in VS Code's built-in Simple Browser panel.

Schema

code
open_simple_browser({
  url: "string"   // HTTP or HTTPS URL (REQUIRED)
})

When to Use

  • Preview locally hosted dev servers (http://localhost:5173)
  • View generated documentation or reports
  • Quick-check a web resource without leaving the editor

5. vscodeAPI — Extension Development Docs

Query VS Code API documentation for extension development guidance.

Schema

code
get_vscode_api({
  query: "string"   // API query with specific names/concepts (REQUIRED)
})

When to Use

  • User is developing a VS Code extension
  • Need to look up specific API interfaces, methods, or contribution points
  • Questions about proposed vs stable APIs

Not for: General VS Code usage questions, agent configuration, or non-extension tasks.


6. installExtension — Install Extensions

Install a VS Code extension by its marketplace ID.

Schema

code
install_extension({
  id: "string",     // Extension ID: publisher.extension (REQUIRED)
  name: "string"    // Human-readable name (REQUIRED)
})

When to Use

  • Part of new workspace/project setup
  • User explicitly requests extension installation
  • Project requires specific tooling extensions

7. newWorkspace — Project Scaffolding

Create a new project workspace with full structure.

Schema

code
create_new_workspace({
  query: "string"   // Project description (REQUIRED)
})

When to Use

  • User wants to create a new project from scratch
  • Setting up framework-based projects (React, Next.js, etc.)
  • Initializing MCP servers or VS Code extensions

Not for: Creating single files, adding to existing projects, or simple code snippets.


8. getProjectSetupInfo — Setup Information

Get project setup steps for specific project types.

Schema

code
get_project_setup_info({
  projectType: "string"   // Project type enum (REQUIRED)
})

Project type enum: python-script, python-project, mcp-server, model-context-protocol-server, vscode-extension, next-js, vite, other

Prerequisite: Must call create_new_workspace first.


Decision Table: Which Sub-Tool?

NeedSub-ToolExample
Get user preference / clarificationaskQuestions"Which approach should I use?"
Execute IDE action programmaticallyrunCommandFormat document, save all
Find/recommend extensionsextensions"Best Python linter extension?"
Preview a local URLopenSimpleBrowserView dev server at localhost
Look up VS Code extension APIvscodeAPI"How does TreeDataProvider work?"
Install an extensioninstallExtensionSet up project tooling
Scaffold a new projectnewWorkspace"Create a new Next.js app"
Get project setup stepsgetProjectSetupInfoSetup info for Python project

Anti-Patterns

Don'tDo Instead
Use markdown-formatted questions for user inputUse askQuestions with native widgets
Guess user preferences when ambiguousAsk via askQuestions with recommended defaults
Run terminal commands for VS Code actionsUse runCommand with proper command ID
Hard-code command IDs without checkingVerify command IDs from the reference tables above
Use vscodeAPI for non-extension questionsUse search or read tools instead
Use newWorkspace for adding files to existing projectsUse create_file tool instead
Use askQuestions when intent is obviousInfer and proceed — don't over-ask

Integration Notes

  • askQuestions wraps vscode.window.showQuickPick() and similar native UI APIs
  • runCommand wraps vscode.commands.executeCommand()
  • extensions wraps VS Code marketplace search API
  • openSimpleBrowser wraps the simpleBrowser.open internal command
  • All sub-tools return structured data — handle responses as JSON
  • Sub-tools are available in all agent modes (user-facing and subagent)