chrome-extension-dev-js-typescript-cursorrules-pro — правило
Правило для Cursor, которое настраивает агента писать код расширений Chrome на JavaScript и TypeScript по единому своду соглашений.
.cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdcЧто делает chrome-extension-dev-js-typescript-cursorrules-pro
Файл задаёт роль: агент считает себя специалистом по разработке расширений Chrome, а также по JavaScript, TypeScript, HTML, CSS, Shadcn UI, Radix UI, Tailwind и Web API. Дальше идёт свод правил по стилю кода, именованию, архитектуре расширения, манифесту и разрешениям, безопасности, вёрстке попапа и страницы настроек, производительности и работе с chrome.*.
Конкретика разложена по разделам. Имена файлов — в нижнем регистре с подчёркиваниями (content_script.js, background_worker.js), функции и переменные — camelCase, классы — PascalCase. Для манифеста правило требует третью версию, если нет особой причины брать вторую, и принцип минимальных привилегий. Общение между частями расширения — через передачу сообщений, состояние — через chrome.storage, задачи по расписанию — через chrome.alarms вместо setInterval. Есть раздел про контекст проекта: перед новой фичей агент должен посмотреть текущее состояние, чтобы не плодить дубли и конфликтующие реализации.
Отдельный пункт про вывод кода: правило требует отдавать файл целиком, а не отдельные изменённые куски. Это заметно раздувает ответы, поэтому на больших файлах агент может упереться в лимит и выдать только релевантный фрагмент с пометкой, куда он встаёт. Ставить стоит, если вы ведёте расширение Chrome и хотите, чтобы агент не мешал v2 и v3 манифеста и не забывал про CSP.
Какие задачи решает
- задать единый стиль кода для расширения Chrome
- выбрать между манифестом v2 и v3
- разложить файлы расширения по ролям: background, content, popup, options
- передавать сообщения между частями расширения без хаоса
- не дублировать уже написанный код при добавлении фичи
Примеры запросов агенту
- добавь обработчик клика в content_script.js, состояние храни в chrome.storage
- перепиши background_worker.js под манифест v3 с минимальными разрешениями
- проверь попап на CSP и вынеси запросы по HTTPS
Как установить chrome-extension-dev-js-typescript-cursorrules-pro
Вручную: положить файлы
.cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdcВо frontmatter: description, globs, alwaysApply
Вручную: положить файлы
.claude/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdПоле paths во frontmatter ограничивает файлы: globs из источника → paths
AGENTS.md
Codex читает AGENTS.md: вставьте текст правила туда
Вручную: положить файлы
.github/instructions/chrome-extension-dev-js-typescript-cursorrules-pro.instructions.mdПоле applyTo задаёт, к каким файлам применять: globs из источника → applyTo
Вручную: положить файлы
.devin/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdВручную: положить файлы
.clinerules/chrome-extension-dev-js-typescript-cursorrules-pro.mdПо шагам, с командами для каждой платформы: Cursor rules: файлы .mdc, четыре режима и замена .cursorrules
Из того же набора68
Похожие
Рядом в теме «Браузер и парсинг»
Всё по теме «Браузер и парсинг» →Вопросы о chrome-extension-dev-js-typescript-cursorrules-pro
Как установить chrome-extension-dev-js-typescript-cursorrules-pro в Cursor?
Создайте файл .cursor/rules/chrome-extension-dev-js-typescript-cursorrules-pro.mdc и вставьте в него содержимое правила.
Что делает chrome-extension-dev-js-typescript-cursorrules-pro?
Задаёт агенту роль эксперта по расширениям Chrome и свод соглашений: именование, структура файлов, работа с chrome.*, безопасность и вёрстка попапа.
Какие технологии покрывает правило?
JavaScript, TypeScript, HTML, CSS, Shadcn UI, Radix UI, Tailwind и Web API, плюс архитектура расширения и манифест.
Исходный текст
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