|
1 | 1 | # Workspaces |
2 | 2 |
|
3 | | -cmux supports multiple workspace backends for different use cases: |
| 3 | +Workspaces in cmux provide isolated development environments for parallel agent work. Each workspace maintains its own Git state, allowing you to explore different approaches, run multiple tasks simultaneously, or test changes without affecting your main repository. |
4 | 4 |
|
5 | | -- **Local workspaces**: [git worktrees](https://git-scm.com/docs/git-worktree) on your local machine |
6 | | -- **SSH workspaces**: Regular git clones on a remote server accessed via SSH |
| 5 | +## Workspace Types |
7 | 6 |
|
8 | | -The backend is selected based on your runtime configuration. Local workspaces use git worktrees which share the `.git` directory with your main repository, while SSH workspaces are independent git clones on the remote machine. |
| 7 | +cmux supports two workspace backends: |
9 | 8 |
|
10 | | -## Basics of worktrees |
| 9 | +- **[Local Workspaces](./local.md)**: Use [git worktrees](https://git-scm.com/docs/git-worktree) on your local machine. Worktrees share the `.git` directory with your main repository while maintaining independent working changes. |
11 | 10 |
|
12 | | -A worktree is a seperate directory on the same filesystem as the main repository that shares a `.git` |
13 | | -but has independent working changes and checkout state. **All committed changes from any worktree are |
14 | | -visible to all other worktrees including the main repository.** |
| 11 | +- **[SSH Workspaces](./ssh.md)**: Regular git clones on a remote server accessed via SSH. These are completely independent repositories stored on the remote machine. |
15 | 12 |
|
16 | | -It's important to note that a **worktree is not locked to a branch**. The agent can switch to new |
17 | | -branches, enter a detached HEAD state, etc. When you create a workspace, the agent will |
18 | | -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** |
| 13 | +## Choosing a Backend |
19 | 14 |
|
20 | | -## Reviewing code |
| 15 | +The workspace backend is selected when you create a workspace: |
21 | 16 |
|
22 | | -Here are a few practical approaches to reviewing changes from workspaces, |
23 | | -depending on how much you want your agent to interact with `git`: |
| 17 | +- **Local**: Best for fast iteration, local testing, and when you want to leverage your local machine's resources |
| 18 | +- **SSH**: Ideal for heavy workloads, long-running tasks, or when you need access to remote infrastructure |
24 | 19 |
|
25 | | -- **Agent codes, commits, and pushes**: Ask agent to submit a PR and review changes in your git Web UI (GitHub, GitLab, etc.) |
26 | | - - Also see: [Agentic Git Identity](./agentic-git-identity.md) |
27 | | - - This is the preferred approach for `cmux` development but requires additional care with repository security. |
28 | | -- **Agent codes and commits**: Review changes from the main repository via `git diff <workspace-branch>`, push changes when deemed acceptable. |
29 | | -- **Agent codes**: enter worktree (click Terminal icon in workspace top bar), run `git add -p` and progressively accept changes into a commit. |
| 20 | +## Key Concepts |
30 | 21 |
|
31 | | -## Reviewing functionality |
| 22 | +- **Isolation**: Each workspace has independent working changes and Git state |
| 23 | +- **Branch flexibility**: Workspaces can switch branches, enter detached HEAD state, or create new branches as needed |
| 24 | +- **Parallel execution**: Run multiple workspaces simultaneously on different tasks |
| 25 | +- **Shared commits**: Local workspaces (using worktrees) share commits with the main repository immediately |
32 | 26 |
|
33 | | -Some changes (esp. UI ones) require the Human to determine acceptability. An effective approach |
34 | | -for this is: |
35 | | - |
36 | | -1. Ask agent to commit WIP when its ready for Human review |
37 | | -1. Human, in main repository, checks out the workspace branch in a detached HEAD state: `git checkout --detach <workspace-branch>` |
38 | | - |
39 | | -Note: this workflow uses the detached HEAD state because the branch is already |
40 | | -checked out in the workspace and you cannot check out the same branch multiple times |
41 | | -across worktrees. |
42 | | - |
43 | | -If you want faster iteration in between commits, you can hop into the worktree directory and run a |
44 | | -dev server (e.g. `bun dev`) there directly and observe the agent's work in real-time. |
45 | | - |
46 | | -## Filesystem Layout |
47 | | - |
48 | | -Local workspaces are stored in `~/.cmux/src/<project-name>/<workspace-name>`. |
49 | | - |
50 | | -SSH workspaces are stored on the remote machine at `~/workspace/<project-name>/<workspace-name>` (or your configured remote path). |
51 | | - |
52 | | -Example layout: |
53 | | - |
54 | | -``` |
55 | | -~/.cmux/src/ |
56 | | - cmux-main/ |
57 | | - improved-auth-ux/ |
58 | | - fix-ci-flakes/ |
59 | | -``` |
| 27 | +See the specific workspace type pages for detailed setup and usage instructions. |
0 commit comments