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

# Environments

> Run a chat or Automation in a folder on your own machine, control what the agent can reach, and keep connection credentials in the cloud.

An **environment** is where agents run commands and work on files. **CloudThinker Cloud** is the managed option. A self-hosted environment connects machines you control, such as a laptop, server, or CI runner. Choose one through **Run in** before starting a chat. Each connected machine runs a background worker process.

> [!NOTE]
>
> Some screenshots show **Workers**, the previous name for Environments.
>
> **Beta.** Environments run on the [CloudThinker CLI](https://docs.cloudthinker.io/guide/cli/overview.md), which is also in beta. Command names and flags may change before general availability. The CLI retains **outpost** in its command syntax, so you'll see `--outpost` in commands.

## How it works

![The Environment on your machine connects out to CloudThinker Cloud, runs file and shell work locally, and sends results back, while connection commands run in the cloud](https://mintcdn.com/cloudthinker/iI9Kw2iEqfV7Vhhh/images/workers/01-how-it-works-light.svg?fit=max\&auto=format\&n=iI9Kw2iEqfV7Vhhh\&q=85\&s=f236034b1cc5a6f370b0b3b2811d69ae)

File and shell work runs on your machine. The model and connection credentials stay in CloudThinker Cloud.

## Why use an environment

* **Work where your code lives.** The agent edits files and runs your own tools in a private repository or on an internal host, with no inbound port opened. The Environment connects outward over HTTPS.
* **Connection credentials stay in the cloud.** Commands that use a workspace connection, such as AWS or Kubernetes, still run in CloudThinker Cloud. That credential never reaches your machine. The agent's shell can still use any credentials already on the machine, such as `~/.aws` or `~/.kube/config`, so run the environment under an account without them if that matters.
* **Your folder's rules apply.** The agent follows the instruction files and Skills you keep in the folder.
* **Personal or shared.** Only you can use a personal environment. A shared environment is available to everyone in the workspace, including Automations.

## Prerequisites

* The CloudThinker CLI installed on the machine, on Linux or macOS. There is no native Windows build. See [CLI](https://docs.cloudthinker.io/guide/cli/overview.md).
* Outbound HTTPS (port 443) from the machine to `app.cloudthinker.io`, directly or through `HTTPS_PROXY`. If your proxy re-signs HTTPS, set `SSL_CERT_FILE` to your company CA bundle.
* A folder you want the agent to work in, such as a repository checkout. For **Worktree**, it must be a git repository and the machine needs git 2.38 or newer.
* To create a shared environment: the workspace Admin role. See [Roles](https://docs.cloudthinker.io/guide/security/roles.md).
* **Allow self-hosted environments** turned on in **More → Workspace settings → General** (see [workspace settings](https://docs.cloudthinker.io/guide/workspaces.md#open-workspace-settings)). It's on unless a workspace Admin turned it off.

The dashboard setup below doesn't need `cloudthinker login` on the machine. The setup command enrolls the environment by itself. The terminal-only setup does need a login.

## Set up an environment

**1. Open the environment setup dialog**

In a new chat, open the **+** menu beside the prompt box, select **Run in**, then select **New environment**. Admins can also go to **Admin Settings → Sandboxes** (an environment is another place a chat can run, next to CloudThinker Cloud) and select **Create environment** in the **Environments** section.

![The Environments section of the Sandboxes page with the Create environment button](https://mintcdn.com/cloudthinker/x17Tte95w-p1fCkb/images/v2/workers-create.webp?fit=max\&auto=format\&n=x17Tte95w-p1fCkb\&q=85\&s=110a179f4c1334b4431fa9be4d9f99bb)

Admin Settings, Sandboxes: Create environment adds a folder on your machine where agents can work

**2. Name the environment**

Enter an **Environment name**, for example `payments-api`. Turn on **Share with workspace** if teammates and Automations should use it. Select **Create environment**. Only Admins see **Share with workspace**; everyone else creates a personal environment.

**Success state:** the dialog shows a setup command. It works once and expires in 10 minutes (the dialog calls it a link).

**3. Run the command in your project folder**

Copy the command, open a terminal in the folder you want to serve, and run it. It looks like this:

```bash theme={null}
cloudthinker --url https://app.cloudthinker.io worker start --register <reference> --workdir "$PWD"
```

`<reference>` is a one-time enrollment code from the dialog. `--url` falls back to the address of your last `cloudthinker login`, else `https://app.cloudthinker.io`, so you can usually drop it.

The Environment saves its credential in a private file (mode `0600`) on this machine. It then checks that it can read files, run a shell command, cancel a command, and upload results. It keeps running in the foreground until you press Ctrl-C.

**Success state:** the terminal prints `Waiting for work.` and the dialog shows **`<name>` is verified**. If the command expired, select **New command**.

**4. Start a chat on the environment**

Select **Start a chat**. A new chat opens with the environment selected.

### Set up from the terminal only

Sign in with `cloudthinker login` first and check the workspace with `cloudthinker whoami`. Then:

```bash theme={null}
cloudthinker worker outpost create payments-api --shared   # omit --shared for a personal Worker
cloudthinker worker start --outpost payments-api --workdir "$PWD"
```

**Success state:** the terminal prints `Waiting for work.`, and the environment shows **Online** in the **Run in** menu.

### Add more machines to an environment

One Environment can have several machines, for example a build server and its standby. Open the environment's settings, select **Connect a machine**, and run the command it gives on the new machine. Each enrollment is a separate machine with its own credential, and each handles up to 4 runs at once by default.

A conversation stays on the first machine and folder that picks it up. It never moves to another machine, even when that machine goes offline.

### Use the CloudThinker Desktop app

In the CloudThinker Desktop app, the **Run in** menu also shows **Open a folder…**, which serves a folder from this computer as an environment with no terminal. For a selected Desktop folder, **Remove this folder** takes it off the list. Selecting a Desktop folder whose Environment is stopped starts it. These actions don't appear in the browser.

## Choose where a chat runs

**1. Pick the environment**

In a new chat, open the **+** menu and select **Run in**. Choose **CloudThinker Cloud** or an environment by name. Picking a target closes the menu.

The **Run in** row appears only when there's something to choose, such as an environment. Offline Environments move to an **Unavailable** submenu, where a row opens that Environment's settings. Organization Admins also see **Manage environments**, which opens **Admin Settings → Sandboxes**.

![The + menu with a Run in row showing CloudThinker Cloud](https://mintcdn.com/cloudthinker/hM4B2TTyAHmL71Fz/images/workers/01-plus-menu-run-in-row.png?fit=max\&auto=format\&n=hM4B2TTyAHmL71Fz\&q=85\&s=15315e1456946e23c70eee0a56137106)

**Success state:** a chip with the environment's name appears in the toolbar. Its tooltip reads like "Files and shell commands run on payments-api. Connections run in CloudThinker Cloud, and credentials stay there. You cannot change this after the first message." While an environment is available, the chip also shows for **CloudThinker Cloud**, so switching is one click.

![The toolbar chip for an environment, with a tooltip that explains what runs where](https://mintcdn.com/cloudthinker/hM4B2TTyAHmL71Fz/images/workers/02-worker-chip-tooltip.png?fit=max\&auto=format\&n=hM4B2TTyAHmL71Fz\&q=85\&s=da691718c2fab722f7a2d7d1690bec1e)

**2. Send the first message**

Ask for something that uses the folder:

```text theme={null}
Run the test suite and fix the first failing test. Show me the diff before you commit.
```

**Success state:** the chip locks. The conversation stays on that Environment for its whole life. To run somewhere else, start a new conversation.

The composer remembers your last choice for the workspace, so the next new chat starts on the same Environment.

### Work in a separate worktree

After you pick an environment, open **Run in** again. It now shows **Configure local environment**. If the folder is a git repository, turn on **Worktree** and pick a base **Branch** before the first message.

The Environment then creates a `cloudthinker/<id>` branch in its own worktree, stored in the environment's state folder outside the folder you serve, so your main checkout stays unchanged. It uses the local branch if one exists, and otherwise fetches `origin/<base>` once.

* **Cleanup:** the environment removes a worktree after 14 days without use, but only when it has no uncommitted changes. It deletes the `cloudthinker/<id>` branch only when that branch is merged or pushed. List them with `cloudthinker worker worktrees ls`, or clean up now with `cloudthinker worker worktrees prune`. Dirty worktrees stay and show as `dirty`.
* **When the switch is greyed out:** a line under it says why, for example "This folder is not a git repository." or "Update the environment to use worktrees." Run `cloudthinker update`, and `cloudthinker worker doctor` to check the git version.

## What an environment can reach

| The agent does this | Where it reaches |
| - | - |
| Reads, writes, edits, or lists files with a file tool | Only inside `--workdir`. Paths outside it, including `..`, are rejected. |
| Runs a shell command | In host mode (the default), the whole machine, as your OS account, using `/bin/bash`. `--workdir` is only the starting directory. In container mode, only the folder and the hosts you allow. See [Environment security](https://docs.cloudthinker.io/guide/worker-security.md). |
| Uses a workspace connection (AWS, Kubernetes, and more) | CloudThinker Cloud, with the credential injected there. Credentials already on the machine are a different matter: the shell can use them. |

> [!WARNING]
>
> In host mode, shell commands on an environment are not sandboxed. They can read `~/.ssh`, write outside the folder, and reach your network. On a sensitive machine:
>
> * Turn on [container mode](https://docs.cloudthinker.io/guide/worker-security.md), so commands run in a container that mounts only the folder and reaches only the hosts you allow.
>
> * Run the environment under a dedicated, non-admin account. Never run `worker start` as root.
>
> * Keep SSH keys and cloud credentials out of that account's home folder.
>
> * Don't rely on [Approvals](https://docs.cloudthinker.io/guide/approvals/overview.md) to protect the machine. It checks commands that reach your systems, such as cloud CLIs, `ssh`, Git pushes, and requests that send a stored credential. A command that only acts on the machine, such as `rm` or a file write, may run without asking.

Shell commands get a reduced environment: `PATH`, `HOME`, `LANG`, `TERM`, `USER`, and `TMPDIR`. To pass more, add flags to `worker start`, for example `cloudthinker worker start --outpost payments-api --workdir "$PWD" --env AWS_PROFILE`. The value comes from the worker process's environment, and you repeat `--env` for each variable. `--inherit-env` passes everything. The Environment's own credential is always left out. `--background` doesn't accept these flags.

Every shell command, background task start or stop, and file write is recorded in **Admin Settings → Audit Logs** under the **Command** filter, for personal and shared environments alike. Organization Owners and Admins can open it. The record keeps a redacted preview of the command (at most 1 KiB), never its output. Reads are not recorded.

### What leaves the machine

The Environment runs the tools, but the model runs in CloudThinker Cloud. These go there and become part of the conversation:

* File contents the agent reads, up to 1.4 MB per file.
* Command output.
* Files the agent uploads as results, up to 64 files and 16 MiB per operation.

Serve only folders whose contents you're fine sending to the model. See [Data protection](https://docs.cloudthinker.io/guide/security/data-protection.md) for how conversations are stored.

### The Use Connections switch

The **Use Connections** switch appears in the **Run in** menu after you pick an environment. It's on by default, and anyone starting the chat can change it. It decides whether the run can use connection commands: commands that go through a workspace connection, such as `aws` or `kubectl`. Its **?** help reads "Connections like AWS or Kubernetes run in CloudThinker Cloud, and credentials stay there. Turn it off to keep everything on this environment." It never moves file or shell work off the environment.

![The Run in menu with the Use Connections switch](https://mintcdn.com/cloudthinker/Oe5_AUbJ0QRKLeSx/images/workers/03-workspace-connections-switch.png?fit=max\&auto=format\&n=Oe5_AUbJ0QRKLeSx\&q=85\&s=bd612e816c1cdbe4e55d29f233b852d4)

| Switch | Connection commands | File tools and shell |
| - | - | - |
| **On** (default) | Run in CloudThinker Cloud | Run on the environment |
| **Off** | Don't run. A crossed-out cloud icon on the chip and a message such as "Use Connections is off. CloudThinker cannot use your Connections in these runs." tell you so. | Run on the environment |

The first message fixes the switch along with the environment.

### What stays in CloudThinker Cloud

[Cyber](https://docs.cloudthinker.io/guide/security/cyber-overview.md) runs and browser sessions need CloudThinker Cloud. In an environment conversation they return an error, and nothing silently moves to the cloud. Start a new conversation in CloudThinker Cloud for those.

## Folder rules and Skills

When a conversation starts, the agent reads the instruction files at the root of the folder: `AGENTS.override.md`, `AGENTS.md`, `CLAUDE.md`, and `GEMINI.md`. It reads every one that exists, not just the first, in that order. When it works in a subfolder, it also picks up the same files from that subfolder and the folders above it. The root files are read once per conversation, so an edit applies from the next conversation.

Skills come only from `.agents/skills/` (up to 64), not from other tools' folders such as `.claude/skills/`. Each Skill is a folder with a `SKILL.md` whose frontmatter has a `description`, and the agent loads it when a task matches. Set `disable-model-invocation: true` to hide one. See [Skill format](https://docs.cloudthinker.io/guide/skills/skill-format.md).

## Keep an environment running

`worker start` stops when you close the terminal. To keep it up, add `--background` to the same command. That does `service install` and `service start` in one step, for the same Environment, folder, concurrency, and label: a systemd user unit on Linux, a LaunchAgent on macOS. On Linux it also turns on lingering so the environment survives logout, or prints the `loginctl enable-linger <user>` command when it can't. It then prints the status, logs, and stop commands. On macOS the LaunchAgent runs only while you're logged in.

| Command (prefix `cloudthinker worker`) | What it does |
| - | - |
| `service install --outpost <name> --workdir <path>` | Register the service without starting it. On Linux, add `--enable-linger` to keep it running after logout. |
| `service start` / `service stop` | Start it, or stop it after current work drains. |
| `service status --json` | Show its state, last exit code, and where the logs are. |
| `service uninstall` | Remove the service. The credential and Environment stay. |
| `service install --system --user <account>` | Run as root: install a machine-wide service (systemd unit or macOS LaunchDaemon) that runs the environment as that account. Enroll the environment as that account first. |
| `status --outpost <name>` | Show availability and CLI version as the workspace sees it. |
| `doctor` | Check version, network, clock, credential, folder, and service. Prints one fix per problem. |
| `outpost ls` / `outpost archive <name>` | List Environments, or retire one after its open work finishes. |

**To upgrade the CLI on a connected machine:** run `cloudthinker worker service stop` (it lets current work finish), then `cloudthinker update`, then `cloudthinker worker service start`. In the foreground, press Ctrl-C, update, and run the same `worker start` command again.

Useful `worker start` flags: `--concurrency <1-32>` (default 4) for the most runs the environment handles at once, `--label <name>` for the folder's display name, `--health-addr 127.0.0.1:9464` for `/healthz` and Prometheus `/metrics` endpoints, `--log-format json` for one JSON log object per line, and `--verbose` (`-v`) to print each operation.

## Manage an environment

Select an environment's row in **Admin Settings → Sandboxes**, or the settings icon beside the selected Environment in the **Run in** menu, to open its settings. The dialog lists each machine with its state (**Online**, **Offline**, **Draining**, **Registered**, or **Needs enrollment**), platform, CLI version, last IP address, last seen time, load, and credential age and expiry. Its **Security** section sets container mode, allowed hosts, and allowed IP addresses: see [Environment security](https://docs.cloudthinker.io/guide/worker-security.md).

A version badge shows when a machine's CLI falls behind: **Update available** or **Outdated**. The fix for both is to run `cloudthinker update` on the machine. `cloudthinker worker status` shows the same badge.

### When Self-hosted environments are turned off

| Banner | Cause | What happens |
| - | - | - |
| "Self-hosted environments are turned off for this workspace…" | A workspace Admin turned off **Allow self-hosted environments** | Environment rows leave the **Run in** menu and **Create environment** is disabled. Turn the setting back on to resume. |
| "Environments are paused by CloudThinker…" | Your operator turned Environments off for the whole instance | Same as above, until the operator turns them back on |

A running `worker start` waits while Self-hosted environments are off, checks every 60 seconds, and resumes on its own, so you don't need to restart it.

## Run an Automation on an environment

In the [Automation](https://docs.cloudthinker.io/guide/automation/automations.md) form, set **Run in** to a shared environment. Automations can't use personal environments, and only workspace Admins can change where an Automation runs. A change to the **Use Connections** switch applies from the next run. If the environment is offline when a run is due, the run never moves to CloudThinker Cloud. Keep shared environments that serve Automations running as a service.

## Troubleshooting

> [accordion] The dialog says Verification failed
>
> One of the startup checks failed. Stop the worker, run `cloudthinker worker doctor` in the folder, apply the fix it prints, then select **New command** and run it again. If it says **Your CLI is out of date**, run `cloudthinker update` first.

> [accordion] The Environment shows Offline
>
> You see **Offline** on the environment's row in **Admin Settings → Sandboxes** and in the **Run in** menu. The process stopped or lost the network. Check that `worker start` or the service is still running with `cloudthinker worker status --outpost <name>`. The Environment reconnects on its own after sleep or a network change.

> [accordion] A shell command can't find a variable or tool
>
> Only `PATH`, `HOME`, `LANG`, `TERM`, `USER`, and `TMPDIR` are passed by default. Restart the environment with `--env NAME` for each variable, or `--inherit-env`.

> [accordion] The Environment exits with WORKDIR\_IDENTITY\_CHANGED
>
> The folder was replaced, for example deleted and recloned. Run `worker start` once with the same `--outpost` and `--workdir` plus `--reset-folder`. Conversations that used the old folder stay unavailable.

> [accordion] The credential expired or was revoked (exit code 3)
>
> A credential stays valid for 30 days after its last use and rotates on its own while the environment runs. If it expires, enroll again with a new command from **Admin Settings → Sandboxes**, or **Run in → New environment**.

> [accordion] Revoke an environment, for example on a lost laptop
>
> In **Admin Settings → Sandboxes**, open the environment's row. Select the revoke icon on one machine (**Revoke this machine**), or **Revoke all machines** (shown with 2 or more machines). Both ask you to confirm. The credential stops working right away: running work stops, and each machine must enroll again. To retire the environment for good, select **Remove environment**, or run `cloudthinker worker outpost archive <name>` once its open conversations finish.

> [accordion] A teammate sees "This conversation runs on another member's personal environment"
>
> The conversation runs on your personal environment, so only you can send messages in it. Teammates can read it but not reply. Create a shared environment instead.

## Next steps

> [card] [CLI](https://docs.cloudthinker.io/guide/cli/overview.md)
>
> Install the CLI, sign in, and run CloudThinker from your terminal.

> [card] [Approvals](https://docs.cloudthinker.io/guide/approvals/overview.md)
>
> Choose which agent actions need a person's approval first.

> [card] [Automations](https://docs.cloudthinker.io/guide/automation/automations.md)
>
> Schedule work to run on a shared environment.

> [card] [Deployment options](https://docs.cloudthinker.io/guide/deployment/overview.md)
>
> Compare CloudThinker Cloud, Environments, and private deployments.


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