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.
.cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdcWhat 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.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/chrome-extension-dev-js-typescript-cursorrules-pro.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdManually: put the files in place
.clinerules/chrome-extension-dev-js-typescript-cursorrules-pro.mdStep 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