עברית 📰 Blog
← Back to Blog
Guides

How to Build a Chrome Extension From Scratch With Claude Code

Stav Adam
Founder, Masterphub
October 29, 2026

Share this article

How to Build a Chrome Extension From Scratch With Claude Code
Short answer: Open an empty folder, start Claude Code, and give it a clear brief: what the extension does, which permissions it may use, and what not to add. Load the result in Chrome with Developer mode and "Load unpacked", test it on a few sites, and fix one problem at a time.

Most web pages are noisy. Ads, pop-ups, sidebars, autoplay videos. You came to read one article and you are fighting the page instead.

In this guide you will build a small Chrome extension called Focus Mode. One click on its icon turns a cluttered page into a clean reading view: a narrow column, calm typography, no distractions. You will build it with Claude Code, step by step, even if you have never written an extension before.

The goal is not only a working tool. It is a repeatable way to work with an AI coding assistant: describe the result, let it build, test, and improve one thing at a time.

What You Will Build

  • A Chrome extension that uses Manifest V3, the current extension format.
  • A toolbar button that switches Focus Mode on and off for the current tab.
  • A content script that finds the main article and hides everything else.
  • A stylesheet that gives the text a comfortable width, size and line height.
  • Minimal permissions, so the extension only touches a page when you click it.

Before You Start

  • Google Chrome on your computer.
  • Claude Code installed and signed in.
  • An empty folder for the project, for example focus-mode.
  • About 30 to 60 minutes.

You don't need to know JavaScript. You do need to read what Claude produces, test it, and describe clearly what is wrong. That is the real skill.

1. How a Chrome Extension Is Built

  • manifest.json describes the extension: name, version, permissions and which files it uses.
  • background.js is a service worker. It listens for events, such as a click on the toolbar icon.
  • focus-mode.js is the content script. It runs inside the web page and changes what you see.
  • focus-mode.css holds the reading styles.
  • Icons for the toolbar.

Knowing these pieces helps you give Claude better instructions and understand what it built. Chrome's own Focus Mode tutorial uses the same idea if you want to compare.

2. Start With a Clear Brief

Open the empty folder in your terminal, start Claude Code, and paste this brief.

Copy and paste prompt: Build the extension

Build a Chrome extension called "Focus Mode" using Manifest V3 in this folder.

What it does: when I click the toolbar icon on any article page, it switches the current tab into a clean reading view. Clicking again restores the original page.

Requirements:

  • Use only the "activeTab" and "scripting" permissions. No host permissions, no access to all sites.
  • A background service worker listens for the toolbar click and injects the content script and stylesheet into the current tab only.
  • The content script finds the main article content (prefer the <article> element, then <main>, then the largest block of paragraph text), hides everything else, and wraps the content in a centered column.
  • Reading styles: max width about 720px, comfortable font size, line height around 1.7, soft background, high-contrast text, images scaled to the column width.
  • Clicking again removes Focus Mode without reloading the page.
  • Include simple placeholder icons in 16, 48 and 128 pixels.
  • Add a short README with installation steps.

Before writing code, list the files you will create and explain in one line what each does. Then build it. Do not add features I did not ask for.

Why this prompt works

  • It describes the result from the user's point of view.
  • It sets limits: minimal permissions and no extra features.
  • It asks for a plan first, so you can catch a wrong direction before any code exists.

3. Load the Extension in Chrome

  1. Open chrome://extensions in Chrome.
  2. Turn on Developer mode in the top right corner.
  3. Click Load unpacked and choose your project folder.
  4. Pin the Focus Mode icon to the toolbar.
  5. Open a long article on any news site or blog and click the icon.

If something fails, the extensions page shows an Errors button for your extension. Copy the error text as it is.

4. Test, Then Fix One Thing at a Time

Test on at least five different sites: a news site, a blog, a documentation page, a long-form magazine and a site with heavy ads. Write down what happens on each.

Copy and paste prompt: Fix a problem

I tested Focus Mode. Here is what happened:

[SITE] | [WHAT YOU EXPECTED] | [WHAT ACTUALLY HAPPENED]

Error from the extensions page, if any: [PASTE ERROR]

Find the cause, explain it in two sentences, and fix only this problem. Don't change anything that already works. Tell me exactly how to retest.

Common problems and their usual causes:

ProblemLikely cause
Nothing happens on clickThe service worker isn't listening, or the action is missing in the manifest
The wrong part of the page staysThe article detection picks a sidebar or comments block
Text is too wide or tinyThe site's own CSS overrides the reading styles
Images overflowImages need a max-width rule inside the column
Doesn't work on some pagesChrome blocks extensions on its own internal pages and the Web Store, which is expected

5. Add One Feature at a Time

Once the basic version works, improve it in small steps. Pick one:

  • A dark reading theme.
  • A keyboard shortcut to toggle Focus Mode.
  • Font size buttons (A- / A+).
  • Estimated reading time at the top of the article.
  • Remember the preferred theme with chrome.storage.

Copy and paste prompt: Add a feature

Add one feature to Focus Mode: [FEATURE].
Keep the current permissions unless this feature truly needs a new one.
If it does, tell me which permission and why before you add it. Update the README.

6. A Quick Security and Quality Review

Before you share the extension with anyone, ask Claude to review it.

Copy and paste prompt: Review before sharing

Review this extension before I share it. Check:
- permissions (are any broader than needed?)
- any code that sends page content anywhere
- use of innerHTML with page data
- behavior on pages without an article
- whether toggling off fully restores the page
Return a short list of issues ranked by importance, then fix the top three.

A good rule: an extension should never send what you read to any server unless that is its stated purpose and the user agreed.

7. Publishing (Optional)

To publish on the Chrome Web Store you need a developer account, a short description, screenshots and a privacy statement explaining what data the extension handles. Focus Mode handles none, which makes the review simpler. Check the current Chrome Web Store policies and fees before you submit.

What You Learned

  • How a Manifest V3 extension is structured.
  • How to brief Claude Code with a clear result and clear limits.
  • How to test on real sites and fix one problem at a time.
  • How to keep permissions small and review before sharing.

The same method works for almost any small tool: describe the result, set the limits, ask for a plan, test, fix one thing, then add the next.

Frequently Asked Questions

Do I need to know how to code?

No, but you need to read what was built, test it carefully and describe problems precisely. Claude Code writes the code; you direct and verify.

Why does the extension use activeTab instead of access to all sites?

activeTab gives temporary access only to the tab where you click the icon. It is safer and makes the extension easier to trust.

Why doesn't it work on the Chrome Web Store or settings pages?

Chrome blocks extensions from changing its own internal pages and the Web Store. That is expected behavior.

Can I use the same approach for other extensions?

Yes. Replace the brief with the result you want, keep the permissions minimal, and follow the same test-and-fix loop.

More AI tools and ready prompts at masterphub.io

Share this article