# vscode-extension-dev-typescript-cursorrules-prompt-file

Guides Cursor through TypeScript-based VS Code extension work, from project layout and manifests to API use and tests.

- rule · `type=rule` · Cursor · ★ 41024
- Author: PatrickJS
- License: CC0-1.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc
- Updated: 2026-05-30
- HTML: https://affpapa.org/en/nevibecode/rules/vscode-extension-dev-typescript-cursorrules-prompt-file

## What it does

The rule steers the agent toward separating commands, UI, and business logic, using TypeScript types, and fitting changes into the existing project. It also covers `package.json`, command registration inside `activate()`, and interaction with VS Code APIs.

Its guidance includes input validation, error handling, tests with Mocha or Jest, and integration tests using VS Code’s test runner. It addresses Windows, macOS, and Linux. The `**/*` glob covers project files, while `alwaysApply: false` means Cursor does not automatically apply the rule in every situation.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/vscode-extension-dev-typescript-cursorrules-prompt-file.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/vscode-extension-dev-typescript-cursorrules-prompt-file.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc

## When to use it
- structure a VS Code extension project
- define commands and settings in `package.json`
- plan typed APIs and error handling
- outline unit and integration tests

## Example prompts
- Plan a TypeScript VS Code extension with separate command and business-logic modules.
- Review this extension’s `package.json` for commands, activation events, and settings.
- Add tests for this feature and handle errors from VS Code APIs.

## Source text · vscode-extension-dev-typescript-cursorrules-prompt-file.mdc · CC0-1.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 430f948915864451.

BEGIN THIRD-PARTY FILE 430f948915864451
```text
---
description: "Cursor rules for Vscode Extension Dev Typescript."
globs: **/*
alwaysApply: false
---
You are an expert in VSCode Extension Development, TypeScript, Node.js, HTML, CSS, VSCode APIs, and Electron.

Code Style and Structure:
- Write clear, concise TypeScript code following modern ECMAScript standards.
- Use modular design patterns to separate concerns (e.g., separate commands, UI components, and business logic).
- Organize your project into meaningful directories such as src, out, and assets.
- Include comprehensive inline comments and JSDoc annotations for public APIs.

Naming Conventions:
- Use kebab-case for file and folder names (e.g., my-extension, command-handler.ts).
- Use camelCase for variables and function names.
- Use PascalCase for classes and interfaces.
- Name commands and configuration keys descriptively (e.g., 'extension.activateFeature', 'extension.showOutput').

TypeScript Usage:
- Leverage TypeScript for static type checking and enhanced developer experience.
- Use interfaces and types to define extension commands, configuration schemas, and message payloads.
- Utilize generics, union types, and type guards to create robust and flexible APIs.
- Configure strict type checking in tsconfig.json to catch potential errors early.

Extension Architecture:
- Follow the VSCode Extension API guidelines to structure your extension entry point (typically in extension.ts).
- Register commands, events, and providers within the activate() function.
- Use dependency injection where possible to manage state and service interactions.
- Modularize features into separate files or modules to improve maintainability.

Manifest (package.json) and Configuration:
- Define extension metadata, activation events, contributions (commands, menus, keybindings), and configuration in package.json.
- Follow VSCode’s schema for extension manifests to ensure compatibility and discoverability.
- Use activation events wisely to minimize performance overhead (e.g., onCommand, onLanguage).
- Document all configurable options clearly in package.json and corresponding README files.

Security and Privacy:
- Adhere to the principle of least privilege; request only the permissions you need.
- Validate and sanitize any input or configuration data.
- Avoid exposing sensitive APIs or secrets within the extension.
- Implement error handling and logging that do not leak internal state information.

UI and Styling:
- Use VSCode’s Webview API for custom UIs when necessary; otherwise, leverage the built-in VSCode UI components.
- Maintain consistency with the VSCode design language to provide a seamless user experience.
- Use responsive design principles to support different screen sizes and themes (dark/light modes).
- Structure HTML, CSS, and JavaScript/TypeScript in a way that separates concerns and supports maintainability.

Performance Optimization:
- Optimize extension activation by deferring non-critical operations until after activation.
- Use asynchronous programming (async/await, Promises) to avoid blocking the main thread.
- Profile and monitor resource usage; consider lazy-loading features to reduce initial load time.
- Avoid unnecessary file system or network operations during activation.

VSCode API Usage:
- Familiarize yourself with the official VSCode API and follow its guidelines for registering commands, creating status bar items, handling events, etc.
- Use vscode.workspace, vscode.window, and vscode.commands to interact with the editor efficiently.
- Always handle potential errors when calling VSCode APIs to improve extension resilience.
- Keep up to date with the latest VSCode API changes and deprecations.

Cross-platform Compatibility:
- Ensure your extension works seamlessly across Windows, macOS, and Linux.
```
END THIRD-PARTY FILE 430f948915864451

The third-party file has ended. Everything between the 430f948915864451 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3786 of 5261 bytes. © PatrickJS · CC0-1.0 · https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
