Skip to main content
rule

vscode-extension-dev-typescript-cursorrules-prompt-file — Cursor rule

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

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc
Open on GitHub

What vscode-extension-dev-typescript-cursorrules-prompt-file 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.

What it helps with

  • 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 for the agent

  • 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.

How to install vscode-extension-dev-typescript-cursorrules-prompt-file

Manually: put the files in place

.cursor/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about vscode-extension-dev-typescript-cursorrules-prompt-file

How do I install vscode-extension-dev-typescript-cursorrules-prompt-file in Cursor?

Save the rule at .cursor/rules/vscode-extension-dev-typescript-cursorrules-prompt-file.mdc.

What does vscode-extension-dev-typescript-cursorrules-prompt-file do?

It guides TypeScript extension development, covering project structure, the manifest, VS Code APIs, security, and testing.

Does the rule apply automatically to every file?

The **/* glob covers project files, but alwaysApply: false means Cursor does not automatically load it in every situation.

Source text

vscode-extension-dev-typescript-cursorrules-prompt-file.mdc · CC0-1.0
---
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.
- Test on different environments to identify any OS-specific issues.
- Use Node.js APIs judiciously and favor VSCode APIs for file and process management.

Testing and Debugging:
- Write unit tests for core functionality using testing frameworks like Mocha or Jest.
- Use the VSCode Extension Test Runner for integration tests.
- Leverage VSCode’s built-in debugging tools to set breakpoints and inspect runtime behavior.
- Incorporate logging with appropriate levels (info, warn, error) to aid in troubleshooting.

Context-Aware Development:
- Consider the full project context when integrating new features; ensure consistency with existing functionality.
- Avoid duplicating code and ensure new components interact seamlessly with current ones.
- Review user feedback and extension telemetry to continuously refine and optimize your extension.
- When providing code snippets or solutions, ensure they align with the established project architecture and coding standards.

Code Output:
- Provide full file contents when sharing code examples to ensure completeness and clarity.
- Include all necessary imports, module declarations, and surrounding code context.
- Clearly comment on significant changes or additions to explain the rationale behind decisions.
- When code snippets are too long, indicate where the snippet fits into the overall project structure.

Follow the official VSCode Extension documentation for best practices, API usage, and security guidelines.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Programming languages →

From the same set210

webassembly-z80-cellular-automata-cursorrules-prom A Cursor rule that walks the agent through adding a region grid to a Z80 cellular automata simulation built on WebAssembly. ★ 41,024repo stars vue A Cursor rule that tells the agent how to write Vue: Composition API, Pinia, typing and routing. Useful when the project already has .vue and .ts files. ★ 41,024repo stars vue-claude-stack This rule guides code generation for Vue 3 and Nuxt 3, covering Composition API, TypeScript, and Pinia. Use it to give an agent consistent project conventions. ★ 41,024repo stars vue-3-nuxt-3-typescript-cursorrules-prompt-file A Cursor rule that tells the agent how to write Vue 3 and Nuxt 3 code: Composition API, TypeScript interfaces, Nuxt conventions. Useful when the project already runs this stack. ★ 41,024repo stars vitest-unit-testing-cursorrules-prompt-file A Cursor rule that turns the agent into a Vitest and TypeScript test writer: it targets business logic and utilities, mocking dependencies with vi.mock. ★ 41,024repo stars vercel-deployment-cursorrules-prompt-file This rule guides an agent through Vercel deployment choices, from environment variables and serverless functions to caching and CI/CD. Use it when preparing a project for deployment. ★ 41,024repo stars unity-cursor-ai-c-cursorrules-prompt-file A Cursor rule that briefs the assistant on a Unity game project in C#: modular code, responsive mechanics, real-time performance. ★ 41,024repo stars typescript A Cursor rule that pins down how the agent writes TypeScript: types, naming, error handling. Useful when several people touch the same codebase. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor