Skip to content

Commit ed88098

Browse files
committed
docs: add workspaces guide
1 parent 5a0bfa7 commit ed88098

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

packages/docs/docs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"group": "Getting started",
1818
"pages": ["index", "quickstart", "development"],
1919
"openapi": "https://opencode.ai/openapi.json"
20+
},
21+
{
22+
"group": "Workspaces",
23+
"pages": ["workspaces"]
2024
}
2125
]
2226
}

packages/docs/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Design a docs site that looks great and empowers your users.
2828
<Card title="API documentation" icon="terminal" href="/api-reference/introduction">
2929
Auto-generate API documentation from OpenAPI specifications.
3030
</Card>
31+
<Card title="Workspaces" icon="terminal" href="/workspaces">
32+
Create isolated git worktrees (sandboxes) from within a project.
33+
</Card>
3134
</Columns>
3235

3336
## Create beautiful pages

packages/docs/workspaces.mdx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: "Workspaces"
3+
description: "Create isolated git worktrees (sandboxes) from within a project"
4+
---
5+
6+
In OpenCode, a **workspace** is an isolated **git worktree** attached to a project.
7+
8+
- The project’s main worktree is the **local** workspace.
9+
- Additional worktrees are **sandbox** workspaces (extra directories tracked on the project).
10+
11+
Each workspace has its own git branch and directory, so you can experiment without disturbing your main working tree.
12+
13+
## Create a workspace from within a project
14+
15+
<Steps>
16+
<Step title="Open the project">Open the project in the OpenCode TUI so it appears in the sidebar.</Step>
17+
18+
<Step title="Create a new workspace">In the project’s **Workspaces** section, choose **New workspace**.</Step>
19+
20+
<Step title="Wait for boot">OpenCode creates the underlying git worktree, populates it, then starts it.</Step>
21+
22+
<Step title="Use it">Select the new workspace to start new sessions inside its isolated directory.</Step>
23+
</Steps>
24+
25+
## What OpenCode does under the hood
26+
27+
When a new workspace is created, OpenCode:
28+
29+
- Creates a git branch using the `opencode/<generated-name>` naming scheme.
30+
- Adds a git worktree directory under OpenCode’s data directory (scoped to the project id).
31+
- Runs a hard reset/population step so the new worktree has the repo contents.
32+
- Bootstraps the worktree, then runs startup scripts.
33+
34+
Startup scripts run in this order:
35+
36+
1. **Project startup**: the project’s `commands.start` (if configured).
37+
2. **Worktree startup**: an optional extra startup command for the new worktree (primarily used when creating worktrees programmatically).
38+
39+
## Manage workspaces
40+
41+
From the workspace sidebar menu you can typically:
42+
43+
- **Rename** the workspace label.
44+
- **Reset** the workspace branch back to the project’s default.
45+
- **Delete** the workspace (removes the worktree and its branch).

0 commit comments

Comments
 (0)