DEV Community

Cover image for I Built a Fully Local Prompt Enhancer Chrome Extension with Gemini Nano

I Built a Fully Local Prompt Enhancer Chrome Extension with Gemini Nano

Over the last few weeks, I’ve been building a Chrome extension called Prompt Enhancer that turns rough ideas into clear, structured prompts for ChatGPT in a single click. It runs fully on‑device using Chrome’s built‑in Gemini Nano via the Prompt API, so nothing ever leaves your browser.

In this post, you’ll see:

  • Why Prompt Enhancer exists (and the workflow problem it solves)
  • How it works end‑to‑end from the user’s perspective
  • The technical architecture: Manifest V3, content scripts, and the Prompt API
  • What’s shipped today and what’s coming next (v2 ideas and roadmap)

The Problem: We Underspecify Prompts

Most people use ChatGPT (or any LLM) like a search bar: dump a half‑formed thought, hit Enter, and hope for magic. The result is usually OK, but not great.

Common issues:

  • Vague prompts like “explain this topic for my exam” with no level, context, or constraints
  • Coding requests with no input/output format, no edge cases, and no performance constraints
  • Writing tasks with no target audience, tone, or length

As a data/AI person, this is painful to watch because prompt quality directly controls output quality. A well‑designed prompt can:

  • Save multiple back‑and‑forth iterations
  • Produce more reliable and testable outputs (especially for code and analysis)
  • Make AI tools actually usable in real workflows

So the idea was simple:

What if you could type as you usually do, then hit one button that rewrites your rough text into a high‑quality prompt?

That’s precisely what Prompt Enhancer does on top of ChatGPT, with almost zero friction.


What Prompt Enhancer Does (User Experience)

From the user’s point of view, Prompt Enhancer adds a tiny bit of superpower to the ChatGPT UI without changing how they use it day‑to‑day.

One‑Click Prompt Upgrade

Once installed and enabled:

  • Open ChatGPT in Chrome.
  • Start typing any rough idea into the input box.
  • You’ll see a small “Enhance” button appear beside or near the textarea.
  • Click Enhance, wait a moment, and your rough text is replaced with a refined, structured prompt.

The enhanced prompt usually:

  • Adds missing context (audience, constraints, format)
  • Clarifies the task (summarise vs critique vs generate vs explain)
  • Specifies outputs (bullet list, table, code with comments, etc.)

You can quickly review the rewritten prompt, tweak anything you like, then hit Enter as usual.

100% On‑Device, No External APIs

The critical design choice: Prompt Enhancer does not call any external API.

Instead, it uses Chrome’s Prompt API to talk to Gemini Nano, the small LLM that Chrome can run locally inside the browser.

That means:

  • No API keys
  • No extra backend server to maintain
  • No prompts going to third‑party infrastructure beyond what ChatGPT itself already uses when you submit

For anyone writing sensitive content (internal docs, research, planning), this matters a lot. The extension never ships your text to another cloud service to enhance it.

Keyboard‑First Flow

To keep things fast for power users, Prompt Enhancer also supports keyboard shortcuts (for example, pressing a combination to trigger an enhancement instead of clicking the button). This keeps the workflow:

Type → Enhance → Enter

All from the keyboard, which is how heavy users of ChatGPT typically operate.


Under the Hood: Architecture and Design

Now for the fun part: how it’s built.

Prompt Enhancer is a Manifest V3 Chrome extension that combines three main pieces:

  1. The extension manifest (permissions + wiring)
  2. A content script that interacts with the ChatGPT DOM
  3. A Prompt API integration that calls Gemini Nano locally

1. Manifest V3 Basics

The manifest.json file:

  • Declares this as a Manifest V3 extension.
  • Specifies the sites where the content script should run (e.g., https://chat.openai.com/*).
  • Requests the minimum permissions needed to inject UI and read/write the textarea.

Keeping permissions minimal helps with both security and Chrome Web Store review. It also forces the architecture to be simple, which is a good constraint for a small but focused tool.

2. Content Script: Injecting the Enhance Button

The content script is responsible for:

  • Detecting when you’re on a ChatGPT page
  • Locating the main input textarea
  • Injecting the floating Enhance button into the UI
  • Listening for click/keyboard events and reading the user’s current text

Because ChatGPT’s UI is a React app that changes frequently, the content script needs to be robust to DOM changes:

  • Use stable selectors where possible
  • Fall back to heuristics like “the largest textarea in the chat input area”
  • Use MutationObserver to re‑attach the button if the UI re-renders

This prevents the extension from silently breaking when ChatGPT updates its frontend.

Once the button is clicked:

  • The script grabs the current textarea value (the rough prompt).
  • It sends this text to the Gemini Nano logic (still inside the same browser context).
  • When the enhanced prompt comes back, the script overwrites the textarea value and restores focus.

3. Using Chrome’s Prompt API with Gemini Nano

The most interesting part is the AI integration.

Chrome has introduced a Prompt API that lets developers send natural‑language requests to the built‑in Gemini Nano model directly inside the browser.

The typical flow is:

  1. Check if the environment supports the AI APIs (for example, Dev or Canary builds with flags enabled if necessary).
  2. Create a language model instance via the Prompt API (this is what connects to Gemini Nano).
  3. Pass a “meta‑prompt” plus the user’s rough text to the model.

The meta‑prompt is where the actual prompt engineering lives. Conceptually, it looks like:

“You are a prompt‑engineering assistant. Rewrite the user’s text as a clear, detailed prompt that specifies context, output format, and constraints, without changing the core intent.”

The model then returns an enhanced version of the prompt, which the extension pipes back into the ChatGPT textarea.

Because Gemini Nano runs locally:

  • Latency is low and predictable (no network round-trip time).
  • The extension can even function with Wi‑Fi turned off, as long as ChatGPT is already loaded and the model is available in Chrome.

This architecture cleanly separates concerns:

  • Content script: DOM integration and UX.
  • AI layer: Prompt API + meta‑prompt logic.

What’s Shipped Today

As of now, Prompt Enhancer includes a solid v1 feature set focused on doing one thing exceptionally well: turn rough prompts into better ones for ChatGPT.

Shipped features:

  • Floating “Enhance” button on the ChatGPT prompt textarea
  • On‑device prompt enhancement using Gemini Nano via Chrome’s Prompt API
  • Full local processing with no external prompt‑enhancement APIs
  • Keyboard shortcut support for in‑flow power usage
  • A minimal, clean UX that feels native to ChatGPT

It’s live on the Chrome Web Store, so users can install it like any other extension and start using it in seconds. Link to the extension


Lessons Learned While Building It

Beyond the feature list, this project taught several practical lessons that are worth sharing.

Designing with Real‑World Constraints

Shipping to the Chrome Web Store forces you to think about:

  • Permissions and privacy policies
  • Clear explanations of what data is accessed, and why
  • How to communicate that everything runs locally and no extra server is involved

Because Prompt Enhancer is entirely local, the privacy story is strong, but it still needs to be communicated clearly in the listing and docs.

Working With Experimental Browser AI

Using Gemini Nano in Chrome is still relatively new, which means:

  • Some setups require enabling flags or using Dev/Canary builds.
  • The APIs and documentation are evolving, so error handling must be defensive.
  • It’s essential to provide a graceful fallback message if the model isn’t available yet on a user’s browser.

This is a trade‑off between being early on a powerful capability and accepting that not every user is ready out of the box.

UX Matters More Than Model Choice

One of the biggest takeaways: users care more about flow than about which model is behind it.

The small details add up:

  • Not breaking the user’s typing flow
  • Giving quick visual feedback when the enhancement is running
  • Respecting the original intent instead of over‑rewriting

In other words, a simple, well‑integrated UX around a local model can improve day‑to‑day AI usage more than yet another separate web app.


Roadmap: What’s Coming Next

Prompt Enhancer v1 focuses on ChatGPT, but there’s a lot of room to grow. Here are some ideas and updates planned for future versions.

1. Multi‑Platform Support

Extend the same enhancement flow beyond ChatGPT to:

  • Claude
  • Gemini web
  • Other AI tools with standard textareas

This would turn Prompt Enhancer into a universal prompt‑upgrade layer atop whichever LLM you prefer.

2. Mode‑Aware Enhancements

Introduce selectable modes such as:

  • “Coding prompt” (add test cases, clarify language, specify constraints)
  • “Writing prompt” (tone, audience, structure)
  • “Analysis prompt” (data format, assumptions, limitations)

These modes would tweak the internal meta‑prompt to better match the user’s goal without making them think about prompt engineering too much.

3. Configurable Meta‑Prompts

Expose some customisation:

  • Let advanced users tweak the internal meta‑prompt
  • Save and reuse custom enhancement styles (e.g., “consultant style”, “exam prep”, “SDE interview”)

This would bridge the gap between a plug‑and‑play extension and a more advanced power tool for prompt engineers.

4. Deeper Chrome Integration

Longer‑term experiments could include:

  • Enhancing prompts based on page context (e.g., selected text on a docs page)
  • Using side panels for history and templates
  • Smarter handling of very long prompts or complex workflows

All while maintaining the core principle: no extra backend, everything stays local.


Closing Thoughts

Prompt Enhancer started as a small experiment: “Can a Chrome extension use on‑device AI to quietly make prompts better without getting in the way?” It has turned into a real, shippable tool that improves day‑to‑day AI workflows while respecting privacy and keeping the architecture clean.

If you use ChatGPT regularly and want to:

  • Get better answers without becoming a full‑time prompt engineer
  • Keep sensitive text local to your device
  • Add a bit of extra power to your existing flow

Then Prompt Enhancer might be worth a try. Link to the extension

You can install it from the Chrome Web Store, and any feedback, bug reports, or v2 ideas are very welcome.

Top comments (0)