---
title: "Workspaces"
description: "A workspace holds the files you work on, all of a repository's or only some, and every edit in it belongs to its change, with nothing to stage."
---

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

# Workspaces

A **workspace** is a directory on your machine where you work on a repository. It holds the files you asked for, all of them or only some, as they are at one of main's landings. Its state is kept in `.af/` at its root, and every `af` command run inside it finds it from the current directory. A workspace starts in a new or empty directory, as a jj workspace or a git clone does. One that cannot be made leaves nothing of itself behind, so the same `af workspace add` can be run again, and it removes nothing it did not write: a file put in the directory meanwhile stays, and so does one it wrote that was changed since.

## Nothing to stage

Every edit in a workspace belongs to its change. There is no staging area and no `add` step: before each command, `af` records the workspace's files into the change's next commit, as jj does. Start a server and a workspace:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af workspace add ~/demo
Workspace at /home/you/demo
Paths: **
main has no landing yet
$ cd ~/demo
$ af new -m "Add a guide and a program"
Working on change rvlrplkwknqqqoxvrktqmzutsppsovtr at commit f41696ad6fd1a2048001fa379ced2927752934ddfb1b76e156138696cbe546a5
```

Write two files, and they are part of the change at once:

```console check
$ mkdir docs src
$ echo "# Guide" > docs/guide.md
$ echo "fn main() {}" > src/main.rs
$ af diff
A docs/guide.md
A src/main.rs
...
```

In a workspace, `@` names the commit it is at, as in jj. Here that is the change's latest commit, with both files in it:

```console check
$ af log -r @
@  rvlrplkw dev@localhost 2026-11-24T13:45:02Z 0a6b045c
│  Add a guide and a program
~
```

Land the change:

```console check
$ af submit
Submitted commit 0a6b045c4775a5e38287033980eab9a2817b98f7a339efa6c1a40396a65a9e15, 0 edits in its last snapshot
```

```console eventually
$ af status
Change rvlrplkwknqqqoxvrktqmzutsppsovtr (landed) at commit 0a6b045c4775a5e38287033980eab9a2817b98f7a339efa6c1a40396a65a9e15
```

## Only the files you need

A repository can be far larger than any one task. A workspace can hold only the files that match the globs you give it, and the forge sends no others. Make a second workspace with only the docs:

```console check
$ af workspace add ~/docs --path 'docs/**'
Workspace at /home/you/docs
Paths: docs/**
At landing 1, 1 file written
$ cd ~/docs
$ ls
docs
$ ls docs
guide.md
```

A change made here lands like any other. Files the workspace does not hold are left as they are on main.

```console check
$ af new -m "Say more in the guide"
Working on change wmykzwnrxolzvlvtlkymuusunokoppyz at commit a8fc1a0a71fd9af330c9abcc816d80713a9fb5cb6e575b7ca4a065b8adceeb0a
$ echo "Read this first." >> docs/guide.md
$ af submit
Submitted commit dbc49b89bffd4aa07190e61da14c9ed9297d90876f2367273d791400803e9184, 1 edit in its last snapshot
```

`af workspace root` names the workspace a directory is in, from anywhere inside it:

```console check
$ cd docs
$ af workspace root
/home/you/docs
```

## Syncing

A workspace stays at its landing until you sync it, or start a new change once its last one has landed. `af sync` brings in main's landings since then. If the workspace has an open change, the change is rebased onto main's latest landing, and any conflicts are written into the files they are in.

Each file is written whole and then put in its place, so a sync that stops partway, from a lost connection or a closed terminal, never leaves a file half written. The next command finishes it. A file you edit in between is never overwritten: it is kept as your edit, and the sync names it.

Back in the first workspace, sync to take the docs change:

```console eventually
$ cd ~/demo
$ af sync
At landing 2: 1 file written, 0 deleted
$ cat docs/guide.md
# Guide
Read this first.
```

## Files you don't track

Every file in a workspace that no `.gitignore` ignores goes into the change. A file that is already tracked stays tracked even once a `.gitignore` ignores it, as in jj. Start a change and build the program into the workspace:

```console check
$ af new -m "Build the program"
Working on change lzxrvvmttluvslmoknyuzurkromlnkuk at commit 491a202ed388cfd1b4a1c0a3af9549eafba3734f9abb2582a80e0aa8ae9f9544
$ mkdir build
$ echo "binary" > build/main
$ af file list
build/main
docs/guide.md
src/main.rs
```

The build's output is now part of the change. To take it out, ignore it, then untrack it with `af file untrack`. The files leave the change and stay on disk:

```console check
$ echo "build/" > .gitignore
$ af file untrack build
Untracked 1 file; it stays on disk
$ af file list
.gitignore
docs/guide.md
src/main.rs
$ ls build
main
```

`af file untrack` refuses a file that no `.gitignore` ignores, since the next snapshot would take it back. Nothing is untracked then:

```console check
$ af file untrack src
Error: 'src/main.rs' is not ignored: files that are not ignored are taken back by the next snapshot. Make sure they're ignored, then try again
[1]
```

Untracking takes a file out of the change, which is a write, so an untrack naming a file in a folder closed to your writes is refused, and nothing is untracked, whatever else the command names. The workspace learns that a folder is closed at its next sync, or from the forge, which refuses the write:

```console check
$ af folder restrict docs --team writers --only-writes --reason "the writers keep the docs"
done: it took effect at once, on your word as an administrator
$ af sync
At landing 2: 0 files written, 0 deleted
$ af file untrack docs src
Error: 'docs/guide.md' is in a folder this actor may not write, and untracking a file writes the change: nothing was untracked
[1]
$ af folder unrestrict docs --reason "anyone may write the docs again"
done: it took effect at once, on your word as an administrator
```

## While af works

Most commands finish before you notice. When one takes longer, such as the first snapshot of a large tree, `af` shows a line on the terminal saying what it is doing, with counts and the time so far:

```text
⠼ Reading changed files: 20,480 of 40,000 (10.1 MB) (2.5s)
```

The line moves through the steps of the command: connecting to the forge, checking files for edits, reading the changed ones, uploading contents the forge doesn't have, sending and saving the snapshot, and taking in files when you sync. Between steps it says `Waiting for the forge`. If another `af` is using the same workspace, such as an agent's `af mcp`, a command waits for it to finish and says `Waiting for another af using this workspace`. It's cleared before any output, so it never ends up in what a command prints.

It's drawn only when standard error is a terminal and standard output isn't a pipe, so scripts, pagers and agents never see it. Turn it off with `--progress never`, or `AF_PROGRESS=never`.

## Next

- [Changes and landings](https://docs.forge.workreef.dev/concepts/changes/): stacks, and how changes land.
- [`af workspace`](https://docs.forge.workreef.dev/reference/af/workspace/) and [`af sync`](https://docs.forge.workreef.dev/reference/af/sync/) in the reference.

Source: https://docs.forge.workreef.dev/concepts/workspaces/index.mdx
