---
title: "Workspaces"
description: "How abx ties boxes to a Git repository or a scratch folder, and how to move, copy or relink them."
---

> Documentation Index
> Fetch the complete documentation index at: https://sandrinodm.github.io/agent-box/llms.txt
> Use this file to discover all available pages before exploring further.

# Workspaces

A workspace is the identity of a Git repository or a scratch folder. It ties the folder to its [boxes](https://sandrinodm.github.io/agent-box/concepts/boxes/), so moving or renaming the folder keeps them. This page explains the two kinds, the marker file that carries the identity, and the commands that change it.

## Git and scratch workspaces

| | Git workspace | Scratch workspace |
| --- | --- | --- |
| Created from | A Git checkout with at least one commit | Any directory, or any checkout with `--no-git` |
| `/work` starts as | The current commit, on the branch `agent/<box>` | Empty |
| Scope | All boxes of the repository | The exact current directory |
| `abx diff`, `abx land` | Yes | No |

Outside a Git checkout, abx uses scratch boxes without being asked. Inside one, `--no-git` selects them. Files in your host directory are never copied into a scratch box, and nothing is copied out automatically.

A scratch workspace is exactly the current directory. abx does not search parent directories for a marker. A Git workspace is shared by all worktrees of one repository, because they share the Git common directory.

## The marker

The identity is a random id (a UUID) in a marker file:

| Kind | Marker |
| --- | --- |
| Git | `<git common dir>/abx/workspace.json`, usually `.git/abx/workspace.json` |
| Scratch | `<folder>/.abx/workspace.json` |

The marker holds only `{"id": "..."}`. With `--no-git` inside a Git checkout, the scratch marker is written to the working tree as an untracked `.abx/` directory, and abx does not edit `.gitignore`.

The first launch in a folder writes the marker and registers the workspace. Commands that only read, such as `abx ls`, never write a marker.

> **A marker is untrusted input**
>
> A downloaded folder can ship its own marker. A marker can only select an id, never a path, and a marker that is not exactly one valid id is an error. abx never replaces it silently.

## The registry

The boxes of a workspace and its record live under `$ABX_HOME/workspaces/<name>-<id8>/`. `<name>` is a slug of the folder name when the workspace was first used, and `<id8>` is the first 8 hex digits of its id (more on a collision). The directory name is only a label: abx finds a workspace by the id in its `workspace.json`, which records the id, kind, name, folder and last use.

```text
$ABX_HOME/workspaces/
  <name>-<id8>/
    workspace.json
    boxes/
    archive/
```

When a folder moves, resolving the workspace refreshes the recorded name and folder. See [Files on the host](https://sandrinodm.github.io/agent-box/reference/files/) for the full layout.

## Inspecting workspaces

```sh
abx workspace          # the workspace of the current folder
abx workspace ls       # every registered workspace
```

`abx workspace` shows the id, name, kind (`git` or `scratch`), folder, state directory, and counts of live and archived boxes. Without a marker it says there is no workspace yet. `abx workspace ls` adds a status per workspace:

| Status | Meaning |
| --- | --- |
| `ok` | The recorded folder exists and carries the workspace's marker. |
| `missing folder` | The recorded folder is gone. |
| `id differs` | The marker there is missing, invalid or has another id. |
| `damaged` | The workspace's `workspace.json` under `$ABX_HOME/workspaces/` can't be read safely, or is missing while box state remains. |

Both accept `--json`. To stop or remove a box in a `missing folder` or `id differs` workspace without relinking a folder first, pass `--workspace <id>` to `abx stop` or `abx rm`.

## Moving, copying and relinking

A moved or renamed folder keeps its marker, so it keeps its boxes. Two cases need a command.

**You lost the marker, or re-cloned the folder.** Attach the folder to the existing workspace:

```sh
abx workspace link <name | id | path>
```

The target is a full id, the first 8 hex digits of one, a directory name under `workspaces/`, a recorded path, or a workspace name, tried in that order. Several matches for a short id or name are an error that lists the candidates.

**You copied a folder and want it to start clean.** A copy carries the original's marker. While the original still exists, abx warns in the copy and the boxes stay with the original. Give the copy its own, empty workspace:

```sh
abx workspace new
```

To have the boxes follow the copy instead, run `abx workspace link <id> --force` in it.

`link` refuses when:

- the workspace is of the other kind (a scratch workspace needs `--no-git`),
- the folder's current marker names another workspace that still has live boxes,
- a live Git box starts from a commit this repository does not have,
- without `--force`, the recorded folder still exists and carries the same marker.

`new` refuses when the folder is the recorded owner of its workspace and that workspace has live boxes, since they would become unreachable from here. `--force` replaces the marker anyway, and `abx workspace link <id>` brings them back. Neither command moves box directories. Both print `{"id", "path", "boxes": {"live", "archived"}}` with `--json`.

## Addressing another folder: `-C`

`-C DIR` runs abx as if it had been started in `DIR`, like `git -C`. Use it to reach the boxes of another folder, or to run from a script that is not in the project:

```sh
abx -C ~/src/app diff fix-auth
abx -C ~/src/app stop fix-auth
```

`DIR` must be a directory, and the option can be given once. It can sit before the command or after it. See [Global options](https://sandrinodm.github.io/agent-box/reference/global-options/).

## Folders abx refuses

abx does not use `$HOME` as a scratch workspace, any folder whose `.abx` would be `ABX_HOME`, or any workspace inside `ABX_HOME`. It fails with `abx does not use <dir> as a workspace. cd into a project folder or pass -C DIR.` A Git checkout rooted at `$HOME` is allowed, because its marker is in `.git/abx/`.

Source: https://sandrinodm.github.io/agent-box/concepts/workspaces/index.mdx
