用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill vscode-extension-dev命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | vscode-extension-dev |
| description | > Use when this capability is needed. |
| Topic | Reference File |
|---|---|
| TypeScript best practices & project setup | references/typescript-setup.md |
| VS Code API namespaces cheatsheet | references/vscode-api.md |
| WebView security & messaging | references/webview-security.md |
| Unit testing (commands, providers, WebView) | references/unit-testing.md |
Always read the relevant reference file(s) before writing extension code.
Before writing any code, confirm:
window, workspace, commands, languages, etc.)my-extension/
├── src/
│ ├── extension.ts # activate() / deactivate() entry point
│ ├── commands/ # One file per command group
│ ├── providers/ # TreeDataProvider, CodeLensProvider, etc.
│ ├── webview/
│ │ ├── panel.ts # WebviewPanel lifecycle manager
│ │ └── media/ # HTML / CSS / JS for the WebView
│ └── utils/
├── package.json # Extension manifest (contributes, activationEvents)
├── tsconfig.json
└── .vscode/
└── launch.json # Extension Host debug config
// package.json
"activationEvents": [
"onCommand:myExt.doThing", // ✅ Lazy
"onLanguage:python", // ✅ Lazy
"onView:myTreeView" // ✅ Lazy
// ❌ Avoid: "*" (activates on every startup)
]
Every subscription/listener must be pushed to context.subscriptions:
export function activate(context: vscode.ExtensionContext) {
const disposable = vscode.commands.registerCommand("myExt.hello", () => {
vscode.window.showInformationMessage("Hello!");
});
context.subscriptions.push(disposable); // ✅ Auto-cleaned on deactivate
}
async function myCommand(): Promise<void> {
try {
await doAsyncWork();
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
vscode.window.showErrorMessage(`MyExt: ${msg}`);
// Log to output channel for diagnostics:
outputChannel.appendLine(`[ERROR] ${msg}`);
}
}
Need UI?
├── Simple text input → vscode.window.showInputBox()
├── Pick from list → vscode.window.showQuickPick()
├── File picker → vscode.window.showOpenDialog()
├── Progress indicator → vscode.window.withProgress()
├── Structured tree data → TreeDataProvider + registerTreeDataProvider()
├── Rich HTML content → WebviewPanel (⚠ read webview-security.md first)
└── Status bar text → vscode.window.createStatusBarItem()
Before writing any WebView code, read references/webview-security.md.
The non-negotiable rules (summary):
localResourceRoots — never leave it as default undefined.retainContextWhenHidden: false — only set to true when state persistence is explicitly required.<script> and <style> tag.webview.html — always sanitize/escape first.Read references/typescript-setup.md for the full tsconfig. Non-negotiable settings:
{
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedLocals": true
}
Never use any — use unknown and narrow with type guards.
| Pitfall | Correct Pattern |
|---|---|
vscode.workspace.rootPath (deprecated) | vscode.workspace.workspaceFolders?.[0].uri |
Hardcoded file paths with path.join in WebView src | webview.asWebviewUri(vscode.Uri.joinPath(...)) |
| Forgetting to dispose event listeners | Push all to context.subscriptions |
postMessage without origin/nonce validation | Always validate in both directions |
| Blocking the extension host with sync I/O | Use async/await + vscode.workspace.fs |
Direct fs module in WebView scripts | WebView has no Node.js — use message passing |
# Unit tests (Vitest — preferred)
npm run test:unit
# Integration tests (requires VS Code window)
npm run test:integration
Test file pattern: src/test/unit/**/*.test.ts
publisher field set in package.jsonengines.vscode specifies minimum versionREADME.md describes all featuresCHANGELOG.md existsicon.png 128×128pxvsce package and inspect the .vsix before publishingvsce publish (requires PAT from marketplace.visualstudio.com)Source: bobosun0713/skills — distributed by TomeVault.