# Chat mode

> Chat mode on code.extension.dev answers a prompt with a structured set of file operations, user steps and assumptions, and repairs its own build errors.

Canonical: https://docs.extension.dev/code/chat-mode
This page as Markdown: https://docs.extension.dev/code/chat-mode.md
Section: Code
Siblings: [AI generation](https://docs.extension.dev/code.md) · [Terminal](https://docs.extension.dev/code/terminal.md) · [Starters and templates](https://docs.extension.dev/code/starters.md) · [Live preview](https://docs.extension.dev/code/preview.md) · [Select to edit](https://docs.extension.dev/code/select-to-edit.md) · [The Code tab](https://docs.extension.dev/code/code-tab.md) · [Build console](https://docs.extension.dev/code/build-console.md) · [Checkpoints](https://docs.extension.dev/code/checkpoints.md) · [Drafts](https://docs.extension.dev/code/drafts.md) · [Firefox engine](https://docs.extension.dev/code/firefox-engine.md) · [Download and run locally](https://docs.extension.dev/code/download-and-run.md) · [Share links](https://docs.extension.dev/code/share.md) · [Publish and import](https://docs.extension.dev/code/publish.md) · [Generation allowance](https://docs.extension.dev/code/allowance.md) · [Settings and sign-in](https://docs.extension.dev/code/settings.md)
Map of every page: https://docs.extension.dev/llms.txt · Whole corpus: https://docs.extension.dev/llms-full.txt

---

# Chat mode

Chat mode is the prompt box that answers with files instead of a terminal
session. Reach for it when your browser has no WebAssembly JSPI, or when you
want one structured answer per prompt rather than an agent running commands.

## Quick start

```text
Build an extension with a toolbar popup that shows a counter I can increment and reset, and remembers the count.
```

Open **Settings**, find the **Assistant surface** card under **Runtime**, and
press **Switch to chat mode**. Type the prompt and send it. The answer writes
the files, the build console compiles them, and the popup opens in the
preview on the right.


## How it works

### When chat mode is on

The terminal is the default surface. Chat mode is on when you switch to it
in **Settings**, when a link carries `?terminal=0`, or when the browser has no
WebAssembly JSPI. In that last case the settings card says so and the switch
is disabled:

```text
The terminal needs WebAssembly JSPI, which Chrome and Edge 137 and Firefox 153 or newer ship; Safari does not yet. This browser does not, so chat mode is on.
```

Your choice is remembered in this browser. A saved choice wins over
`?terminal=1`, so a link cannot pull you back into the terminal once you
picked chat.

### A prompt starts from a template

The first prompt on an empty workspace is routed to a starting template, so
the model edits a working extension instead of inventing one. The chat shows
**Picking the best starting template** while it chooses. Later prompts load
the project you already have and edit it in place.

### The answer is structured

Every reply is one JSON object the workbench validates before it touches a
file:

| Part | What it holds |
| --- | --- |
| `project` | The extension's name and description |
| `operations` | `write`, `delete` and `rename` operations against your files |
| `preview` | The entry page the preview opens, its mount selector and notes |
| `user_steps` | What you must do by hand, such as grant a permission |
| `assumptions` | What the model decided when the prompt did not say |
| `reasoning` | A summary, the steps taken and the tradeoffs |

Only changed files come back. A correction edits what is there, so the parts
that were already right stay as they are.

### Repairs

When the build fails after an answer, chat mode sends the diagnostics back
and asks for a fix, up to 4 times. When the build passes but the preview
reports a runtime error, it asks for a runtime fix, up to 2 times. After that
it stops and leaves the problem in the build console for you.

### What chat mode shares with the terminal

Both modes write the same files, build in the same compiler, and run in the
same preview. Checkpoints, drafts, download, share and publish work the same
way in both. Chat mode has no commands, so `build`, `preview-open` and the
rest belong to the [terminal](/code/terminal).

## Reference

| Limit | Value |
| --- | --- |
| Messages per conversation | 50 |
| Files in one answer | 200 |
| Operations in one answer | 120 |
| Size of one written file | 2 MB |
| User steps in one answer | 7 |
| Assumptions in one answer | 20 |
| Reasoning steps in one answer | 8 |
| Build repairs per prompt | 4 |
| Runtime repairs per prompt | 2 |
| Allowance spent per prompt | 1 unit |

## When it fails

- **The settings card says chat mode is on and the switch is disabled.** The
  browser has no WebAssembly JSPI. Chat mode still works. For the terminal,
  use Chrome or Edge 137 or newer, or Firefox 153 or newer.
- **The reply is refused with `Too many messages (max 50).`** The
  conversation is full. Start a new project from the project switcher, or
  open the same draft in the terminal, where `/new` starts a fresh
  conversation.
- **The build is still red after the repairs.** Read the build console under
  the preview and send the error back as your next prompt, or restore the
  last known good [checkpoint](/code/checkpoints).
- **The preview loads and nothing visible happens.** Read the user steps and
  the assumptions in the answer. Many extensions need a step the page cannot
  take for you.
- **Generation is locked.** The daily or monthly allowance is spent. See
  [Generation allowance](/code/allowance) for what keeps working.

## Next

- [Terminal](/code/terminal) for the agent and its commands
- [Starters and templates](/code/starters) for the cards and links that seed
  a workspace
- [Build console](/code/build-console) for what the compiler reports
- [Generation allowance](/code/allowance) for the units a prompt spends
