Home › VS Code extensions › VS Code extension Copilot instructions

VS Code extension Copilot instructions

Copilot instructions for VS Code extensions in TypeScript: activation events, disposables, contribution points, webview security, and @vscode/test-cli tests.

GitHub CopilotVS Code extensions

How to use

Save this as .github/copilot-instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/copilot-instructions.mdDownload  
# Copilot instructions — VS Code extension (TypeScript)

## Commands
`npm run compile` (or `npm run watch`) · `npm run lint` · `npm test` (`@vscode/test-cli` + `@vscode/test-electron`) · package: `npx @vscode/vsce package`. Never run `vsce publish` unless asked.

## Rules
- Respect `engines.vscode` in `package.json`; only use APIs available in that version. Don't use proposed APIs.
- Activate lazily: use specific `activationEvents` (`onCommand`, `onLanguage:x`, `workspaceContains:`) or rely on contribution-based activation. Never `*`.
- Everything registered in `activate(context)` is pushed to `context.subscriptions` (commands, listeners, providers, status bar items). No leaked disposables.
- Every command in code is declared in `contributes.commands` with a `category`, and settings in `contributes.configuration` with types, defaults and descriptions. Read settings via `vscode.workspace.getConfiguration('myExt')`.
- Keep `activate` fast; defer heavy work and show progress with `vscode.window.withProgress`.
- Use `vscode.Uri` and `vscode.workspace.fs` instead of Node `fs` and string paths so remote and virtual workspaces work.
- Webviews: set `enableScripts` only when needed, a strict Content-Security-Policy with a nonce, `localResourceRoots` limited to the extension's media folder, and load assets via `webview.asWebviewUri`. Validate every message from the webview.
- Secrets go in `context.secrets`, never in settings or globalState.
- Long-running language features belong in a language server (`vscode-languageclient`), not the extension host.
- User-facing strings via `vscode.l10n.t()`.

## Tests
Integration tests under `src/test/` with `@vscode/test-cli` (`.vscode-test.mjs`); unit-test pure logic without the `vscode` module.

More: all VS Code extensions rules · all GitHub Copilot rules

Related rules

Electron app AGENTS.md

AGENTS.md for Electron desktop apps (Electron Forge or electron-vite): process layout, IPC contracts, and release safety.

AGENTS.mdElectron

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

Tauri 2 Rust backend rules

Cursor rules for the Rust side of Tauri 2 apps: commands, typed errors, state, plugins, and capability files.

CursorTauri

Tauri 2 desktop app Windsurf rules

Windsurf rules for Tauri 2 desktop/mobile apps: Rust commands, capabilities and permissions, and a web frontend.

WindsurfTauri

Angular 20 Copilot instructions

Copilot instructions for Angular 20 apps using standalone components, signals, and the new control flow.

GitHub CopilotAngular

Code review Copilot instructions

Copilot instructions focused on pull request review: what to flag, severity labels, and how to word comments.

GitHub CopilotAgent workflows

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.