Best AI Prompts for Chrome Extension Development with Cursor
TL;DR
- Cursor’s IDE context means it can see your full extension project structure, making it effective for cross-file coordination tasks like updating the manifest when you add a new content script.
- The most effective Cursor prompts for extension work use the @file reference to specify exactly which file you are modifying and why.
- Manifest.json management is the single highest-leverage area to automate in Cursor, because changes to extension behavior almost always require manifest updates.
- Use Cursor’s chat to diagnose specific Chrome DevTools errors by pasting the error message and the relevant code.
- Cursor’s Tab feature lets you apply AI-generated changes across multiple files in a single session, which is ideal for extension-wide refactoring.
Chrome extension development with Cursor is a fundamentally different experience from using AI coding assistants in a standard IDE, because extensions have a specific multi-file structure that Cursor can learn and reference. When Cursor knows your manifest.json, it knows what content scripts, background scripts, and permissions are registered. This means that when you ask it to add a new content script, it can update the manifest automatically. This cross-file coordination is where Cursor provides the most leverage over standalone AI tools.
1. The Multi-File Coordination Problem
Chrome extension development requires coordinated changes across multiple files. Adding a new feature typically means: updating manifest.json to register the new script or permission, writing the background service worker logic, writing the content script logic, updating the popup if there is one, and updating any shared utilities. In a standard editor, these changes are independent and easy to get out of sync.
Cursor’s context awareness means it can see all your extension files simultaneously. The prompts in this guide are designed to leverage that awareness, asking Cursor to manage cross-file consistency automatically.
2. The Manifest-First Development Prompt
Rather than writing code and then updating the manifest, the most efficient Cursor workflow is to define the manifest first and then ask Cursor to generate the code that satisfies it.
Prompt for manifest-first extension development:
We are building a Chrome Extension called "ReadLater" that lets users save articles to read later, with the ability to tag, search, and organize saved items. The extension uses Manifest V3.
Here is the complete manifest.json:
[PASTE MANIFEST.JSON]
I want you to generate the full extension implementation. The extension has:
- A browser action (toolbar icon) that opens a popup
- Content scripts that run on article pages (detected by: article tag OR main content area OR body with >500 words)
- A background service worker
- chrome.storage.local for data persistence
Generate the following files based on the manifest:
1. **background.js**: The service worker should handle:
- Message receiving from content script (save article) and popup (get/save/delete/search)
- Data storage operations using chrome.storage.local with the storage keys: articles (array), tags (object mapping tag to article IDs)
- On install (chrome.runtime.onInstalled), set a default article if the storage is empty
2. **content.js**: The content script should:
- Detect if it is on an article page using the detection criteria above
- If article, extract: title (from og:title or document.title), url (window.location.href), content (article text content), excerpt (first 200 chars), published date (from meta tags or heuristics)
- Show a small "Save to ReadLater" button fixed in the bottom-right corner
- On click, send the extracted data to background via chrome.runtime.sendMessage
- Show confirmation (saved) or error (already saved) feedback
3. **popup.html + popup.js**: The popup should:
- Show the user's saved article list (title, url, date saved)
- Allow searching articles by title or tag
- Allow adding/removing tags from articles
- Allow deleting articles
- Have a "Open all unread" button
- Show article count in the popup header
4. **utils.js**: Shared utility functions for:
- Truncating text to a specific length with ellipsis
- Generating a unique ID for articles
- Formatting relative dates ("3 days ago")
All code must be Manifest V3 compliant. Do not use any persistent background page patterns.
The manifest-first approach ensures that the generated code is always consistent with the registered scripts and permissions. If the manifest says a content script should run on article pages, Cursor will generate code that implements exactly that.
3. The Feature Addition Prompt
When adding a new feature to an existing extension, the key is to specify which files should be modified and what the manifest update should be.
Prompt for adding a new feature:
I have an existing Chrome Extension with the following files: manifest.json, background.js, content.js, popup.html, popup.js, utils.js. The extension lets users save articles for later reading.
I want to add a new feature: "Read Time Estimate." When a user saves an article, the content script should calculate the estimated read time based on word count (assuming 200 words per minute) and display it on the article page after saving. The read time should also be stored with the article in chrome.storage.local.
Current state of content.js:
[PASTE content.js]
Tasks:
1. Update content.js to calculate read time (word count / 200, rounded up to nearest minute, minimum 1 minute)
2. Update the saved article data sent to background.js to include readTimeMinutes field
3. Update background.js schema to expect and store readTimeMinutes in the articles array
4. Update popup.js to display read time in the article list
5. Update manifest.json if any new permissions or script registrations are needed (if not, say so)
Do not modify any files other than those listed above. Generate complete replacement code for each file that needs changes.
4. The Error Diagnosis Prompt
Cursor can diagnose Chrome extension errors when you provide the specific error message and the relevant source code.
Prompt for diagnosing extension errors:
My Chrome Extension is producing the following error in Chrome DevTools:
[PASTE EXACT ERROR MESSAGE FROM CHROME DEVTOOLS CONSOLE OR SERVICE WORKER INSPECTOR]
My extension is Manifest V3. The error appears when:
[DESCRIBE WHEN THE ERROR OCCURS - e.g., "when clicking the browser action button" or "when visiting any webpage"]
Here are the relevant files:
[PASTE manifest.json]
[PASTE background.js OR the specific function mentioned in the error]
The expected behavior is:
[DESCRIBE WHAT SHOULD HAPPEN]
What is the cause of this error and what specific code change would fix it? Be specific about which file and what line needs to change.
5. The Cross-File Consistency Audit
Cursor can audit your extension for consistency between the manifest and the actual code files, catching bugs where a script is referenced in the manifest but not implemented, or vice versa.
Prompt for consistency audit:
Audit my Chrome Extension project for consistency between manifest.json and the actual implemented files. Check for:
1. **Registered but missing**: Are there scripts registered in manifest.json that do not have corresponding files in the project?
2. **Present but not registered**: Are there JavaScript files in the project that are not registered in manifest.json?
3. **Permission consistency**: Are all permissions declared in manifest.json actually used in the code? Are all permissions used in the code declared in manifest.json?
4. **Message handling completeness**: In background.js, is there a chrome.runtime.onMessage listener that handles every message type that could be sent from content.js and popup.js? Are all message senders in content.js and popup.js matched by handlers in background.js?
5. **Storage key consistency**: Are the storage keys used in background.js and popup.js consistent? Do they use the same key names throughout?
Files in my project:
[LIST ALL FILES IN PROJECT DIRECTORY]
[PASTE manifest.json]
[PASTE background.js]
[PASTE content.js]
[PASTE popup.js]
Provide a report of any inconsistencies found, with specific file and line references and specific recommended fixes.
6. The Tab Feature for Multi-File Refactoring
Cursor’s Tab feature allows you to apply generated changes across multiple files in a single session. For extension-wide refactoring, this is significantly faster than making changes file by file.
Prompt for extension-wide refactoring using Tab:
I need to refactor my Chrome Extension's storage strategy. Currently, all article data is stored in a single flat array in chrome.storage.local. I need to restructure it to use a better schema.
Current schema in background.js:
[PASTE current storage schema section]
New schema requirements:
- Split into two storage keys: articlesById (object mapping article ID to article object) and articleIdsByDate (array of article IDs sorted by date, newest first)
- This allows efficient pagination (get first N from articleIdsByDate) and efficient lookup (get by ID from articlesById)
- All existing CRUD operations in background.js need to be updated to use the new schema
- popup.js fetches articles via a chrome.runtime.sendMessage to background — update the message format to support pagination (page number and page size parameters)
- content.js saves articles via chrome.runtime.sendMessage — update the message format to use the new article ID generation
Generate updated versions of:
1. background.js (new schema + updated CRUD operations + updated message handlers)
2. popup.js (updated fetch/pagination logic)
3. content.js (updated save message format)
4. manifest.json (if any changes needed — likely none)
Use the Tab feature to generate all four files in one response so I can apply them together.
FAQ
How does Cursor’s context awareness help with manifest management? Cursor can see your full project directory structure. When you add a new JavaScript file and ask Cursor to register it in the manifest, it knows the file exists and can update the manifest correctly. Without project context, AI tools may generate manifest entries that reference files that do not exist or use incorrect paths.
What is the most common bug that Cursor can catch in existing extension code? Storage key inconsistency: popup.js and background.js using different key names for the same data, or one file expecting a data structure that the other does not provide. Running the consistency audit prompt surfaces these bugs quickly.
How do I ask Cursor to update only specific files without affecting others? Name the specific files in your prompt: “Generate changes only for background.js and popup.js. Do not modify content.js or manifest.json.” Cursor will respect this scope if it is clearly stated.
Can Cursor help me test extension code? Cursor can generate test scaffolding (e.g., Jest tests for utility functions in utils.js) and mock chrome API objects. However, full extension testing requires Chrome’s runtime environment, which Cursor cannot replicate. Use Cursor to generate test code and test manually in Chrome’s developer mode.
What is the Tab feature and how do I use it for extensions? The Tab feature in Cursor AI allows you to accept or reject individual suggested edits across multiple files in a single review. For multi-file extension refactoring, generate all the file changes in one prompt and then use Tab to apply or reject each change individually before committing.
Conclusion
Cursor’s IDE context makes Chrome extension development significantly more efficient, particularly for the cross-file coordination tasks that are extension development’s most tedious aspect. The manifest-first workflow, consistency audits, and multi-file refactoring capabilities address the specific coordination overhead that makes extension development slower than standard web development.
Key Takeaways:
- Use manifest-first development: define what the manifest registers, then ask Cursor to generate the code that satisfies it.
- Use the feature addition prompt to manage cross-file changes automatically when adding new functionality.
- Run the consistency audit prompt periodically to catch the storage key and message handling inconsistencies that are common in multi-file extensions.
- Use the Tab feature for multi-file refactoring to apply changes across all extension files simultaneously.
- When debugging, always provide the exact error message and specify Manifest V3 compliance.
Next Step: Open your Chrome Extension project in Cursor and run the consistency audit prompt. If it finds issues (and it usually will in projects older than a few weeks), address them before adding any new features. Then use the feature addition prompt to add one new capability. You will immediately notice the difference in coordination overhead compared to managing manifest and code changes manually.