> ## Documentation Index
> Fetch the complete documentation index at: https://archie.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# The chat and branches

> The chat writes to the branch you are on. See how it shows where each step writes, what it asks when a branch is protected, and how it confirms table changes and picks an environment.

The chat works on the branch you are on. This page explains what the chat shows you before and while it writes, what it asks when a branch is protected, and how it handles changes to data and environments.

## The chat shows where it writes

Every step of a chat response that writes something shows its **destination** next to it, in the form *step → destination*.

| Destination | Example |
| - | - |
| The Frontend | Frontend, branch fix-prices |
| A service | service profile-linker, branch main |
| The data of an environment | master environment data |
| A service in an environment | service profile-linker, branch main, environment staging |

Steps that only read show no destination. Archie works out the destination from the action itself, not from the text the model wrote. People who cannot view code do not see it.

## Protected branches: the chat asks where to continue

If the chat is about to write to a protected branch, it stops before it writes and ends its reply with a card.

For the Frontend, the card reads "*branch* is protected. Choose where to continue." For a service, it reads "*branch* is protected, service *name*. Choose where to continue." The card has two actions:

* **Create branch *name* and continue** creates a branch from the protected one, moves that part of your project to it, and the chat carries on with what was pending. You do not need to repeat your request. The suggested name is the source branch plus `-changes`, for example `main-changes`. If that name is taken, Archie adds a number.
* **Use another branch** lists the unprotected branches of that Frontend or service. Pick one and the chat continues there. If there is none, the list says **No other branches available**.

After you choose, that part of the project stays on the new branch for your next requests, and the branch menu shows it.

Some details:

* If you have unsaved edits when you create the branch from the card, they go with the new branch.
* If you reached your plan's branch limit, the card shows the limit notice and **Create branch** is not available. **Use another branch** still works.
* If Archie cannot create the branch, the card stays open with "Couldn't continue on that branch. Try again." and you can try again.
* A card that waits too long expires and can no longer be confirmed. Ask again.

## Changing a table from a branch

Tables, columns, enums, and indexes belong to an **environment**, and every branch connected to that environment shares them. When you are on a branch other than the default and ask the chat to change a table, the chat first asks you to confirm. The card explains that the change affects the data of the environment, which all branches share.

* **Apply** makes the change.
* **Cancel** leaves the table as it is.

On the default branch, the chat does not ask this extra question. Changes to the rows of a table have their own confirmations.

## Which environment the chat uses

The chat keeps an active environment for the conversation and uses it for data, schema, and services. It asks you in two cases:

| Situation | What the chat asks |
| - | - |
| No environment is active yet and the project has several | **Which environment should I work in?** The card has one button for each environment. |
| The conversation works in one environment, but the Backend selector shows another | "You have the *staging* environment selected, but we were working in *DEV*. Should I switch the conversation to *staging*?" The card has **Switch to *staging*** and **Stay in *DEV***. |

Your answer sets the environment of the conversation. The choice never moves the Backend selector. The destination of each step tells you which environment it used.

## Generate functions on a service's branch

The chat writes functions to the branch the service is on, and it asks the same protected branch question before it generates. See [Branches in a Logic service](https://archie.com/docs/backend/logic/branches.md#generate-functions-on-a-branch).

## Next steps

* [Protected branches](https://archie.com/docs/frontend/branching/protected-branches.md)
* [Environments](https://archie.com/docs/backend/environments.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.