I’ve been tinkering with LLM‑backed helpers for years, and the most surprising thing I’ve discovered is how little friction there is when you turn Chrome DevTools itself into the front‑end for an “AI coding agent”. The browser already gives you a live JavaScript runtime, a network inspector, a DOM view, and a console that can evaluate arbitrary snippets. If you can feed those snippets into a language model and get back code, you’ve essentially built a chrome devtools ai coding agent without leaving the page you’re debugging. In this post I’ll walk through the exact pieces I use, the minimal plumbing required, and the concrete ways senior engineers can start leveraging the combo for day‑to‑day debugging and refactoring. I’ll also be blunt about the blind spots—there are still gaps in context handling, latency, and security that you need to manage yourself.

Why Chrome DevTools feels like a natural UI for AI assistance

When you open DevTools you already have three things that map cleanly to an LLM‑driven workflow:

  1. A REPL‑style console – you type JavaScript (or TypeScript via ts-node) and see immediate results. An LLM can treat each console line as a prompt and return a code fragment that you can paste back in.
  2. Network and source panels – the DevTools Protocol (CDP) exposes every request, response, and source file. An AI can query those resources to answer “why is this request failing?” or “what shape does this JSON have?”.
  3. Breakpoints and stack frames – the debugger lets you pause execution and inspect variables. If you hook into the Debugger.paused event you can ask the model to “suggest a fix for the thrown error” right at the breakpoint.

Because the UI is already built for inspection, you don’t need a separate web app or VS Code extension. You just need a thin bridge that forwards the user’s intent to a model and injects the model’s output back into the console. The result is an interactive, context‑rich assistant that lives exactly where you’re looking at the problem.

Setting up the environment – the tools you actually need

Installing a local LLM server

Running the model locally keeps latency low (sub‑second for 7B‑ish models) and avoids sending proprietary code to a third‑party API. I currently use Ollama because it ships a single binary, supports the OpenAI‑compatible /v1/chat/completions endpoint, and can pull models like llama3.1:8b. The installation steps are straightforward:

# macOS / Linux – download the latest release
curl -L -o ollama https://github.com/ollama/ollama/releases/download/v0.1.30/ollama-linux-amd64
chmod +x ollama
sudo mv ollama /usr/local/bin/

# Start the daemon (runs in the background)
ollama serve &
# Pull a model (adjust size to your GPU/CPU)
ollama pull llama3.1:8b

If you’re on Windows you can grab the .exe from the same releases page. The daemon listens on http://127.0.0.1:11434, which is the address we’ll point our DevTools extension at.

Verification note – The exact version number (v0.1.30) and binary name (ollama-linux-amd64) are based on the latest release at the time of writing; you should verify the current URL on the official GitHub releases page.

Adding a DevTools extension

Chrome lets you load unpacked extensions from a local directory. The minimal extension I use consists of three files:

chrome-ai-assistant/
├─ manifest.json
├─ background.js
└─ panel.html

manifest.json

{
  "name": "AI Coding Assistant",
  "description": "Bridge between DevTools console and a local LLM",
  "version": "0.1",
  "manifest_version": 3,
  "permissions": ["activeTab", "scripting", "storage"],
  "devtools_page": "panel.html"
}

panel.html – a tiny UI that just forwards a text box to the background script:

<!doctype html>
<html>
  <head>
    <style>
      body { font-family: system-ui; margin: 0; padding: 8px; }
      textarea { width: 100%; height: 4rem; }
      button { margin-top: 4px; }
    </style>
  </head>
  <body>
    <textarea id="prompt" placeholder="Ask the model…"></textarea>
    <button id="send">Send</button>
    <pre id="response"></pre>
    <script src="panel.js"></script>
  </body>
</html>

panel.js (inline for brevity) forwards the prompt to background.js, which in turn calls the Ollama API and injects the response into the inspected page’s console:

document.getElementById('send').addEventListener('click', async () => {
  const prompt = document.getElementById('prompt').value;
  const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
  chrome.runtime.sendMessage({ tabId: tab.id, prompt });
});

background.js does the heavy lifting:

chrome.runtime.onMessage.addListener(async (msg, _, sendResponse) => {
  const { tabId, prompt } = msg;
  const response = await fetch('http://127.0.0.1:11434/api/chat', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      model: 'llama3.1:8b',
      messages: [{ role: 'user', content: prompt }],
      stream: false
    })
  }).then(r => r.json());

  const code = response.message?.content?.trim() ?? '';
  // Inject the code into the console of the inspected page
  chrome.scripting.executeScript({
    target: { tabId },
    func: (snippet) => console.log('%c[AI]', 'color:#0b5', snippet),
    args: [code]
  });
});

Load the folder via chrome://extensions → Load unpacked and open DevTools on any page. You’ll see a new “AI Coding Assistant” tab next to Elements, Console, etc. From there you can type natural‑language prompts and watch the generated code appear in the console.

Hooking the LLM into the DevTools console

The extension above is a proof‑of‑concept, but you can tighten the integration by using the Chrome DevTools Protocol (CDP) directly from a Node script. This gives you programmatic access to the same events the UI surface provides, and you can embed the logic into your existing debugging scripts.

Using the Runtime.evaluate API

CDP’s Runtime.evaluate lets you run arbitrary JavaScript in the context of the inspected page. The Node client chrome-remote-interface (CRI) is a thin wrapper around the protocol:

npm i -D chrome-remote-interface
// devtools-llm.ts
import CDP from 'chrome-remote-interface';
import fetch from 'node-fetch';

async function askLLM(prompt: string): Promise<string> {
  const res = await fetch('http://127.0.0.1:11434/api/chat', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      model: 'llama3.1:8b',
      messages: [{ role: 'user', content: prompt }],
      stream: false
    })
  });
  const json = await res.json();
  return json.message?.content?.trim() ?? '';
}

(async () => {
  const client = await CDP();
  const { Runtime, Page } = client;

  await Page.enable();
  await Runtime.enable();

  // Navigate to a test page
  await Page.navigate({ url: 'https://example.com' });
  await Page.loadEventFired();

  // Example: ask the model to generate a fetch wrapper
  const prompt = `Write a TypeScript function called fetchJson(url: string) that returns parsed JSON and throws on non‑2xx responses.`;
  const code = await askLLM(prompt);

  // Evaluate the generated code in the page context
  const evalResult = await Runtime.evaluate({ expression: code, awaitPromise: true });
  console.log('LLM injected:', evalResult.result?.description);
  client.close();
})();

Running ts-node devtools-llm.ts will spin up a headless Chrome instance (via the default debugging port 9222), navigate to a page, ask the LLM for a snippet, and evaluate it directly. Because the code runs inside the page, you can immediately call fetchJson from the console or from other scripts.

A minimal TypeScript wrapper for repeated calls

If you plan to use the assistant throughout a debugging session, wrapping the request/response cycle in a reusable class keeps the code tidy:

// src/ChromeAIAssistant.ts
import CDP from 'chrome-remote-interface';
import fetch from 'node-fetch';

export class ChromeAIAssistant {
  private client!: CDP.Client;
  private runtime!: CDP.Runtime;
  private page!: CDP.Page;
  private model = 'llama3.1:8b';
  private endpoint = 'http://127.0.0.1:11434/api/chat';

  async connect() {
    this.client = await CDP();
    this.runtime = this.client.Runtime;
    this.page = this.client.Page;
    await this.page.enable();
    await this.runtime.enable();
  }

  async navigate(url: string) {
    await this.page.navigate({ url });
    await this.page.loadEventFired();
  }

  private async queryModel(prompt: string): Promise<string> {
    const res = await fetch(this.endpoint, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        model: this.model,
        messages: [{ role: 'user', content: prompt }],
        stream: false
      })
    });
    const json = await res.json();
    return json.message?.content?.trim() ?? '';
  }

  async ask(prompt: string): Promise<string> {
    const code = await this.queryModel(prompt);
    const { result, exceptionDetails } = await this.runtime.evaluate({
      expression: code,
      awaitPromise: true,
      returnByValue: true
    });
    if (exceptionDetails) {
      throw new Error(`LLM code threw: ${exceptionDetails.text}`);
    }
    return JSON.stringify(result?.value);
  }

  close() {
    this.client?.close();
  }
}

You can now instantiate ChromeAIAssistant in any script, send natural‑language prompts, and get back the evaluated result. The class abstracts away the CDP plumbing, leaving you free to focus on the what rather than the how.

Building a simple “chrome devtools ai coding agent”

Putting the pieces together, here’s a compact script that turns the DevTools console into an interactive AI assistant. The script registers a custom console command >ai that forwards the rest of the line to the model and prints the response.

// src/aiConsoleCommand.ts
import { ChromeAIAssistant } from './ChromeAIAssistant';

(async () => {
  const assistant = new ChromeAIAssistant();
  await assistant.connect();
  await assistant.navigate('https://example.com');

  // Listen for console commands via the Runtime.consoleAPICalled event
  assistant.client.Runtime.consoleAPICalled(async ({ args, type }) => {
    if (type !== 'log' || !args[0]?.value?.startsWith('>ai ')) return;

    const userPrompt = args[0].value.slice(4).trim(); // strip '>ai '
    try {
      const result = await assistant.ask(userPrompt);
      // Echo the LLM’s answer back to the console
      await assistant.runtime.evaluate({
        expression: `console.log('%c[AI]', 'color:#0b5', ${result});`,
        contextId: undefined
      });
    } catch (e) {
      await assistant.runtime.evaluate({
        expression: `console.error('AI error:', ${JSON.stringify(e.message)})`,
        contextId: undefined
      });
    }
  });

  console.log('AI console command ready. Type >ai <your request> in the DevTools console.');
})();

Run this with ts-node src/aiConsoleCommand.ts. Open Chrome, open DevTools on any page, and type:

>ai Write a one‑liner that extracts the domain from window.location.href

The assistant will respond with something like:

[AI] const domain = new URL(window.location.href).hostname;

You can then copy‑paste that line or, if you’re feeling adventurous, have the script automatically evaluate it by extending the consoleAPICalled handler.

Practical use cases

On‑the‑fly type inference and refactor suggestions

When you’re debugging a TypeScript-heavy front‑end, you often hit any or missing type definitions. By sending the current variable’s runtime shape to the model you can ask for a proper interface:

>ai Given the object {id:42, name:"Bob", tags:["admin","user"]}, generate a TypeScript interface

The assistant replies:

interface User {
  id: number;
  name: string;
  tags: string[];
}

You can then paste the interface into your source file, reducing the back‑and‑forth with the type checker.

Debug‑time query of stack traces

Suppose a promise rejection lands you in a minified bundle. You can capture the stack string, feed it to the model, and ask for a human‑readable explanation:

>ai Explain this stack trace and point out the likely cause:
Error: Network request failed
    at fetch (app.min.js:1:12345)
    at async processData (app.min.js:1:67890)

The model can suggest that the failure likely stems from a missing CORS header or an invalid URL, saving you the time of manually mapping minified line numbers.

Generating test scaffolding from a failing assertion

When a unit test fails, you can ask the assistant to generate a minimal reproducer:

>ai The test `expect(calc(2,3)).toBe(5)` failed because calc returns undefined. Write a Jest test that reproduces the failure and a stub implementation that passes.

The response will include both a failing test case and a simple implementation, giving you a quick “green‑first” baseline to iterate from.

Managing context and privacy

Feeding live code into an LLM raises two practical concerns:

  1. Scope of the prompt – The model only sees what you explicitly send. If you want it to understand the surrounding module, you need to prepend the relevant source files. A pragmatic pattern is to read the file from disk (via Node’s fs.readFileSync) and concatenate it with the user prompt before the API call.
  2. Sensitive data – Even on a local Ollama server, the model’s weights are immutable, but the prompt history can be cached in RAM. For highly confidential codebases, consider scrubbing identifiers (e.g., replace API keys with <REDACTED>) before sending.

A simple sanitization helper:

function sanitize(prompt: string): string {
  return prompt.replace(/['"][A-Za-z0-9_]{32,}['"]/g, '<REDACTED>');
}

Apply it right before the fetch call in ChromeAIAssistant. This isn’t bullet‑proof, but it reduces accidental leakage.

Limitations and uncertainty

Even with a tight DevTools‑LLM loop, there are still open questions:

  • Determinism – LLMs are stochastic; the same prompt can yield different code on each call. For production pipelines you’ll need to lock the model’s temperature (e.g., temperature: 0.0) and possibly cache the generated snippet.
  • Version drift – The Chrome DevTools Protocol evolves; new Chrome releases may add or deprecate methods. My scripts target Chrome 124 (the version current as of late 2026). If you upgrade to Chrome 125+, verify that Runtime.evaluate still accepts awaitPromise and returnByValue.
  • Model capability – Smaller local models (7‑8 B) sometimes hallucinate type signatures or miss edge‑case error handling. In those cases I fall back to a cloud‑hosted model (e.g., OpenAI gpt-4o-mini) for the specific request, but that re‑introduces data‑privacy concerns.

Verification note – The exact behavior of temperature: 0.0 guaranteeing deterministic output is based on the OpenAI API spec; local Ollama implementations may vary. Test this flag with your chosen model before relying on it.

Deploying to a team – CI/CD considerations

If you find the assistant useful for individual debugging, you can scale it to a team by packaging the extension and the LLM server as Docker containers. A typical docker-compose.yml looks like this:

version: '3.9'
services:
  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    restart: unless-stopped
    environment:
      - OLLAMA_MODEL=llama3.1:8b

  chrome-agent:
    build: ./chrome-ai-assistant
    volumes:
      - /tmp/chrome-profile:/profile
    command: >
      google-chrome --remote-debugging-port=9222
      --user-data-dir=/profile
      --disable-gpu --headless
    ports:
      - "9222:9222"
    depends_on:
      - ollama

The chrome-agent service runs Chrome in headless mode with remote debugging enabled, while the ollama service hosts the model. Your CI pipelines can then spin up this stack, run integration tests that invoke the ChromeAIAssistant class, and even generate code snippets automatically for failing tests.

When you push changes to a shared repo, you might want to enforce that any generated code passes a lint step (npm run lint) before it’s merged. This mirrors the patterns described in our post on AI Agent Code Review: Patterns That Scale in Production, where we treat LLM output as a “pull request” that must be reviewed by both a human and a static analyzer.

Conclusion

Turning Chrome DevTools into an chrome devtools ai coding agent is less about “magical AI” and more about wiring together two tools you already trust: the browser’s inspection UI and a locally hosted LLM. The result is an interactive, context‑aware assistant that lives exactly where you’re looking at the problem, without the friction of a separate IDE plugin or a cloud‑only API.

The approach is deliberately lightweight: a few lines of Node, a tiny extension, and a running Ollama server. That simplicity makes it easy to experiment, iterate, and, if you need to, replace components (swap Ollama for vLLM, replace the extension with a VS Code custom view, etc.). At the same time, you inherit the same concerns that any production AI pipeline has—privacy, determinism, and version compatibility.

If you’re a senior engineer looking for a pragmatic way to bring LLM assistance into your day‑to‑day debugging, give this setup a spin. Start with the minimal extension, try the >ai console command, and gradually evolve the workflow into the more robust CDP‑driven scripts shown above. You’ll quickly discover where the assistant shines (quick refactors, test scaffolding) and where it still needs a human’s judgment (architectural decisions, security‑critical code). That balance—leveraging AI for the repetitive, keeping humans for the strategic—is the sweet spot I aim for in every production‑grade AI tool I build.

Building the assistant is the easy half; keeping it safe is the other, and AI agent code review covers what to check. I build this kind of tooling as part of AI engineering, usually on a full-stack codebase. The extension platform itself is documented at Chrome for Developers. If you want an assistant scoped to your own product, start a project.

Frequently asked questions

Can a browser extension safely hold an API key?

No. Anything shipped to the browser can be read from it. The extension should call your own endpoint, which holds the key and enforces who may use it.

What can the assistant see that I should worry about?

The page it is attached to: DOM, network responses, and whatever is in local storage. Scope it to the tab the user chose, and never to all tabs by default.

How do you ship an internal extension to a team?

Through a managed policy or a private listing rather than a zip passed around. That gives you a way to update it and a way to remove it.