Skip to main content
rule

chrome-extension-dev-js-typescript-cursorrules-pro — Cursor rule

A Cursor rule that points the agent at one set of conventions for building Chrome extensions in JavaScript and TypeScript.

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

What chrome-extension-dev-js-typescript-cursorrules-pro does

The file sets a role: the agent treats itself as an expert in Chrome extension development plus JavaScript, TypeScript, HTML, CSS, Shadcn UI, Radix UI, Tailwind and Web APIs. From there it lays out sections on code style, naming, extension architecture, manifest and permissions, security, popup and options UI, performance, and chrome.* usage.

Naming is spelled out. Files use lowercase with underscores (content_script.js, background_worker.js), functions and variables use camelCase, classes use PascalCase. On the manifest the rule asks for v3 unless there is a specific reason for v2, and for least-privilege permissions. Components talk over message passing, state lives in chrome.storage, and scheduled work goes through chrome.alarms rather than setInterval. One section covers project context: before adding a feature the agent should review the current state so it does not duplicate or contradict what is already there.

Code output is the part worth knowing about. The rule tells the agent to return the whole file instead of just the changed lines. That makes responses long, so on a big file the agent may hit its limit and fall back to the relevant section with a note about where it fits. Worth adding if you maintain a Chrome extension and want the agent to stop mixing manifest v2 habits into v3 work.

What it helps with

  • keep one code style across a Chrome extension
  • pick between manifest v2 and v3
  • split extension files into background, content, popup and options roles
  • pass messages between extension parts without a mess
  • avoid duplicating existing code when adding a feature

Example prompts for the agent

  • add a click handler in content_script.js and keep state in chrome.storage
  • rewrite background_worker.js for manifest v3 with least-privilege permissions
  • check the popup against CSP and move requests to HTTPS

How to install chrome-extension-dev-js-typescript-cursorrules-pro

Manually: put the files in place

.cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.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 chrome-extension-dev-js-typescript-cursorrules-pro

How do I install chrome-extension-dev-js-typescript-cursorrules-pro in Cursor?

Create .cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdc and paste the rule contents into it.

What does chrome-extension-dev-js-typescript-cursorrules-pro do?

It gives the agent an expert role for Chrome extension work and a convention set covering naming, file structure, chrome.* APIs, security and popup UI.

Which technologies does the rule cover?

JavaScript, TypeScript, HTML, CSS, Shadcn UI, Radix UI, Tailwind and Web APIs, along with extension architecture and the manifest.

Source text

chrome-extension-dev-js-typescript-cursorrules-pro.mdc · CC0-1.0
---
description: "Cursor rules for VSCode extension development with Electron and TypeScript integration."
globs: **/*
alwaysApply: false
---
You are an expert in Chrome Extension Development, JavaScript, TypeScript, HTML, CSS, Shadcn UI, Radix UI, Tailwind and Web APIs.

Code Style and Structure:

- Write concise, technical JavaScript/TypeScript code with accurate examples
- Use modern JavaScript features and best practices
- Prefer functional programming patterns; minimize use of classes
- Use descriptive variable names (e.g., isExtensionEnabled, hasPermission)
- Structure files: manifest.json, background scripts, content scripts, popup scripts, options page

Naming Conventions:

- Use lowercase with underscores for file names (e.g., content_script.js, background_worker.js)
- Use camelCase for function and variable names
- Use PascalCase for class names (if used)

TypeScript Usage:

- Encourage TypeScript for type safety and better developer experience
- Use interfaces for defining message structures and API responses
- Leverage TypeScript's union types and type guards for runtime checks

Extension Architecture:

- Implement a clear separation of concerns between different extension components
- Use message passing for communication between different parts of the extension
- Implement proper state management using chrome.storage API

Manifest and Permissions:

- Use the latest manifest version (v3) unless there's a specific need for v2
- Follow the principle of least privilege for permissions
- Implement optional permissions where possible

Security and Privacy:

- Implement Content Security Policy (CSP) in manifest.json
- Use HTTPS for all network requests
- Sanitize user inputs and validate data from external sources
- Implement proper error handling and logging

UI and Styling:

- Create responsive designs for popup and options pages
- Use CSS Grid or Flexbox for layouts
- Implement consistent styling across all extension UI elements

Performance Optimization:

- Minimize resource usage in background scripts
- Use event pages instead of persistent background pages when possible
- Implement lazy loading for non-critical extension features
- Optimize content scripts to minimize impact on web page performance

Browser API Usage:

- Utilize chrome.* APIs effectively (e.g., chrome.tabs, chrome.storage, chrome.runtime)
- Implement proper error handling for all API calls
- Use chrome.alarms for scheduling tasks instead of setInterval

Cross-browser Compatibility:

- Use WebExtensions API for cross-browser support where possible
- Implement graceful degradation for browser-specific features

Testing and Debugging:

- Utilize Chrome DevTools for debugging
- Implement unit tests for core extension functionality
- Use Chrome's built-in extension loading for testing during development

Context-Aware Development:

- Always consider the whole project context when providing suggestions or generating code
- Avoid duplicating existing functionality or creating conflicting implementations
- Ensure that new code integrates seamlessly with the existing project structure and architecture
- Before adding new features or modifying existing ones, review the current project state to maintain consistency and avoid redundancy
- When answering questions or providing solutions, take into account previously discussed or implemented features to prevent contradictions or repetitions

Code Output:

- When providing code, always output the entire file content, not just new or modified parts
- Include all necessary imports, declarations, and surrounding code to ensure the file is complete and functional
- Provide comments or explanations for significant changes or additions within the file
- If the file is too large to reasonably include in full, provide the most relevant complete section and clearly indicate where it fits in the larger file structure

Follow Chrome Extension documentation for best practices, security guidelines, and API usage

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

Similar IDE rules

Everything for Browser and scraping →

From the same set68

cypress-defect-tracking-cursorrules-prompt-file A Cursor rule that turns the agent into a QA engineer: writes Cypress tests tagged by team, category and case ID, and builds reports through qa-shadow-report. ★ 41,011repo stars cursorrules-cursor-ai-wordpress-draft-macos-prompt A Cursor rule that describes the PressThat project: a system tray app that connects to WordPress and creates draft posts. Useful if you work on that app in Cursor. ★ 41,011repo stars cursor-ai-react-typescript-shadcn-ui-cursorrules-p A Cursor rule that pushes the agent toward React and TypeScript code written the way shadcn/ui and Tailwind CSS projects expect. ★ 41,011repo stars code-style-consistency-cursorrules-prompt-file A Cursor rule that makes the agent study your codebase conventions first and write new code to match them. Useful in repos with an established style. ★ 41,011repo stars cloudflare-workers-hono-angular-saas-cursorrules-prompt-file A Cursor rule that pins the stack and conventions for SaaS on Cloudflare Workers: Hono API, Angular, Drizzle, Clerk, Stripe. ★ 41,011repo stars ascii-simulation-game-cursorrules-prompt-file A Cursor rule that frames an observer-only ASCII simulation: 10x10 grid, turn-based play, logs for nearly everything. Useful if you are building something in the spirit of Conway's Game of Life. ★ 41,011repo stars ankra-cli A Cursor rule that tells the agent how to drive the Ankra CLI: clusters, stacks, Helm releases and tokens. ★ 41,011repo stars android-jetpack-compose-cursorrules-prompt-file A Cursor rule that steers the agent through Android development with Jetpack Compose: architecture, state, tests. ★ 41,011repo 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