Skip to content

Commit 9a85da3

Browse files
committed
docs: add Workspaces documentation
1 parent 6649295 commit 9a85da3

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Features
1010

11+
- [Workspaces](./workspaces.md)
1112
- [Models](./models.md)
1213
- [Keyboard Shortcuts](./keybinds.md)
1314
- [Vim Mode](./vim-mode.md)

docs/theme/custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
/* Docs-specific tokens */
2626
--color-code: hsl(214.52deg 100% 71.11%);
27-
--link-color: var(--color-plan-mode);
27+
--link-color: rgb(62, 140, 218);
2828
--link-hover: var(--color-plan-mode-hover);
2929
--content-max-width: 78ch;
3030
--radius-lg: 10px;

docs/workspaces.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Workspaces
2+
3+
Currently, cmux supports one Workspace backend: [git worktrees](https://git-scm.com/docs/git-worktree).
4+
5+
We plan on adding support for SSH and Docker backends in the near future for
6+
additional isolation and security.
7+
8+
## Basics of worktrees
9+
10+
A worktree is a seperate directory on the same filesystem as the main repository that shares a `.git`
11+
but has independent working changes and checkout state. **All committed changes from any worktree are
12+
visible to all other worktrees including the main repository.**
13+
14+
It's important to note that a **worktree is not locked to a branch**. The agent can switch to new
15+
branches, enter a detached HEAD state, etc. When you create a workspace, the agent will
16+
begin at the selected branch but may switch freely in the course of the session. **We empower users to define their agent's branching strategy in AGENTS.md**
17+
18+
## Reviewing code
19+
20+
Here are a few practical approaches to reviewing changes from workspaces,
21+
depending on how much you want your agent to interact with `git`:
22+
23+
- **Agent codes, commits, and pushes**: Ask agent to submit a PR and review changes in your git Web UI (GitHub, GitLab, etc.)
24+
- Also see: [Agentic Git Identity](./agentic-git-identity.md)
25+
- This is the preferred approach for `cmux` development but requires additional care with repository security.
26+
- **Agent codes and commits**: Review changes from the main repository via `git diff <workspace-branch>`, push changes when deemed acceptable.
27+
- **Agent codes**: enter worktree (click Terminal icon in workspace top bar), run `git add -p` and progressively accept changes into a commit.
28+
29+
## Reviewing functionality
30+
31+
Some changes (esp. UI ones) require the Human to determine acceptability. An effective approach
32+
for this is:
33+
34+
1. Ask agent to commit WIP when its ready for Human review
35+
1. Human, in main repository, checks out the workspace branch in a detached HEAD state: `git checkout --detach <workspace-branch>`
36+
37+
Note: this workflow uses the detached HEAD state because the branch is already
38+
checked out in the workspace and you cannot check out the same branch multiple times
39+
across worktrees.
40+
41+
If you want faster iteration in between commits, you can hop into the worktree directory and run a
42+
dev server (e.g. `bun dev`) there directly and observe the agent's work in real-time.
43+
44+
## Filesystem Layout
45+
46+
All worktrees are stored in `~/.cmux/src/<project-name>/<workspace-name>`.
47+
48+
Example layout:
49+
50+
```
51+
~/.cmux/src/
52+
cmux-main/
53+
improved-auth-ux/
54+
fix-ci-flakes/
55+
```

0 commit comments

Comments
 (0)